blob: 33453319742508251d3b9a96d2ca1c26312cdcd8 [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,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100227 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200228 ALC888_ACER_ASPIRE_8930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200229 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200230 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100231 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200232 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200233 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200234 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200235 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200236 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200237 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100238 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100239 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100240 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100241 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800242 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200243 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200244 ALC888_ASUS_M90V,
245 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200246 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100247 ALC1200_ASUS_P5Q,
Guido Günther3e1647c52009-06-05 00:47:26 +0200248 ALC883_SONY_VAIO_TT,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200249 ALC883_AUTO,
250 ALC883_MODEL_LAST,
251};
252
Kailang Yangdf694da2005-12-05 19:42:22 +0100253/* for GPIO Poll */
254#define GPIO_MASK 0x03
255
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200256/* extra amp-initialization sequence types */
257enum {
258 ALC_INIT_NONE,
259 ALC_INIT_DEFAULT,
260 ALC_INIT_GPIO1,
261 ALC_INIT_GPIO2,
262 ALC_INIT_GPIO3,
263};
264
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265struct alc_spec {
266 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100267 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100269 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100270 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
Kailang Yangdf694da2005-12-05 19:42:22 +0100272 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200273 * don't forget NULL
274 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200275 */
276 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Takashi Iwai812a2cc2009-05-16 10:00:49 +0200278 char stream_name_analog[16]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 struct hda_pcm_stream *stream_analog_playback;
280 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100281 struct hda_pcm_stream *stream_analog_alt_playback;
282 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Takashi Iwai812a2cc2009-05-16 10:00:49 +0200284 char stream_name_digital[16]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 struct hda_pcm_stream *stream_digital_playback;
286 struct hda_pcm_stream *stream_digital_capture;
287
288 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200289 struct hda_multi_out multiout; /* playback set-up
290 * max_channels, dacs must be set
291 * dig_out_nid and hp_nid are optional
292 */
Takashi Iwai63300792008-01-24 15:31:36 +0100293 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100294 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100295 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
297 /* capture */
298 unsigned int num_adc_nids;
299 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100300 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200301 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
303 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200304 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 const struct hda_input_mux *input_mux;
306 unsigned int cur_mux[3];
307
308 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100309 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200311 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200312 int const_channel_count;
313 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
315 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100316 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200317
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200318 /* dynamic controls, init_verbs and input_mux */
319 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200320 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200321 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200322 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100323
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100324 /* hooks */
325 void (*init_hook)(struct hda_codec *codec);
326 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
327
Takashi Iwai834be882006-03-01 14:16:17 +0100328 /* for pin sensing */
329 unsigned int sense_updated: 1;
330 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100331 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200332
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100333 /* other flags */
334 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200335 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100336
Takashi Iwai2134ea42008-01-10 16:53:55 +0100337 /* for virtual master */
338 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200339#ifdef CONFIG_SND_HDA_POWER_SAVE
340 struct hda_loopback_check loopback;
341#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200342
343 /* for PLL fix */
344 hda_nid_t pll_nid;
345 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100346};
347
348/*
349 * configuration template - to be copied to the spec instance
350 */
351struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200352 struct snd_kcontrol_new *mixers[5]; /* should be identical size
353 * with spec
354 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100355 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100356 const struct hda_verb *init_verbs[5];
357 unsigned int num_dacs;
358 hda_nid_t *dac_nids;
359 hda_nid_t dig_out_nid; /* optional */
360 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800361 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100362 unsigned int num_adc_nids;
363 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100364 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100365 hda_nid_t dig_in_nid;
366 unsigned int num_channel_mode;
367 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200368 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200369 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200370 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100371 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100372 void (*unsol_event)(struct hda_codec *, unsigned int);
373 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200374#ifdef CONFIG_SND_HDA_POWER_SAVE
375 struct hda_amp_list *loopbacks;
376#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377};
378
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379
380/*
381 * input MUX handling
382 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200383static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
384 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385{
386 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
387 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200388 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
389 if (mux_idx >= spec->num_mux_defs)
390 mux_idx = 0;
391 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392}
393
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200394static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
395 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396{
397 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
398 struct alc_spec *spec = codec->spec;
399 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
400
401 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
402 return 0;
403}
404
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200405static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
406 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407{
408 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
409 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100410 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100412 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100413 hda_nid_t nid = spec->capsrc_nids ?
414 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200415 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416
Takashi Iwaicd896c32008-11-18 12:36:33 +0100417 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
418 imux = &spec->input_mux[mux_idx];
419
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200420 type = (get_wcaps(codec, nid) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
421 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100422 /* Matrix-mixer style (e.g. ALC882) */
423 unsigned int *cur_val = &spec->cur_mux[adc_idx];
424 unsigned int i, idx;
425
426 idx = ucontrol->value.enumerated.item[0];
427 if (idx >= imux->num_items)
428 idx = imux->num_items - 1;
429 if (*cur_val == idx)
430 return 0;
431 for (i = 0; i < imux->num_items; i++) {
432 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
433 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
434 imux->items[i].index,
435 HDA_AMP_MUTE, v);
436 }
437 *cur_val = idx;
438 return 1;
439 } else {
440 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100441 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100442 &spec->cur_mux[adc_idx]);
443 }
444}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200445
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446/*
447 * channel mode setting
448 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200449static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
450 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451{
452 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
453 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100454 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
455 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456}
457
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200458static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
459 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
462 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100463 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200464 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200465 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466}
467
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
469 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470{
471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200473 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
474 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200475 &spec->ext_channel_count);
476 if (err >= 0 && !spec->const_channel_count) {
477 spec->multiout.max_channels = spec->ext_channel_count;
478 if (spec->need_dac_fix)
479 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
480 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200481 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482}
483
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100485 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200486 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100487 * being part of a format specifier. Maximum allowed length of a value is
488 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100489 *
490 * Note: some retasking pin complexes seem to ignore requests for input
491 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
492 * are requested. Therefore order this list so that this behaviour will not
493 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200494 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
495 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200496 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100497static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100498 "Mic 50pc bias", "Mic 80pc bias",
499 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100500};
501static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100502 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100503};
504/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200505 * in the pin being assumed to be exclusively an input or an output pin. In
506 * addition, "input" pins may or may not process the mic bias option
507 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
508 * accept requests for bias as of chip versions up to March 2006) and/or
509 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100510 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200511#define ALC_PIN_DIR_IN 0x00
512#define ALC_PIN_DIR_OUT 0x01
513#define ALC_PIN_DIR_INOUT 0x02
514#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
515#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100516
Kailang Yangea1fb292008-08-26 12:58:38 +0200517/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100518 * For each direction the minimum and maximum values are given.
519 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200520static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100521 { 0, 2 }, /* ALC_PIN_DIR_IN */
522 { 3, 4 }, /* ALC_PIN_DIR_OUT */
523 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200524 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
525 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100526};
527#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
528#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
529#define alc_pin_mode_n_items(_dir) \
530 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
531
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200532static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
533 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200534{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100535 unsigned int item_num = uinfo->value.enumerated.item;
536 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
537
538 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200539 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100540 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
541
542 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
543 item_num = alc_pin_mode_min(dir);
544 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200545 return 0;
546}
547
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200548static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
549 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200550{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100551 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200552 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
553 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100554 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200555 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200556 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
557 AC_VERB_GET_PIN_WIDGET_CONTROL,
558 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200559
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100560 /* Find enumerated value for current pinctl setting */
561 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200562 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200564 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100565 return 0;
566}
567
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200568static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
569 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100570{
571 signed int change;
572 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
573 hda_nid_t nid = kcontrol->private_value & 0xffff;
574 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
575 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200576 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
577 AC_VERB_GET_PIN_WIDGET_CONTROL,
578 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100579
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200580 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100581 val = alc_pin_mode_min(dir);
582
583 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100584 if (change) {
585 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200586 snd_hda_codec_write_cache(codec, nid, 0,
587 AC_VERB_SET_PIN_WIDGET_CONTROL,
588 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100589
Kailang Yangea1fb292008-08-26 12:58:38 +0200590 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100591 * for the requested pin mode. Enum values of 2 or less are
592 * input modes.
593 *
594 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200595 * reduces noise slightly (particularly on input) so we'll
596 * do it. However, having both input and output buffers
597 * enabled simultaneously doesn't seem to be problematic if
598 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100599 */
600 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200601 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
602 HDA_AMP_MUTE, HDA_AMP_MUTE);
603 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
604 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100605 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200606 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
607 HDA_AMP_MUTE, HDA_AMP_MUTE);
608 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
609 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100610 }
611 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200612 return change;
613}
614
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100615#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200616 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100617 .info = alc_pin_mode_info, \
618 .get = alc_pin_mode_get, \
619 .put = alc_pin_mode_put, \
620 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100621
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100622/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
623 * together using a mask with more than one bit set. This control is
624 * currently used only by the ALC260 test model. At this stage they are not
625 * needed for any "production" models.
626 */
627#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200628#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200629
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200630static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
631 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100632{
633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
634 hda_nid_t nid = kcontrol->private_value & 0xffff;
635 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
636 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200637 unsigned int val = snd_hda_codec_read(codec, nid, 0,
638 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100639
640 *valp = (val & mask) != 0;
641 return 0;
642}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200643static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
644 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100645{
646 signed int change;
647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
648 hda_nid_t nid = kcontrol->private_value & 0xffff;
649 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
650 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200651 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
652 AC_VERB_GET_GPIO_DATA,
653 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100654
655 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200656 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
657 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100658 gpio_data &= ~mask;
659 else
660 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200661 snd_hda_codec_write_cache(codec, nid, 0,
662 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100663
664 return change;
665}
666#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
667 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
668 .info = alc_gpio_data_info, \
669 .get = alc_gpio_data_get, \
670 .put = alc_gpio_data_put, \
671 .private_value = nid | (mask<<16) }
672#endif /* CONFIG_SND_DEBUG */
673
Jonathan Woithe92621f12006-02-28 11:47:47 +0100674/* A switch control to allow the enabling of the digital IO pins on the
675 * ALC260. This is incredibly simplistic; the intention of this control is
676 * to provide something in the test model allowing digital outputs to be
677 * identified if present. If models are found which can utilise these
678 * outputs a more complete mixer control can be devised for those models if
679 * necessary.
680 */
681#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200682#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200683
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200684static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
685 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100686{
687 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
688 hda_nid_t nid = kcontrol->private_value & 0xffff;
689 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
690 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200691 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100692 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100693
694 *valp = (val & mask) != 0;
695 return 0;
696}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200697static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
698 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100699{
700 signed int change;
701 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
702 hda_nid_t nid = kcontrol->private_value & 0xffff;
703 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
704 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200705 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100706 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200707 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100708
709 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200710 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100711 if (val==0)
712 ctrl_data &= ~mask;
713 else
714 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200715 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
716 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100717
718 return change;
719}
720#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
721 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
722 .info = alc_spdif_ctrl_info, \
723 .get = alc_spdif_ctrl_get, \
724 .put = alc_spdif_ctrl_put, \
725 .private_value = nid | (mask<<16) }
726#endif /* CONFIG_SND_DEBUG */
727
Jonathan Woithef8225f62008-01-08 12:16:54 +0100728/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
729 * Again, this is only used in the ALC26x test models to help identify when
730 * the EAPD line must be asserted for features to work.
731 */
732#ifdef CONFIG_SND_DEBUG
733#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
734
735static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
736 struct snd_ctl_elem_value *ucontrol)
737{
738 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
739 hda_nid_t nid = kcontrol->private_value & 0xffff;
740 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
741 long *valp = ucontrol->value.integer.value;
742 unsigned int val = snd_hda_codec_read(codec, nid, 0,
743 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
744
745 *valp = (val & mask) != 0;
746 return 0;
747}
748
749static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
750 struct snd_ctl_elem_value *ucontrol)
751{
752 int change;
753 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
754 hda_nid_t nid = kcontrol->private_value & 0xffff;
755 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
756 long val = *ucontrol->value.integer.value;
757 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
758 AC_VERB_GET_EAPD_BTLENABLE,
759 0x00);
760
761 /* Set/unset the masked control bit(s) as needed */
762 change = (!val ? 0 : mask) != (ctrl_data & mask);
763 if (!val)
764 ctrl_data &= ~mask;
765 else
766 ctrl_data |= mask;
767 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
768 ctrl_data);
769
770 return change;
771}
772
773#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
774 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
775 .info = alc_eapd_ctrl_info, \
776 .get = alc_eapd_ctrl_get, \
777 .put = alc_eapd_ctrl_put, \
778 .private_value = nid | (mask<<16) }
779#endif /* CONFIG_SND_DEBUG */
780
Kailang Yangdf694da2005-12-05 19:42:22 +0100781/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100782 * set up the input pin config (depending on the given auto-pin type)
783 */
784static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
785 int auto_pin_type)
786{
787 unsigned int val = PIN_IN;
788
789 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
790 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100791 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100792 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
793 if (pincap & AC_PINCAP_VREF_80)
794 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200795 else if (pincap & AC_PINCAP_VREF_50)
796 val = PIN_VREF50;
797 else if (pincap & AC_PINCAP_VREF_100)
798 val = PIN_VREF100;
799 else if (pincap & AC_PINCAP_VREF_GRD)
800 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100801 }
802 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
803}
804
805/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100806 */
807static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
808{
809 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
810 return;
811 spec->mixers[spec->num_mixers++] = mix;
812}
813
814static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
815{
816 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
817 return;
818 spec->init_verbs[spec->num_init_verbs++] = verb;
819}
820
Takashi Iwaidaead532008-11-28 12:55:36 +0100821#ifdef CONFIG_PROC_FS
822/*
823 * hook for proc
824 */
825static void print_realtek_coef(struct snd_info_buffer *buffer,
826 struct hda_codec *codec, hda_nid_t nid)
827{
828 int coeff;
829
830 if (nid != 0x20)
831 return;
832 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
833 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
834 coeff = snd_hda_codec_read(codec, nid, 0,
835 AC_VERB_GET_COEF_INDEX, 0);
836 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
837}
838#else
839#define print_realtek_coef NULL
840#endif
841
Takashi Iwaid88897e2008-10-31 15:01:37 +0100842/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100843 * set up from the preset table
844 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200845static void setup_preset(struct alc_spec *spec,
846 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100847{
848 int i;
849
850 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100851 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100852 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200853 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
854 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100855 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200856
Kailang Yangdf694da2005-12-05 19:42:22 +0100857 spec->channel_mode = preset->channel_mode;
858 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200859 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200860 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100861
Hector Martin3b315d72009-06-02 10:54:19 +0200862 if (preset->const_channel_count)
863 spec->multiout.max_channels = preset->const_channel_count;
864 else
865 spec->multiout.max_channels = spec->channel_mode[0].channels;
866 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100867
868 spec->multiout.num_dacs = preset->num_dacs;
869 spec->multiout.dac_nids = preset->dac_nids;
870 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800871 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100872 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200873
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200874 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200875 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200876 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100877 spec->input_mux = preset->input_mux;
878
879 spec->num_adc_nids = preset->num_adc_nids;
880 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100881 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100882 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100883
884 spec->unsol_event = preset->unsol_event;
885 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200886#ifdef CONFIG_SND_HDA_POWER_SAVE
887 spec->loopback.amplist = preset->loopbacks;
888#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100889}
890
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200891/* Enable GPIO mask and set output */
892static struct hda_verb alc_gpio1_init_verbs[] = {
893 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
894 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
895 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
896 { }
897};
898
899static struct hda_verb alc_gpio2_init_verbs[] = {
900 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
901 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
902 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
903 { }
904};
905
Kailang Yangbdd148a2007-05-08 15:19:08 +0200906static struct hda_verb alc_gpio3_init_verbs[] = {
907 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
908 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
909 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
910 { }
911};
912
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200913/*
914 * Fix hardware PLL issue
915 * On some codecs, the analog PLL gating control must be off while
916 * the default value is 1.
917 */
918static void alc_fix_pll(struct hda_codec *codec)
919{
920 struct alc_spec *spec = codec->spec;
921 unsigned int val;
922
923 if (!spec->pll_nid)
924 return;
925 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
926 spec->pll_coef_idx);
927 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
928 AC_VERB_GET_PROC_COEF, 0);
929 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
930 spec->pll_coef_idx);
931 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
932 val & ~(1 << spec->pll_coef_bit));
933}
934
935static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
936 unsigned int coef_idx, unsigned int coef_bit)
937{
938 struct alc_spec *spec = codec->spec;
939 spec->pll_nid = nid;
940 spec->pll_coef_idx = coef_idx;
941 spec->pll_coef_bit = coef_bit;
942 alc_fix_pll(codec);
943}
944
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200945static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200946{
947 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200948 unsigned int present;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200949 unsigned int nid = spec->autocfg.hp_pins[0];
950 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200951
952 /* need to execute and sync at first */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200953 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
954 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200955 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200956 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
957 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
958 nid = spec->autocfg.speaker_pins[i];
959 if (!nid)
960 break;
961 snd_hda_codec_write(codec, nid, 0,
962 AC_VERB_SET_PIN_WIDGET_CONTROL,
963 spec->jack_present ? 0 : PIN_OUT);
964 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200965}
966
Sasha Alexandrdef319f2009-06-16 16:00:15 -0400967#if 0 /* it's broken in some cases -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200968static void alc_mic_automute(struct hda_codec *codec)
969{
970 struct alc_spec *spec = codec->spec;
971 unsigned int present;
972 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
973 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
974 unsigned int mix_nid = spec->capsrc_nids[0];
975 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
976
977 capsrc_idx_mic = mic_nid - 0x18;
978 capsrc_idx_fmic = fmic_nid - 0x18;
979 present = snd_hda_codec_read(codec, mic_nid, 0,
980 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
981 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
982 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
983 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
984 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
985 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
986 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
987}
Takashi Iwai4605b712008-10-31 14:18:24 +0100988#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100989#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100990#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200991
Kailang Yangc9b58002007-10-16 14:30:01 +0200992/* unsolicited event for HP jack sensing */
993static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
994{
995 if (codec->vendor_id == 0x10ec0880)
996 res >>= 28;
997 else
998 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200999 switch (res) {
1000 case ALC880_HP_EVENT:
1001 alc_automute_pin(codec);
1002 break;
1003 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001004 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001005 break;
1006 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001007}
1008
1009static void alc_inithook(struct hda_codec *codec)
1010{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001011 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001012 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001013}
1014
Kailang Yangf9423e72008-05-27 12:32:25 +02001015/* additional initialization for ALC888 variants */
1016static void alc888_coef_init(struct hda_codec *codec)
1017{
1018 unsigned int tmp;
1019
1020 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1021 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1022 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001023 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001024 /* alc888S-VC */
1025 snd_hda_codec_read(codec, 0x20, 0,
1026 AC_VERB_SET_PROC_COEF, 0x830);
1027 else
1028 /* alc888-VB */
1029 snd_hda_codec_read(codec, 0x20, 0,
1030 AC_VERB_SET_PROC_COEF, 0x3030);
1031}
1032
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001033static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001034{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001035 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001036
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001037 switch (type) {
1038 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001039 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1040 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001041 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001042 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1043 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001044 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001045 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1046 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001047 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001048 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001049 case 0x10ec0260:
1050 snd_hda_codec_write(codec, 0x0f, 0,
1051 AC_VERB_SET_EAPD_BTLENABLE, 2);
1052 snd_hda_codec_write(codec, 0x10, 0,
1053 AC_VERB_SET_EAPD_BTLENABLE, 2);
1054 break;
1055 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001056 case 0x10ec0267:
1057 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001058 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001059 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001060 case 0x10ec0660:
1061 case 0x10ec0662:
1062 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001063 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001064 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001065 snd_hda_codec_write(codec, 0x14, 0,
1066 AC_VERB_SET_EAPD_BTLENABLE, 2);
1067 snd_hda_codec_write(codec, 0x15, 0,
1068 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001069 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001070 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001071 switch (codec->vendor_id) {
1072 case 0x10ec0260:
1073 snd_hda_codec_write(codec, 0x1a, 0,
1074 AC_VERB_SET_COEF_INDEX, 7);
1075 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1076 AC_VERB_GET_PROC_COEF, 0);
1077 snd_hda_codec_write(codec, 0x1a, 0,
1078 AC_VERB_SET_COEF_INDEX, 7);
1079 snd_hda_codec_write(codec, 0x1a, 0,
1080 AC_VERB_SET_PROC_COEF,
1081 tmp | 0x2010);
1082 break;
1083 case 0x10ec0262:
1084 case 0x10ec0880:
1085 case 0x10ec0882:
1086 case 0x10ec0883:
1087 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001088 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001089 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001090 snd_hda_codec_write(codec, 0x20, 0,
1091 AC_VERB_SET_COEF_INDEX, 7);
1092 tmp = snd_hda_codec_read(codec, 0x20, 0,
1093 AC_VERB_GET_PROC_COEF, 0);
1094 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001095 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001096 snd_hda_codec_write(codec, 0x20, 0,
1097 AC_VERB_SET_PROC_COEF,
1098 tmp | 0x2010);
1099 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001100 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001101 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001102 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001103 case 0x10ec0267:
1104 case 0x10ec0268:
1105 snd_hda_codec_write(codec, 0x20, 0,
1106 AC_VERB_SET_COEF_INDEX, 7);
1107 tmp = snd_hda_codec_read(codec, 0x20, 0,
1108 AC_VERB_GET_PROC_COEF, 0);
1109 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001110 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001111 snd_hda_codec_write(codec, 0x20, 0,
1112 AC_VERB_SET_PROC_COEF,
1113 tmp | 0x3000);
1114 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001115 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001116 break;
1117 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001118}
Kailang Yangea1fb292008-08-26 12:58:38 +02001119
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001120static void alc_init_auto_hp(struct hda_codec *codec)
1121{
1122 struct alc_spec *spec = codec->spec;
1123
1124 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001125 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001126
Kailang Yangc9b58002007-10-16 14:30:01 +02001127 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001128 if (spec->autocfg.line_out_pins[0] &&
1129 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001130 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001131 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001132 else
1133 return;
1134 }
1135
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001136 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1137 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001138 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1139 AC_VERB_SET_UNSOLICITED_ENABLE,
1140 AC_USRSP_EN | ALC880_HP_EVENT);
1141 spec->unsol_event = alc_sku_unsol_event;
1142}
1143
1144/* check subsystem ID and set up device-specific initialization;
1145 * return 1 if initialized, 0 if invalid SSID
1146 */
1147/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1148 * 31 ~ 16 : Manufacture ID
1149 * 15 ~ 8 : SKU ID
1150 * 7 ~ 0 : Assembly ID
1151 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1152 */
1153static int alc_subsystem_id(struct hda_codec *codec,
1154 hda_nid_t porta, hda_nid_t porte,
1155 hda_nid_t portd)
1156{
1157 unsigned int ass, tmp, i;
1158 unsigned nid;
1159 struct alc_spec *spec = codec->spec;
1160
1161 ass = codec->subsystem_id & 0xffff;
1162 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1163 goto do_sku;
1164
1165 /* invalid SSID, check the special NID pin defcfg instead */
1166 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001167 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001168 * 29~21 : reserve
1169 * 20 : PCBEEP input
1170 * 19~16 : Check sum (15:1)
1171 * 15~1 : Custom
1172 * 0 : override
1173 */
1174 nid = 0x1d;
1175 if (codec->vendor_id == 0x10ec0260)
1176 nid = 0x17;
1177 ass = snd_hda_codec_get_pincfg(codec, nid);
1178 snd_printd("realtek: No valid SSID, "
1179 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001180 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001181 if (!(ass & 1) && !(ass & 0x100000))
1182 return 0;
1183 if ((ass >> 30) != 1) /* no physical connection */
1184 return 0;
1185
1186 /* check sum */
1187 tmp = 0;
1188 for (i = 1; i < 16; i++) {
1189 if ((ass >> i) & 1)
1190 tmp++;
1191 }
1192 if (((ass >> 16) & 0xf) != tmp)
1193 return 0;
1194do_sku:
1195 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1196 ass & 0xffff, codec->vendor_id);
1197 /*
1198 * 0 : override
1199 * 1 : Swap Jack
1200 * 2 : 0 --> Desktop, 1 --> Laptop
1201 * 3~5 : External Amplifier control
1202 * 7~6 : Reserved
1203 */
1204 tmp = (ass & 0x38) >> 3; /* external Amp control */
1205 switch (tmp) {
1206 case 1:
1207 spec->init_amp = ALC_INIT_GPIO1;
1208 break;
1209 case 3:
1210 spec->init_amp = ALC_INIT_GPIO2;
1211 break;
1212 case 7:
1213 spec->init_amp = ALC_INIT_GPIO3;
1214 break;
1215 case 5:
1216 spec->init_amp = ALC_INIT_DEFAULT;
1217 break;
1218 }
1219
1220 /* is laptop or Desktop and enable the function "Mute internal speaker
1221 * when the external headphone out jack is plugged"
1222 */
1223 if (!(ass & 0x8000))
1224 return 1;
1225 /*
1226 * 10~8 : Jack location
1227 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1228 * 14~13: Resvered
1229 * 15 : 1 --> enable the function "Mute internal speaker
1230 * when the external headphone out jack is plugged"
1231 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001232 if (!spec->autocfg.hp_pins[0]) {
1233 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1234 if (tmp == 0)
1235 spec->autocfg.hp_pins[0] = porta;
1236 else if (tmp == 1)
1237 spec->autocfg.hp_pins[0] = porte;
1238 else if (tmp == 2)
1239 spec->autocfg.hp_pins[0] = portd;
1240 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001241 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001242 }
1243
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001244 alc_init_auto_hp(codec);
1245 return 1;
1246}
Kailang Yangea1fb292008-08-26 12:58:38 +02001247
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001248static void alc_ssid_check(struct hda_codec *codec,
1249 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1250{
1251 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1252 struct alc_spec *spec = codec->spec;
1253 snd_printd("realtek: "
1254 "Enable default setup for auto mode as fallback\n");
1255 spec->init_amp = ALC_INIT_DEFAULT;
1256 alc_init_auto_hp(codec);
1257 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001258}
1259
Takashi Iwai41e41f12005-06-08 14:48:49 +02001260/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001261 * Fix-up pin default configurations
1262 */
1263
1264struct alc_pincfg {
1265 hda_nid_t nid;
1266 u32 val;
1267};
1268
1269static void alc_fix_pincfg(struct hda_codec *codec,
1270 const struct snd_pci_quirk *quirk,
1271 const struct alc_pincfg **pinfix)
1272{
1273 const struct alc_pincfg *cfg;
1274
1275 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1276 if (!quirk)
1277 return;
1278
1279 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001280 for (; cfg->nid; cfg++)
1281 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001282}
1283
1284/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001285 * ALC888
1286 */
1287
1288/*
1289 * 2ch mode
1290 */
1291static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1292/* Mic-in jack as mic in */
1293 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1294 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1295/* Line-in jack as Line in */
1296 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1297 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1298/* Line-Out as Front */
1299 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1300 { } /* end */
1301};
1302
1303/*
1304 * 4ch mode
1305 */
1306static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1307/* Mic-in jack as mic in */
1308 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1309 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1310/* Line-in jack as Surround */
1311 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1312 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1313/* Line-Out as Front */
1314 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1315 { } /* end */
1316};
1317
1318/*
1319 * 6ch mode
1320 */
1321static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1322/* Mic-in jack as CLFE */
1323 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1324 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1325/* Line-in jack as Surround */
1326 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1327 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1328/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1329 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1330 { } /* end */
1331};
1332
1333/*
1334 * 8ch mode
1335 */
1336static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1337/* Mic-in jack as CLFE */
1338 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1339 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1340/* Line-in jack as Surround */
1341 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1342 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1343/* Line-Out as Side */
1344 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1345 { } /* end */
1346};
1347
1348static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1349 { 2, alc888_4ST_ch2_intel_init },
1350 { 4, alc888_4ST_ch4_intel_init },
1351 { 6, alc888_4ST_ch6_intel_init },
1352 { 8, alc888_4ST_ch8_intel_init },
1353};
1354
1355/*
1356 * ALC888 Fujitsu Siemens Amillo xa3530
1357 */
1358
1359static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1360/* Front Mic: set to PIN_IN (empty by default) */
1361 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1362/* Connect Internal HP to Front */
1363 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1364 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1365 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1366/* Connect Bass HP to Front */
1367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1369 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1370/* Connect Line-Out side jack (SPDIF) to Side */
1371 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1372 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1373 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1374/* Connect Mic jack to CLFE */
1375 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1376 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1377 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1378/* Connect Line-in jack to Surround */
1379 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1380 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1381 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1382/* Connect HP out jack to Front */
1383 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1384 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1385 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1386/* Enable unsolicited event for HP jack and Line-out jack */
1387 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1388 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1389 {}
1390};
1391
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001392static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001393{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001394 struct alc_spec *spec = codec->spec;
1395 unsigned int val, mute;
1396 hda_nid_t nid;
1397 int i;
1398
1399 spec->jack_present = 0;
1400 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1401 nid = spec->autocfg.hp_pins[i];
1402 if (!nid)
1403 break;
1404 val = snd_hda_codec_read(codec, nid, 0,
1405 AC_VERB_GET_PIN_SENSE, 0);
1406 if (val & AC_PINSENSE_PRESENCE) {
1407 spec->jack_present = 1;
1408 break;
1409 }
1410 }
1411
1412 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001413 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001414 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1415 nid = spec->autocfg.speaker_pins[i];
1416 if (!nid)
1417 break;
1418 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1419 HDA_AMP_MUTE, mute);
1420 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001421}
1422
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001423static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1424 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001425{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001426 if (codec->vendor_id == 0x10ec0880)
1427 res >>= 28;
1428 else
1429 res >>= 26;
1430 if (res == ALC880_HP_EVENT)
1431 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001432}
1433
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001434static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1435{
1436 struct alc_spec *spec = codec->spec;
1437
1438 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1439 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1440 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1441 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1442 alc_automute_amp(codec);
1443}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001444
1445/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001446 * ALC888 Acer Aspire 4930G model
1447 */
1448
1449static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1450/* Front Mic: set to PIN_IN (empty by default) */
1451 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1452/* Unselect Front Mic by default in input mixer 3 */
1453 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001454/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001455 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1456/* Connect Internal HP to front */
1457 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1458 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1459 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1460/* Connect HP out to front */
1461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1462 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1463 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1464 { }
1465};
1466
Hector Martin3b315d72009-06-02 10:54:19 +02001467/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001468 * ALC888 Acer Aspire 6530G model
1469 */
1470
1471static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1472/* Bias voltage on for external mic port */
1473 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1474/* Enable unsolicited event for HP jack */
1475 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1476/* Enable speaker output */
1477 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1478 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1479/* Enable headphone output */
1480 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1481 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1482 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1483 { }
1484};
1485
1486/*
Hector Martin018df412009-06-04 00:13:40 +02001487 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001488 */
1489
Hector Martin018df412009-06-04 00:13:40 +02001490static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001491/* Front Mic: set to PIN_IN (empty by default) */
1492 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1493/* Unselect Front Mic by default in input mixer 3 */
1494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1495/* Enable unsolicited event for HP jack */
1496 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1497/* Connect Internal Front to Front */
1498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1501/* Connect Internal Rear to Rear */
1502 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1503 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1504 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1505/* Connect Internal CLFE to CLFE */
1506 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1507 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1508 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1509/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001510 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001511 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1512 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1513/* Enable all DACs */
1514/* DAC DISABLE/MUTE 1? */
1515/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1516 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1517 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1518/* DAC DISABLE/MUTE 2? */
1519/* some bit here disables the other DACs. Init=0x4900 */
1520 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1521 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1522/* Enable amplifiers */
1523 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1524 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001525/* DMIC fix
1526 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1527 * which makes the stereo useless. However, either the mic or the ALC889
1528 * makes the signal become a difference/sum signal instead of standard
1529 * stereo, which is annoying. So instead we flip this bit which makes the
1530 * codec replicate the sum signal to both channels, turning it into a
1531 * normal mono mic.
1532 */
1533/* DMIC_CONTROL? Init value = 0x0001 */
1534 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1535 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001536 { }
1537};
1538
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001539static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001540 /* Front mic only available on one ADC */
1541 {
1542 .num_items = 4,
1543 .items = {
1544 { "Mic", 0x0 },
1545 { "Line", 0x2 },
1546 { "CD", 0x4 },
1547 { "Front Mic", 0xb },
1548 },
1549 },
1550 {
1551 .num_items = 3,
1552 .items = {
1553 { "Mic", 0x0 },
1554 { "Line", 0x2 },
1555 { "CD", 0x4 },
1556 },
1557 }
1558};
1559
Tony Vroond2fd4b02009-06-21 00:40:10 +01001560static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1561 /* Interal mic only available on one ADC */
1562 {
1563 .num_items = 3,
1564 .items = {
1565 { "Ext Mic", 0x0 },
1566 { "CD", 0x4 },
1567 { "Int Mic", 0xb },
1568 },
1569 },
1570 {
1571 .num_items = 2,
1572 .items = {
1573 { "Ext Mic", 0x0 },
1574 { "CD", 0x4 },
1575 },
1576 }
1577};
1578
Hector Martin018df412009-06-04 00:13:40 +02001579static struct hda_input_mux alc889_capture_sources[3] = {
1580 /* Digital mic only available on first "ADC" */
1581 {
1582 .num_items = 5,
1583 .items = {
1584 { "Mic", 0x0 },
1585 { "Line", 0x2 },
1586 { "CD", 0x4 },
1587 { "Front Mic", 0xb },
1588 { "Input Mix", 0xa },
1589 },
1590 },
1591 {
1592 .num_items = 4,
1593 .items = {
1594 { "Mic", 0x0 },
1595 { "Line", 0x2 },
1596 { "CD", 0x4 },
1597 { "Input Mix", 0xa },
1598 },
1599 },
1600 {
1601 .num_items = 4,
1602 .items = {
1603 { "Mic", 0x0 },
1604 { "Line", 0x2 },
1605 { "CD", 0x4 },
1606 { "Input Mix", 0xa },
1607 },
1608 }
1609};
1610
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001611static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001612 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1613 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1614 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1615 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1616 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1617 HDA_OUTPUT),
1618 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1619 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1620 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1621 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1622 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1623 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1624 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1625 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1626 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1628 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1629 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001630 { } /* end */
1631};
1632
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001633static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001634{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001635 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001636
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001637 spec->autocfg.hp_pins[0] = 0x15;
1638 spec->autocfg.speaker_pins[0] = 0x14;
1639 alc_automute_amp(codec);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001640}
1641
Hector Martin018df412009-06-04 00:13:40 +02001642static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001643{
1644 struct alc_spec *spec = codec->spec;
1645
1646 spec->autocfg.hp_pins[0] = 0x15;
1647 spec->autocfg.speaker_pins[0] = 0x14;
1648 spec->autocfg.speaker_pins[1] = 0x16;
1649 spec->autocfg.speaker_pins[2] = 0x1b;
1650 alc_automute_amp(codec);
1651}
1652
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001653/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001654 * ALC880 3-stack model
1655 *
1656 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001657 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1658 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001659 */
1660
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001661static hda_nid_t alc880_dac_nids[4] = {
1662 /* front, rear, clfe, rear_surr */
1663 0x02, 0x05, 0x04, 0x03
1664};
1665
1666static hda_nid_t alc880_adc_nids[3] = {
1667 /* ADC0-2 */
1668 0x07, 0x08, 0x09,
1669};
1670
1671/* The datasheet says the node 0x07 is connected from inputs,
1672 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001673 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001674 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001675static hda_nid_t alc880_adc_nids_alt[2] = {
1676 /* ADC1-2 */
1677 0x08, 0x09,
1678};
1679
1680#define ALC880_DIGOUT_NID 0x06
1681#define ALC880_DIGIN_NID 0x0a
1682
1683static struct hda_input_mux alc880_capture_source = {
1684 .num_items = 4,
1685 .items = {
1686 { "Mic", 0x0 },
1687 { "Front Mic", 0x3 },
1688 { "Line", 0x2 },
1689 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001690 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001691};
1692
1693/* channel source setting (2/6 channel selection for 3-stack) */
1694/* 2ch mode */
1695static struct hda_verb alc880_threestack_ch2_init[] = {
1696 /* set line-in to input, mute it */
1697 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1698 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1699 /* set mic-in to input vref 80%, mute it */
1700 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1701 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001702 { } /* end */
1703};
1704
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001705/* 6ch mode */
1706static struct hda_verb alc880_threestack_ch6_init[] = {
1707 /* set line-in to output, unmute it */
1708 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1709 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1710 /* set mic-in to output, unmute it */
1711 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1712 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1713 { } /* end */
1714};
1715
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001716static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001717 { 2, alc880_threestack_ch2_init },
1718 { 6, alc880_threestack_ch6_init },
1719};
1720
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001721static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001722 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001723 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001724 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001725 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001726 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1727 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001728 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1729 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001730 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1731 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1732 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1733 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1734 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1735 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1736 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1737 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001738 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001739 {
1740 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1741 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001742 .info = alc_ch_mode_info,
1743 .get = alc_ch_mode_get,
1744 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001745 },
1746 { } /* end */
1747};
1748
1749/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001750static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1751 struct snd_ctl_elem_info *uinfo)
1752{
1753 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1754 struct alc_spec *spec = codec->spec;
1755 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001756
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001757 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001758 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1759 HDA_INPUT);
1760 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001761 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001762 return err;
1763}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001764
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001765static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1766 unsigned int size, unsigned int __user *tlv)
1767{
1768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1769 struct alc_spec *spec = codec->spec;
1770 int err;
1771
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001772 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001773 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1774 HDA_INPUT);
1775 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001776 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001777 return err;
1778}
1779
1780typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1781 struct snd_ctl_elem_value *ucontrol);
1782
1783static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1784 struct snd_ctl_elem_value *ucontrol,
1785 getput_call_t func)
1786{
1787 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1788 struct alc_spec *spec = codec->spec;
1789 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1790 int err;
1791
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001792 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001793 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1794 3, 0, HDA_INPUT);
1795 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001796 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001797 return err;
1798}
1799
1800static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1801 struct snd_ctl_elem_value *ucontrol)
1802{
1803 return alc_cap_getput_caller(kcontrol, ucontrol,
1804 snd_hda_mixer_amp_volume_get);
1805}
1806
1807static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1808 struct snd_ctl_elem_value *ucontrol)
1809{
1810 return alc_cap_getput_caller(kcontrol, ucontrol,
1811 snd_hda_mixer_amp_volume_put);
1812}
1813
1814/* capture mixer elements */
1815#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1816
1817static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1818 struct snd_ctl_elem_value *ucontrol)
1819{
1820 return alc_cap_getput_caller(kcontrol, ucontrol,
1821 snd_hda_mixer_amp_switch_get);
1822}
1823
1824static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1825 struct snd_ctl_elem_value *ucontrol)
1826{
1827 return alc_cap_getput_caller(kcontrol, ucontrol,
1828 snd_hda_mixer_amp_switch_put);
1829}
1830
Takashi Iwaia23b6882009-03-23 15:21:36 +01001831#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001832 { \
1833 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1834 .name = "Capture Switch", \
1835 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1836 .count = num, \
1837 .info = alc_cap_sw_info, \
1838 .get = alc_cap_sw_get, \
1839 .put = alc_cap_sw_put, \
1840 }, \
1841 { \
1842 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1843 .name = "Capture Volume", \
1844 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1845 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1846 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1847 .count = num, \
1848 .info = alc_cap_vol_info, \
1849 .get = alc_cap_vol_get, \
1850 .put = alc_cap_vol_put, \
1851 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001852 }
1853
1854#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001855 { \
1856 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1857 /* .name = "Capture Source", */ \
1858 .name = "Input Source", \
1859 .count = num, \
1860 .info = alc_mux_enum_info, \
1861 .get = alc_mux_enum_get, \
1862 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001863 }
1864
1865#define DEFINE_CAPMIX(num) \
1866static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1867 _DEFINE_CAPMIX(num), \
1868 _DEFINE_CAPSRC(num), \
1869 { } /* end */ \
1870}
1871
1872#define DEFINE_CAPMIX_NOSRC(num) \
1873static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1874 _DEFINE_CAPMIX(num), \
1875 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001876}
1877
1878/* up to three ADCs */
1879DEFINE_CAPMIX(1);
1880DEFINE_CAPMIX(2);
1881DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01001882DEFINE_CAPMIX_NOSRC(1);
1883DEFINE_CAPMIX_NOSRC(2);
1884DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001885
1886/*
1887 * ALC880 5-stack model
1888 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001889 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1890 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001891 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1892 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1893 */
1894
1895/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001896static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001897 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001898 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001899 { } /* end */
1900};
1901
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001902/* channel source setting (6/8 channel selection for 5-stack) */
1903/* 6ch mode */
1904static struct hda_verb alc880_fivestack_ch6_init[] = {
1905 /* set line-in to input, mute it */
1906 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1907 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001908 { } /* end */
1909};
1910
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001911/* 8ch mode */
1912static struct hda_verb alc880_fivestack_ch8_init[] = {
1913 /* set line-in to output, unmute it */
1914 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1915 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1916 { } /* end */
1917};
1918
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001919static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001920 { 6, alc880_fivestack_ch6_init },
1921 { 8, alc880_fivestack_ch8_init },
1922};
1923
1924
1925/*
1926 * ALC880 6-stack model
1927 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001928 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1929 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001930 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1931 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1932 */
1933
1934static hda_nid_t alc880_6st_dac_nids[4] = {
1935 /* front, rear, clfe, rear_surr */
1936 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001937};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001938
1939static struct hda_input_mux alc880_6stack_capture_source = {
1940 .num_items = 4,
1941 .items = {
1942 { "Mic", 0x0 },
1943 { "Front Mic", 0x1 },
1944 { "Line", 0x2 },
1945 { "CD", 0x4 },
1946 },
1947};
1948
1949/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001950static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001951 { 8, NULL },
1952};
1953
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001954static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001955 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001956 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001957 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001958 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001959 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1960 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001961 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1962 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001963 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001964 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001965 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1966 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1968 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1971 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1972 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001973 {
1974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1975 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001976 .info = alc_ch_mode_info,
1977 .get = alc_ch_mode_get,
1978 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001979 },
1980 { } /* end */
1981};
1982
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001983
1984/*
1985 * ALC880 W810 model
1986 *
1987 * W810 has rear IO for:
1988 * Front (DAC 02)
1989 * Surround (DAC 03)
1990 * Center/LFE (DAC 04)
1991 * Digital out (06)
1992 *
1993 * The system also has a pair of internal speakers, and a headphone jack.
1994 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001995 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001996 * There is a variable resistor to control the speaker or headphone
1997 * volume. This is a hardware-only device without a software API.
1998 *
1999 * Plugging headphones in will disable the internal speakers. This is
2000 * implemented in hardware, not via the driver using jack sense. In
2001 * a similar fashion, plugging into the rear socket marked "front" will
2002 * disable both the speakers and headphones.
2003 *
2004 * For input, there's a microphone jack, and an "audio in" jack.
2005 * These may not do anything useful with this driver yet, because I
2006 * haven't setup any initialization verbs for these yet...
2007 */
2008
2009static hda_nid_t alc880_w810_dac_nids[3] = {
2010 /* front, rear/surround, clfe */
2011 0x02, 0x03, 0x04
2012};
2013
2014/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002015static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002016 { 6, NULL }
2017};
2018
2019/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002020static struct snd_kcontrol_new alc880_w810_base_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("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002024 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002025 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2026 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002027 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2028 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2030 { } /* end */
2031};
2032
2033
2034/*
2035 * Z710V model
2036 *
2037 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002038 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2039 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002040 */
2041
2042static hda_nid_t alc880_z71v_dac_nids[1] = {
2043 0x02
2044};
2045#define ALC880_Z71V_HP_DAC 0x03
2046
2047/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002048static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002049 { 2, NULL }
2050};
2051
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002052static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002053 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002054 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002055 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002056 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002057 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2058 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2060 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2061 { } /* end */
2062};
2063
2064
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002065/*
2066 * ALC880 F1734 model
2067 *
2068 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2069 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2070 */
2071
2072static hda_nid_t alc880_f1734_dac_nids[1] = {
2073 0x03
2074};
2075#define ALC880_F1734_HP_DAC 0x02
2076
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002077static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002078 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002079 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002080 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2081 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002082 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2083 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002084 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002086 { } /* end */
2087};
2088
Takashi Iwai937b4162008-02-11 14:52:36 +01002089static struct hda_input_mux alc880_f1734_capture_source = {
2090 .num_items = 2,
2091 .items = {
2092 { "Mic", 0x1 },
2093 { "CD", 0x4 },
2094 },
2095};
2096
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002097
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002098/*
2099 * ALC880 ASUS model
2100 *
2101 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2102 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2103 * Mic = 0x18, Line = 0x1a
2104 */
2105
2106#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2107#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2108
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002109static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002111 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002112 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002113 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002114 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2115 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002116 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2117 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002118 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2119 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2120 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2121 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002124 {
2125 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2126 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002127 .info = alc_ch_mode_info,
2128 .get = alc_ch_mode_get,
2129 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002130 },
2131 { } /* end */
2132};
2133
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002134/*
2135 * ALC880 ASUS W1V model
2136 *
2137 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2138 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2139 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2140 */
2141
2142/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002143static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002144 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2145 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002146 { } /* end */
2147};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002148
Kailang Yangdf694da2005-12-05 19:42:22 +01002149/* TCL S700 */
2150static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2151 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2152 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2153 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2154 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2155 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2158 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2159 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002160 { } /* end */
2161};
2162
Kailang Yangccc656c2006-10-17 12:32:26 +02002163/* Uniwill */
2164static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002165 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2166 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2167 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2168 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002169 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2170 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2171 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2172 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2173 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2174 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2175 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2176 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2179 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2180 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002181 {
2182 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2183 .name = "Channel Mode",
2184 .info = alc_ch_mode_info,
2185 .get = alc_ch_mode_get,
2186 .put = alc_ch_mode_put,
2187 },
2188 { } /* end */
2189};
2190
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002191static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2192 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2193 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2194 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2195 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2198 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2199 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2200 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2201 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2202 { } /* end */
2203};
2204
Kailang Yangccc656c2006-10-17 12:32:26 +02002205static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002206 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2207 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2208 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2209 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2212 { } /* end */
2213};
2214
Linus Torvalds1da177e2005-04-16 15:20:36 -07002215/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002216 * virtual master controls
2217 */
2218
2219/*
2220 * slave controls for virtual master
2221 */
2222static const char *alc_slave_vols[] = {
2223 "Front Playback Volume",
2224 "Surround Playback Volume",
2225 "Center Playback Volume",
2226 "LFE Playback Volume",
2227 "Side Playback Volume",
2228 "Headphone Playback Volume",
2229 "Speaker Playback Volume",
2230 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002231 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002232 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002233 NULL,
2234};
2235
2236static const char *alc_slave_sws[] = {
2237 "Front Playback Switch",
2238 "Surround Playback Switch",
2239 "Center Playback Switch",
2240 "LFE Playback Switch",
2241 "Side Playback Switch",
2242 "Headphone Playback Switch",
2243 "Speaker Playback Switch",
2244 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002245 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002246 NULL,
2247};
2248
2249/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002250 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002251 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002252
2253static void alc_free_kctls(struct hda_codec *codec);
2254
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002255/* additional beep mixers; the actual parameters are overwritten at build */
2256static struct snd_kcontrol_new alc_beep_mixer[] = {
2257 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2258 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2259 { } /* end */
2260};
2261
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262static int alc_build_controls(struct hda_codec *codec)
2263{
2264 struct alc_spec *spec = codec->spec;
2265 int err;
2266 int i;
2267
2268 for (i = 0; i < spec->num_mixers; i++) {
2269 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2270 if (err < 0)
2271 return err;
2272 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002273 if (spec->cap_mixer) {
2274 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2275 if (err < 0)
2276 return err;
2277 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002279 err = snd_hda_create_spdif_out_ctls(codec,
2280 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002281 if (err < 0)
2282 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002283 if (!spec->no_analog) {
2284 err = snd_hda_create_spdif_share_sw(codec,
2285 &spec->multiout);
2286 if (err < 0)
2287 return err;
2288 spec->multiout.share_spdif = 1;
2289 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002290 }
2291 if (spec->dig_in_nid) {
2292 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2293 if (err < 0)
2294 return err;
2295 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002296
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002297 /* create beep controls if needed */
2298 if (spec->beep_amp) {
2299 struct snd_kcontrol_new *knew;
2300 for (knew = alc_beep_mixer; knew->name; knew++) {
2301 struct snd_kcontrol *kctl;
2302 kctl = snd_ctl_new1(knew, codec);
2303 if (!kctl)
2304 return -ENOMEM;
2305 kctl->private_value = spec->beep_amp;
2306 err = snd_hda_ctl_add(codec, kctl);
2307 if (err < 0)
2308 return err;
2309 }
2310 }
2311
Takashi Iwai2134ea42008-01-10 16:53:55 +01002312 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002313 if (!spec->no_analog &&
2314 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002315 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002316 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002317 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002318 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002319 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002320 if (err < 0)
2321 return err;
2322 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002323 if (!spec->no_analog &&
2324 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002325 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2326 NULL, alc_slave_sws);
2327 if (err < 0)
2328 return err;
2329 }
2330
Takashi Iwai603c4012008-07-30 15:01:44 +02002331 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002332 return 0;
2333}
2334
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002335
Linus Torvalds1da177e2005-04-16 15:20:36 -07002336/*
2337 * initialize the codec volumes, etc
2338 */
2339
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002340/*
2341 * generic initialization of ADC, input mixers and output mixers
2342 */
2343static struct hda_verb alc880_volume_init_verbs[] = {
2344 /*
2345 * Unmute ADC0-2 and set the default input to mic-in
2346 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002347 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002348 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002349 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002350 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002351 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002352 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002353
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002354 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2355 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002356 * Note: PASD motherboards uses the Line In 2 as the input for front
2357 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002358 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002359 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002360 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2361 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2362 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2363 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2364 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2365 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002367
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002368 /*
2369 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002371 /* set vol=0 to output mixers */
2372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2375 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2376 /* set up input amps for analog loopback */
2377 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002378 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2379 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002380 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2381 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002382 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2383 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002384 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2385 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002386
2387 { }
2388};
2389
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002390/*
2391 * 3-stack pin configuration:
2392 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2393 */
2394static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2395 /*
2396 * preset connection lists of input pins
2397 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2398 */
2399 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2400 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2401 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2402
2403 /*
2404 * Set pin mode and muting
2405 */
2406 /* set front pin widgets 0x14 for output */
2407 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2408 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2409 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2410 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2411 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2412 /* Mic2 (as headphone out) for HP output */
2413 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2414 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2415 /* Line In pin widget for input */
2416 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2417 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2418 /* Line2 (as front mic) pin widget for input and vref at 80% */
2419 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2420 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2421 /* CD pin widget for input */
2422 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2423
2424 { }
2425};
2426
2427/*
2428 * 5-stack pin configuration:
2429 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2430 * line-in/side = 0x1a, f-mic = 0x1b
2431 */
2432static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2433 /*
2434 * preset connection lists of input pins
2435 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2436 */
2437 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2438 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2439
2440 /*
2441 * Set pin mode and muting
2442 */
2443 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002444 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2445 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2446 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2447 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002448 /* unmute pins for output (no gain on this amp) */
2449 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2451 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2452 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2453
Linus Torvalds1da177e2005-04-16 15:20:36 -07002454 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002455 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002456 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2457 /* Mic2 (as headphone out) for HP output */
2458 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002459 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002460 /* Line In pin widget for input */
2461 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2463 /* Line2 (as front mic) pin widget for input and vref at 80% */
2464 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2465 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2466 /* CD pin widget for input */
2467 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002468
2469 { }
2470};
2471
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002472/*
2473 * W810 pin configuration:
2474 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2475 */
2476static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002477 /* hphone/speaker input selector: front DAC */
2478 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2479
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002480 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2481 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2483 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2484 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2485 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2486
2487 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002488 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002489
Linus Torvalds1da177e2005-04-16 15:20:36 -07002490 { }
2491};
2492
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002493/*
2494 * Z71V pin configuration:
2495 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2496 */
2497static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002500 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002501 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002502
Takashi Iwai16ded522005-06-10 19:58:24 +02002503 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002504 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002505 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002506 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002507
2508 { }
2509};
2510
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002511/*
2512 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002513 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2514 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002515 */
2516static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2517 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2518
Takashi Iwai16ded522005-06-10 19:58:24 +02002519 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002520 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002521 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002522 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002523 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002524 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002525 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002526 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2527
Takashi Iwai16ded522005-06-10 19:58:24 +02002528 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002529 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002530 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002531 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002532 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002533 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002534 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002535 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002536 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002537
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002538 { }
2539};
Takashi Iwai16ded522005-06-10 19:58:24 +02002540
Kailang Yangccc656c2006-10-17 12:32:26 +02002541/*
2542 * Uniwill pin configuration:
2543 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2544 * line = 0x1a
2545 */
2546static struct hda_verb alc880_uniwill_init_verbs[] = {
2547 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2548
2549 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2550 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2552 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2553 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2554 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2555 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2556 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2557 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2558 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2559 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2560 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2561 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2562 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2563
2564 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2565 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2566 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2567 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2568 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2569 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2570 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2571 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2572 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2573
2574 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2575 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2576
2577 { }
2578};
2579
2580/*
2581* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002582* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002583 */
2584static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2585 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2586
2587 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2588 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2589 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2591 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2592 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2593 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2595 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2596 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2597 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2598 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2599
2600 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2601 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2602 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2603 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2604 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2605 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2606
2607 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2608 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2609
2610 { }
2611};
2612
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002613static struct hda_verb alc880_beep_init_verbs[] = {
2614 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2615 { }
2616};
2617
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002618/* auto-toggle front mic */
2619static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2620{
2621 unsigned int present;
2622 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002623
2624 present = snd_hda_codec_read(codec, 0x18, 0,
2625 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002626 bits = present ? HDA_AMP_MUTE : 0;
2627 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002628}
2629
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002630static void alc880_uniwill_init_hook(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002631{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002632 struct alc_spec *spec = codec->spec;
2633
2634 spec->autocfg.hp_pins[0] = 0x14;
2635 spec->autocfg.speaker_pins[0] = 0x15;
2636 spec->autocfg.speaker_pins[0] = 0x16;
2637 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002638 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002639}
2640
2641static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2642 unsigned int res)
2643{
2644 /* Looks like the unsol event is incompatible with the standard
2645 * definition. 4bit tag is placed at 28 bit!
2646 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002647 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002648 case ALC880_MIC_EVENT:
2649 alc880_uniwill_mic_automute(codec);
2650 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002651 default:
2652 alc_automute_amp_unsol_event(codec, res);
2653 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002654 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002655}
2656
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002657static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002658{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002659 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002660
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002661 spec->autocfg.hp_pins[0] = 0x14;
2662 spec->autocfg.speaker_pins[0] = 0x15;
2663 alc_automute_amp(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002664}
2665
2666static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2667{
2668 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002669
Kailang Yangccc656c2006-10-17 12:32:26 +02002670 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002671 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2672 present &= HDA_AMP_VOLMASK;
2673 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2674 HDA_AMP_VOLMASK, present);
2675 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2676 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002677}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002678
Kailang Yangccc656c2006-10-17 12:32:26 +02002679static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2680 unsigned int res)
2681{
2682 /* Looks like the unsol event is incompatible with the standard
2683 * definition. 4bit tag is placed at 28 bit!
2684 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002685 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002686 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002687 else
2688 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002689}
2690
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002691/*
2692 * F1734 pin configuration:
2693 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2694 */
2695static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002696 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002697 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2698 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2699 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2700 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2701
2702 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2704 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2705 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2706
2707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002709 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002710 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2711 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2712 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2713 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2714 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2715 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002716
Takashi Iwai937b4162008-02-11 14:52:36 +01002717 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2718 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2719
Takashi Iwai16ded522005-06-10 19:58:24 +02002720 { }
2721};
2722
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002723/*
2724 * ASUS pin configuration:
2725 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2726 */
2727static struct hda_verb alc880_pin_asus_init_verbs[] = {
2728 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2729 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2730 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2731 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2732
2733 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2734 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2735 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2736 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2737 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2738 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2739 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2740 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2741
2742 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2743 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2744 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2746 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2747 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2748 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2749 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2750 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002751
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002752 { }
2753};
2754
2755/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002756#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2757#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002758#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002759
Kailang Yangdf694da2005-12-05 19:42:22 +01002760/* Clevo m520g init */
2761static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2762 /* headphone output */
2763 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2764 /* line-out */
2765 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2766 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2767 /* Line-in */
2768 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2769 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2770 /* CD */
2771 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2772 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2773 /* Mic1 (rear panel) */
2774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2776 /* Mic2 (front panel) */
2777 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2778 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2779 /* headphone */
2780 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2781 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2782 /* change to EAPD mode */
2783 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2784 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2785
2786 { }
2787};
2788
2789static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002790 /* change to EAPD mode */
2791 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2792 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2793
Kailang Yangdf694da2005-12-05 19:42:22 +01002794 /* Headphone output */
2795 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2796 /* Front output*/
2797 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2798 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2799
2800 /* Line In pin widget for input */
2801 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2802 /* CD pin widget for input */
2803 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2804 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2805 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2806
2807 /* change to EAPD mode */
2808 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2809 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2810
2811 { }
2812};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002813
2814/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002815 * LG m1 express dual
2816 *
2817 * Pin assignment:
2818 * Rear Line-In/Out (blue): 0x14
2819 * Build-in Mic-In: 0x15
2820 * Speaker-out: 0x17
2821 * HP-Out (green): 0x1b
2822 * Mic-In/Out (red): 0x19
2823 * SPDIF-Out: 0x1e
2824 */
2825
2826/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2827static hda_nid_t alc880_lg_dac_nids[3] = {
2828 0x05, 0x02, 0x03
2829};
2830
2831/* seems analog CD is not working */
2832static struct hda_input_mux alc880_lg_capture_source = {
2833 .num_items = 3,
2834 .items = {
2835 { "Mic", 0x1 },
2836 { "Line", 0x5 },
2837 { "Internal Mic", 0x6 },
2838 },
2839};
2840
2841/* 2,4,6 channel modes */
2842static struct hda_verb alc880_lg_ch2_init[] = {
2843 /* set line-in and mic-in to input */
2844 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2845 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2846 { }
2847};
2848
2849static struct hda_verb alc880_lg_ch4_init[] = {
2850 /* set line-in to out and mic-in to input */
2851 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2852 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2853 { }
2854};
2855
2856static struct hda_verb alc880_lg_ch6_init[] = {
2857 /* set line-in and mic-in to output */
2858 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2859 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2860 { }
2861};
2862
2863static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2864 { 2, alc880_lg_ch2_init },
2865 { 4, alc880_lg_ch4_init },
2866 { 6, alc880_lg_ch6_init },
2867};
2868
2869static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002870 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2871 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002872 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2873 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2874 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2875 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2876 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2877 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2880 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2881 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2882 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2883 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2884 {
2885 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2886 .name = "Channel Mode",
2887 .info = alc_ch_mode_info,
2888 .get = alc_ch_mode_get,
2889 .put = alc_ch_mode_put,
2890 },
2891 { } /* end */
2892};
2893
2894static struct hda_verb alc880_lg_init_verbs[] = {
2895 /* set capture source to mic-in */
2896 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2897 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2898 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2899 /* mute all amp mixer inputs */
2900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2902 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002903 /* line-in to input */
2904 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2905 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2906 /* built-in mic */
2907 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2908 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2909 /* speaker-out */
2910 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2911 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2912 /* mic-in to input */
2913 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2914 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2915 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2916 /* HP-out */
2917 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2918 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2919 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2920 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002921 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002922 { }
2923};
2924
2925/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002926static void alc880_lg_init_hook(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002927{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002928 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002929
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002930 spec->autocfg.hp_pins[0] = 0x1b;
2931 spec->autocfg.speaker_pins[0] = 0x17;
2932 alc_automute_amp(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002933}
2934
2935/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002936 * LG LW20
2937 *
2938 * Pin assignment:
2939 * Speaker-out: 0x14
2940 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002941 * Built-in Mic-In: 0x19
2942 * Line-In: 0x1b
2943 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002944 * SPDIF-Out: 0x1e
2945 */
2946
Takashi Iwaid6815182006-03-23 16:06:23 +01002947static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002948 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002949 .items = {
2950 { "Mic", 0x0 },
2951 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002952 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002953 },
2954};
2955
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002956#define alc880_lg_lw_modes alc880_threestack_modes
2957
Takashi Iwaid6815182006-03-23 16:06:23 +01002958static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002959 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2960 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2961 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2962 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2963 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2964 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2965 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2966 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2968 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2971 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2972 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002973 {
2974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2975 .name = "Channel Mode",
2976 .info = alc_ch_mode_info,
2977 .get = alc_ch_mode_get,
2978 .put = alc_ch_mode_put,
2979 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002980 { } /* end */
2981};
2982
2983static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002984 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2985 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2986 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2987
Takashi Iwaid6815182006-03-23 16:06:23 +01002988 /* set capture source to mic-in */
2989 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2990 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2991 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002992 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002993 /* speaker-out */
2994 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2995 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2996 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002997 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2998 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2999 /* mic-in to input */
3000 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3001 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3002 /* built-in mic */
3003 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3004 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3005 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003006 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003007 { }
3008};
3009
3010/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003011static void alc880_lg_lw_init_hook(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003012{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003013 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003014
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003015 spec->autocfg.hp_pins[0] = 0x1b;
3016 spec->autocfg.speaker_pins[0] = 0x14;
3017 alc_automute_amp(codec);
Takashi Iwaid6815182006-03-23 16:06:23 +01003018}
3019
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003020static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3021 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3022 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3023 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3024 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3025 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3026 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3027 { } /* end */
3028};
3029
3030static struct hda_input_mux alc880_medion_rim_capture_source = {
3031 .num_items = 2,
3032 .items = {
3033 { "Mic", 0x0 },
3034 { "Internal Mic", 0x1 },
3035 },
3036};
3037
3038static struct hda_verb alc880_medion_rim_init_verbs[] = {
3039 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3040
3041 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3042 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3043
3044 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3045 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3046 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3047 /* Mic2 (as headphone out) for HP output */
3048 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3049 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3050 /* Internal Speaker */
3051 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3052 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3053
3054 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3055 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3056
3057 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3058 { }
3059};
3060
3061/* toggle speaker-output according to the hp-jack state */
3062static void alc880_medion_rim_automute(struct hda_codec *codec)
3063{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003064 struct alc_spec *spec = codec->spec;
3065 alc_automute_amp(codec);
3066 /* toggle EAPD */
3067 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003068 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3069 else
3070 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3071}
3072
3073static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3074 unsigned int res)
3075{
3076 /* Looks like the unsol event is incompatible with the standard
3077 * definition. 4bit tag is placed at 28 bit!
3078 */
3079 if ((res >> 28) == ALC880_HP_EVENT)
3080 alc880_medion_rim_automute(codec);
3081}
3082
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003083static void alc880_medion_rim_init_hook(struct hda_codec *codec)
3084{
3085 struct alc_spec *spec = codec->spec;
3086
3087 spec->autocfg.hp_pins[0] = 0x14;
3088 spec->autocfg.speaker_pins[0] = 0x1b;
3089 alc880_medion_rim_automute(codec);
3090}
3091
Takashi Iwaicb53c622007-08-10 17:21:45 +02003092#ifdef CONFIG_SND_HDA_POWER_SAVE
3093static struct hda_amp_list alc880_loopbacks[] = {
3094 { 0x0b, HDA_INPUT, 0 },
3095 { 0x0b, HDA_INPUT, 1 },
3096 { 0x0b, HDA_INPUT, 2 },
3097 { 0x0b, HDA_INPUT, 3 },
3098 { 0x0b, HDA_INPUT, 4 },
3099 { } /* end */
3100};
3101
3102static struct hda_amp_list alc880_lg_loopbacks[] = {
3103 { 0x0b, HDA_INPUT, 1 },
3104 { 0x0b, HDA_INPUT, 6 },
3105 { 0x0b, HDA_INPUT, 7 },
3106 { } /* end */
3107};
3108#endif
3109
Takashi Iwaid6815182006-03-23 16:06:23 +01003110/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003111 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003112 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003113
Linus Torvalds1da177e2005-04-16 15:20:36 -07003114static int alc_init(struct hda_codec *codec)
3115{
3116 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003117 unsigned int i;
3118
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003119 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003120 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003121
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003122 for (i = 0; i < spec->num_init_verbs; i++)
3123 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003124
3125 if (spec->init_hook)
3126 spec->init_hook(codec);
3127
Linus Torvalds1da177e2005-04-16 15:20:36 -07003128 return 0;
3129}
3130
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003131static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3132{
3133 struct alc_spec *spec = codec->spec;
3134
3135 if (spec->unsol_event)
3136 spec->unsol_event(codec, res);
3137}
3138
Takashi Iwaicb53c622007-08-10 17:21:45 +02003139#ifdef CONFIG_SND_HDA_POWER_SAVE
3140static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3141{
3142 struct alc_spec *spec = codec->spec;
3143 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3144}
3145#endif
3146
Linus Torvalds1da177e2005-04-16 15:20:36 -07003147/*
3148 * Analog playback callbacks
3149 */
3150static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3151 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003152 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003153{
3154 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003155 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3156 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003157}
3158
3159static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3160 struct hda_codec *codec,
3161 unsigned int stream_tag,
3162 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003163 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003164{
3165 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003166 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3167 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003168}
3169
3170static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3171 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003172 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003173{
3174 struct alc_spec *spec = codec->spec;
3175 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3176}
3177
3178/*
3179 * Digital out
3180 */
3181static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3182 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003183 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003184{
3185 struct alc_spec *spec = codec->spec;
3186 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3187}
3188
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003189static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3190 struct hda_codec *codec,
3191 unsigned int stream_tag,
3192 unsigned int format,
3193 struct snd_pcm_substream *substream)
3194{
3195 struct alc_spec *spec = codec->spec;
3196 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3197 stream_tag, format, substream);
3198}
3199
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003200static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3201 struct hda_codec *codec,
3202 struct snd_pcm_substream *substream)
3203{
3204 struct alc_spec *spec = codec->spec;
3205 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3206}
3207
Linus Torvalds1da177e2005-04-16 15:20:36 -07003208static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3209 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003210 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003211{
3212 struct alc_spec *spec = codec->spec;
3213 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3214}
3215
3216/*
3217 * Analog capture
3218 */
Takashi Iwai63300792008-01-24 15:31:36 +01003219static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003220 struct hda_codec *codec,
3221 unsigned int stream_tag,
3222 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003223 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003224{
3225 struct alc_spec *spec = codec->spec;
3226
Takashi Iwai63300792008-01-24 15:31:36 +01003227 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003228 stream_tag, 0, format);
3229 return 0;
3230}
3231
Takashi Iwai63300792008-01-24 15:31:36 +01003232static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003233 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003234 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003235{
3236 struct alc_spec *spec = codec->spec;
3237
Takashi Iwai888afa12008-03-18 09:57:50 +01003238 snd_hda_codec_cleanup_stream(codec,
3239 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003240 return 0;
3241}
3242
3243
3244/*
3245 */
3246static struct hda_pcm_stream alc880_pcm_analog_playback = {
3247 .substreams = 1,
3248 .channels_min = 2,
3249 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003250 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003251 .ops = {
3252 .open = alc880_playback_pcm_open,
3253 .prepare = alc880_playback_pcm_prepare,
3254 .cleanup = alc880_playback_pcm_cleanup
3255 },
3256};
3257
3258static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003259 .substreams = 1,
3260 .channels_min = 2,
3261 .channels_max = 2,
3262 /* NID is set in alc_build_pcms */
3263};
3264
3265static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3266 .substreams = 1,
3267 .channels_min = 2,
3268 .channels_max = 2,
3269 /* NID is set in alc_build_pcms */
3270};
3271
3272static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3273 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003274 .channels_min = 2,
3275 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003276 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003277 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003278 .prepare = alc880_alt_capture_pcm_prepare,
3279 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003280 },
3281};
3282
3283static struct hda_pcm_stream alc880_pcm_digital_playback = {
3284 .substreams = 1,
3285 .channels_min = 2,
3286 .channels_max = 2,
3287 /* NID is set in alc_build_pcms */
3288 .ops = {
3289 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003290 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003291 .prepare = alc880_dig_playback_pcm_prepare,
3292 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003293 },
3294};
3295
3296static struct hda_pcm_stream alc880_pcm_digital_capture = {
3297 .substreams = 1,
3298 .channels_min = 2,
3299 .channels_max = 2,
3300 /* NID is set in alc_build_pcms */
3301};
3302
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003303/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003304static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003305 .substreams = 0,
3306 .channels_min = 0,
3307 .channels_max = 0,
3308};
3309
Linus Torvalds1da177e2005-04-16 15:20:36 -07003310static int alc_build_pcms(struct hda_codec *codec)
3311{
3312 struct alc_spec *spec = codec->spec;
3313 struct hda_pcm *info = spec->pcm_rec;
3314 int i;
3315
3316 codec->num_pcms = 1;
3317 codec->pcm_info = info;
3318
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003319 if (spec->no_analog)
3320 goto skip_analog;
3321
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003322 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3323 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003324 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003325
Takashi Iwai4a471b72005-12-07 13:56:29 +01003326 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003327 if (snd_BUG_ON(!spec->multiout.dac_nids))
3328 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003329 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3330 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3331 }
3332 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003333 if (snd_BUG_ON(!spec->adc_nids))
3334 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003335 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3336 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3337 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003338
Takashi Iwai4a471b72005-12-07 13:56:29 +01003339 if (spec->channel_mode) {
3340 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3341 for (i = 0; i < spec->num_channel_mode; i++) {
3342 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3343 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3344 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003345 }
3346 }
3347
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003348 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003349 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003350 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003351 snprintf(spec->stream_name_digital,
3352 sizeof(spec->stream_name_digital),
3353 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003354 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003355 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003356 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003357 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003358 if (spec->dig_out_type)
3359 info->pcm_type = spec->dig_out_type;
3360 else
3361 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003362 if (spec->multiout.dig_out_nid &&
3363 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003364 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3365 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3366 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003367 if (spec->dig_in_nid &&
3368 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003369 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3370 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3371 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003372 /* FIXME: do we need this for all Realtek codec models? */
3373 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003374 }
3375
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003376 if (spec->no_analog)
3377 return 0;
3378
Takashi Iwaie08a0072006-09-07 17:52:14 +02003379 /* If the use of more than one ADC is requested for the current
3380 * model, configure a second analog capture-only PCM.
3381 */
3382 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003383 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3384 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003385 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003386 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003387 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003388 if (spec->alt_dac_nid) {
3389 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3390 *spec->stream_analog_alt_playback;
3391 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3392 spec->alt_dac_nid;
3393 } else {
3394 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3395 alc_pcm_null_stream;
3396 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3397 }
3398 if (spec->num_adc_nids > 1) {
3399 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3400 *spec->stream_analog_alt_capture;
3401 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3402 spec->adc_nids[1];
3403 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3404 spec->num_adc_nids - 1;
3405 } else {
3406 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3407 alc_pcm_null_stream;
3408 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003409 }
3410 }
3411
Linus Torvalds1da177e2005-04-16 15:20:36 -07003412 return 0;
3413}
3414
Takashi Iwai603c4012008-07-30 15:01:44 +02003415static void alc_free_kctls(struct hda_codec *codec)
3416{
3417 struct alc_spec *spec = codec->spec;
3418
3419 if (spec->kctls.list) {
3420 struct snd_kcontrol_new *kctl = spec->kctls.list;
3421 int i;
3422 for (i = 0; i < spec->kctls.used; i++)
3423 kfree(kctl[i].name);
3424 }
3425 snd_array_free(&spec->kctls);
3426}
3427
Linus Torvalds1da177e2005-04-16 15:20:36 -07003428static void alc_free(struct hda_codec *codec)
3429{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003430 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003431
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003432 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003433 return;
3434
Takashi Iwai603c4012008-07-30 15:01:44 +02003435 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003436 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003437 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003438}
3439
Takashi Iwaie044c392008-10-27 16:56:24 +01003440#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003441static int alc_resume(struct hda_codec *codec)
3442{
Takashi Iwaie044c392008-10-27 16:56:24 +01003443 codec->patch_ops.init(codec);
3444 snd_hda_codec_resume_amp(codec);
3445 snd_hda_codec_resume_cache(codec);
3446 return 0;
3447}
Takashi Iwaie044c392008-10-27 16:56:24 +01003448#endif
3449
Linus Torvalds1da177e2005-04-16 15:20:36 -07003450/*
3451 */
3452static struct hda_codec_ops alc_patch_ops = {
3453 .build_controls = alc_build_controls,
3454 .build_pcms = alc_build_pcms,
3455 .init = alc_init,
3456 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003457 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003458#ifdef SND_HDA_NEEDS_RESUME
3459 .resume = alc_resume,
3460#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003461#ifdef CONFIG_SND_HDA_POWER_SAVE
3462 .check_power_status = alc_check_power_status,
3463#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003464};
3465
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003466
3467/*
3468 * Test configuration for debugging
3469 *
3470 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3471 * enum controls.
3472 */
3473#ifdef CONFIG_SND_DEBUG
3474static hda_nid_t alc880_test_dac_nids[4] = {
3475 0x02, 0x03, 0x04, 0x05
3476};
3477
3478static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003479 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003480 .items = {
3481 { "In-1", 0x0 },
3482 { "In-2", 0x1 },
3483 { "In-3", 0x2 },
3484 { "In-4", 0x3 },
3485 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003486 { "Front", 0x5 },
3487 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003488 },
3489};
3490
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003491static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003492 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003493 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003494 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003495 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003496};
3497
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003498static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3499 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003500{
3501 static char *texts[] = {
3502 "N/A", "Line Out", "HP Out",
3503 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3504 };
3505 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3506 uinfo->count = 1;
3507 uinfo->value.enumerated.items = 8;
3508 if (uinfo->value.enumerated.item >= 8)
3509 uinfo->value.enumerated.item = 7;
3510 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3511 return 0;
3512}
3513
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003514static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3515 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003516{
3517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3518 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3519 unsigned int pin_ctl, item = 0;
3520
3521 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3522 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3523 if (pin_ctl & AC_PINCTL_OUT_EN) {
3524 if (pin_ctl & AC_PINCTL_HP_EN)
3525 item = 2;
3526 else
3527 item = 1;
3528 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3529 switch (pin_ctl & AC_PINCTL_VREFEN) {
3530 case AC_PINCTL_VREF_HIZ: item = 3; break;
3531 case AC_PINCTL_VREF_50: item = 4; break;
3532 case AC_PINCTL_VREF_GRD: item = 5; break;
3533 case AC_PINCTL_VREF_80: item = 6; break;
3534 case AC_PINCTL_VREF_100: item = 7; break;
3535 }
3536 }
3537 ucontrol->value.enumerated.item[0] = item;
3538 return 0;
3539}
3540
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003541static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3542 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003543{
3544 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3545 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3546 static unsigned int ctls[] = {
3547 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3548 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3549 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3550 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3551 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3552 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3553 };
3554 unsigned int old_ctl, new_ctl;
3555
3556 old_ctl = snd_hda_codec_read(codec, nid, 0,
3557 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3558 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3559 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003560 int val;
3561 snd_hda_codec_write_cache(codec, nid, 0,
3562 AC_VERB_SET_PIN_WIDGET_CONTROL,
3563 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003564 val = ucontrol->value.enumerated.item[0] >= 3 ?
3565 HDA_AMP_MUTE : 0;
3566 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3567 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003568 return 1;
3569 }
3570 return 0;
3571}
3572
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003573static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3574 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003575{
3576 static char *texts[] = {
3577 "Front", "Surround", "CLFE", "Side"
3578 };
3579 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3580 uinfo->count = 1;
3581 uinfo->value.enumerated.items = 4;
3582 if (uinfo->value.enumerated.item >= 4)
3583 uinfo->value.enumerated.item = 3;
3584 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3585 return 0;
3586}
3587
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003588static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3589 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003590{
3591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3592 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3593 unsigned int sel;
3594
3595 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3596 ucontrol->value.enumerated.item[0] = sel & 3;
3597 return 0;
3598}
3599
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003600static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3601 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003602{
3603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3604 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3605 unsigned int sel;
3606
3607 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3608 if (ucontrol->value.enumerated.item[0] != sel) {
3609 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003610 snd_hda_codec_write_cache(codec, nid, 0,
3611 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003612 return 1;
3613 }
3614 return 0;
3615}
3616
3617#define PIN_CTL_TEST(xname,nid) { \
3618 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3619 .name = xname, \
3620 .info = alc_test_pin_ctl_info, \
3621 .get = alc_test_pin_ctl_get, \
3622 .put = alc_test_pin_ctl_put, \
3623 .private_value = nid \
3624 }
3625
3626#define PIN_SRC_TEST(xname,nid) { \
3627 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3628 .name = xname, \
3629 .info = alc_test_pin_src_info, \
3630 .get = alc_test_pin_src_get, \
3631 .put = alc_test_pin_src_put, \
3632 .private_value = nid \
3633 }
3634
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003635static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003636 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3637 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3638 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3639 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003640 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3641 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3642 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3643 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003644 PIN_CTL_TEST("Front Pin Mode", 0x14),
3645 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3646 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3647 PIN_CTL_TEST("Side Pin Mode", 0x17),
3648 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3649 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3650 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3651 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3652 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3653 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3654 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3655 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3656 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3657 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3658 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3659 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3660 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3661 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3662 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3663 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3664 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3665 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003666 {
3667 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3668 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003669 .info = alc_ch_mode_info,
3670 .get = alc_ch_mode_get,
3671 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003672 },
3673 { } /* end */
3674};
3675
3676static struct hda_verb alc880_test_init_verbs[] = {
3677 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3680 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3681 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3682 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3683 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3684 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3685 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003686 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003687 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3688 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3689 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3690 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003691 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003692 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3693 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3694 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3695 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003696 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003697 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3698 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3699 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3700 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003701 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003702 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3703 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003704 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3705 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3706 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003707 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3709 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3710 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3711 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003712 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003714 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003715 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003716 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003717 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003718 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003719 /* Analog input/passthru */
3720 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3721 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003725 { }
3726};
3727#endif
3728
Linus Torvalds1da177e2005-04-16 15:20:36 -07003729/*
3730 */
3731
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003732static const char *alc880_models[ALC880_MODEL_LAST] = {
3733 [ALC880_3ST] = "3stack",
3734 [ALC880_TCL_S700] = "tcl",
3735 [ALC880_3ST_DIG] = "3stack-digout",
3736 [ALC880_CLEVO] = "clevo",
3737 [ALC880_5ST] = "5stack",
3738 [ALC880_5ST_DIG] = "5stack-digout",
3739 [ALC880_W810] = "w810",
3740 [ALC880_Z71V] = "z71v",
3741 [ALC880_6ST] = "6stack",
3742 [ALC880_6ST_DIG] = "6stack-digout",
3743 [ALC880_ASUS] = "asus",
3744 [ALC880_ASUS_W1V] = "asus-w1v",
3745 [ALC880_ASUS_DIG] = "asus-dig",
3746 [ALC880_ASUS_DIG2] = "asus-dig2",
3747 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003748 [ALC880_UNIWILL_P53] = "uniwill-p53",
3749 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003750 [ALC880_F1734] = "F1734",
3751 [ALC880_LG] = "lg",
3752 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003753 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003754#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003755 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003756#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003757 [ALC880_AUTO] = "auto",
3758};
3759
3760static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003761 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003762 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3763 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3764 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3765 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3766 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3767 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3768 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3769 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003770 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3771 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003772 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3773 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3774 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3775 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3776 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3777 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3778 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3779 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3780 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3781 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003782 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003783 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3784 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3785 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003786 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003787 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003788 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3789 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003790 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3791 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003792 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3793 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3794 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3795 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003796 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3797 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003798 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003799 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003800 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003801 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003802 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3803 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003804 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003805 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003806 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003807 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003808 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003809 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003810 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003811 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003812 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003813 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3814 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003815 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003816 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3817 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3818 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3819 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003820 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3821 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003822 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003823 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003824 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3825 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003826 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3827 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3828 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003829 /* default Intel */
3830 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003831 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3832 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003833 {}
3834};
3835
Takashi Iwai16ded522005-06-10 19:58:24 +02003836/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003837 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003838 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003839static struct alc_config_preset alc880_presets[] = {
3840 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003841 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003842 .init_verbs = { alc880_volume_init_verbs,
3843 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003844 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003845 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003846 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3847 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003848 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003849 .input_mux = &alc880_capture_source,
3850 },
3851 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003852 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003853 .init_verbs = { alc880_volume_init_verbs,
3854 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003855 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003856 .dac_nids = alc880_dac_nids,
3857 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003858 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3859 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003860 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003861 .input_mux = &alc880_capture_source,
3862 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003863 [ALC880_TCL_S700] = {
3864 .mixers = { alc880_tcl_s700_mixer },
3865 .init_verbs = { alc880_volume_init_verbs,
3866 alc880_pin_tcl_S700_init_verbs,
3867 alc880_gpio2_init_verbs },
3868 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3869 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003870 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3871 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003872 .hp_nid = 0x03,
3873 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3874 .channel_mode = alc880_2_jack_modes,
3875 .input_mux = &alc880_capture_source,
3876 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003877 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003878 .mixers = { alc880_three_stack_mixer,
3879 alc880_five_stack_mixer},
3880 .init_verbs = { alc880_volume_init_verbs,
3881 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003882 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3883 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003884 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3885 .channel_mode = alc880_fivestack_modes,
3886 .input_mux = &alc880_capture_source,
3887 },
3888 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003889 .mixers = { alc880_three_stack_mixer,
3890 alc880_five_stack_mixer },
3891 .init_verbs = { alc880_volume_init_verbs,
3892 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003893 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3894 .dac_nids = alc880_dac_nids,
3895 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003896 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3897 .channel_mode = alc880_fivestack_modes,
3898 .input_mux = &alc880_capture_source,
3899 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003900 [ALC880_6ST] = {
3901 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003902 .init_verbs = { alc880_volume_init_verbs,
3903 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003904 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3905 .dac_nids = alc880_6st_dac_nids,
3906 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3907 .channel_mode = alc880_sixstack_modes,
3908 .input_mux = &alc880_6stack_capture_source,
3909 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003910 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003911 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003912 .init_verbs = { alc880_volume_init_verbs,
3913 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003914 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3915 .dac_nids = alc880_6st_dac_nids,
3916 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003917 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3918 .channel_mode = alc880_sixstack_modes,
3919 .input_mux = &alc880_6stack_capture_source,
3920 },
3921 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003922 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003923 .init_verbs = { alc880_volume_init_verbs,
3924 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003925 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003926 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3927 .dac_nids = alc880_w810_dac_nids,
3928 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003929 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3930 .channel_mode = alc880_w810_modes,
3931 .input_mux = &alc880_capture_source,
3932 },
3933 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003934 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003935 .init_verbs = { alc880_volume_init_verbs,
3936 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003937 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3938 .dac_nids = alc880_z71v_dac_nids,
3939 .dig_out_nid = ALC880_DIGOUT_NID,
3940 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003941 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3942 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003943 .input_mux = &alc880_capture_source,
3944 },
3945 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003946 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003947 .init_verbs = { alc880_volume_init_verbs,
3948 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003949 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3950 .dac_nids = alc880_f1734_dac_nids,
3951 .hp_nid = 0x02,
3952 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3953 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003954 .input_mux = &alc880_f1734_capture_source,
3955 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003956 .init_hook = alc880_uniwill_p53_init_hook,
Takashi Iwai16ded522005-06-10 19:58:24 +02003957 },
3958 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003959 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003960 .init_verbs = { alc880_volume_init_verbs,
3961 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003962 alc880_gpio1_init_verbs },
3963 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3964 .dac_nids = alc880_asus_dac_nids,
3965 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3966 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003967 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003968 .input_mux = &alc880_capture_source,
3969 },
3970 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003971 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003972 .init_verbs = { alc880_volume_init_verbs,
3973 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003974 alc880_gpio1_init_verbs },
3975 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3976 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003977 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003978 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3979 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003980 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003981 .input_mux = &alc880_capture_source,
3982 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003983 [ALC880_ASUS_DIG2] = {
3984 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003985 .init_verbs = { alc880_volume_init_verbs,
3986 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003987 alc880_gpio2_init_verbs }, /* use GPIO2 */
3988 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3989 .dac_nids = alc880_asus_dac_nids,
3990 .dig_out_nid = ALC880_DIGOUT_NID,
3991 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3992 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003993 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003994 .input_mux = &alc880_capture_source,
3995 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003996 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003997 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003998 .init_verbs = { alc880_volume_init_verbs,
3999 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004000 alc880_gpio1_init_verbs },
4001 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4002 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004003 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004004 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4005 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004006 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004007 .input_mux = &alc880_capture_source,
4008 },
4009 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004010 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004011 .init_verbs = { alc880_volume_init_verbs,
4012 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004013 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4014 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004015 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004016 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4017 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004018 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004019 .input_mux = &alc880_capture_source,
4020 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004021 [ALC880_UNIWILL] = {
4022 .mixers = { alc880_uniwill_mixer },
4023 .init_verbs = { alc880_volume_init_verbs,
4024 alc880_uniwill_init_verbs },
4025 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4026 .dac_nids = alc880_asus_dac_nids,
4027 .dig_out_nid = ALC880_DIGOUT_NID,
4028 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4029 .channel_mode = alc880_threestack_modes,
4030 .need_dac_fix = 1,
4031 .input_mux = &alc880_capture_source,
4032 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004033 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004034 },
4035 [ALC880_UNIWILL_P53] = {
4036 .mixers = { alc880_uniwill_p53_mixer },
4037 .init_verbs = { alc880_volume_init_verbs,
4038 alc880_uniwill_p53_init_verbs },
4039 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4040 .dac_nids = alc880_asus_dac_nids,
4041 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004042 .channel_mode = alc880_threestack_modes,
4043 .input_mux = &alc880_capture_source,
4044 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004045 .init_hook = alc880_uniwill_p53_init_hook,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004046 },
4047 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004048 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004049 .init_verbs = { alc880_volume_init_verbs,
4050 alc880_uniwill_p53_init_verbs,
4051 alc880_beep_init_verbs },
4052 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4053 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004054 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004055 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4056 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004057 .input_mux = &alc880_capture_source,
4058 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004059 .init_hook = alc880_uniwill_p53_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004060 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004061 [ALC880_CLEVO] = {
4062 .mixers = { alc880_three_stack_mixer },
4063 .init_verbs = { alc880_volume_init_verbs,
4064 alc880_pin_clevo_init_verbs },
4065 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4066 .dac_nids = alc880_dac_nids,
4067 .hp_nid = 0x03,
4068 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4069 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004070 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004071 .input_mux = &alc880_capture_source,
4072 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004073 [ALC880_LG] = {
4074 .mixers = { alc880_lg_mixer },
4075 .init_verbs = { alc880_volume_init_verbs,
4076 alc880_lg_init_verbs },
4077 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4078 .dac_nids = alc880_lg_dac_nids,
4079 .dig_out_nid = ALC880_DIGOUT_NID,
4080 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4081 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004082 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004083 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004084 .unsol_event = alc_automute_amp_unsol_event,
4085 .init_hook = alc880_lg_init_hook,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004086#ifdef CONFIG_SND_HDA_POWER_SAVE
4087 .loopbacks = alc880_lg_loopbacks,
4088#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004089 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004090 [ALC880_LG_LW] = {
4091 .mixers = { alc880_lg_lw_mixer },
4092 .init_verbs = { alc880_volume_init_verbs,
4093 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004094 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004095 .dac_nids = alc880_dac_nids,
4096 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004097 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4098 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004099 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004100 .unsol_event = alc_automute_amp_unsol_event,
4101 .init_hook = alc880_lg_lw_init_hook,
Takashi Iwaid6815182006-03-23 16:06:23 +01004102 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004103 [ALC880_MEDION_RIM] = {
4104 .mixers = { alc880_medion_rim_mixer },
4105 .init_verbs = { alc880_volume_init_verbs,
4106 alc880_medion_rim_init_verbs,
4107 alc_gpio2_init_verbs },
4108 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4109 .dac_nids = alc880_dac_nids,
4110 .dig_out_nid = ALC880_DIGOUT_NID,
4111 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4112 .channel_mode = alc880_2_jack_modes,
4113 .input_mux = &alc880_medion_rim_capture_source,
4114 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004115 .init_hook = alc880_medion_rim_init_hook,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004116 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004117#ifdef CONFIG_SND_DEBUG
4118 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004119 .mixers = { alc880_test_mixer },
4120 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004121 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4122 .dac_nids = alc880_test_dac_nids,
4123 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004124 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4125 .channel_mode = alc880_test_modes,
4126 .input_mux = &alc880_test_capture_source,
4127 },
4128#endif
4129};
4130
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004131/*
4132 * Automatic parse of I/O pins from the BIOS configuration
4133 */
4134
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004135enum {
4136 ALC_CTL_WIDGET_VOL,
4137 ALC_CTL_WIDGET_MUTE,
4138 ALC_CTL_BIND_MUTE,
4139};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004140static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004141 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4142 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004143 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004144};
4145
4146/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004147static int add_control(struct alc_spec *spec, int type, const char *name,
4148 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004149{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004150 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004151
Takashi Iwai603c4012008-07-30 15:01:44 +02004152 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4153 knew = snd_array_new(&spec->kctls);
4154 if (!knew)
4155 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004156 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004157 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004158 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004159 return -ENOMEM;
4160 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004161 return 0;
4162}
4163
4164#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4165#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4166#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4167#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4168#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4169#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4170#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4171#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4172#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4173#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4174#define ALC880_PIN_CD_NID 0x1c
4175
4176/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004177static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4178 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004179{
4180 hda_nid_t nid;
4181 int assigned[4];
4182 int i, j;
4183
4184 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004185 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004186
4187 /* check the pins hardwired to audio widget */
4188 for (i = 0; i < cfg->line_outs; i++) {
4189 nid = cfg->line_out_pins[i];
4190 if (alc880_is_fixed_pin(nid)) {
4191 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004192 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004193 assigned[idx] = 1;
4194 }
4195 }
4196 /* left pins can be connect to any audio widget */
4197 for (i = 0; i < cfg->line_outs; i++) {
4198 nid = cfg->line_out_pins[i];
4199 if (alc880_is_fixed_pin(nid))
4200 continue;
4201 /* search for an empty channel */
4202 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004203 if (!assigned[j]) {
4204 spec->multiout.dac_nids[i] =
4205 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004206 assigned[j] = 1;
4207 break;
4208 }
4209 }
4210 }
4211 spec->multiout.num_dacs = cfg->line_outs;
4212 return 0;
4213}
4214
4215/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004216static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4217 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004218{
4219 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004220 static const char *chname[4] = {
4221 "Front", "Surround", NULL /*CLFE*/, "Side"
4222 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004223 hda_nid_t nid;
4224 int i, err;
4225
4226 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004227 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004228 continue;
4229 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4230 if (i == 2) {
4231 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004232 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4233 "Center Playback Volume",
4234 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4235 HDA_OUTPUT));
4236 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004237 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004238 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4239 "LFE Playback Volume",
4240 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4241 HDA_OUTPUT));
4242 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004243 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004244 err = add_control(spec, ALC_CTL_BIND_MUTE,
4245 "Center Playback Switch",
4246 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4247 HDA_INPUT));
4248 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004249 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004250 err = add_control(spec, ALC_CTL_BIND_MUTE,
4251 "LFE Playback Switch",
4252 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4253 HDA_INPUT));
4254 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004255 return err;
4256 } else {
4257 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004258 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4259 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4260 HDA_OUTPUT));
4261 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004262 return err;
4263 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004264 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4265 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4266 HDA_INPUT));
4267 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004268 return err;
4269 }
4270 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004271 return 0;
4272}
4273
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004274/* add playback controls for speaker and HP outputs */
4275static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4276 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004277{
4278 hda_nid_t nid;
4279 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004280 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004281
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004282 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004283 return 0;
4284
4285 if (alc880_is_fixed_pin(pin)) {
4286 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004287 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004288 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004289 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004290 else
4291 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004292 /* control HP volume/switch on the output mixer amp */
4293 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004294 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004295 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4296 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4297 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004298 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004299 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004300 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4301 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4302 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004303 return err;
4304 } else if (alc880_is_multi_pin(pin)) {
4305 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004306 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004307 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004308 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4309 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4310 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004311 return err;
4312 }
4313 return 0;
4314}
4315
4316/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004317static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4318 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004319 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004320{
4321 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004322 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004323
4324 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004325 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4326 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4327 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004328 return err;
4329 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004330 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4331 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4332 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004333 return err;
4334 return 0;
4335}
4336
4337/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004338static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4339 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004340{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004341 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004342 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004343
4344 for (i = 0; i < AUTO_PIN_LAST; i++) {
4345 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004346 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004347 err = new_analog_input(spec, cfg->input_pins[i],
4348 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004349 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004350 if (err < 0)
4351 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004352 imux->items[imux->num_items].label =
4353 auto_pin_cfg_labels[i];
4354 imux->items[imux->num_items].index =
4355 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004356 imux->num_items++;
4357 }
4358 }
4359 return 0;
4360}
4361
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004362static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4363 unsigned int pin_type)
4364{
4365 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4366 pin_type);
4367 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004368 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4369 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004370}
4371
Kailang Yangdf694da2005-12-05 19:42:22 +01004372static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4373 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004374 int dac_idx)
4375{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004376 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004377 /* need the manual connection? */
4378 if (alc880_is_multi_pin(nid)) {
4379 struct alc_spec *spec = codec->spec;
4380 int idx = alc880_multi_pin_idx(nid);
4381 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4382 AC_VERB_SET_CONNECT_SEL,
4383 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4384 }
4385}
4386
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004387static int get_pin_type(int line_out_type)
4388{
4389 if (line_out_type == AUTO_PIN_HP_OUT)
4390 return PIN_HP;
4391 else
4392 return PIN_OUT;
4393}
4394
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004395static void alc880_auto_init_multi_out(struct hda_codec *codec)
4396{
4397 struct alc_spec *spec = codec->spec;
4398 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004399
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004400 for (i = 0; i < spec->autocfg.line_outs; i++) {
4401 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004402 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4403 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004404 }
4405}
4406
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004407static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004408{
4409 struct alc_spec *spec = codec->spec;
4410 hda_nid_t pin;
4411
Takashi Iwai82bc9552006-03-21 11:24:42 +01004412 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004413 if (pin) /* connect to front */
4414 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004415 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004416 if (pin) /* connect to front */
4417 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4418}
4419
4420static void alc880_auto_init_analog_input(struct hda_codec *codec)
4421{
4422 struct alc_spec *spec = codec->spec;
4423 int i;
4424
4425 for (i = 0; i < AUTO_PIN_LAST; i++) {
4426 hda_nid_t nid = spec->autocfg.input_pins[i];
4427 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004428 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004429 if (nid != ALC880_PIN_CD_NID &&
4430 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004431 snd_hda_codec_write(codec, nid, 0,
4432 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004433 AMP_OUT_MUTE);
4434 }
4435 }
4436}
4437
4438/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004439/* return 1 if successful, 0 if the proper config is not found,
4440 * or a negative error code
4441 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004442static int alc880_parse_auto_config(struct hda_codec *codec)
4443{
4444 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004445 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004446 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004447
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004448 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4449 alc880_ignore);
4450 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004451 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004452 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004453 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004454
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004455 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4456 if (err < 0)
4457 return err;
4458 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4459 if (err < 0)
4460 return err;
4461 err = alc880_auto_create_extra_out(spec,
4462 spec->autocfg.speaker_pins[0],
4463 "Speaker");
4464 if (err < 0)
4465 return err;
4466 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4467 "Headphone");
4468 if (err < 0)
4469 return err;
4470 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4471 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004472 return err;
4473
4474 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4475
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004476 /* check multiple SPDIF-out (for recent codecs) */
4477 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4478 hda_nid_t dig_nid;
4479 err = snd_hda_get_connections(codec,
4480 spec->autocfg.dig_out_pins[i],
4481 &dig_nid, 1);
4482 if (err < 0)
4483 continue;
4484 if (!i)
4485 spec->multiout.dig_out_nid = dig_nid;
4486 else {
4487 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4488 spec->slave_dig_outs[i - 1] = dig_nid;
4489 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4490 break;
4491 }
4492 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004493 if (spec->autocfg.dig_in_pin)
4494 spec->dig_in_nid = ALC880_DIGIN_NID;
4495
Takashi Iwai603c4012008-07-30 15:01:44 +02004496 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004497 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004498
Takashi Iwaid88897e2008-10-31 15:01:37 +01004499 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004500
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004501 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004502 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004503
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004504 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4505
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004506 return 1;
4507}
4508
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004509/* additional initialization for auto-configuration model */
4510static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004511{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004512 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004513 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004514 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004515 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004516 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004517 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004518}
4519
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004520static void set_capture_mixer(struct alc_spec *spec)
4521{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004522 static struct snd_kcontrol_new *caps[2][3] = {
4523 { alc_capture_mixer_nosrc1,
4524 alc_capture_mixer_nosrc2,
4525 alc_capture_mixer_nosrc3 },
4526 { alc_capture_mixer1,
4527 alc_capture_mixer2,
4528 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004529 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004530 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4531 int mux;
4532 if (spec->input_mux && spec->input_mux->num_items > 1)
4533 mux = 1;
4534 else
4535 mux = 0;
4536 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4537 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004538}
4539
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004540#define set_beep_amp(spec, nid, idx, dir) \
4541 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4542
4543/*
4544 * OK, here we have finally the patch for ALC880
4545 */
4546
Linus Torvalds1da177e2005-04-16 15:20:36 -07004547static int patch_alc880(struct hda_codec *codec)
4548{
4549 struct alc_spec *spec;
4550 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004551 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004552
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004553 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004554 if (spec == NULL)
4555 return -ENOMEM;
4556
4557 codec->spec = spec;
4558
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004559 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4560 alc880_models,
4561 alc880_cfg_tbl);
4562 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02004563 printk(KERN_INFO "hda_codec: Unknown model for %s, "
4564 "trying auto-probe from BIOS...\n", codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004565 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004566 }
4567
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004568 if (board_config == ALC880_AUTO) {
4569 /* automatic parse from the BIOS config */
4570 err = alc880_parse_auto_config(codec);
4571 if (err < 0) {
4572 alc_free(codec);
4573 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004574 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004575 printk(KERN_INFO
4576 "hda_codec: Cannot set up configuration "
4577 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004578 board_config = ALC880_3ST;
4579 }
4580 }
4581
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004582 err = snd_hda_attach_beep_device(codec, 0x1);
4583 if (err < 0) {
4584 alc_free(codec);
4585 return err;
4586 }
4587
Kailang Yangdf694da2005-12-05 19:42:22 +01004588 if (board_config != ALC880_AUTO)
4589 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004590
Linus Torvalds1da177e2005-04-16 15:20:36 -07004591 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4592 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004593 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004594
Linus Torvalds1da177e2005-04-16 15:20:36 -07004595 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4596 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4597
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004598 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004599 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004600 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004601 /* get type */
4602 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004603 if (wcap != AC_WID_AUD_IN) {
4604 spec->adc_nids = alc880_adc_nids_alt;
4605 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004606 } else {
4607 spec->adc_nids = alc880_adc_nids;
4608 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004609 }
4610 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004611 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004612 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004613
Takashi Iwai2134ea42008-01-10 16:53:55 +01004614 spec->vmaster_nid = 0x0c;
4615
Linus Torvalds1da177e2005-04-16 15:20:36 -07004616 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004617 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004618 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004619#ifdef CONFIG_SND_HDA_POWER_SAVE
4620 if (!spec->loopback.amplist)
4621 spec->loopback.amplist = alc880_loopbacks;
4622#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004623 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004624
4625 return 0;
4626}
4627
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004628
Linus Torvalds1da177e2005-04-16 15:20:36 -07004629/*
4630 * ALC260 support
4631 */
4632
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004633static hda_nid_t alc260_dac_nids[1] = {
4634 /* front */
4635 0x02,
4636};
4637
4638static hda_nid_t alc260_adc_nids[1] = {
4639 /* ADC0 */
4640 0x04,
4641};
4642
Kailang Yangdf694da2005-12-05 19:42:22 +01004643static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004644 /* ADC1 */
4645 0x05,
4646};
4647
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004648/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4649 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4650 */
4651static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004652 /* ADC0, ADC1 */
4653 0x04, 0x05
4654};
4655
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004656#define ALC260_DIGOUT_NID 0x03
4657#define ALC260_DIGIN_NID 0x06
4658
4659static struct hda_input_mux alc260_capture_source = {
4660 .num_items = 4,
4661 .items = {
4662 { "Mic", 0x0 },
4663 { "Front Mic", 0x1 },
4664 { "Line", 0x2 },
4665 { "CD", 0x4 },
4666 },
4667};
4668
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004669/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004670 * headphone jack and the internal CD lines since these are the only pins at
4671 * which audio can appear. For flexibility, also allow the option of
4672 * recording the mixer output on the second ADC (ADC0 doesn't have a
4673 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004674 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004675static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4676 {
4677 .num_items = 3,
4678 .items = {
4679 { "Mic/Line", 0x0 },
4680 { "CD", 0x4 },
4681 { "Headphone", 0x2 },
4682 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004683 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004684 {
4685 .num_items = 4,
4686 .items = {
4687 { "Mic/Line", 0x0 },
4688 { "CD", 0x4 },
4689 { "Headphone", 0x2 },
4690 { "Mixer", 0x5 },
4691 },
4692 },
4693
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004694};
4695
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004696/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4697 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004698 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004699static struct hda_input_mux alc260_acer_capture_sources[2] = {
4700 {
4701 .num_items = 4,
4702 .items = {
4703 { "Mic", 0x0 },
4704 { "Line", 0x2 },
4705 { "CD", 0x4 },
4706 { "Headphone", 0x5 },
4707 },
4708 },
4709 {
4710 .num_items = 5,
4711 .items = {
4712 { "Mic", 0x0 },
4713 { "Line", 0x2 },
4714 { "CD", 0x4 },
4715 { "Headphone", 0x6 },
4716 { "Mixer", 0x5 },
4717 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004718 },
4719};
Michael Schwingencc959482009-02-22 18:58:45 +01004720
4721/* Maxdata Favorit 100XS */
4722static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4723 {
4724 .num_items = 2,
4725 .items = {
4726 { "Line/Mic", 0x0 },
4727 { "CD", 0x4 },
4728 },
4729 },
4730 {
4731 .num_items = 3,
4732 .items = {
4733 { "Line/Mic", 0x0 },
4734 { "CD", 0x4 },
4735 { "Mixer", 0x5 },
4736 },
4737 },
4738};
4739
Linus Torvalds1da177e2005-04-16 15:20:36 -07004740/*
4741 * This is just place-holder, so there's something for alc_build_pcms to look
4742 * at when it calculates the maximum number of channels. ALC260 has no mixer
4743 * element which allows changing the channel mode, so the verb list is
4744 * never used.
4745 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004746static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004747 { 2, NULL },
4748};
4749
Kailang Yangdf694da2005-12-05 19:42:22 +01004750
4751/* Mixer combinations
4752 *
4753 * basic: base_output + input + pc_beep + capture
4754 * HP: base_output + input + capture_alt
4755 * HP_3013: hp_3013 + input + capture
4756 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004757 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004758 */
4759
4760static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004761 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004762 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004763 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4764 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4765 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4766 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4767 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004768};
Kailang Yangdf694da2005-12-05 19:42:22 +01004769
4770static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004771 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4772 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4773 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4774 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4775 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4776 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4777 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4778 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004779 { } /* end */
4780};
4781
Takashi Iwaibec15c32008-01-28 18:16:30 +01004782/* update HP, line and mono out pins according to the master switch */
4783static void alc260_hp_master_update(struct hda_codec *codec,
4784 hda_nid_t hp, hda_nid_t line,
4785 hda_nid_t mono)
4786{
4787 struct alc_spec *spec = codec->spec;
4788 unsigned int val = spec->master_sw ? PIN_HP : 0;
4789 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004790 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004791 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004792 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004793 val);
4794 /* mono (speaker) depending on the HP jack sense */
4795 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004796 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004797 val);
4798}
4799
4800static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4801 struct snd_ctl_elem_value *ucontrol)
4802{
4803 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4804 struct alc_spec *spec = codec->spec;
4805 *ucontrol->value.integer.value = spec->master_sw;
4806 return 0;
4807}
4808
4809static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4810 struct snd_ctl_elem_value *ucontrol)
4811{
4812 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4813 struct alc_spec *spec = codec->spec;
4814 int val = !!*ucontrol->value.integer.value;
4815 hda_nid_t hp, line, mono;
4816
4817 if (val == spec->master_sw)
4818 return 0;
4819 spec->master_sw = val;
4820 hp = (kcontrol->private_value >> 16) & 0xff;
4821 line = (kcontrol->private_value >> 8) & 0xff;
4822 mono = kcontrol->private_value & 0xff;
4823 alc260_hp_master_update(codec, hp, line, mono);
4824 return 1;
4825}
4826
4827static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4828 {
4829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4830 .name = "Master Playback Switch",
4831 .info = snd_ctl_boolean_mono_info,
4832 .get = alc260_hp_master_sw_get,
4833 .put = alc260_hp_master_sw_put,
4834 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4835 },
4836 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4837 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4838 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4839 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4840 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4841 HDA_OUTPUT),
4842 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4843 { } /* end */
4844};
4845
4846static struct hda_verb alc260_hp_unsol_verbs[] = {
4847 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4848 {},
4849};
4850
4851static void alc260_hp_automute(struct hda_codec *codec)
4852{
4853 struct alc_spec *spec = codec->spec;
4854 unsigned int present;
4855
4856 present = snd_hda_codec_read(codec, 0x10, 0,
4857 AC_VERB_GET_PIN_SENSE, 0);
4858 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4859 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4860}
4861
4862static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4863{
4864 if ((res >> 26) == ALC880_HP_EVENT)
4865 alc260_hp_automute(codec);
4866}
4867
Kailang Yangdf694da2005-12-05 19:42:22 +01004868static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004869 {
4870 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4871 .name = "Master Playback Switch",
4872 .info = snd_ctl_boolean_mono_info,
4873 .get = alc260_hp_master_sw_get,
4874 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004875 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004876 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004877 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4878 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4879 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4880 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4881 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004883 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4884 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004885 { } /* end */
4886};
4887
Kailang Yang3f878302008-08-26 13:02:23 +02004888static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4889 .ops = &snd_hda_bind_vol,
4890 .values = {
4891 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4892 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4893 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4894 0
4895 },
4896};
4897
4898static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4899 .ops = &snd_hda_bind_sw,
4900 .values = {
4901 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4902 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4903 0
4904 },
4905};
4906
4907static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4908 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4909 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4910 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4911 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4912 { } /* end */
4913};
4914
Takashi Iwaibec15c32008-01-28 18:16:30 +01004915static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4916 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4917 {},
4918};
4919
4920static void alc260_hp_3013_automute(struct hda_codec *codec)
4921{
4922 struct alc_spec *spec = codec->spec;
4923 unsigned int present;
4924
4925 present = snd_hda_codec_read(codec, 0x15, 0,
4926 AC_VERB_GET_PIN_SENSE, 0);
4927 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004928 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004929}
4930
4931static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4932 unsigned int res)
4933{
4934 if ((res >> 26) == ALC880_HP_EVENT)
4935 alc260_hp_3013_automute(codec);
4936}
4937
Kailang Yang3f878302008-08-26 13:02:23 +02004938static void alc260_hp_3012_automute(struct hda_codec *codec)
4939{
4940 unsigned int present, bits;
4941
4942 present = snd_hda_codec_read(codec, 0x10, 0,
4943 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4944
4945 bits = present ? 0 : PIN_OUT;
4946 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4947 bits);
4948 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4949 bits);
4950 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4951 bits);
4952}
4953
4954static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4955 unsigned int res)
4956{
4957 if ((res >> 26) == ALC880_HP_EVENT)
4958 alc260_hp_3012_automute(codec);
4959}
4960
4961/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004962 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4963 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004964static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004965 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004966 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004967 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004968 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4969 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4970 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4971 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004972 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004973 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4974 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004975 { } /* end */
4976};
4977
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004978/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4979 * versions of the ALC260 don't act on requests to enable mic bias from NID
4980 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4981 * datasheet doesn't mention this restriction. At this stage it's not clear
4982 * whether this behaviour is intentional or is a hardware bug in chip
4983 * revisions available in early 2006. Therefore for now allow the
4984 * "Headphone Jack Mode" control to span all choices, but if it turns out
4985 * that the lack of mic bias for this NID is intentional we could change the
4986 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4987 *
4988 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4989 * don't appear to make the mic bias available from the "line" jack, even
4990 * though the NID used for this jack (0x14) can supply it. The theory is
4991 * that perhaps Acer have included blocking capacitors between the ALC260
4992 * and the output jack. If this turns out to be the case for all such
4993 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4994 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004995 *
4996 * The C20x Tablet series have a mono internal speaker which is controlled
4997 * via the chip's Mono sum widget and pin complex, so include the necessary
4998 * controls for such models. On models without a "mono speaker" the control
4999 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005000 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005001static struct snd_kcontrol_new alc260_acer_mixer[] = {
5002 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5003 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005004 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005005 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005006 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005007 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005008 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005009 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5010 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5012 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5013 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5014 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5015 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5016 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005017 { } /* end */
5018};
5019
Michael Schwingencc959482009-02-22 18:58:45 +01005020/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5021 */
5022static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5023 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5024 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5025 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5026 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5027 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5028 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5029 { } /* end */
5030};
5031
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005032/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5033 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5034 */
5035static struct snd_kcontrol_new alc260_will_mixer[] = {
5036 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5037 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5038 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5039 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5040 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5041 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5042 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5043 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5044 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5045 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005046 { } /* end */
5047};
5048
5049/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5050 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5051 */
5052static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5053 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5054 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5055 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5056 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5057 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5058 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5059 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5060 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5061 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5062 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5063 { } /* end */
5064};
5065
Kailang Yangdf694da2005-12-05 19:42:22 +01005066/*
5067 * initialization verbs
5068 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005069static struct hda_verb alc260_init_verbs[] = {
5070 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005071 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005072 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005073 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005074 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005075 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005076 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005077 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005078 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005079 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005080 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005081 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005082 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005083 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005084 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005085 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005086 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005087 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5088 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005089 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005090 /* set connection select to line in (default select for this ADC) */
5091 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005092 /* mute capture amp left and right */
5093 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5094 /* set connection select to line in (default select for this ADC) */
5095 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005096 /* set vol=0 Line-Out mixer amp left and right */
5097 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5098 /* unmute pin widget amp left and right (no gain on this amp) */
5099 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5100 /* set vol=0 HP mixer amp left and right */
5101 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5102 /* unmute pin widget amp left and right (no gain on this amp) */
5103 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5104 /* set vol=0 Mono mixer amp left and right */
5105 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5106 /* unmute pin widget amp left and right (no gain on this amp) */
5107 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5108 /* unmute LINE-2 out pin */
5109 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005110 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5111 * Line In 2 = 0x03
5112 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005113 /* mute analog inputs */
5114 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5118 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005119 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005120 /* mute Front out path */
5121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5122 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5123 /* mute Headphone out path */
5124 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5125 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5126 /* mute Mono out path */
5127 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5128 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005129 { }
5130};
5131
Takashi Iwai474167d2006-05-17 17:17:43 +02005132#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005133static struct hda_verb alc260_hp_init_verbs[] = {
5134 /* Headphone and output */
5135 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5136 /* mono output */
5137 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5138 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5139 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5140 /* Mic2 (front panel) pin widget for input and vref at 80% */
5141 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5142 /* Line In pin widget for input */
5143 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5144 /* Line-2 pin widget for output */
5145 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5146 /* CD pin widget for input */
5147 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5148 /* unmute amp left and right */
5149 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5150 /* set connection select to line in (default select for this ADC) */
5151 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5152 /* unmute Line-Out mixer amp left and right (volume = 0) */
5153 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5154 /* mute pin widget amp left and right (no gain on this amp) */
5155 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5156 /* unmute HP mixer amp left and right (volume = 0) */
5157 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5158 /* mute pin widget amp left and right (no gain on this amp) */
5159 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005160 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5161 * Line In 2 = 0x03
5162 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005163 /* mute analog inputs */
5164 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5165 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5166 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5167 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5168 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005169 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5170 /* Unmute Front out path */
5171 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5172 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5173 /* Unmute Headphone out path */
5174 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5175 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5176 /* Unmute Mono out path */
5177 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5178 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5179 { }
5180};
Takashi Iwai474167d2006-05-17 17:17:43 +02005181#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005182
5183static struct hda_verb alc260_hp_3013_init_verbs[] = {
5184 /* Line out and output */
5185 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5186 /* mono output */
5187 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5188 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5189 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5190 /* Mic2 (front panel) pin widget for input and vref at 80% */
5191 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5192 /* Line In pin widget for input */
5193 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5194 /* Headphone pin widget for output */
5195 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5196 /* CD pin widget for input */
5197 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5198 /* unmute amp left and right */
5199 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5200 /* set connection select to line in (default select for this ADC) */
5201 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5202 /* unmute Line-Out mixer amp left and right (volume = 0) */
5203 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5204 /* mute pin widget amp left and right (no gain on this amp) */
5205 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5206 /* unmute HP mixer amp left and right (volume = 0) */
5207 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5208 /* mute pin widget amp left and right (no gain on this amp) */
5209 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005210 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5211 * Line In 2 = 0x03
5212 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005213 /* mute analog inputs */
5214 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5215 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5216 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5217 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5218 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005219 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5220 /* Unmute Front out path */
5221 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5223 /* Unmute Headphone out path */
5224 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5225 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5226 /* Unmute Mono out path */
5227 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5228 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5229 { }
5230};
5231
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005232/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005233 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5234 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005235 */
5236static struct hda_verb alc260_fujitsu_init_verbs[] = {
5237 /* Disable all GPIOs */
5238 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5239 /* Internal speaker is connected to headphone pin */
5240 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5241 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5242 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005243 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5244 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5245 /* Ensure all other unused pins are disabled and muted. */
5246 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5247 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005248 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005249 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005250 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005251 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5252 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5253 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005254
Jonathan Woithef7ace402006-02-28 11:46:14 +01005255 /* Disable digital (SPDIF) pins */
5256 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5257 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005258
Kailang Yangea1fb292008-08-26 12:58:38 +02005259 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005260 * when acting as an output.
5261 */
5262 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5263
5264 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005265 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5266 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5267 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5268 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5269 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5270 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5271 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5272 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5273 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005274
Jonathan Woithef7ace402006-02-28 11:46:14 +01005275 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5276 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5277 /* Unmute Line1 pin widget output buffer since it starts as an output.
5278 * If the pin mode is changed by the user the pin mode control will
5279 * take care of enabling the pin's input/output buffers as needed.
5280 * Therefore there's no need to enable the input buffer at this
5281 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005282 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005283 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005284 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005285 * mixer ctrl)
5286 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005287 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005288
Jonathan Woithef7ace402006-02-28 11:46:14 +01005289 /* Mute capture amp left and right */
5290 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005291 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005292 * in (on mic1 pin)
5293 */
5294 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005295
Jonathan Woithef7ace402006-02-28 11:46:14 +01005296 /* Do the same for the second ADC: mute capture input amp and
5297 * set ADC connection to line in (on mic1 pin)
5298 */
5299 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5300 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005301
Jonathan Woithef7ace402006-02-28 11:46:14 +01005302 /* Mute all inputs to mixer widget (even unconnected ones) */
5303 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5304 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5305 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5306 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5307 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5309 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5310 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005311
5312 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005313};
5314
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005315/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5316 * similar laptops (adapted from Fujitsu init verbs).
5317 */
5318static struct hda_verb alc260_acer_init_verbs[] = {
5319 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5320 * the headphone jack. Turn this on and rely on the standard mute
5321 * methods whenever the user wants to turn these outputs off.
5322 */
5323 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5324 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5325 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5326 /* Internal speaker/Headphone jack is connected to Line-out pin */
5327 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5328 /* Internal microphone/Mic jack is connected to Mic1 pin */
5329 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5330 /* Line In jack is connected to Line1 pin */
5331 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005332 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5333 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005334 /* Ensure all other unused pins are disabled and muted. */
5335 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5336 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005337 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5338 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5339 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5340 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5341 /* Disable digital (SPDIF) pins */
5342 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5343 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5344
Kailang Yangea1fb292008-08-26 12:58:38 +02005345 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005346 * bus when acting as outputs.
5347 */
5348 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5349 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5350
5351 /* Start with output sum widgets muted and their output gains at min */
5352 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5353 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5354 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5355 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5356 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5357 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5358 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5359 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5360 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5361
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005362 /* Unmute Line-out pin widget amp left and right
5363 * (no equiv mixer ctrl)
5364 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005365 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005366 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5367 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005368 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5369 * inputs. If the pin mode is changed by the user the pin mode control
5370 * will take care of enabling the pin's input/output buffers as needed.
5371 * Therefore there's no need to enable the input buffer at this
5372 * stage.
5373 */
5374 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5375 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5376
5377 /* Mute capture amp left and right */
5378 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5379 /* Set ADC connection select to match default mixer setting - mic
5380 * (on mic1 pin)
5381 */
5382 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5383
5384 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005385 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005386 */
5387 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005388 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005389
5390 /* Mute all inputs to mixer widget (even unconnected ones) */
5391 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5392 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5393 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5394 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5395 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5396 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5399
5400 { }
5401};
5402
Michael Schwingencc959482009-02-22 18:58:45 +01005403/* Initialisation sequence for Maxdata Favorit 100XS
5404 * (adapted from Acer init verbs).
5405 */
5406static struct hda_verb alc260_favorit100_init_verbs[] = {
5407 /* GPIO 0 enables the output jack.
5408 * Turn this on and rely on the standard mute
5409 * methods whenever the user wants to turn these outputs off.
5410 */
5411 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5412 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5413 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5414 /* Line/Mic input jack is connected to Mic1 pin */
5415 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5416 /* Ensure all other unused pins are disabled and muted. */
5417 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5418 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5419 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5420 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5421 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5422 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5423 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5424 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5425 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5426 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5427 /* Disable digital (SPDIF) pins */
5428 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5429 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5430
5431 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5432 * bus when acting as outputs.
5433 */
5434 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5435 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5436
5437 /* Start with output sum widgets muted and their output gains at min */
5438 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5440 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5441 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5442 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5444 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5445 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5446 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5447
5448 /* Unmute Line-out pin widget amp left and right
5449 * (no equiv mixer ctrl)
5450 */
5451 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5452 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5453 * inputs. If the pin mode is changed by the user the pin mode control
5454 * will take care of enabling the pin's input/output buffers as needed.
5455 * Therefore there's no need to enable the input buffer at this
5456 * stage.
5457 */
5458 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5459
5460 /* Mute capture amp left and right */
5461 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5462 /* Set ADC connection select to match default mixer setting - mic
5463 * (on mic1 pin)
5464 */
5465 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5466
5467 /* Do similar with the second ADC: mute capture input amp and
5468 * set ADC connection to mic to match ALSA's default state.
5469 */
5470 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5471 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5472
5473 /* Mute all inputs to mixer widget (even unconnected ones) */
5474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5476 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5478 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5479 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5480 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5481 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5482
5483 { }
5484};
5485
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005486static struct hda_verb alc260_will_verbs[] = {
5487 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5488 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5489 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5490 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5491 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5492 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5493 {}
5494};
5495
5496static struct hda_verb alc260_replacer_672v_verbs[] = {
5497 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5498 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5499 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5500
5501 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5502 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5503 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5504
5505 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5506 {}
5507};
5508
5509/* toggle speaker-output according to the hp-jack state */
5510static void alc260_replacer_672v_automute(struct hda_codec *codec)
5511{
5512 unsigned int present;
5513
5514 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5515 present = snd_hda_codec_read(codec, 0x0f, 0,
5516 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5517 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005518 snd_hda_codec_write_cache(codec, 0x01, 0,
5519 AC_VERB_SET_GPIO_DATA, 1);
5520 snd_hda_codec_write_cache(codec, 0x0f, 0,
5521 AC_VERB_SET_PIN_WIDGET_CONTROL,
5522 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005523 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005524 snd_hda_codec_write_cache(codec, 0x01, 0,
5525 AC_VERB_SET_GPIO_DATA, 0);
5526 snd_hda_codec_write_cache(codec, 0x0f, 0,
5527 AC_VERB_SET_PIN_WIDGET_CONTROL,
5528 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005529 }
5530}
5531
5532static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5533 unsigned int res)
5534{
5535 if ((res >> 26) == ALC880_HP_EVENT)
5536 alc260_replacer_672v_automute(codec);
5537}
5538
Kailang Yang3f878302008-08-26 13:02:23 +02005539static struct hda_verb alc260_hp_dc7600_verbs[] = {
5540 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5541 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5542 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5543 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5544 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5545 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5546 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5547 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5548 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5549 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5550 {}
5551};
5552
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005553/* Test configuration for debugging, modelled after the ALC880 test
5554 * configuration.
5555 */
5556#ifdef CONFIG_SND_DEBUG
5557static hda_nid_t alc260_test_dac_nids[1] = {
5558 0x02,
5559};
5560static hda_nid_t alc260_test_adc_nids[2] = {
5561 0x04, 0x05,
5562};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005563/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005564 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005565 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005566 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005567static struct hda_input_mux alc260_test_capture_sources[2] = {
5568 {
5569 .num_items = 7,
5570 .items = {
5571 { "MIC1 pin", 0x0 },
5572 { "MIC2 pin", 0x1 },
5573 { "LINE1 pin", 0x2 },
5574 { "LINE2 pin", 0x3 },
5575 { "CD pin", 0x4 },
5576 { "LINE-OUT pin", 0x5 },
5577 { "HP-OUT pin", 0x6 },
5578 },
5579 },
5580 {
5581 .num_items = 8,
5582 .items = {
5583 { "MIC1 pin", 0x0 },
5584 { "MIC2 pin", 0x1 },
5585 { "LINE1 pin", 0x2 },
5586 { "LINE2 pin", 0x3 },
5587 { "CD pin", 0x4 },
5588 { "Mixer", 0x5 },
5589 { "LINE-OUT pin", 0x6 },
5590 { "HP-OUT pin", 0x7 },
5591 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005592 },
5593};
5594static struct snd_kcontrol_new alc260_test_mixer[] = {
5595 /* Output driver widgets */
5596 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5597 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5598 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5599 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5600 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5601 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5602
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005603 /* Modes for retasking pin widgets
5604 * Note: the ALC260 doesn't seem to act on requests to enable mic
5605 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5606 * mention this restriction. At this stage it's not clear whether
5607 * this behaviour is intentional or is a hardware bug in chip
5608 * revisions available at least up until early 2006. Therefore for
5609 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5610 * choices, but if it turns out that the lack of mic bias for these
5611 * NIDs is intentional we could change their modes from
5612 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5613 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005614 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5615 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5616 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5617 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5618 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5619 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5620
5621 /* Loopback mixer controls */
5622 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5623 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5624 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5625 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5626 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5627 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5628 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5629 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5630 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5631 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005632 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5633 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5634 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5635 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005636
5637 /* Controls for GPIO pins, assuming they are configured as outputs */
5638 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5639 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5640 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5641 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5642
Jonathan Woithe92621f12006-02-28 11:47:47 +01005643 /* Switches to allow the digital IO pins to be enabled. The datasheet
5644 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005645 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005646 */
5647 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5648 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5649
Jonathan Woithef8225f62008-01-08 12:16:54 +01005650 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5651 * this output to turn on an external amplifier.
5652 */
5653 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5654 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5655
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005656 { } /* end */
5657};
5658static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005659 /* Enable all GPIOs as outputs with an initial value of 0 */
5660 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5661 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5662 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5663
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005664 /* Enable retasking pins as output, initially without power amp */
5665 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5666 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5667 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5668 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5669 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5670 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5671
Jonathan Woithe92621f12006-02-28 11:47:47 +01005672 /* Disable digital (SPDIF) pins initially, but users can enable
5673 * them via a mixer switch. In the case of SPDIF-out, this initverb
5674 * payload also sets the generation to 0, output to be in "consumer"
5675 * PCM format, copyright asserted, no pre-emphasis and no validity
5676 * control.
5677 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005678 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5679 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5680
Kailang Yangea1fb292008-08-26 12:58:38 +02005681 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005682 * OUT1 sum bus when acting as an output.
5683 */
5684 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5685 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5686 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5687 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5688
5689 /* Start with output sum widgets muted and their output gains at min */
5690 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5691 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5692 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5693 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5694 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5695 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5696 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5697 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5698 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5699
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005700 /* Unmute retasking pin widget output buffers since the default
5701 * state appears to be output. As the pin mode is changed by the
5702 * user the pin mode control will take care of enabling the pin's
5703 * input/output buffers as needed.
5704 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005705 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5706 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5707 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5708 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5709 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5710 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5711 /* Also unmute the mono-out pin widget */
5712 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5713
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005714 /* Mute capture amp left and right */
5715 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005716 /* Set ADC connection select to match default mixer setting (mic1
5717 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005718 */
5719 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5720
5721 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005722 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005723 */
5724 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5725 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5726
5727 /* Mute all inputs to mixer widget (even unconnected ones) */
5728 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5729 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5730 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5731 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5732 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5733 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5734 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5735 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5736
5737 { }
5738};
5739#endif
5740
Takashi Iwai63300792008-01-24 15:31:36 +01005741#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5742#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005743
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005744#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5745#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5746
Kailang Yangdf694da2005-12-05 19:42:22 +01005747/*
5748 * for BIOS auto-configuration
5749 */
5750
5751static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005752 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005753{
5754 hda_nid_t nid_vol;
5755 unsigned long vol_val, sw_val;
5756 char name[32];
5757 int err;
5758
5759 if (nid >= 0x0f && nid < 0x11) {
5760 nid_vol = nid - 0x7;
5761 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5762 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5763 } else if (nid == 0x11) {
5764 nid_vol = nid - 0x7;
5765 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5766 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5767 } else if (nid >= 0x12 && nid <= 0x15) {
5768 nid_vol = 0x08;
5769 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5770 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5771 } else
5772 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005773
Takashi Iwai863b4512008-10-21 17:01:47 +02005774 if (!(*vol_bits & (1 << nid_vol))) {
5775 /* first control for the volume widget */
5776 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5777 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5778 if (err < 0)
5779 return err;
5780 *vol_bits |= (1 << nid_vol);
5781 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005782 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005783 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5784 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005785 return err;
5786 return 1;
5787}
5788
5789/* add playback controls from the parsed DAC table */
5790static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5791 const struct auto_pin_cfg *cfg)
5792{
5793 hda_nid_t nid;
5794 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005795 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005796
5797 spec->multiout.num_dacs = 1;
5798 spec->multiout.dac_nids = spec->private_dac_nids;
5799 spec->multiout.dac_nids[0] = 0x02;
5800
5801 nid = cfg->line_out_pins[0];
5802 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005803 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005804 if (err < 0)
5805 return err;
5806 }
5807
Takashi Iwai82bc9552006-03-21 11:24:42 +01005808 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005809 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005810 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005811 if (err < 0)
5812 return err;
5813 }
5814
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005815 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005816 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005817 err = alc260_add_playback_controls(spec, nid, "Headphone",
5818 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005819 if (err < 0)
5820 return err;
5821 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005822 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005823}
5824
5825/* create playback/capture controls for input pins */
5826static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5827 const struct auto_pin_cfg *cfg)
5828{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005829 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005830 int i, err, idx;
5831
5832 for (i = 0; i < AUTO_PIN_LAST; i++) {
5833 if (cfg->input_pins[i] >= 0x12) {
5834 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005835 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005836 auto_pin_cfg_labels[i], idx,
5837 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005838 if (err < 0)
5839 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005840 imux->items[imux->num_items].label =
5841 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005842 imux->items[imux->num_items].index = idx;
5843 imux->num_items++;
5844 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005845 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005846 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005847 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005848 auto_pin_cfg_labels[i], idx,
5849 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005850 if (err < 0)
5851 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005852 imux->items[imux->num_items].label =
5853 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005854 imux->items[imux->num_items].index = idx;
5855 imux->num_items++;
5856 }
5857 }
5858 return 0;
5859}
5860
5861static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5862 hda_nid_t nid, int pin_type,
5863 int sel_idx)
5864{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005865 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005866 /* need the manual connection? */
5867 if (nid >= 0x12) {
5868 int idx = nid - 0x12;
5869 snd_hda_codec_write(codec, idx + 0x0b, 0,
5870 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005871 }
5872}
5873
5874static void alc260_auto_init_multi_out(struct hda_codec *codec)
5875{
5876 struct alc_spec *spec = codec->spec;
5877 hda_nid_t nid;
5878
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005879 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005880 if (nid) {
5881 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5882 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5883 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005884
Takashi Iwai82bc9552006-03-21 11:24:42 +01005885 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005886 if (nid)
5887 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5888
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005889 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005890 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005891 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005892}
Kailang Yangdf694da2005-12-05 19:42:22 +01005893
5894#define ALC260_PIN_CD_NID 0x16
5895static void alc260_auto_init_analog_input(struct hda_codec *codec)
5896{
5897 struct alc_spec *spec = codec->spec;
5898 int i;
5899
5900 for (i = 0; i < AUTO_PIN_LAST; i++) {
5901 hda_nid_t nid = spec->autocfg.input_pins[i];
5902 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005903 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005904 if (nid != ALC260_PIN_CD_NID &&
5905 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005906 snd_hda_codec_write(codec, nid, 0,
5907 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005908 AMP_OUT_MUTE);
5909 }
5910 }
5911}
5912
5913/*
5914 * generic initialization of ADC, input mixers and output mixers
5915 */
5916static struct hda_verb alc260_volume_init_verbs[] = {
5917 /*
5918 * Unmute ADC0-1 and set the default input to mic-in
5919 */
5920 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5921 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5922 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5923 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005924
Kailang Yangdf694da2005-12-05 19:42:22 +01005925 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5926 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005927 * Note: PASD motherboards uses the Line In 2 as the input for
5928 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005929 */
5930 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005931 /* mute analog inputs */
5932 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5933 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5934 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005937
5938 /*
5939 * Set up output mixers (0x08 - 0x0a)
5940 */
5941 /* set vol=0 to output mixers */
5942 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5943 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5944 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5945 /* set up input amps for analog loopback */
5946 /* Amp Indices: DAC = 0, mixer = 1 */
5947 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5948 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5949 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5950 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5951 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5952 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005953
Kailang Yangdf694da2005-12-05 19:42:22 +01005954 { }
5955};
5956
5957static int alc260_parse_auto_config(struct hda_codec *codec)
5958{
5959 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005960 int err;
5961 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5962
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005963 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5964 alc260_ignore);
5965 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005966 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005967 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5968 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005969 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005970 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005971 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005972 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5973 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005974 return err;
5975
5976 spec->multiout.max_channels = 2;
5977
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005978 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005979 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005980 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005981 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005982
Takashi Iwaid88897e2008-10-31 15:01:37 +01005983 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005984
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005985 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005986 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005987
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005988 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
5989
Kailang Yangdf694da2005-12-05 19:42:22 +01005990 return 1;
5991}
5992
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005993/* additional initialization for auto-configuration model */
5994static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005995{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005996 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005997 alc260_auto_init_multi_out(codec);
5998 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005999 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006000 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006001}
6002
Takashi Iwaicb53c622007-08-10 17:21:45 +02006003#ifdef CONFIG_SND_HDA_POWER_SAVE
6004static struct hda_amp_list alc260_loopbacks[] = {
6005 { 0x07, HDA_INPUT, 0 },
6006 { 0x07, HDA_INPUT, 1 },
6007 { 0x07, HDA_INPUT, 2 },
6008 { 0x07, HDA_INPUT, 3 },
6009 { 0x07, HDA_INPUT, 4 },
6010 { } /* end */
6011};
6012#endif
6013
Kailang Yangdf694da2005-12-05 19:42:22 +01006014/*
6015 * ALC260 configurations
6016 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006017static const char *alc260_models[ALC260_MODEL_LAST] = {
6018 [ALC260_BASIC] = "basic",
6019 [ALC260_HP] = "hp",
6020 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006021 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006022 [ALC260_FUJITSU_S702X] = "fujitsu",
6023 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006024 [ALC260_WILL] = "will",
6025 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006026 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006027#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006028 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006029#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006030 [ALC260_AUTO] = "auto",
6031};
6032
6033static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006034 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006035 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006036 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006037 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006038 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006039 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006040 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006041 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006042 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6043 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6044 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6045 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6046 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6047 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6048 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6049 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6050 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006051 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006052 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006053 {}
6054};
6055
Kailang Yangdf694da2005-12-05 19:42:22 +01006056static struct alc_config_preset alc260_presets[] = {
6057 [ALC260_BASIC] = {
6058 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006059 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006060 .init_verbs = { alc260_init_verbs },
6061 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6062 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006063 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006064 .adc_nids = alc260_adc_nids,
6065 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6066 .channel_mode = alc260_modes,
6067 .input_mux = &alc260_capture_source,
6068 },
6069 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006070 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006071 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006072 .init_verbs = { alc260_init_verbs,
6073 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006074 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6075 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006076 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6077 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006078 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6079 .channel_mode = alc260_modes,
6080 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006081 .unsol_event = alc260_hp_unsol_event,
6082 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006083 },
Kailang Yang3f878302008-08-26 13:02:23 +02006084 [ALC260_HP_DC7600] = {
6085 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006086 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006087 .init_verbs = { alc260_init_verbs,
6088 alc260_hp_dc7600_verbs },
6089 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6090 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006091 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6092 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006093 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6094 .channel_mode = alc260_modes,
6095 .input_mux = &alc260_capture_source,
6096 .unsol_event = alc260_hp_3012_unsol_event,
6097 .init_hook = alc260_hp_3012_automute,
6098 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006099 [ALC260_HP_3013] = {
6100 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006101 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006102 .init_verbs = { alc260_hp_3013_init_verbs,
6103 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006104 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6105 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006106 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6107 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006108 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6109 .channel_mode = alc260_modes,
6110 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006111 .unsol_event = alc260_hp_3013_unsol_event,
6112 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006113 },
6114 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006115 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006116 .init_verbs = { alc260_fujitsu_init_verbs },
6117 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6118 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006119 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6120 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006121 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6122 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006123 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6124 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006125 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006126 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006127 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006128 .init_verbs = { alc260_acer_init_verbs },
6129 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6130 .dac_nids = alc260_dac_nids,
6131 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6132 .adc_nids = alc260_dual_adc_nids,
6133 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6134 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006135 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6136 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006137 },
Michael Schwingencc959482009-02-22 18:58:45 +01006138 [ALC260_FAVORIT100] = {
6139 .mixers = { alc260_favorit100_mixer },
6140 .init_verbs = { alc260_favorit100_init_verbs },
6141 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6142 .dac_nids = alc260_dac_nids,
6143 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6144 .adc_nids = alc260_dual_adc_nids,
6145 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6146 .channel_mode = alc260_modes,
6147 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6148 .input_mux = alc260_favorit100_capture_sources,
6149 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006150 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006151 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006152 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6153 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6154 .dac_nids = alc260_dac_nids,
6155 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6156 .adc_nids = alc260_adc_nids,
6157 .dig_out_nid = ALC260_DIGOUT_NID,
6158 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6159 .channel_mode = alc260_modes,
6160 .input_mux = &alc260_capture_source,
6161 },
6162 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006163 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006164 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6165 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6166 .dac_nids = alc260_dac_nids,
6167 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6168 .adc_nids = alc260_adc_nids,
6169 .dig_out_nid = ALC260_DIGOUT_NID,
6170 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6171 .channel_mode = alc260_modes,
6172 .input_mux = &alc260_capture_source,
6173 .unsol_event = alc260_replacer_672v_unsol_event,
6174 .init_hook = alc260_replacer_672v_automute,
6175 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006176#ifdef CONFIG_SND_DEBUG
6177 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006178 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006179 .init_verbs = { alc260_test_init_verbs },
6180 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6181 .dac_nids = alc260_test_dac_nids,
6182 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6183 .adc_nids = alc260_test_adc_nids,
6184 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6185 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006186 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6187 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006188 },
6189#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006190};
6191
Linus Torvalds1da177e2005-04-16 15:20:36 -07006192static int patch_alc260(struct hda_codec *codec)
6193{
6194 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006195 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006196
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006197 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006198 if (spec == NULL)
6199 return -ENOMEM;
6200
6201 codec->spec = spec;
6202
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006203 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6204 alc260_models,
6205 alc260_cfg_tbl);
6206 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02006207 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, "
6208 "trying auto-probe from BIOS...\n",
6209 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006210 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006211 }
6212
Kailang Yangdf694da2005-12-05 19:42:22 +01006213 if (board_config == ALC260_AUTO) {
6214 /* automatic parse from the BIOS config */
6215 err = alc260_parse_auto_config(codec);
6216 if (err < 0) {
6217 alc_free(codec);
6218 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006219 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006220 printk(KERN_INFO
6221 "hda_codec: Cannot set up configuration "
6222 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006223 board_config = ALC260_BASIC;
6224 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006225 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006226
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006227 err = snd_hda_attach_beep_device(codec, 0x1);
6228 if (err < 0) {
6229 alc_free(codec);
6230 return err;
6231 }
6232
Kailang Yangdf694da2005-12-05 19:42:22 +01006233 if (board_config != ALC260_AUTO)
6234 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006235
Linus Torvalds1da177e2005-04-16 15:20:36 -07006236 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6237 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6238
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006239 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6240 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6241
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006242 if (!spec->adc_nids && spec->input_mux) {
6243 /* check whether NID 0x04 is valid */
6244 unsigned int wcap = get_wcaps(codec, 0x04);
6245 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6246 /* get type */
6247 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6248 spec->adc_nids = alc260_adc_nids_alt;
6249 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6250 } else {
6251 spec->adc_nids = alc260_adc_nids;
6252 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6253 }
6254 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006255 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006256 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006257
Takashi Iwai2134ea42008-01-10 16:53:55 +01006258 spec->vmaster_nid = 0x08;
6259
Linus Torvalds1da177e2005-04-16 15:20:36 -07006260 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006261 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006262 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006263#ifdef CONFIG_SND_HDA_POWER_SAVE
6264 if (!spec->loopback.amplist)
6265 spec->loopback.amplist = alc260_loopbacks;
6266#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006267 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006268
6269 return 0;
6270}
6271
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006272
Linus Torvalds1da177e2005-04-16 15:20:36 -07006273/*
6274 * ALC882 support
6275 *
6276 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6277 * configuration. Each pin widget can choose any input DACs and a mixer.
6278 * Each ADC is connected from a mixer of all inputs. This makes possible
6279 * 6-channel independent captures.
6280 *
6281 * In addition, an independent DAC for the multi-playback (not used in this
6282 * driver yet).
6283 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006284#define ALC882_DIGOUT_NID 0x06
6285#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006286
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006287static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006288 { 8, NULL }
6289};
6290
6291static hda_nid_t alc882_dac_nids[4] = {
6292 /* front, rear, clfe, rear_surr */
6293 0x02, 0x03, 0x04, 0x05
6294};
6295
Kailang Yangdf694da2005-12-05 19:42:22 +01006296/* identical with ALC880 */
6297#define alc882_adc_nids alc880_adc_nids
6298#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006299
Takashi Iwaie1406342008-02-11 18:32:32 +01006300static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6301static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6302
Linus Torvalds1da177e2005-04-16 15:20:36 -07006303/* input MUX */
6304/* FIXME: should be a matrix-type input source selection */
6305
6306static struct hda_input_mux alc882_capture_source = {
6307 .num_items = 4,
6308 .items = {
6309 { "Mic", 0x0 },
6310 { "Front Mic", 0x1 },
6311 { "Line", 0x2 },
6312 { "CD", 0x4 },
6313 },
6314};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006315
6316static struct hda_input_mux mb5_capture_source = {
6317 .num_items = 3,
6318 .items = {
6319 { "Mic", 0x1 },
6320 { "Line", 0x2 },
6321 { "CD", 0x4 },
6322 },
6323};
6324
Kailang Yangdf694da2005-12-05 19:42:22 +01006325/*
Kailang Yang272a5272007-05-14 11:00:38 +02006326 * 2ch mode
6327 */
6328static struct hda_verb alc882_3ST_ch2_init[] = {
6329 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6330 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6331 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6332 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6333 { } /* end */
6334};
6335
6336/*
6337 * 6ch mode
6338 */
6339static struct hda_verb alc882_3ST_ch6_init[] = {
6340 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6341 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6342 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6343 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6344 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6345 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6346 { } /* end */
6347};
6348
6349static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6350 { 2, alc882_3ST_ch2_init },
6351 { 6, alc882_3ST_ch6_init },
6352};
6353
6354/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006355 * 6ch mode
6356 */
6357static struct hda_verb alc882_sixstack_ch6_init[] = {
6358 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6359 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6360 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6361 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6362 { } /* end */
6363};
6364
6365/*
6366 * 8ch mode
6367 */
6368static struct hda_verb alc882_sixstack_ch8_init[] = {
6369 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6370 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6371 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6372 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6373 { } /* end */
6374};
6375
6376static struct hda_channel_mode alc882_sixstack_modes[2] = {
6377 { 6, alc882_sixstack_ch6_init },
6378 { 8, alc882_sixstack_ch8_init },
6379};
6380
Takashi Iwai87350ad2007-08-16 18:19:38 +02006381/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006382 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006383 */
6384
6385/*
6386 * 2ch mode
6387 */
6388static struct hda_verb alc885_mbp_ch2_init[] = {
6389 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6390 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6391 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6392 { } /* end */
6393};
6394
6395/*
6396 * 6ch mode
6397 */
6398static struct hda_verb alc885_mbp_ch6_init[] = {
6399 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6400 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6401 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6402 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6403 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6404 { } /* end */
6405};
6406
6407static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6408 { 2, alc885_mbp_ch2_init },
6409 { 6, alc885_mbp_ch6_init },
6410};
6411
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006412/*
6413 * 2ch
6414 * Speakers/Woofer/HP = Front
6415 * LineIn = Input
6416 */
6417static struct hda_verb alc885_mb5_ch2_init[] = {
6418 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6419 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6420 { } /* end */
6421};
6422
6423/*
6424 * 6ch mode
6425 * Speakers/HP = Front
6426 * Woofer = LFE
6427 * LineIn = Surround
6428 */
6429static struct hda_verb alc885_mb5_ch6_init[] = {
6430 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6431 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6432 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6433 { } /* end */
6434};
6435
6436static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6437 { 2, alc885_mb5_ch2_init },
6438 { 6, alc885_mb5_ch6_init },
6439};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006440
Linus Torvalds1da177e2005-04-16 15:20:36 -07006441/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6442 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6443 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006444static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006445 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006446 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006447 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006448 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006449 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6450 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006451 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6452 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006453 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006454 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006455 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6456 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6457 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6458 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6459 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006461 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006462 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6463 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006464 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006465 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006466 { } /* end */
6467};
6468
Takashi Iwai87350ad2007-08-16 18:19:38 +02006469static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006470 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6471 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6472 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6473 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6474 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6475 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6477 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006478 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006479 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6480 { } /* end */
6481};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006482
6483static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006484 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6485 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6486 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6487 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6488 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6489 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6490 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6491 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006492 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6493 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6494 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6495 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6496 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6497 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6498 { } /* end */
6499};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006500
Kailang Yangbdd148a2007-05-08 15:19:08 +02006501static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6502 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6503 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6504 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6505 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6506 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6507 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6508 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6509 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6510 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006511 { } /* end */
6512};
6513
Kailang Yang272a5272007-05-14 11:00:38 +02006514static struct snd_kcontrol_new alc882_targa_mixer[] = {
6515 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6516 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6517 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6518 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6519 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6520 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6521 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6522 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6523 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006524 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006525 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6526 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006527 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006528 { } /* end */
6529};
6530
6531/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6532 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6533 */
6534static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6535 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6536 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6537 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6538 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6539 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6540 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6541 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6542 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6543 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6544 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6546 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006547 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006548 { } /* end */
6549};
6550
Takashi Iwai914759b2007-09-06 14:52:04 +02006551static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6552 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6553 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6554 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6555 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6556 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6557 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6558 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6559 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6560 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6561 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006562 { } /* end */
6563};
6564
Kailang Yangdf694da2005-12-05 19:42:22 +01006565static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6566 {
6567 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6568 .name = "Channel Mode",
6569 .info = alc_ch_mode_info,
6570 .get = alc_ch_mode_get,
6571 .put = alc_ch_mode_put,
6572 },
6573 { } /* end */
6574};
6575
Linus Torvalds1da177e2005-04-16 15:20:36 -07006576static struct hda_verb alc882_init_verbs[] = {
6577 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006578 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6579 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6580 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006581 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006582 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6583 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6584 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006585 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006586 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6587 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6588 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006589 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006590 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6591 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6592 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006593
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006594 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006595 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006596 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006597 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006598 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006599 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006600 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006601 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006602 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006603 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006604 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006605 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006606 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006607 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006608 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006609 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006610 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006611 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006612 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6613 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006614 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006615 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6616 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006617 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006618 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6619 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6620 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6621 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6622 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006623 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006624 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006625
6626 /* FIXME: use matrix-type input source selection */
6627 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6628 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006629 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6630 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6631 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6632 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006633 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006634 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6635 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6636 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6637 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006638 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6641 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6642 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6643 /* ADC1: mute amp left and right */
6644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006645 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006646 /* ADC2: mute amp left and right */
6647 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006648 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006649 /* ADC3: mute amp left and right */
6650 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006651 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006652
6653 { }
6654};
6655
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006656static struct hda_verb alc882_eapd_verbs[] = {
6657 /* change to EAPD mode */
6658 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006659 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006660 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006661};
6662
Tobin Davis9102cd12006-12-15 10:02:12 +01006663/* Mac Pro test */
6664static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6665 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6666 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6667 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6668 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6669 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006670 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006671 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6672 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006673 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006674 { } /* end */
6675};
6676
6677static struct hda_verb alc882_macpro_init_verbs[] = {
6678 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6680 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6681 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6682 /* Front Pin: output 0 (0x0c) */
6683 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6684 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6685 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6686 /* Front Mic pin: input vref at 80% */
6687 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6688 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6689 /* Speaker: output */
6690 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6692 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6693 /* Headphone output (output 0 - 0x0c) */
6694 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6695 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6696 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6697
6698 /* FIXME: use matrix-type input source selection */
6699 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6700 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6701 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6702 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6703 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6704 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6705 /* Input mixer2 */
6706 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6707 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6708 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6709 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6710 /* Input mixer3 */
6711 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6712 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6713 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6714 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6715 /* ADC1: mute amp left and right */
6716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6717 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6718 /* ADC2: mute amp left and right */
6719 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6720 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6721 /* ADC3: mute amp left and right */
6722 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6723 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6724
6725 { }
6726};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006727
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006728/* Macbook 5,1 */
6729static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006730 /* DACs */
6731 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6732 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6733 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6734 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006735 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006736 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6737 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006739 /* Surround mixer */
6740 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6741 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6743 /* LFE mixer */
6744 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6745 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6746 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6747 /* HP mixer */
6748 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6749 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6750 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6751 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006752 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6753 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006754 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6755 /* LFE Pin (0x0e) */
6756 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6757 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6758 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
6759 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006760 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6761 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006762 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006763 /* Front Mic pin: input vref at 80% */
6764 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6765 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6766 /* Line In pin */
6767 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6768 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6769
6770 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6771 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6772 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6773 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6774 { }
6775};
6776
Takashi Iwai87350ad2007-08-16 18:19:38 +02006777/* Macbook Pro rev3 */
6778static struct hda_verb alc885_mbp3_init_verbs[] = {
6779 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6780 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6781 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6782 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6783 /* Rear mixer */
6784 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6785 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6786 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6787 /* Front Pin: output 0 (0x0c) */
6788 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6789 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6790 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6791 /* HP Pin: output 0 (0x0d) */
6792 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6794 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6795 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6796 /* Mic (rear) pin: input vref at 80% */
6797 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6798 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6799 /* Front Mic pin: input vref at 80% */
6800 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6801 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6802 /* Line In pin: use output 1 when in LineOut mode */
6803 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6804 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6805 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6806
6807 /* FIXME: use matrix-type input source selection */
6808 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6809 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6810 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6811 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6812 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6813 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6814 /* Input mixer2 */
6815 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6816 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6817 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6818 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6819 /* Input mixer3 */
6820 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6821 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6822 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6823 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6824 /* ADC1: mute amp left and right */
6825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6826 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6827 /* ADC2: mute amp left and right */
6828 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6829 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6830 /* ADC3: mute amp left and right */
6831 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6832 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6833
6834 { }
6835};
6836
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006837/* iMac 24 mixer. */
6838static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6839 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6840 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6841 { } /* end */
6842};
6843
6844/* iMac 24 init verbs. */
6845static struct hda_verb alc885_imac24_init_verbs[] = {
6846 /* Internal speakers: output 0 (0x0c) */
6847 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6848 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6849 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6850 /* Internal speakers: output 0 (0x0c) */
6851 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6852 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6853 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6854 /* Headphone: output 0 (0x0c) */
6855 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6856 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6857 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6858 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6859 /* Front Mic: input vref at 80% */
6860 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6861 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6862 { }
6863};
6864
6865/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006866static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006867{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006868 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006869
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006870 spec->autocfg.hp_pins[0] = 0x14;
6871 spec->autocfg.speaker_pins[0] = 0x18;
6872 spec->autocfg.speaker_pins[1] = 0x1a;
6873 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006874}
6875
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006876static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006877{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006878 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006879
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006880 spec->autocfg.hp_pins[0] = 0x15;
6881 spec->autocfg.speaker_pins[0] = 0x14;
6882 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02006883}
6884
6885
Kailang Yang272a5272007-05-14 11:00:38 +02006886static struct hda_verb alc882_targa_verbs[] = {
6887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6889
6890 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6891 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006892
Kailang Yang272a5272007-05-14 11:00:38 +02006893 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6894 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6895 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6896
6897 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6898 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6899 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6900 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6901 { } /* end */
6902};
6903
6904/* toggle speaker-output according to the hp-jack state */
6905static void alc882_targa_automute(struct hda_codec *codec)
6906{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006907 struct alc_spec *spec = codec->spec;
6908 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006909 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006910 spec->jack_present ? 1 : 3);
6911}
6912
6913static void alc882_targa_init_hook(struct hda_codec *codec)
6914{
6915 struct alc_spec *spec = codec->spec;
6916
6917 spec->autocfg.hp_pins[0] = 0x14;
6918 spec->autocfg.speaker_pins[0] = 0x1b;
6919 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006920}
6921
6922static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6923{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006924 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02006925 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006926}
6927
6928static struct hda_verb alc882_asus_a7j_verbs[] = {
6929 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6930 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6931
6932 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6933 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6934 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006935
Kailang Yang272a5272007-05-14 11:00:38 +02006936 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6937 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6938 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6939
6940 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6941 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6942 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6943 { } /* end */
6944};
6945
Takashi Iwai914759b2007-09-06 14:52:04 +02006946static struct hda_verb alc882_asus_a7m_verbs[] = {
6947 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6948 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6949
6950 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6951 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6952 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006953
Takashi Iwai914759b2007-09-06 14:52:04 +02006954 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6955 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6956 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6957
6958 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6959 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6960 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6961 { } /* end */
6962};
6963
Tobin Davis9102cd12006-12-15 10:02:12 +01006964static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6965{
6966 unsigned int gpiostate, gpiomask, gpiodir;
6967
6968 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6969 AC_VERB_GET_GPIO_DATA, 0);
6970
6971 if (!muted)
6972 gpiostate |= (1 << pin);
6973 else
6974 gpiostate &= ~(1 << pin);
6975
6976 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6977 AC_VERB_GET_GPIO_MASK, 0);
6978 gpiomask |= (1 << pin);
6979
6980 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6981 AC_VERB_GET_GPIO_DIRECTION, 0);
6982 gpiodir |= (1 << pin);
6983
6984
6985 snd_hda_codec_write(codec, codec->afg, 0,
6986 AC_VERB_SET_GPIO_MASK, gpiomask);
6987 snd_hda_codec_write(codec, codec->afg, 0,
6988 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6989
6990 msleep(1);
6991
6992 snd_hda_codec_write(codec, codec->afg, 0,
6993 AC_VERB_SET_GPIO_DATA, gpiostate);
6994}
6995
Takashi Iwai7debbe52007-08-16 15:01:03 +02006996/* set up GPIO at initialization */
6997static void alc885_macpro_init_hook(struct hda_codec *codec)
6998{
6999 alc882_gpio_mute(codec, 0, 0);
7000 alc882_gpio_mute(codec, 1, 0);
7001}
7002
7003/* set up GPIO and update auto-muting at initialization */
7004static void alc885_imac24_init_hook(struct hda_codec *codec)
7005{
7006 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007007 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007008}
7009
Kailang Yangdf694da2005-12-05 19:42:22 +01007010/*
7011 * generic initialization of ADC, input mixers and output mixers
7012 */
7013static struct hda_verb alc882_auto_init_verbs[] = {
7014 /*
7015 * Unmute ADC0-2 and set the default input to mic-in
7016 */
7017 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7018 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7019 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7020 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7021 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7022 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7023
Takashi Iwaicb53c622007-08-10 17:21:45 +02007024 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007025 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007026 * Note: PASD motherboards uses the Line In 2 as the input for
7027 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007028 */
7029 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007030 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7031 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7032 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7033 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7034 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007035
7036 /*
7037 * Set up output mixers (0x0c - 0x0f)
7038 */
7039 /* set vol=0 to output mixers */
7040 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7041 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7042 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7043 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7044 /* set up input amps for analog loopback */
7045 /* Amp Indices: DAC = 0, mixer = 1 */
7046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7049 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7050 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7051 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7052 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7053 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7054 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7055 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7056
7057 /* FIXME: use matrix-type input source selection */
7058 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7059 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7060 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7062 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7064 /* Input mixer2 */
7065 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7066 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7067 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7069 /* Input mixer3 */
7070 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7071 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7072 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7074
7075 { }
7076};
7077
Takashi Iwaicb53c622007-08-10 17:21:45 +02007078#ifdef CONFIG_SND_HDA_POWER_SAVE
7079#define alc882_loopbacks alc880_loopbacks
7080#endif
7081
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007082/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007083#define alc882_pcm_analog_playback alc880_pcm_analog_playback
7084#define alc882_pcm_analog_capture alc880_pcm_analog_capture
7085#define alc882_pcm_digital_playback alc880_pcm_digital_playback
7086#define alc882_pcm_digital_capture alc880_pcm_digital_capture
7087
7088/*
7089 * configuration and preset
7090 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007091static const char *alc882_models[ALC882_MODEL_LAST] = {
7092 [ALC882_3ST_DIG] = "3stack-dig",
7093 [ALC882_6ST_DIG] = "6stack-dig",
7094 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02007095 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02007096 [ALC882_TARGA] = "targa",
7097 [ALC882_ASUS_A7J] = "asus-a7j",
7098 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01007099 [ALC885_MACPRO] = "macpro",
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007100 [ALC885_MB5] = "mb5",
Takashi Iwai87350ad2007-08-16 18:19:38 +02007101 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007102 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007103 [ALC882_AUTO] = "auto",
7104};
7105
7106static struct snd_pci_quirk alc882_cfg_tbl[] = {
7107 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02007108 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02007109 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02007110 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007111 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02007112 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01007113 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007114 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01007115 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007116 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
7117 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
7118 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01007119 {}
7120};
7121
7122static struct alc_config_preset alc882_presets[] = {
7123 [ALC882_3ST_DIG] = {
7124 .mixers = { alc882_base_mixer },
7125 .init_verbs = { alc882_init_verbs },
7126 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7127 .dac_nids = alc882_dac_nids,
7128 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007129 .dig_in_nid = ALC882_DIGIN_NID,
7130 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7131 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007132 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007133 .input_mux = &alc882_capture_source,
7134 },
7135 [ALC882_6ST_DIG] = {
7136 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7137 .init_verbs = { alc882_init_verbs },
7138 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7139 .dac_nids = alc882_dac_nids,
7140 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007141 .dig_in_nid = ALC882_DIGIN_NID,
7142 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7143 .channel_mode = alc882_sixstack_modes,
7144 .input_mux = &alc882_capture_source,
7145 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007146 [ALC882_ARIMA] = {
7147 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7148 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
7149 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7150 .dac_nids = alc882_dac_nids,
7151 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7152 .channel_mode = alc882_sixstack_modes,
7153 .input_mux = &alc882_capture_source,
7154 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02007155 [ALC882_W2JC] = {
7156 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
7157 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7158 alc880_gpio1_init_verbs },
7159 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7160 .dac_nids = alc882_dac_nids,
7161 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7162 .channel_mode = alc880_threestack_modes,
7163 .need_dac_fix = 1,
7164 .input_mux = &alc882_capture_source,
7165 .dig_out_nid = ALC882_DIGOUT_NID,
7166 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007167 [ALC885_MBP3] = {
7168 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
7169 .init_verbs = { alc885_mbp3_init_verbs,
7170 alc880_gpio1_init_verbs },
7171 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7172 .dac_nids = alc882_dac_nids,
7173 .channel_mode = alc885_mbp_6ch_modes,
7174 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
7175 .input_mux = &alc882_capture_source,
7176 .dig_out_nid = ALC882_DIGOUT_NID,
7177 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007178 .unsol_event = alc_automute_amp_unsol_event,
7179 .init_hook = alc885_mbp3_init_hook,
Takashi Iwai87350ad2007-08-16 18:19:38 +02007180 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007181 [ALC885_MB5] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007182 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007183 .init_verbs = { alc885_mb5_init_verbs,
7184 alc880_gpio1_init_verbs },
7185 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7186 .dac_nids = alc882_dac_nids,
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007187 .channel_mode = alc885_mb5_6ch_modes,
7188 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007189 .input_mux = &mb5_capture_source,
7190 .dig_out_nid = ALC882_DIGOUT_NID,
7191 .dig_in_nid = ALC882_DIGIN_NID,
7192 },
Tobin Davis9102cd12006-12-15 10:02:12 +01007193 [ALC885_MACPRO] = {
7194 .mixers = { alc882_macpro_mixer },
7195 .init_verbs = { alc882_macpro_init_verbs },
7196 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7197 .dac_nids = alc882_dac_nids,
7198 .dig_out_nid = ALC882_DIGOUT_NID,
7199 .dig_in_nid = ALC882_DIGIN_NID,
7200 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7201 .channel_mode = alc882_ch_modes,
7202 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007203 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01007204 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007205 [ALC885_IMAC24] = {
7206 .mixers = { alc885_imac24_mixer },
7207 .init_verbs = { alc885_imac24_init_verbs },
7208 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7209 .dac_nids = alc882_dac_nids,
7210 .dig_out_nid = ALC882_DIGOUT_NID,
7211 .dig_in_nid = ALC882_DIGIN_NID,
7212 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7213 .channel_mode = alc882_ch_modes,
7214 .input_mux = &alc882_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007215 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007216 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007217 },
Kailang Yang272a5272007-05-14 11:00:38 +02007218 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007219 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007220 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
7221 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7222 .dac_nids = alc882_dac_nids,
7223 .dig_out_nid = ALC882_DIGOUT_NID,
7224 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7225 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007226 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007227 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7228 .channel_mode = alc882_3ST_6ch_modes,
7229 .need_dac_fix = 1,
7230 .input_mux = &alc882_capture_source,
7231 .unsol_event = alc882_targa_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007232 .init_hook = alc882_targa_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02007233 },
7234 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007235 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007236 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7237 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7238 .dac_nids = alc882_dac_nids,
7239 .dig_out_nid = ALC882_DIGOUT_NID,
7240 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7241 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007242 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007243 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7244 .channel_mode = alc882_3ST_6ch_modes,
7245 .need_dac_fix = 1,
7246 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007247 },
Takashi Iwai914759b2007-09-06 14:52:04 +02007248 [ALC882_ASUS_A7M] = {
7249 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7250 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7251 alc880_gpio1_init_verbs,
7252 alc882_asus_a7m_verbs },
7253 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7254 .dac_nids = alc882_dac_nids,
7255 .dig_out_nid = ALC882_DIGOUT_NID,
7256 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7257 .channel_mode = alc880_threestack_modes,
7258 .need_dac_fix = 1,
7259 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007260 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007261};
7262
7263
7264/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007265 * Pin config fixes
7266 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007267enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007268 PINFIX_ABIT_AW9D_MAX
7269};
7270
7271static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7272 { 0x15, 0x01080104 }, /* side */
7273 { 0x16, 0x01011012 }, /* rear */
7274 { 0x17, 0x01016011 }, /* clfe */
7275 { }
7276};
7277
7278static const struct alc_pincfg *alc882_pin_fixes[] = {
7279 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7280};
7281
7282static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7283 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7284 {}
7285};
7286
7287/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007288 * BIOS auto configuration
7289 */
7290static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7291 hda_nid_t nid, int pin_type,
7292 int dac_idx)
7293{
7294 /* set as output */
7295 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007296 int idx;
7297
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007298 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007299 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7300 idx = 4;
7301 else
7302 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007303 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7304
7305}
7306
7307static void alc882_auto_init_multi_out(struct hda_codec *codec)
7308{
7309 struct alc_spec *spec = codec->spec;
7310 int i;
7311
7312 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007313 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007314 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007315 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007316 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007317 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007318 }
7319}
7320
7321static void alc882_auto_init_hp_out(struct hda_codec *codec)
7322{
7323 struct alc_spec *spec = codec->spec;
7324 hda_nid_t pin;
7325
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007326 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007327 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007328 /* use dac 0 */
7329 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007330 pin = spec->autocfg.speaker_pins[0];
7331 if (pin)
7332 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007333}
7334
7335#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7336#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7337
7338static void alc882_auto_init_analog_input(struct hda_codec *codec)
7339{
7340 struct alc_spec *spec = codec->spec;
7341 int i;
7342
7343 for (i = 0; i < AUTO_PIN_LAST; i++) {
7344 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007345 if (!nid)
7346 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007347 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007348 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7349 snd_hda_codec_write(codec, nid, 0,
7350 AC_VERB_SET_AMP_GAIN_MUTE,
7351 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007352 }
7353}
7354
Takashi Iwaif511b012008-08-15 16:46:42 +02007355static void alc882_auto_init_input_src(struct hda_codec *codec)
7356{
7357 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007358 int c;
7359
7360 for (c = 0; c < spec->num_adc_nids; c++) {
7361 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7362 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007363 unsigned int mux_idx;
7364 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007365 int conns, mute, idx, item;
7366
7367 conns = snd_hda_get_connections(codec, nid, conn_list,
7368 ARRAY_SIZE(conn_list));
7369 if (conns < 0)
7370 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007371 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7372 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007373 for (idx = 0; idx < conns; idx++) {
7374 /* if the current connection is the selected one,
7375 * unmute it as default - otherwise mute it
7376 */
7377 mute = AMP_IN_MUTE(idx);
7378 for (item = 0; item < imux->num_items; item++) {
7379 if (imux->items[item].index == idx) {
7380 if (spec->cur_mux[c] == item)
7381 mute = AMP_IN_UNMUTE(idx);
7382 break;
7383 }
7384 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007385 /* check if we have a selector or mixer
7386 * we could check for the widget type instead, but
7387 * just check for Amp-In presence (in case of mixer
7388 * without amp-in there is something wrong, this
7389 * function shouldn't be used or capsrc nid is wrong)
7390 */
7391 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7392 snd_hda_codec_write(codec, nid, 0,
7393 AC_VERB_SET_AMP_GAIN_MUTE,
7394 mute);
7395 else if (mute != AMP_IN_MUTE(idx))
7396 snd_hda_codec_write(codec, nid, 0,
7397 AC_VERB_SET_CONNECT_SEL,
7398 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007399 }
7400 }
7401}
7402
Takashi Iwai776e1842007-08-29 15:07:11 +02007403/* add mic boosts if needed */
7404static int alc_auto_add_mic_boost(struct hda_codec *codec)
7405{
7406 struct alc_spec *spec = codec->spec;
7407 int err;
7408 hda_nid_t nid;
7409
7410 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007411 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007412 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7413 "Mic Boost",
7414 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7415 if (err < 0)
7416 return err;
7417 }
7418 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007419 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007420 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7421 "Front Mic Boost",
7422 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7423 if (err < 0)
7424 return err;
7425 }
7426 return 0;
7427}
7428
Kailang Yangdf694da2005-12-05 19:42:22 +01007429/* almost identical with ALC880 parser... */
7430static int alc882_parse_auto_config(struct hda_codec *codec)
7431{
7432 struct alc_spec *spec = codec->spec;
7433 int err = alc880_parse_auto_config(codec);
7434
7435 if (err < 0)
7436 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007437 else if (!err)
7438 return 0; /* no config found */
7439
7440 err = alc_auto_add_mic_boost(codec);
7441 if (err < 0)
7442 return err;
7443
7444 /* hack - override the init verbs */
7445 spec->init_verbs[0] = alc882_auto_init_verbs;
7446
7447 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007448}
7449
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007450/* additional initialization for auto-configuration model */
7451static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007452{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007453 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007454 alc882_auto_init_multi_out(codec);
7455 alc882_auto_init_hp_out(codec);
7456 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007457 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007458 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007459 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007460}
7461
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007462static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7463
Linus Torvalds1da177e2005-04-16 15:20:36 -07007464static int patch_alc882(struct hda_codec *codec)
7465{
7466 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007467 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007468
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007469 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007470 if (spec == NULL)
7471 return -ENOMEM;
7472
Linus Torvalds1da177e2005-04-16 15:20:36 -07007473 codec->spec = spec;
7474
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007475 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7476 alc882_models,
7477 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007478
Kailang Yangdf694da2005-12-05 19:42:22 +01007479 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007480 /* Pick up systems that don't supply PCI SSID */
7481 switch (codec->subsystem_id) {
7482 case 0x106b0c00: /* Mac Pro */
7483 board_config = ALC885_MACPRO;
7484 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007485 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007486 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007487 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007488 board_config = ALC885_IMAC24;
7489 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007490 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007491 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007492 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007493 case 0x106b2c00: /* Macbook Pro rev3 */
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007494 /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */
Luke Yelavich2a884642009-01-28 15:58:38 +11007495 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007496 board_config = ALC885_MBP3;
7497 break;
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007498 case 0x106b3f00: /* Macbook 5,1 */
Takashi Iwai7442f9d2009-05-14 18:20:33 +02007499 case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense
7500 * seems not working, so apparently
7501 * no perfect solution yet
7502 */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007503 board_config = ALC885_MB5;
7504 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007505 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007506 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007507 if (codec->revision_id == 0x100101 ||
7508 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007509 alc_free(codec);
7510 return patch_alc883(codec);
7511 }
Takashi Iwai6c627f32009-05-18 12:33:36 +02007512 printk(KERN_INFO "hda_codec: Unknown model for %s, "
7513 "trying auto-probe from BIOS...\n",
7514 codec->chip_name);
Tobin Davis081d17c2007-02-15 17:46:18 +01007515 board_config = ALC882_AUTO;
7516 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007517 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007518
Takashi Iwaif95474e2007-07-10 00:47:43 +02007519 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7520
Kailang Yangdf694da2005-12-05 19:42:22 +01007521 if (board_config == ALC882_AUTO) {
7522 /* automatic parse from the BIOS config */
7523 err = alc882_parse_auto_config(codec);
7524 if (err < 0) {
7525 alc_free(codec);
7526 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007527 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007528 printk(KERN_INFO
7529 "hda_codec: Cannot set up configuration "
7530 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007531 board_config = ALC882_3ST_DIG;
7532 }
7533 }
7534
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007535 err = snd_hda_attach_beep_device(codec, 0x1);
7536 if (err < 0) {
7537 alc_free(codec);
7538 return err;
7539 }
7540
Kailang Yangdf694da2005-12-05 19:42:22 +01007541 if (board_config != ALC882_AUTO)
7542 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007543
Kailang Yangdf694da2005-12-05 19:42:22 +01007544 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7545 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007546 /* FIXME: setup DAC5 */
7547 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7548 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007549
Kailang Yangdf694da2005-12-05 19:42:22 +01007550 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7551 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007552
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007553 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007554 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007555 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007556 /* get type */
7557 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007558 if (wcap != AC_WID_AUD_IN) {
7559 spec->adc_nids = alc882_adc_nids_alt;
7560 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007561 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007562 } else {
7563 spec->adc_nids = alc882_adc_nids;
7564 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007565 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007566 }
7567 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007568 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007569 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007570
Takashi Iwai2134ea42008-01-10 16:53:55 +01007571 spec->vmaster_nid = 0x0c;
7572
Linus Torvalds1da177e2005-04-16 15:20:36 -07007573 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007574 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007575 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007576#ifdef CONFIG_SND_HDA_POWER_SAVE
7577 if (!spec->loopback.amplist)
7578 spec->loopback.amplist = alc882_loopbacks;
7579#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007580 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007581
7582 return 0;
7583}
7584
7585/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007586 * ALC883 support
7587 *
7588 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7589 * configuration. Each pin widget can choose any input DACs and a mixer.
7590 * Each ADC is connected from a mixer of all inputs. This makes possible
7591 * 6-channel independent captures.
7592 *
7593 * In addition, an independent DAC for the multi-playback (not used in this
7594 * driver yet).
7595 */
7596#define ALC883_DIGOUT_NID 0x06
7597#define ALC883_DIGIN_NID 0x0a
7598
Wu Fengguang3ab90932008-11-17 09:51:09 +01007599#define ALC1200_DIGOUT_NID 0x10
7600
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007601static hda_nid_t alc883_dac_nids[4] = {
7602 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007603 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007604};
7605
7606static hda_nid_t alc883_adc_nids[2] = {
7607 /* ADC1-2 */
7608 0x08, 0x09,
7609};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007610
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007611static hda_nid_t alc883_adc_nids_alt[1] = {
7612 /* ADC1 */
7613 0x08,
7614};
7615
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007616static hda_nid_t alc883_adc_nids_rev[2] = {
7617 /* ADC2-1 */
7618 0x09, 0x08
7619};
7620
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007621#define alc889_adc_nids alc880_adc_nids
7622
Takashi Iwaie1406342008-02-11 18:32:32 +01007623static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7624
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007625static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7626
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007627#define alc889_capsrc_nids alc882_capsrc_nids
7628
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007629/* input MUX */
7630/* FIXME: should be a matrix-type input source selection */
7631
7632static struct hda_input_mux alc883_capture_source = {
7633 .num_items = 4,
7634 .items = {
7635 { "Mic", 0x0 },
7636 { "Front Mic", 0x1 },
7637 { "Line", 0x2 },
7638 { "CD", 0x4 },
7639 },
7640};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007641
Jiang zhe17bba1b2008-06-04 12:11:07 +02007642static struct hda_input_mux alc883_3stack_6ch_intel = {
7643 .num_items = 4,
7644 .items = {
7645 { "Mic", 0x1 },
7646 { "Front Mic", 0x0 },
7647 { "Line", 0x2 },
7648 { "CD", 0x4 },
7649 },
7650};
7651
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007652static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7653 .num_items = 2,
7654 .items = {
7655 { "Mic", 0x1 },
7656 { "Line", 0x2 },
7657 },
7658};
7659
Kailang Yang272a5272007-05-14 11:00:38 +02007660static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7661 .num_items = 4,
7662 .items = {
7663 { "Mic", 0x0 },
7664 { "iMic", 0x1 },
7665 { "Line", 0x2 },
7666 { "CD", 0x4 },
7667 },
7668};
7669
Jiang zhefb97dc62008-03-06 11:07:11 +01007670static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7671 .num_items = 2,
7672 .items = {
7673 { "Mic", 0x0 },
7674 { "Int Mic", 0x1 },
7675 },
7676};
7677
Kailang Yange2757d52008-08-26 13:17:46 +02007678static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7679 .num_items = 3,
7680 .items = {
7681 { "Mic", 0x0 },
7682 { "Front Mic", 0x1 },
7683 { "Line", 0x4 },
7684 },
7685};
7686
7687static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7688 .num_items = 2,
7689 .items = {
7690 { "Mic", 0x0 },
7691 { "Line", 0x2 },
7692 },
7693};
7694
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007695static struct hda_input_mux alc889A_mb31_capture_source = {
7696 .num_items = 2,
7697 .items = {
7698 { "Mic", 0x0 },
7699 /* Front Mic (0x01) unused */
7700 { "Line", 0x2 },
7701 /* Line 2 (0x03) unused */
7702 /* CD (0x04) unsused? */
7703 },
7704};
7705
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007706/*
7707 * 2ch mode
7708 */
7709static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7710 { 2, NULL }
7711};
7712
7713/*
7714 * 2ch mode
7715 */
7716static struct hda_verb alc883_3ST_ch2_init[] = {
7717 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7718 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7719 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7720 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7721 { } /* end */
7722};
7723
7724/*
Tobin Davisb2011312007-09-17 12:45:11 +02007725 * 4ch mode
7726 */
7727static struct hda_verb alc883_3ST_ch4_init[] = {
7728 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7729 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7730 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7731 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7732 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7733 { } /* end */
7734};
7735
7736/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007737 * 6ch mode
7738 */
7739static struct hda_verb alc883_3ST_ch6_init[] = {
7740 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7741 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7742 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7743 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7744 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7745 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7746 { } /* end */
7747};
7748
Tobin Davisb2011312007-09-17 12:45:11 +02007749static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007750 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007751 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007752 { 6, alc883_3ST_ch6_init },
7753};
7754
David Heidelberger64a8be72009-06-08 16:15:18 +02007755
7756/*
7757 * 2ch mode
7758 */
7759static struct hda_verb alc883_4ST_ch2_init[] = {
Takashi Iwaif03ecf52009-06-08 16:38:17 +02007760 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
David Heidelberger64a8be72009-06-08 16:15:18 +02007761 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7762 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7763 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7764 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7765 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7766 { } /* end */
7767};
7768
7769/*
7770 * 4ch mode
7771 */
7772static struct hda_verb alc883_4ST_ch4_init[] = {
7773 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7774 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7775 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7776 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
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
7783/*
7784 * 6ch mode
7785 */
7786static struct hda_verb alc883_4ST_ch6_init[] = {
7787 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7788 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7789 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7790 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7791 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7792 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7793 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7794 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7795 { } /* end */
7796};
7797
7798/*
7799 * 8ch mode
7800 */
7801static struct hda_verb alc883_4ST_ch8_init[] = {
7802 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7803 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7804 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7805 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7806 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7807 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
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
7814static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7815 { 2, alc883_4ST_ch2_init },
7816 { 4, alc883_4ST_ch4_init },
7817 { 6, alc883_4ST_ch6_init },
7818 { 8, alc883_4ST_ch8_init },
7819};
7820
7821
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007822/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007823 * 2ch mode
7824 */
7825static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7826 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7827 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7828 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7829 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7830 { } /* end */
7831};
7832
7833/*
7834 * 4ch mode
7835 */
7836static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7837 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7838 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7839 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7840 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7841 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7842 { } /* end */
7843};
7844
7845/*
7846 * 6ch mode
7847 */
7848static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7849 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7850 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7851 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7852 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7853 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7854 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7855 { } /* end */
7856};
7857
7858static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7859 { 2, alc883_3ST_ch2_intel_init },
7860 { 4, alc883_3ST_ch4_intel_init },
7861 { 6, alc883_3ST_ch6_intel_init },
7862};
7863
7864/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007865 * 6ch mode
7866 */
7867static struct hda_verb alc883_sixstack_ch6_init[] = {
7868 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7869 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7870 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7871 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7872 { } /* end */
7873};
7874
7875/*
7876 * 8ch mode
7877 */
7878static struct hda_verb alc883_sixstack_ch8_init[] = {
7879 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7880 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7881 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7882 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7883 { } /* end */
7884};
7885
7886static struct hda_channel_mode alc883_sixstack_modes[2] = {
7887 { 6, alc883_sixstack_ch6_init },
7888 { 8, alc883_sixstack_ch8_init },
7889};
7890
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007891/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7892static struct hda_verb alc889A_mb31_ch2_init[] = {
7893 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7894 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7895 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7896 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7897 { } /* end */
7898};
7899
7900/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7901static struct hda_verb alc889A_mb31_ch4_init[] = {
7902 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7903 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7904 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7905 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7906 { } /* end */
7907};
7908
7909/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7910static struct hda_verb alc889A_mb31_ch5_init[] = {
7911 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7912 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7913 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7914 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7915 { } /* end */
7916};
7917
7918/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7919static struct hda_verb alc889A_mb31_ch6_init[] = {
7920 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7921 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7922 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7923 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7924 { } /* end */
7925};
7926
7927static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7928 { 2, alc889A_mb31_ch2_init },
7929 { 4, alc889A_mb31_ch4_init },
7930 { 5, alc889A_mb31_ch5_init },
7931 { 6, alc889A_mb31_ch6_init },
7932};
7933
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007934static struct hda_verb alc883_medion_eapd_verbs[] = {
7935 /* eanable EAPD on medion laptop */
7936 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7937 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7938 { }
7939};
7940
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007941/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7942 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7943 */
7944
7945static struct snd_kcontrol_new alc883_base_mixer[] = {
7946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7947 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7948 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7949 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7950 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7951 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7952 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7953 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7954 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7955 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7956 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7957 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7958 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7959 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7960 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7961 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007962 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007963 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7964 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007965 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007966 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007967 { } /* end */
7968};
7969
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007970static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7971 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7972 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7973 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7974 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7975 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7976 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7977 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7978 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7979 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7981 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7982 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7983 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007984 { } /* end */
7985};
7986
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007987static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007988 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7989 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7990 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7991 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7993 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7995 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7996 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7997 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007998 { } /* end */
7999};
8000
Jiang zhefb97dc62008-03-06 11:07:11 +01008001static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8002 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8003 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8004 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8005 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8007 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8009 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8010 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8011 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008012 { } /* end */
8013};
8014
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008015static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8016 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8017 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8018 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8019 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8020 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8021 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8022 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8023 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008024 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008025 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8026 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008027 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008028 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008029 { } /* end */
8030};
8031
8032static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8033 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8034 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8035 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8036 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8037 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8038 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8039 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8040 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8041 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8042 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8043 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8044 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8045 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8046 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008047 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8049 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008050 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008051 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008052 { } /* end */
8053};
8054
Jiang zhe17bba1b2008-06-04 12:11:07 +02008055static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8056 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8057 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8058 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8059 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8060 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8061 HDA_OUTPUT),
8062 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8063 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8064 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8065 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8066 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8067 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8068 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8069 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8070 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8071 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8072 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8073 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8074 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8075 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008076 { } /* end */
8077};
8078
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008079static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008080 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008081 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008082 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008083 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008084 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8085 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008086 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8087 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008088 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8089 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8090 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8091 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8092 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8093 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008094 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008095 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8096 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008097 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008098 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008099 { } /* end */
8100};
8101
Sasha Alexandrc2592492009-06-16 14:52:54 -04008102static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008103 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8104 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8105 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8106 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8107 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8108 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8109 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8110 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8111 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8112 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8113 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8114 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8115 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008117 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008118 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008119 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008120};
Kailang Yangccc656c2006-10-17 12:32:26 +02008121
Sasha Alexandrc2592492009-06-16 14:52:54 -04008122static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008123 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8124 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8125 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8126 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8127 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8128 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008129 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008131 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8132 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8133 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008134 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008135};
Kailang Yangccc656c2006-10-17 12:32:26 +02008136
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008137static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8138 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8139 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008140 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8141 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008142 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8143 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8144 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008146 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008147};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008148
Kailang Yang272a5272007-05-14 11:00:38 +02008149static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8150 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8151 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8152 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8153 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8154 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8155 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8156 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8157 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8158 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008159 { } /* end */
8160};
8161
8162static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8163 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8164 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8165 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8166 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8167 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8168 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8169 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8170 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8171 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008172 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008173};
Kailang Yang272a5272007-05-14 11:00:38 +02008174
Tobin Davis2880a862007-08-07 11:50:26 +02008175static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008176 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8177 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008178 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008179 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8180 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008181 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8182 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8183 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008184 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008185};
Tobin Davis2880a862007-08-07 11:50:26 +02008186
Tony Vroond2fd4b02009-06-21 00:40:10 +01008187static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8188 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8189 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8190 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8191 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
8192 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8193 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8195 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8196 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8197 { } /* end */
8198};
8199
Kailang Yange2757d52008-08-26 13:17:46 +02008200static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8201 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8202 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8203 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8204 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8205 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8206 0x0d, 1, 0x0, HDA_OUTPUT),
8207 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8208 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8209 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8210 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8211 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008212 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8213 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8214 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8215 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8217 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8218 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8219 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8220 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8221 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008222 { } /* end */
8223};
8224
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008225static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8226 /* Output mixers */
8227 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8228 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8229 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8230 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8231 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8232 HDA_OUTPUT),
8233 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8234 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8235 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8236 /* Output switches */
8237 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8238 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8239 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8240 /* Boost mixers */
8241 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8242 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8243 /* Input mixers */
8244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8246 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8247 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8248 { } /* end */
8249};
8250
Guido Günther3e1647c52009-06-05 00:47:26 +02008251static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8252 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8253 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8254 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8255 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8256 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8257 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8258 { } /* end */
8259};
8260
Kailang Yange2757d52008-08-26 13:17:46 +02008261static struct hda_bind_ctls alc883_bind_cap_vol = {
8262 .ops = &snd_hda_bind_vol,
8263 .values = {
8264 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8265 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8266 0
8267 },
8268};
8269
8270static struct hda_bind_ctls alc883_bind_cap_switch = {
8271 .ops = &snd_hda_bind_sw,
8272 .values = {
8273 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8274 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8275 0
8276 },
8277};
8278
8279static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8280 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8281 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8282 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8283 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8284 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8285 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8286 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8287 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008288 { } /* end */
8289};
8290
8291static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008292 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8293 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8294 {
8295 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8296 /* .name = "Capture Source", */
8297 .name = "Input Source",
8298 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008299 .info = alc_mux_enum_info,
8300 .get = alc_mux_enum_get,
8301 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008302 },
8303 { } /* end */
8304};
8305
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008306static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8307 {
8308 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8309 .name = "Channel Mode",
8310 .info = alc_ch_mode_info,
8311 .get = alc_ch_mode_get,
8312 .put = alc_ch_mode_put,
8313 },
8314 { } /* end */
8315};
8316
8317static struct hda_verb alc883_init_verbs[] = {
8318 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02008319 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008320 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8321 /* ADC2: mute amp left and right */
8322 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8323 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8324 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8327 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8328 /* Rear mixer */
8329 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8330 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8332 /* CLFE mixer */
8333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8335 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8336 /* Side mixer */
8337 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8338 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8339 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8340
Takashi Iwaicb53c622007-08-10 17:21:45 +02008341 /* mute analog input loopbacks */
8342 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8343 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8344 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8345 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8346 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008347
8348 /* Front Pin: output 0 (0x0c) */
8349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8350 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8351 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8352 /* Rear Pin: output 1 (0x0d) */
8353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8355 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8356 /* CLFE Pin: output 2 (0x0e) */
8357 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8358 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8359 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8360 /* Side Pin: output 3 (0x0f) */
8361 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8362 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8363 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8364 /* Mic (rear) pin: input vref at 80% */
8365 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8366 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8367 /* Front Mic pin: input vref at 80% */
8368 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8369 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8370 /* Line In pin: input */
8371 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8372 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8373 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8374 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8375 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8376 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8377 /* CD pin widget for input */
8378 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8379
8380 /* FIXME: use matrix-type input source selection */
8381 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8382 /* Input mixer2 */
8383 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008384 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8385 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8386 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008387 /* Input mixer3 */
8388 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008389 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8390 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8391 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008392 { }
8393};
8394
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008395/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008396static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008397{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008398 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008399
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008400 spec->autocfg.hp_pins[0] = 0x15;
8401 spec->autocfg.speaker_pins[0] = 0x14;
8402 spec->autocfg.speaker_pins[1] = 0x17;
8403 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008404}
8405
8406/* auto-toggle front mic */
8407/*
8408static void alc883_mitac_mic_automute(struct hda_codec *codec)
8409{
8410 unsigned int present;
8411 unsigned char bits;
8412
8413 present = snd_hda_codec_read(codec, 0x18, 0,
8414 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8415 bits = present ? HDA_AMP_MUTE : 0;
8416 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8417}
8418*/
8419
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008420static struct hda_verb alc883_mitac_verbs[] = {
8421 /* HP */
8422 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8423 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8424 /* Subwoofer */
8425 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8426 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8427
8428 /* enable unsolicited event */
8429 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8430 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8431
8432 { } /* end */
8433};
8434
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008435static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008436 /* HP */
8437 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8438 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8439 /* Int speaker */
8440 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8441 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8442
8443 /* enable unsolicited event */
8444 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008445 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008446
8447 { } /* end */
8448};
8449
Jiang zhefb97dc62008-03-06 11:07:11 +01008450static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8451 /* HP */
8452 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8453 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8454 /* Subwoofer */
8455 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8456 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8457
8458 /* enable unsolicited event */
8459 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8460
8461 { } /* end */
8462};
8463
Sasha Alexandrc2592492009-06-16 14:52:54 -04008464static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8467
8468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8469 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008470
David Heidelberger64a8be72009-06-08 16:15:18 +02008471/* Connect Line-Out side jack (SPDIF) to Side */
8472 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8473 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8474 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8475/* Connect Mic jack to CLFE */
8476 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8477 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8478 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8479/* Connect Line-in jack to Surround */
8480 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8481 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8482 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8483/* Connect HP out jack to Front */
8484 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8485 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8486 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008487
8488 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008489
8490 { } /* end */
8491};
8492
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008493static struct hda_verb alc883_lenovo_101e_verbs[] = {
8494 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8495 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8496 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8497 { } /* end */
8498};
8499
Kailang Yang272a5272007-05-14 11:00:38 +02008500static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8501 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8502 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8503 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8505 { } /* end */
8506};
8507
8508static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8509 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8511 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8512 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8513 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8514 { } /* end */
8515};
8516
Kailang Yang189609a2007-08-20 11:31:23 +02008517static struct hda_verb alc883_haier_w66_verbs[] = {
8518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8520
8521 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8522
8523 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8524 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8525 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8526 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8527 { } /* end */
8528};
8529
Kailang Yange2757d52008-08-26 13:17:46 +02008530static struct hda_verb alc888_lenovo_sky_verbs[] = {
8531 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8532 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8533 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8534 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8535 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8536 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8537 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8538 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8539 { } /* end */
8540};
8541
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008542static struct hda_verb alc888_6st_dell_verbs[] = {
8543 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8544 { }
8545};
8546
Guido Günther3e1647c52009-06-05 00:47:26 +02008547static struct hda_verb alc883_vaiott_verbs[] = {
8548 /* HP */
8549 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8550 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8551
8552 /* enable unsolicited event */
8553 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8554
8555 { } /* end */
8556};
8557
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008558static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008559{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008560 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008561
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008562 spec->autocfg.hp_pins[0] = 0x1b;
8563 spec->autocfg.speaker_pins[0] = 0x14;
8564 spec->autocfg.speaker_pins[1] = 0x16;
8565 spec->autocfg.speaker_pins[2] = 0x18;
8566 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008567}
8568
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008569static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008570 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008571 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8572 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008573 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008574 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008575};
8576
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008577/*
8578 * 2ch mode
8579 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008580static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008581 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8582 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8583 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8584 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008585 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008586};
8587
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008588/*
8589 * 4ch mode
8590 */
8591static struct hda_verb alc888_3st_hp_4ch_init[] = {
8592 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8593 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8594 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8595 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8596 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8597 { } /* end */
8598};
8599
8600/*
8601 * 6ch mode
8602 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008603static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008604 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8605 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008606 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008607 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8608 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008609 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8610 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008611};
8612
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008613static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008614 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008615 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008616 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008617};
8618
Kailang Yang272a5272007-05-14 11:00:38 +02008619/* toggle front-jack and RCA according to the hp-jack state */
8620static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8621{
8622 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008623
Kailang Yang272a5272007-05-14 11:00:38 +02008624 present = snd_hda_codec_read(codec, 0x1b, 0,
8625 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008626 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8627 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8628 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8629 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008630}
8631
8632/* toggle RCA according to the front-jack state */
8633static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8634{
8635 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008636
Kailang Yang272a5272007-05-14 11:00:38 +02008637 present = snd_hda_codec_read(codec, 0x14, 0,
8638 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008639 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8640 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008641}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008642
Kailang Yang272a5272007-05-14 11:00:38 +02008643static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8644 unsigned int res)
8645{
8646 if ((res >> 26) == ALC880_HP_EVENT)
8647 alc888_lenovo_ms7195_front_automute(codec);
8648 if ((res >> 26) == ALC880_FRONT_EVENT)
8649 alc888_lenovo_ms7195_rca_automute(codec);
8650}
8651
8652static struct hda_verb alc883_medion_md2_verbs[] = {
8653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8655
8656 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8657
8658 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8659 { } /* end */
8660};
8661
8662/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008663static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008664{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008665 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008666
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008667 spec->autocfg.hp_pins[0] = 0x14;
8668 spec->autocfg.speaker_pins[0] = 0x15;
8669 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008670}
8671
Kailang Yangccc656c2006-10-17 12:32:26 +02008672/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008673#define alc883_targa_init_hook alc882_targa_init_hook
8674#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008675
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008676static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8677{
8678 unsigned int present;
8679
8680 present = snd_hda_codec_read(codec, 0x18, 0,
8681 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8682 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8683 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8684}
8685
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008686static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008687{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008688 struct alc_spec *spec = codec->spec;
8689
8690 spec->autocfg.hp_pins[0] = 0x15;
8691 spec->autocfg.speaker_pins[0] = 0x14;
8692 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008693 alc883_clevo_m720_mic_automute(codec);
8694}
8695
8696static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008697 unsigned int res)
8698{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008699 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008700 case ALC880_MIC_EVENT:
8701 alc883_clevo_m720_mic_automute(codec);
8702 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008703 default:
8704 alc_automute_amp_unsol_event(codec, res);
8705 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008706 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008707}
8708
Jiang zhefb97dc62008-03-06 11:07:11 +01008709/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008710static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008711{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008712 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008713
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008714 spec->autocfg.hp_pins[0] = 0x14;
8715 spec->autocfg.speaker_pins[0] = 0x15;
8716 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008717}
8718
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008719static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008720{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008721 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008722
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008723 spec->autocfg.hp_pins[0] = 0x1b;
8724 spec->autocfg.speaker_pins[0] = 0x14;
8725 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008726}
8727
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008728static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8729{
8730 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008731 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008732
David Heidelberger64a8be72009-06-08 16:15:18 +02008733 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8734 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008735 bits = present ? HDA_AMP_MUTE : 0;
8736 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8737 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008738}
8739
8740static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8741{
8742 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008743 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008744
8745 present = snd_hda_codec_read(codec, 0x1b, 0,
8746 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008747 bits = present ? HDA_AMP_MUTE : 0;
8748 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8749 HDA_AMP_MUTE, bits);
8750 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8751 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008752}
8753
8754static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8755 unsigned int res)
8756{
8757 if ((res >> 26) == ALC880_HP_EVENT)
8758 alc883_lenovo_101e_all_automute(codec);
8759 if ((res >> 26) == ALC880_FRONT_EVENT)
8760 alc883_lenovo_101e_ispeaker_automute(codec);
8761}
8762
Takashi Iwai676a9b52007-08-16 15:23:35 +02008763/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008764static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008765{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008766 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008767
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008768 spec->autocfg.hp_pins[0] = 0x14;
8769 spec->autocfg.speaker_pins[0] = 0x15;
8770 spec->autocfg.speaker_pins[1] = 0x16;
8771 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008772}
8773
Kailang Yangd1a991a2007-08-15 16:21:59 +02008774static struct hda_verb alc883_acer_eapd_verbs[] = {
8775 /* HP Pin: output 0 (0x0c) */
8776 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8777 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8778 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8779 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008780 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8781 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008782 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008783 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8784 /* eanable EAPD on medion laptop */
8785 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8786 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008787 /* enable unsolicited event */
8788 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008789 { }
8790};
8791
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008792static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008793{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008794 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008795
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008796 spec->autocfg.hp_pins[0] = 0x1b;
8797 spec->autocfg.speaker_pins[0] = 0x14;
8798 spec->autocfg.speaker_pins[1] = 0x15;
8799 spec->autocfg.speaker_pins[2] = 0x16;
8800 spec->autocfg.speaker_pins[3] = 0x17;
8801 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008802}
8803
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008804static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008805{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008806 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008807
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008808 spec->autocfg.hp_pins[0] = 0x1b;
8809 spec->autocfg.speaker_pins[0] = 0x14;
8810 spec->autocfg.speaker_pins[1] = 0x15;
8811 spec->autocfg.speaker_pins[2] = 0x16;
8812 spec->autocfg.speaker_pins[3] = 0x17;
8813 spec->autocfg.speaker_pins[4] = 0x1a;
8814 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008815}
8816
Guido Günther3e1647c52009-06-05 00:47:26 +02008817static void alc883_vaiott_init_hook(struct hda_codec *codec)
8818{
8819 struct alc_spec *spec = codec->spec;
8820
8821 spec->autocfg.hp_pins[0] = 0x15;
8822 spec->autocfg.speaker_pins[0] = 0x14;
8823 spec->autocfg.speaker_pins[1] = 0x17;
8824 alc_automute_amp(codec);
8825}
8826
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008827/*
8828 * generic initialization of ADC, input mixers and output mixers
8829 */
8830static struct hda_verb alc883_auto_init_verbs[] = {
8831 /*
8832 * Unmute ADC0-2 and set the default input to mic-in
8833 */
8834 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8835 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8836 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8837 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8838
Takashi Iwaicb53c622007-08-10 17:21:45 +02008839 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008840 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008841 * Note: PASD motherboards uses the Line In 2 as the input for
8842 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008843 */
8844 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008845 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8846 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8847 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8848 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8849 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008850
8851 /*
8852 * Set up output mixers (0x0c - 0x0f)
8853 */
8854 /* set vol=0 to output mixers */
8855 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8856 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8857 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8858 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8859 /* set up input amps for analog loopback */
8860 /* Amp Indices: DAC = 0, mixer = 1 */
8861 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8862 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8863 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8864 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8865 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8866 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8867 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8868 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8869 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8870 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8871
8872 /* FIXME: use matrix-type input source selection */
8873 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8874 /* Input mixer1 */
8875 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8876 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8877 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008878 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008879 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8880 /* Input mixer2 */
8881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8882 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8883 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008884 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008885 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008886
8887 { }
8888};
8889
Kailang Yange2757d52008-08-26 13:17:46 +02008890static struct hda_verb alc888_asus_m90v_verbs[] = {
8891 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8892 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8893 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8894 /* enable unsolicited event */
8895 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8896 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8897 { } /* end */
8898};
8899
8900static void alc883_nb_mic_automute(struct hda_codec *codec)
8901{
8902 unsigned int present;
8903
8904 present = snd_hda_codec_read(codec, 0x18, 0,
8905 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8906 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8907 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8908 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8909 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8910}
8911
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008912static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008913{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008914 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008915
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008916 spec->autocfg.hp_pins[0] = 0x1b;
8917 spec->autocfg.speaker_pins[0] = 0x14;
8918 spec->autocfg.speaker_pins[1] = 0x15;
8919 spec->autocfg.speaker_pins[2] = 0x16;
8920 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008921}
8922
8923static void alc883_mode2_unsol_event(struct hda_codec *codec,
8924 unsigned int res)
8925{
8926 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008927 case ALC880_MIC_EVENT:
8928 alc883_nb_mic_automute(codec);
8929 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008930 default:
8931 alc_sku_unsol_event(codec, res);
8932 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008933 }
8934}
8935
8936static void alc883_mode2_inithook(struct hda_codec *codec)
8937{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008938 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008939 alc883_nb_mic_automute(codec);
8940}
8941
8942static struct hda_verb alc888_asus_eee1601_verbs[] = {
8943 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8944 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8945 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8946 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8948 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8949 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8950 /* enable unsolicited event */
8951 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8952 { } /* end */
8953};
8954
Kailang Yange2757d52008-08-26 13:17:46 +02008955static void alc883_eee1601_inithook(struct hda_codec *codec)
8956{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008957 struct alc_spec *spec = codec->spec;
8958
8959 spec->autocfg.hp_pins[0] = 0x14;
8960 spec->autocfg.speaker_pins[0] = 0x1b;
8961 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008962}
8963
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008964static struct hda_verb alc889A_mb31_verbs[] = {
8965 /* Init rear pin (used as headphone output) */
8966 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8967 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8968 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8969 /* Init line pin (used as output in 4ch and 6ch mode) */
8970 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8971 /* Init line 2 pin (used as headphone out by default) */
8972 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8973 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8974 { } /* end */
8975};
8976
8977/* Mute speakers according to the headphone jack state */
8978static void alc889A_mb31_automute(struct hda_codec *codec)
8979{
8980 unsigned int present;
8981
8982 /* Mute only in 2ch or 4ch mode */
8983 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8984 == 0x00) {
8985 present = snd_hda_codec_read(codec, 0x15, 0,
8986 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8987 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8988 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8989 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8990 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8991 }
8992}
8993
8994static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8995{
8996 if ((res >> 26) == ALC880_HP_EVENT)
8997 alc889A_mb31_automute(codec);
8998}
8999
Takashi Iwaicb53c622007-08-10 17:21:45 +02009000#ifdef CONFIG_SND_HDA_POWER_SAVE
9001#define alc883_loopbacks alc880_loopbacks
9002#endif
9003
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009004/* pcm configuration: identical with ALC880 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009005#define alc883_pcm_analog_playback alc880_pcm_analog_playback
9006#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01009007#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009008#define alc883_pcm_digital_playback alc880_pcm_digital_playback
9009#define alc883_pcm_digital_capture alc880_pcm_digital_capture
9010
9011/*
9012 * configuration and preset
9013 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009014static const char *alc883_models[ALC883_MODEL_LAST] = {
9015 [ALC883_3ST_2ch_DIG] = "3stack-dig",
9016 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9017 [ALC883_3ST_6ch] = "3stack-6ch",
9018 [ALC883_6ST_DIG] = "6stack-dig",
9019 [ALC883_TARGA_DIG] = "targa-dig",
9020 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009021 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009022 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009023 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009024 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009025 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009026 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009027 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009028 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009029 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009030 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009031 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9032 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009033 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009034 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009035 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009036 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009037 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009038 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009039 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009040 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009041 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009042 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009043 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c52009-06-05 00:47:26 +02009044 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009045 [ALC883_AUTO] = "auto",
9046};
9047
9048static struct snd_pci_quirk alc883_cfg_tbl[] = {
9049 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009050 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009051 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009052 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009053 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9054 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009055 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009056 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9057 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009058 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
9059 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009060 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9061 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009062 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9063 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01009064 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01009065 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009066 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
9067 ALC888_ACER_ASPIRE_4930G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009068 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009069 ALC888_ACER_ASPIRE_6530G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009070 /* default Acer -- disabled as it causes more problems.
9071 * model=auto should work fine now
9072 */
9073 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009074 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02009075 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009076 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9077 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009078 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009079 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009080 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009081 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009082 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009083 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009084 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009085 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02009086 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009087 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009088 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009089 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9090 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009091 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009092 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02009093 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009094 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9095 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9096 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02009097 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009098 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009099 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009100 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9101 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9102 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9103 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9104 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9105 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
9106 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9107 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9108 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009109 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009110 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9111 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009112 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009113 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009114 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009115 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009116 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009117 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009118 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009119 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009120 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9121 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009122 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009123 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009124 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009125 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009126 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009127 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009128 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009129 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009130 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009131 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9132 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009133 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009134 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009135 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009136 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009137 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009138 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9139 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009140 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08009141 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009142 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Guido Günther3e1647c52009-06-05 00:47:26 +02009143 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009144 {}
9145};
9146
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009147static hda_nid_t alc883_slave_dig_outs[] = {
9148 ALC1200_DIGOUT_NID, 0,
9149};
9150
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009151static hda_nid_t alc1200_slave_dig_outs[] = {
9152 ALC883_DIGOUT_NID, 0,
9153};
9154
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009155static struct alc_config_preset alc883_presets[] = {
9156 [ALC883_3ST_2ch_DIG] = {
9157 .mixers = { alc883_3ST_2ch_mixer },
9158 .init_verbs = { alc883_init_verbs },
9159 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9160 .dac_nids = alc883_dac_nids,
9161 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009162 .dig_in_nid = ALC883_DIGIN_NID,
9163 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9164 .channel_mode = alc883_3ST_2ch_modes,
9165 .input_mux = &alc883_capture_source,
9166 },
9167 [ALC883_3ST_6ch_DIG] = {
9168 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9169 .init_verbs = { alc883_init_verbs },
9170 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9171 .dac_nids = alc883_dac_nids,
9172 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009173 .dig_in_nid = ALC883_DIGIN_NID,
9174 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9175 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009176 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009177 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009178 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009179 [ALC883_3ST_6ch] = {
9180 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9181 .init_verbs = { alc883_init_verbs },
9182 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9183 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009184 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9185 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009186 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009187 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009188 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009189 [ALC883_3ST_6ch_INTEL] = {
9190 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9191 .init_verbs = { alc883_init_verbs },
9192 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9193 .dac_nids = alc883_dac_nids,
9194 .dig_out_nid = ALC883_DIGOUT_NID,
9195 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009196 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009197 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9198 .channel_mode = alc883_3ST_6ch_intel_modes,
9199 .need_dac_fix = 1,
9200 .input_mux = &alc883_3stack_6ch_intel,
9201 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009202 [ALC883_6ST_DIG] = {
9203 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9204 .init_verbs = { alc883_init_verbs },
9205 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9206 .dac_nids = alc883_dac_nids,
9207 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009208 .dig_in_nid = ALC883_DIGIN_NID,
9209 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9210 .channel_mode = alc883_sixstack_modes,
9211 .input_mux = &alc883_capture_source,
9212 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009213 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009214 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
9215 .init_verbs = { alc883_init_verbs, alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009216 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9217 .dac_nids = alc883_dac_nids,
9218 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009219 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9220 .channel_mode = alc883_3ST_6ch_modes,
9221 .need_dac_fix = 1,
9222 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009223 .unsol_event = alc883_targa_unsol_event,
9224 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009225 },
9226 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009227 .mixers = { alc883_targa_2ch_mixer},
9228 .init_verbs = { alc883_init_verbs, alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009229 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9230 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009231 .adc_nids = alc883_adc_nids_alt,
9232 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009233 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009234 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9235 .channel_mode = alc883_3ST_2ch_modes,
9236 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009237 .unsol_event = alc883_targa_unsol_event,
9238 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009239 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009240 [ALC883_TARGA_8ch_DIG] = {
9241 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9242 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009243 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009244 .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 .dig_in_nid = ALC883_DIGIN_NID,
9251 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9252 .channel_mode = alc883_4ST_8ch_modes,
9253 .need_dac_fix = 1,
9254 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009255 .unsol_event = alc883_targa_unsol_event,
9256 .init_hook = alc883_targa_init_hook,
David Heidelberger64a8be72009-06-08 16:15:18 +02009257 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009258 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009259 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009260 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9261 * and the headphone jack. Turn this on and rely on the
9262 * standard mute methods whenever the user wants to turn
9263 * these outputs off.
9264 */
9265 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9266 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9267 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009268 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9269 .channel_mode = alc883_3ST_2ch_modes,
9270 .input_mux = &alc883_capture_source,
9271 },
Tobin Davis2880a862007-08-07 11:50:26 +02009272 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009273 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009274 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009275 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9276 .dac_nids = alc883_dac_nids,
9277 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009278 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9279 .channel_mode = alc883_3ST_2ch_modes,
9280 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009281 .unsol_event = alc_automute_amp_unsol_event,
9282 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009283 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009284 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009285 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009286 alc883_chmode_mixer },
9287 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9288 alc888_acer_aspire_4930g_verbs },
9289 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9290 .dac_nids = alc883_dac_nids,
9291 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9292 .adc_nids = alc883_adc_nids_rev,
9293 .capsrc_nids = alc883_capsrc_nids_rev,
9294 .dig_out_nid = ALC883_DIGOUT_NID,
9295 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9296 .channel_mode = alc883_3ST_6ch_modes,
9297 .need_dac_fix = 1,
9298 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009299 ARRAY_SIZE(alc888_2_capture_sources),
9300 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009301 .unsol_event = alc_automute_amp_unsol_event,
9302 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009303 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009304 [ALC888_ACER_ASPIRE_6530G] = {
9305 .mixers = { alc888_acer_aspire_6530_mixer },
9306 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9307 alc888_acer_aspire_6530g_verbs },
9308 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9309 .dac_nids = alc883_dac_nids,
9310 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9311 .adc_nids = alc883_adc_nids_rev,
9312 .capsrc_nids = alc883_capsrc_nids_rev,
9313 .dig_out_nid = ALC883_DIGOUT_NID,
9314 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9315 .channel_mode = alc883_3ST_2ch_modes,
9316 .num_mux_defs =
9317 ARRAY_SIZE(alc888_2_capture_sources),
9318 .input_mux = alc888_acer_aspire_6530_sources,
9319 .unsol_event = alc_automute_amp_unsol_event,
9320 .init_hook = alc888_acer_aspire_4930g_init_hook,
9321 },
Hector Martin3b315d72009-06-02 10:54:19 +02009322 [ALC888_ACER_ASPIRE_8930G] = {
9323 .mixers = { alc888_base_mixer,
9324 alc883_chmode_mixer },
9325 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009326 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009327 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9328 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009329 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9330 .adc_nids = alc889_adc_nids,
9331 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009332 .dig_out_nid = ALC883_DIGOUT_NID,
9333 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9334 .channel_mode = alc883_3ST_6ch_modes,
9335 .need_dac_fix = 1,
9336 .const_channel_count = 6,
9337 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009338 ARRAY_SIZE(alc889_capture_sources),
9339 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009340 .unsol_event = alc_automute_amp_unsol_event,
Hector Martin018df412009-06-04 00:13:40 +02009341 .init_hook = alc889_acer_aspire_8930g_init_hook,
Hector Martin3b315d72009-06-02 10:54:19 +02009342 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009343 [ALC883_MEDION] = {
9344 .mixers = { alc883_fivestack_mixer,
9345 alc883_chmode_mixer },
9346 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009347 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009348 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9349 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009350 .adc_nids = alc883_adc_nids_alt,
9351 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009352 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9353 .channel_mode = alc883_sixstack_modes,
9354 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009355 },
Kailang Yang272a5272007-05-14 11:00:38 +02009356 [ALC883_MEDION_MD2] = {
9357 .mixers = { alc883_medion_md2_mixer},
9358 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9359 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9360 .dac_nids = alc883_dac_nids,
9361 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009362 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9363 .channel_mode = alc883_3ST_2ch_modes,
9364 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009365 .unsol_event = alc_automute_amp_unsol_event,
9366 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02009367 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009368 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009369 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009370 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9371 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9372 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009373 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9374 .channel_mode = alc883_3ST_2ch_modes,
9375 .input_mux = &alc883_capture_source,
9376 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009377 [ALC883_CLEVO_M720] = {
9378 .mixers = { alc883_clevo_m720_mixer },
9379 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009380 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9381 .dac_nids = alc883_dac_nids,
9382 .dig_out_nid = ALC883_DIGOUT_NID,
9383 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9384 .channel_mode = alc883_3ST_2ch_modes,
9385 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009386 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009387 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009388 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009389 [ALC883_LENOVO_101E_2ch] = {
9390 .mixers = { alc883_lenovo_101e_2ch_mixer},
9391 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9392 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9393 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009394 .adc_nids = alc883_adc_nids_alt,
9395 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009396 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9397 .channel_mode = alc883_3ST_2ch_modes,
9398 .input_mux = &alc883_lenovo_101e_capture_source,
9399 .unsol_event = alc883_lenovo_101e_unsol_event,
9400 .init_hook = alc883_lenovo_101e_all_automute,
9401 },
Kailang Yang272a5272007-05-14 11:00:38 +02009402 [ALC883_LENOVO_NB0763] = {
9403 .mixers = { alc883_lenovo_nb0763_mixer },
9404 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9405 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9406 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009407 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9408 .channel_mode = alc883_3ST_2ch_modes,
9409 .need_dac_fix = 1,
9410 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009411 .unsol_event = alc_automute_amp_unsol_event,
9412 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02009413 },
9414 [ALC888_LENOVO_MS7195_DIG] = {
9415 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9416 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9417 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9418 .dac_nids = alc883_dac_nids,
9419 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009420 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9421 .channel_mode = alc883_3ST_6ch_modes,
9422 .need_dac_fix = 1,
9423 .input_mux = &alc883_capture_source,
9424 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9425 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009426 },
9427 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009428 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009429 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9430 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9431 .dac_nids = alc883_dac_nids,
9432 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009433 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9434 .channel_mode = alc883_3ST_2ch_modes,
9435 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009436 .unsol_event = alc_automute_amp_unsol_event,
9437 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009438 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009439 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009440 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009441 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009442 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9443 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009444 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9445 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009446 .need_dac_fix = 1,
9447 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009448 .unsol_event = alc_automute_amp_unsol_event,
9449 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009450 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009451 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009452 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009453 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9454 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9455 .dac_nids = alc883_dac_nids,
9456 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009457 .dig_in_nid = ALC883_DIGIN_NID,
9458 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9459 .channel_mode = alc883_sixstack_modes,
9460 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009461 .unsol_event = alc_automute_amp_unsol_event,
9462 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009463 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009464 [ALC883_MITAC] = {
9465 .mixers = { alc883_mitac_mixer },
9466 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9467 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9468 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009469 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9470 .channel_mode = alc883_3ST_2ch_modes,
9471 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009472 .unsol_event = alc_automute_amp_unsol_event,
9473 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009474 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009475 [ALC883_FUJITSU_PI2515] = {
9476 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9477 .init_verbs = { alc883_init_verbs,
9478 alc883_2ch_fujitsu_pi2515_verbs},
9479 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9480 .dac_nids = alc883_dac_nids,
9481 .dig_out_nid = ALC883_DIGOUT_NID,
9482 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9483 .channel_mode = alc883_3ST_2ch_modes,
9484 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009485 .unsol_event = alc_automute_amp_unsol_event,
9486 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01009487 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009488 [ALC888_FUJITSU_XA3530] = {
9489 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9490 .init_verbs = { alc883_init_verbs,
9491 alc888_fujitsu_xa3530_verbs },
9492 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9493 .dac_nids = alc883_dac_nids,
9494 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9495 .adc_nids = alc883_adc_nids_rev,
9496 .capsrc_nids = alc883_capsrc_nids_rev,
9497 .dig_out_nid = ALC883_DIGOUT_NID,
9498 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9499 .channel_mode = alc888_4ST_8ch_intel_modes,
9500 .num_mux_defs =
9501 ARRAY_SIZE(alc888_2_capture_sources),
9502 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009503 .unsol_event = alc_automute_amp_unsol_event,
9504 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009505 },
Kailang Yange2757d52008-08-26 13:17:46 +02009506 [ALC888_LENOVO_SKY] = {
9507 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9508 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9509 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9510 .dac_nids = alc883_dac_nids,
9511 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009512 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9513 .channel_mode = alc883_sixstack_modes,
9514 .need_dac_fix = 1,
9515 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009516 .unsol_event = alc_automute_amp_unsol_event,
9517 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009518 },
9519 [ALC888_ASUS_M90V] = {
9520 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9521 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9522 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9523 .dac_nids = alc883_dac_nids,
9524 .dig_out_nid = ALC883_DIGOUT_NID,
9525 .dig_in_nid = ALC883_DIGIN_NID,
9526 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9527 .channel_mode = alc883_3ST_6ch_modes,
9528 .need_dac_fix = 1,
9529 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9530 .unsol_event = alc883_mode2_unsol_event,
9531 .init_hook = alc883_mode2_inithook,
9532 },
9533 [ALC888_ASUS_EEE1601] = {
9534 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009535 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009536 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9537 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9538 .dac_nids = alc883_dac_nids,
9539 .dig_out_nid = ALC883_DIGOUT_NID,
9540 .dig_in_nid = ALC883_DIGIN_NID,
9541 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9542 .channel_mode = alc883_3ST_2ch_modes,
9543 .need_dac_fix = 1,
9544 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009545 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009546 .init_hook = alc883_eee1601_inithook,
9547 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009548 [ALC1200_ASUS_P5Q] = {
9549 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9550 .init_verbs = { alc883_init_verbs },
9551 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9552 .dac_nids = alc883_dac_nids,
9553 .dig_out_nid = ALC1200_DIGOUT_NID,
9554 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009555 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009556 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9557 .channel_mode = alc883_sixstack_modes,
9558 .input_mux = &alc883_capture_source,
9559 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009560 [ALC889A_MB31] = {
9561 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9562 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9563 alc880_gpio1_init_verbs },
9564 .adc_nids = alc883_adc_nids,
9565 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9566 .dac_nids = alc883_dac_nids,
9567 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9568 .channel_mode = alc889A_mb31_6ch_modes,
9569 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9570 .input_mux = &alc889A_mb31_capture_source,
9571 .dig_out_nid = ALC883_DIGOUT_NID,
9572 .unsol_event = alc889A_mb31_unsol_event,
9573 .init_hook = alc889A_mb31_automute,
9574 },
Guido Günther3e1647c52009-06-05 00:47:26 +02009575 [ALC883_SONY_VAIO_TT] = {
9576 .mixers = { alc883_vaiott_mixer },
9577 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9578 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9579 .dac_nids = alc883_dac_nids,
9580 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9581 .channel_mode = alc883_3ST_2ch_modes,
9582 .input_mux = &alc883_capture_source,
9583 .unsol_event = alc_automute_amp_unsol_event,
9584 .init_hook = alc883_vaiott_init_hook,
9585 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009586};
9587
9588
9589/*
9590 * BIOS auto configuration
9591 */
9592static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9593 hda_nid_t nid, int pin_type,
9594 int dac_idx)
9595{
9596 /* set as output */
9597 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009598 int idx;
9599
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009600 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009601 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9602 idx = 4;
9603 else
9604 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009605 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9606
9607}
9608
9609static void alc883_auto_init_multi_out(struct hda_codec *codec)
9610{
9611 struct alc_spec *spec = codec->spec;
9612 int i;
9613
9614 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009615 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009616 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009617 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009618 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009619 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009620 }
9621}
9622
9623static void alc883_auto_init_hp_out(struct hda_codec *codec)
9624{
9625 struct alc_spec *spec = codec->spec;
9626 hda_nid_t pin;
9627
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009628 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009629 if (pin) /* connect to front */
9630 /* use dac 0 */
9631 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009632 pin = spec->autocfg.speaker_pins[0];
9633 if (pin)
9634 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009635}
9636
9637#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9638#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9639
9640static void alc883_auto_init_analog_input(struct hda_codec *codec)
9641{
9642 struct alc_spec *spec = codec->spec;
9643 int i;
9644
9645 for (i = 0; i < AUTO_PIN_LAST; i++) {
9646 hda_nid_t nid = spec->autocfg.input_pins[i];
9647 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009648 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009649 if (nid != ALC883_PIN_CD_NID &&
9650 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009651 snd_hda_codec_write(codec, nid, 0,
9652 AC_VERB_SET_AMP_GAIN_MUTE,
9653 AMP_OUT_MUTE);
9654 }
9655 }
9656}
9657
Takashi Iwaif511b012008-08-15 16:46:42 +02009658#define alc883_auto_init_input_src alc882_auto_init_input_src
9659
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009660/* almost identical with ALC880 parser... */
9661static int alc883_parse_auto_config(struct hda_codec *codec)
9662{
9663 struct alc_spec *spec = codec->spec;
9664 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009665 struct auto_pin_cfg *cfg = &spec->autocfg;
9666 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009667
9668 if (err < 0)
9669 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009670 else if (!err)
9671 return 0; /* no config found */
9672
9673 err = alc_auto_add_mic_boost(codec);
9674 if (err < 0)
9675 return err;
9676
9677 /* hack - override the init verbs */
9678 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009679
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009680 /* setup input_mux for ALC889 */
9681 if (codec->vendor_id == 0x10ec0889) {
9682 /* digital-mic input pin is excluded in alc880_auto_create..()
9683 * because it's under 0x18
9684 */
9685 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9686 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9687 struct hda_input_mux *imux = &spec->private_imux[0];
9688 for (i = 1; i < 3; i++)
9689 memcpy(&spec->private_imux[i],
9690 &spec->private_imux[0],
9691 sizeof(spec->private_imux[0]));
9692 imux->items[imux->num_items].label = "Int DMic";
9693 imux->items[imux->num_items].index = 0x0b;
9694 imux->num_items++;
9695 spec->num_mux_defs = 3;
9696 spec->input_mux = spec->private_imux;
9697 }
9698 }
9699
Takashi Iwai776e1842007-08-29 15:07:11 +02009700 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009701}
9702
9703/* additional initialization for auto-configuration model */
9704static void alc883_auto_init(struct hda_codec *codec)
9705{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009706 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009707 alc883_auto_init_multi_out(codec);
9708 alc883_auto_init_hp_out(codec);
9709 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009710 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009711 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009712 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009713}
9714
9715static int patch_alc883(struct hda_codec *codec)
9716{
9717 struct alc_spec *spec;
9718 int err, board_config;
9719
9720 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9721 if (spec == NULL)
9722 return -ENOMEM;
9723
9724 codec->spec = spec;
9725
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009726 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9727
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009728 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9729 alc883_models,
9730 alc883_cfg_tbl);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009731 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
9732 /* Pick up systems that don't supply PCI SSID */
9733 switch (codec->subsystem_id) {
9734 case 0x106b3600: /* Macbook 3.1 */
9735 board_config = ALC889A_MB31;
9736 break;
9737 default:
9738 printk(KERN_INFO
9739 "hda_codec: Unknown model for %s, trying "
9740 "auto-probe from BIOS...\n", codec->chip_name);
9741 board_config = ALC883_AUTO;
9742 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009743 }
9744
9745 if (board_config == ALC883_AUTO) {
9746 /* automatic parse from the BIOS config */
9747 err = alc883_parse_auto_config(codec);
9748 if (err < 0) {
9749 alc_free(codec);
9750 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009751 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009752 printk(KERN_INFO
9753 "hda_codec: Cannot set up configuration "
9754 "from BIOS. Using base mode...\n");
9755 board_config = ALC883_3ST_2ch_DIG;
9756 }
9757 }
9758
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009759 err = snd_hda_attach_beep_device(codec, 0x1);
9760 if (err < 0) {
9761 alc_free(codec);
9762 return err;
9763 }
9764
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009765 if (board_config != ALC883_AUTO)
9766 setup_preset(spec, &alc883_presets[board_config]);
9767
Kailang Yang2f893282008-05-27 12:14:47 +02009768 switch (codec->vendor_id) {
9769 case 0x10ec0888:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009770 if (!spec->num_adc_nids) {
9771 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9772 spec->adc_nids = alc883_adc_nids;
9773 }
9774 if (!spec->capsrc_nids)
9775 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009776 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009777 break;
9778 case 0x10ec0889:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009779 if (!spec->num_adc_nids) {
9780 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9781 spec->adc_nids = alc889_adc_nids;
9782 }
9783 if (!spec->capsrc_nids)
9784 spec->capsrc_nids = alc889_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009785 break;
9786 default:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009787 if (!spec->num_adc_nids) {
9788 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9789 spec->adc_nids = alc883_adc_nids;
9790 }
9791 if (!spec->capsrc_nids)
9792 spec->capsrc_nids = alc883_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009793 break;
9794 }
9795
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009796 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9797 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009798 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009799
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009800 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9801 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9802
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009803 if (!spec->cap_mixer)
9804 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009805 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009806
Takashi Iwai2134ea42008-01-10 16:53:55 +01009807 spec->vmaster_nid = 0x0c;
9808
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009809 codec->patch_ops = alc_patch_ops;
9810 if (board_config == ALC883_AUTO)
9811 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009812
Takashi Iwaicb53c622007-08-10 17:21:45 +02009813#ifdef CONFIG_SND_HDA_POWER_SAVE
9814 if (!spec->loopback.amplist)
9815 spec->loopback.amplist = alc883_loopbacks;
9816#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009817 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009818
9819 return 0;
9820}
9821
9822/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009823 * ALC262 support
9824 */
9825
9826#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9827#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9828
9829#define alc262_dac_nids alc260_dac_nids
9830#define alc262_adc_nids alc882_adc_nids
9831#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009832#define alc262_capsrc_nids alc882_capsrc_nids
9833#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009834
9835#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009836#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009837
Kailang Yang4e555fe2008-08-26 13:05:55 +02009838static hda_nid_t alc262_dmic_adc_nids[1] = {
9839 /* ADC0 */
9840 0x09
9841};
9842
9843static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9844
Kailang Yangdf694da2005-12-05 19:42:22 +01009845static struct snd_kcontrol_new alc262_base_mixer[] = {
9846 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9847 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9848 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9849 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9850 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9851 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9853 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009854 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009855 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9856 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009857 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009858 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9860 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9861 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009862 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009863};
9864
Takashi Iwaice875f02008-01-28 18:17:43 +01009865/* update HP, line and mono-out pins according to the master switch */
9866static void alc262_hp_master_update(struct hda_codec *codec)
9867{
9868 struct alc_spec *spec = codec->spec;
9869 int val = spec->master_sw;
9870
9871 /* HP & line-out */
9872 snd_hda_codec_write_cache(codec, 0x1b, 0,
9873 AC_VERB_SET_PIN_WIDGET_CONTROL,
9874 val ? PIN_HP : 0);
9875 snd_hda_codec_write_cache(codec, 0x15, 0,
9876 AC_VERB_SET_PIN_WIDGET_CONTROL,
9877 val ? PIN_HP : 0);
9878 /* mono (speaker) depending on the HP jack sense */
9879 val = val && !spec->jack_present;
9880 snd_hda_codec_write_cache(codec, 0x16, 0,
9881 AC_VERB_SET_PIN_WIDGET_CONTROL,
9882 val ? PIN_OUT : 0);
9883}
9884
9885static void alc262_hp_bpc_automute(struct hda_codec *codec)
9886{
9887 struct alc_spec *spec = codec->spec;
9888 unsigned int presence;
9889 presence = snd_hda_codec_read(codec, 0x1b, 0,
9890 AC_VERB_GET_PIN_SENSE, 0);
9891 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9892 alc262_hp_master_update(codec);
9893}
9894
9895static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9896{
9897 if ((res >> 26) != ALC880_HP_EVENT)
9898 return;
9899 alc262_hp_bpc_automute(codec);
9900}
9901
9902static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9903{
9904 struct alc_spec *spec = codec->spec;
9905 unsigned int presence;
9906 presence = snd_hda_codec_read(codec, 0x15, 0,
9907 AC_VERB_GET_PIN_SENSE, 0);
9908 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9909 alc262_hp_master_update(codec);
9910}
9911
9912static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9913 unsigned int res)
9914{
9915 if ((res >> 26) != ALC880_HP_EVENT)
9916 return;
9917 alc262_hp_wildwest_automute(codec);
9918}
9919
Takashi Iwaib72519b2009-05-08 14:31:55 +02009920#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009921
9922static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9923 struct snd_ctl_elem_value *ucontrol)
9924{
9925 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9926 struct alc_spec *spec = codec->spec;
9927 int val = !!*ucontrol->value.integer.value;
9928
9929 if (val == spec->master_sw)
9930 return 0;
9931 spec->master_sw = val;
9932 alc262_hp_master_update(codec);
9933 return 1;
9934}
9935
Takashi Iwaib72519b2009-05-08 14:31:55 +02009936#define ALC262_HP_MASTER_SWITCH \
9937 { \
9938 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9939 .name = "Master Playback Switch", \
9940 .info = snd_ctl_boolean_mono_info, \
9941 .get = alc262_hp_master_sw_get, \
9942 .put = alc262_hp_master_sw_put, \
9943 }
9944
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009945static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009946 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009947 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9948 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9949 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009950 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9951 HDA_OUTPUT),
9952 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9953 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009956 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009957 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9958 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009959 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009960 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9961 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9962 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9963 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009964 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9965 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9966 { } /* end */
9967};
9968
Kailang Yangcd7509a2007-01-26 18:33:17 +01009969static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009970 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009971 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9972 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9973 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9974 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009975 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9976 HDA_OUTPUT),
9977 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9978 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009979 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9980 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009981 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9984 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9985 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009986 { } /* end */
9987};
9988
9989static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9990 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9991 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009992 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009993 { } /* end */
9994};
9995
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009996/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009997static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009998{
9999 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010000
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010001 spec->autocfg.hp_pins[0] = 0x15;
10002 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
10003 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010004}
10005
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010006static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010007 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10008 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010009 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10010 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10013 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10014 { } /* end */
10015};
10016
10017static struct hda_verb alc262_hp_t5735_verbs[] = {
10018 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10019 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10020
10021 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10022 { }
10023};
10024
Kailang Yang8c427222008-01-10 13:03:59 +010010025static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010026 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10027 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010028 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10029 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010030 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10031 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10032 { } /* end */
10033};
10034
10035static struct hda_verb alc262_hp_rp5700_verbs[] = {
10036 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10037 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10038 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10039 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10040 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10041 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10042 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10043 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10044 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10045 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10046 {}
10047};
10048
10049static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10050 .num_items = 1,
10051 .items = {
10052 { "Line", 0x1 },
10053 },
10054};
10055
Takashi Iwai42171c12009-05-08 14:11:43 +020010056/* bind hp and internal speaker mute (with plug check) as master switch */
10057static void alc262_hippo_master_update(struct hda_codec *codec)
10058{
10059 struct alc_spec *spec = codec->spec;
10060 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10061 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10062 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10063 unsigned int mute;
10064
10065 /* HP */
10066 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10067 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10068 HDA_AMP_MUTE, mute);
10069 /* mute internal speaker per jack sense */
10070 if (spec->jack_present)
10071 mute = HDA_AMP_MUTE;
10072 if (line_nid)
10073 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10074 HDA_AMP_MUTE, mute);
10075 if (speaker_nid && speaker_nid != line_nid)
10076 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10077 HDA_AMP_MUTE, mute);
10078}
10079
10080#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10081
10082static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10083 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010084{
10085 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010086 struct alc_spec *spec = codec->spec;
10087 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010088
Takashi Iwai42171c12009-05-08 14:11:43 +020010089 if (val == spec->master_sw)
10090 return 0;
10091 spec->master_sw = val;
10092 alc262_hippo_master_update(codec);
10093 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010094}
Takashi Iwai5b319542007-07-26 11:49:22 +020010095
Takashi Iwai42171c12009-05-08 14:11:43 +020010096#define ALC262_HIPPO_MASTER_SWITCH \
10097 { \
10098 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10099 .name = "Master Playback Switch", \
10100 .info = snd_ctl_boolean_mono_info, \
10101 .get = alc262_hippo_master_sw_get, \
10102 .put = alc262_hippo_master_sw_put, \
10103 }
10104
10105static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10106 ALC262_HIPPO_MASTER_SWITCH,
10107 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10114 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10115 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10116 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10117 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10118 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10119 { } /* end */
10120};
10121
10122static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10123 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10124 ALC262_HIPPO_MASTER_SWITCH,
10125 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10126 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10131 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10132 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10133 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10134 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10135 { } /* end */
10136};
10137
10138/* mute/unmute internal speaker according to the hp jack and mute state */
10139static void alc262_hippo_automute(struct hda_codec *codec)
10140{
10141 struct alc_spec *spec = codec->spec;
10142 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10143 unsigned int present;
10144
10145 /* need to execute and sync at first */
10146 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10147 present = snd_hda_codec_read(codec, hp_nid, 0,
10148 AC_VERB_GET_PIN_SENSE, 0);
10149 spec->jack_present = (present & 0x80000000) != 0;
10150 alc262_hippo_master_update(codec);
10151}
10152
10153static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10154{
10155 if ((res >> 26) != ALC880_HP_EVENT)
10156 return;
10157 alc262_hippo_automute(codec);
10158}
10159
10160static void alc262_hippo_init_hook(struct hda_codec *codec)
10161{
10162 struct alc_spec *spec = codec->spec;
10163
10164 spec->autocfg.hp_pins[0] = 0x15;
10165 spec->autocfg.speaker_pins[0] = 0x14;
10166 alc262_hippo_automute(codec);
10167}
10168
10169static void alc262_hippo1_init_hook(struct hda_codec *codec)
10170{
10171 struct alc_spec *spec = codec->spec;
10172
10173 spec->autocfg.hp_pins[0] = 0x1b;
10174 spec->autocfg.speaker_pins[0] = 0x14;
10175 alc262_hippo_automute(codec);
10176}
10177
10178
Kailang Yang272a5272007-05-14 11:00:38 +020010179static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010180 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010181 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010182 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10183 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10184 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10185 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10186 { } /* end */
10187};
10188
Kailang Yang83c34212007-07-05 11:43:05 +020010189static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010190 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10191 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010192 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10193 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10194 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10195 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10196 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10197 { } /* end */
10198};
Kailang Yang272a5272007-05-14 11:00:38 +020010199
Tony Vroonba340e82009-02-02 19:01:30 +000010200static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10201 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10202 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10203 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10204 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10205 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10206 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10207 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10208 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10209 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10210 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10211 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10212 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10213 { } /* end */
10214};
10215
10216static struct hda_verb alc262_tyan_verbs[] = {
10217 /* Headphone automute */
10218 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10219 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10220 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10221
10222 /* P11 AUX_IN, white 4-pin connector */
10223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10224 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10225 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10226 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10227
10228 {}
10229};
10230
10231/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010232static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010233{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010234 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010235
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010236 spec->autocfg.hp_pins[0] = 0x1b;
10237 spec->autocfg.speaker_pins[0] = 0x15;
10238 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +000010239}
10240
Tony Vroonba340e82009-02-02 19:01:30 +000010241
Kailang Yangdf694da2005-12-05 19:42:22 +010010242#define alc262_capture_mixer alc882_capture_mixer
10243#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10244
10245/*
10246 * generic initialization of ADC, input mixers and output mixers
10247 */
10248static struct hda_verb alc262_init_verbs[] = {
10249 /*
10250 * Unmute ADC0-2 and set the default input to mic-in
10251 */
10252 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10253 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10254 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10255 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10256 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10257 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10258
Takashi Iwaicb53c622007-08-10 17:21:45 +020010259 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010260 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010261 * Note: PASD motherboards uses the Line In 2 as the input for
10262 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010263 */
10264 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10267 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10268 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10269 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010270
10271 /*
10272 * Set up output mixers (0x0c - 0x0e)
10273 */
10274 /* set vol=0 to output mixers */
10275 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10276 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10277 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10278 /* set up input amps for analog loopback */
10279 /* Amp Indices: DAC = 0, mixer = 1 */
10280 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10281 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10282 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10283 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10284 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10285 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10286
10287 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10288 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10289 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10290 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10291 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10292 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10293
10294 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10295 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10296 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10297 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10298 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010299
Kailang Yangdf694da2005-12-05 19:42:22 +010010300 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10301 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010302
Kailang Yangdf694da2005-12-05 19:42:22 +010010303 /* FIXME: use matrix-type input source selection */
10304 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10305 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10306 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10307 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10308 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10309 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10310 /* Input mixer2 */
10311 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10312 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10313 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10314 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10315 /* Input mixer3 */
10316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10317 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10318 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010319 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010320
10321 { }
10322};
10323
Kailang Yang4e555fe2008-08-26 13:05:55 +020010324static struct hda_verb alc262_eapd_verbs[] = {
10325 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10326 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10327 { }
10328};
10329
Kailang Yangccc656c2006-10-17 12:32:26 +020010330static struct hda_verb alc262_hippo_unsol_verbs[] = {
10331 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10332 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10333 {}
10334};
10335
10336static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10337 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10338 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10339 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10340
10341 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10342 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10343 {}
10344};
10345
Kailang Yang272a5272007-05-14 11:00:38 +020010346static struct hda_verb alc262_sony_unsol_verbs[] = {
10347 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10348 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10349 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10350
10351 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10352 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010353 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010354};
10355
Kailang Yang4e555fe2008-08-26 13:05:55 +020010356static struct hda_input_mux alc262_dmic_capture_source = {
10357 .num_items = 2,
10358 .items = {
10359 { "Int DMic", 0x9 },
10360 { "Mic", 0x0 },
10361 },
10362};
10363
10364static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10365 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10366 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10367 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010370 { } /* end */
10371};
10372
10373static struct hda_verb alc262_toshiba_s06_verbs[] = {
10374 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10375 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10376 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10377 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10378 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10379 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10380 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10381 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10382 {}
10383};
10384
10385static void alc262_dmic_automute(struct hda_codec *codec)
10386{
10387 unsigned int present;
10388
10389 present = snd_hda_codec_read(codec, 0x18, 0,
10390 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10391 snd_hda_codec_write(codec, 0x22, 0,
10392 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10393}
10394
Kailang Yang4e555fe2008-08-26 13:05:55 +020010395
10396/* unsolicited event for HP jack sensing */
10397static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10398 unsigned int res)
10399{
Kailang Yang4e555fe2008-08-26 13:05:55 +020010400 if ((res >> 26) == ALC880_MIC_EVENT)
10401 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010402 else
10403 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010404}
10405
10406static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10407{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010408 struct alc_spec *spec = codec->spec;
10409
10410 spec->autocfg.hp_pins[0] = 0x15;
10411 spec->autocfg.speaker_pins[0] = 0x14;
10412 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010413 alc262_dmic_automute(codec);
10414}
10415
Takashi Iwai834be882006-03-01 14:16:17 +010010416/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010417 * nec model
10418 * 0x15 = headphone
10419 * 0x16 = internal speaker
10420 * 0x18 = external mic
10421 */
10422
10423static struct snd_kcontrol_new alc262_nec_mixer[] = {
10424 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10425 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10426
10427 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10428 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10429 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10430
10431 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10432 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10433 { } /* end */
10434};
10435
10436static struct hda_verb alc262_nec_verbs[] = {
10437 /* Unmute Speaker */
10438 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10439
10440 /* Headphone */
10441 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10442 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10443
10444 /* External mic to headphone */
10445 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10446 /* External mic to speaker */
10447 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10448 {}
10449};
10450
10451/*
Takashi Iwai834be882006-03-01 14:16:17 +010010452 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010453 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10454 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010455 */
10456
10457#define ALC_HP_EVENT 0x37
10458
10459static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10460 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10461 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010462 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10463 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010464 {}
10465};
10466
Jiang zhe0e31daf2008-03-20 12:12:39 +010010467static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10468 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10469 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10470 {}
10471};
10472
Takashi Iwai834be882006-03-01 14:16:17 +010010473static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010474 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010475 .items = {
10476 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010477 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010478 { "CD", 0x4 },
10479 },
10480};
10481
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010482static struct hda_input_mux alc262_HP_capture_source = {
10483 .num_items = 5,
10484 .items = {
10485 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010486 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010487 { "Line", 0x2 },
10488 { "CD", 0x4 },
10489 { "AUX IN", 0x6 },
10490 },
10491};
10492
zhejiangaccbe492007-08-31 12:36:05 +020010493static struct hda_input_mux alc262_HP_D7000_capture_source = {
10494 .num_items = 4,
10495 .items = {
10496 { "Mic", 0x0 },
10497 { "Front Mic", 0x2 },
10498 { "Line", 0x1 },
10499 { "CD", 0x4 },
10500 },
10501};
10502
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010503/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010504static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10505{
10506 struct alc_spec *spec = codec->spec;
10507 unsigned int mute;
10508
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010509 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010510 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010511 /* need to execute and sync at first */
10512 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010513 /* check laptop HP jack */
10514 present = snd_hda_codec_read(codec, 0x14, 0,
10515 AC_VERB_GET_PIN_SENSE, 0);
10516 /* need to execute and sync at first */
10517 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10518 /* check docking HP jack */
10519 present |= snd_hda_codec_read(codec, 0x1b, 0,
10520 AC_VERB_GET_PIN_SENSE, 0);
10521 if (present & AC_PINSENSE_PRESENCE)
10522 spec->jack_present = 1;
10523 else
10524 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010525 spec->sense_updated = 1;
10526 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010527 /* unmute internal speaker only if both HPs are unplugged and
10528 * master switch is on
10529 */
10530 if (spec->jack_present)
10531 mute = HDA_AMP_MUTE;
10532 else
Takashi Iwai834be882006-03-01 14:16:17 +010010533 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010534 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10535 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010536}
10537
10538/* unsolicited event for HP jack sensing */
10539static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10540 unsigned int res)
10541{
10542 if ((res >> 26) != ALC_HP_EVENT)
10543 return;
10544 alc262_fujitsu_automute(codec, 1);
10545}
10546
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010547static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10548{
10549 alc262_fujitsu_automute(codec, 1);
10550}
10551
Takashi Iwai834be882006-03-01 14:16:17 +010010552/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010553static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10554 .ops = &snd_hda_bind_vol,
10555 .values = {
10556 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10557 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10558 0
10559 },
10560};
Takashi Iwai834be882006-03-01 14:16:17 +010010561
Jiang zhe0e31daf2008-03-20 12:12:39 +010010562/* mute/unmute internal speaker according to the hp jack and mute state */
10563static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10564{
10565 struct alc_spec *spec = codec->spec;
10566 unsigned int mute;
10567
10568 if (force || !spec->sense_updated) {
10569 unsigned int present_int_hp;
10570 /* need to execute and sync at first */
10571 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10572 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10573 AC_VERB_GET_PIN_SENSE, 0);
10574 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10575 spec->sense_updated = 1;
10576 }
10577 if (spec->jack_present) {
10578 /* mute internal speaker */
10579 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10580 HDA_AMP_MUTE, HDA_AMP_MUTE);
10581 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10582 HDA_AMP_MUTE, HDA_AMP_MUTE);
10583 } else {
10584 /* unmute internal speaker if necessary */
10585 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10586 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10587 HDA_AMP_MUTE, mute);
10588 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10589 HDA_AMP_MUTE, mute);
10590 }
10591}
10592
10593/* unsolicited event for HP jack sensing */
10594static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10595 unsigned int res)
10596{
10597 if ((res >> 26) != ALC_HP_EVENT)
10598 return;
10599 alc262_lenovo_3000_automute(codec, 1);
10600}
10601
Takashi Iwai834be882006-03-01 14:16:17 +010010602/* bind hp and internal speaker mute (with plug check) */
10603static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10604 struct snd_ctl_elem_value *ucontrol)
10605{
10606 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10607 long *valp = ucontrol->value.integer.value;
10608 int change;
10609
Tony Vroon5d9fab22008-03-14 17:09:18 +010010610 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10611 HDA_AMP_MUTE,
10612 valp ? 0 : HDA_AMP_MUTE);
10613 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10614 HDA_AMP_MUTE,
10615 valp ? 0 : HDA_AMP_MUTE);
10616
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010617 if (change)
10618 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010619 return change;
10620}
10621
10622static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010623 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010624 {
10625 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10626 .name = "Master Playback Switch",
10627 .info = snd_hda_mixer_amp_switch_info,
10628 .get = snd_hda_mixer_amp_switch_get,
10629 .put = alc262_fujitsu_master_sw_put,
10630 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10631 },
10632 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10633 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10634 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010637 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10638 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10639 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010640 { } /* end */
10641};
10642
Jiang zhe0e31daf2008-03-20 12:12:39 +010010643/* bind hp and internal speaker mute (with plug check) */
10644static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10645 struct snd_ctl_elem_value *ucontrol)
10646{
10647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10648 long *valp = ucontrol->value.integer.value;
10649 int change;
10650
10651 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10652 HDA_AMP_MUTE,
10653 valp ? 0 : HDA_AMP_MUTE);
10654
10655 if (change)
10656 alc262_lenovo_3000_automute(codec, 0);
10657 return change;
10658}
10659
10660static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10661 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10662 {
10663 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10664 .name = "Master Playback Switch",
10665 .info = snd_hda_mixer_amp_switch_info,
10666 .get = snd_hda_mixer_amp_switch_get,
10667 .put = alc262_lenovo_3000_master_sw_put,
10668 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10669 },
10670 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10671 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10672 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10674 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10675 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10676 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10677 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10678 { } /* end */
10679};
10680
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010681static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10682 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010683 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010684 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10685 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10686 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10687 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10688 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10689 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10690 { } /* end */
10691};
10692
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010693/* additional init verbs for Benq laptops */
10694static struct hda_verb alc262_EAPD_verbs[] = {
10695 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10696 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10697 {}
10698};
10699
Kailang Yang83c34212007-07-05 11:43:05 +020010700static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10701 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10702 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10703
10704 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10705 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10706 {}
10707};
10708
Tobin Davisf651b502007-10-26 12:40:47 +020010709/* Samsung Q1 Ultra Vista model setup */
10710static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010711 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10712 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010713 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10714 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10715 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010716 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010717 { } /* end */
10718};
10719
10720static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010721 /* output mixer */
10722 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10723 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10725 /* speaker */
10726 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10727 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10728 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10729 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10730 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010732 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10733 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10734 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10735 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10736 /* internal mic */
10737 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10738 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10739 /* ADC, choose mic */
10740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10741 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10742 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10743 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10744 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10745 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10746 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10747 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10748 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10749 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010750 {}
10751};
10752
Tobin Davisf651b502007-10-26 12:40:47 +020010753/* mute/unmute internal speaker according to the hp jack and mute state */
10754static void alc262_ultra_automute(struct hda_codec *codec)
10755{
10756 struct alc_spec *spec = codec->spec;
10757 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010758
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010759 mute = 0;
10760 /* auto-mute only when HP is used as HP */
10761 if (!spec->cur_mux[0]) {
10762 unsigned int present;
10763 /* need to execute and sync at first */
10764 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10765 present = snd_hda_codec_read(codec, 0x15, 0,
10766 AC_VERB_GET_PIN_SENSE, 0);
10767 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10768 if (spec->jack_present)
10769 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010770 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010771 /* mute/unmute internal speaker */
10772 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10773 HDA_AMP_MUTE, mute);
10774 /* mute/unmute HP */
10775 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10776 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010777}
10778
10779/* unsolicited event for HP jack sensing */
10780static void alc262_ultra_unsol_event(struct hda_codec *codec,
10781 unsigned int res)
10782{
10783 if ((res >> 26) != ALC880_HP_EVENT)
10784 return;
10785 alc262_ultra_automute(codec);
10786}
10787
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010788static struct hda_input_mux alc262_ultra_capture_source = {
10789 .num_items = 2,
10790 .items = {
10791 { "Mic", 0x1 },
10792 { "Headphone", 0x7 },
10793 },
10794};
10795
10796static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10797 struct snd_ctl_elem_value *ucontrol)
10798{
10799 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10800 struct alc_spec *spec = codec->spec;
10801 int ret;
10802
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010803 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010804 if (!ret)
10805 return 0;
10806 /* reprogram the HP pin as mic or HP according to the input source */
10807 snd_hda_codec_write_cache(codec, 0x15, 0,
10808 AC_VERB_SET_PIN_WIDGET_CONTROL,
10809 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10810 alc262_ultra_automute(codec); /* mute/unmute HP */
10811 return ret;
10812}
10813
10814static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10815 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10816 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10817 {
10818 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10819 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010820 .info = alc_mux_enum_info,
10821 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010822 .put = alc262_ultra_mux_enum_put,
10823 },
10824 { } /* end */
10825};
10826
Kailang Yangdf694da2005-12-05 19:42:22 +010010827/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010828static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10829 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010830{
10831 hda_nid_t nid;
10832 int err;
10833
10834 spec->multiout.num_dacs = 1; /* only use one dac */
10835 spec->multiout.dac_nids = spec->private_dac_nids;
10836 spec->multiout.dac_nids[0] = 2;
10837
10838 nid = cfg->line_out_pins[0];
10839 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010840 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10841 "Front Playback Volume",
10842 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10843 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010844 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010845 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10846 "Front Playback Switch",
10847 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10848 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010849 return err;
10850 }
10851
Takashi Iwai82bc9552006-03-21 11:24:42 +010010852 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010853 if (nid) {
10854 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010855 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10856 "Speaker Playback Volume",
10857 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10858 HDA_OUTPUT));
10859 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010860 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010861 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10862 "Speaker Playback Switch",
10863 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10864 HDA_OUTPUT));
10865 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010866 return err;
10867 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010868 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10869 "Speaker Playback Switch",
10870 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10871 HDA_OUTPUT));
10872 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010873 return err;
10874 }
10875 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010876 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010877 if (nid) {
10878 /* spec->multiout.hp_nid = 2; */
10879 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010880 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10881 "Headphone Playback Volume",
10882 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10883 HDA_OUTPUT));
10884 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010885 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010886 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10887 "Headphone Playback Switch",
10888 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10889 HDA_OUTPUT));
10890 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010891 return err;
10892 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010893 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10894 "Headphone Playback Switch",
10895 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10896 HDA_OUTPUT));
10897 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010898 return err;
10899 }
10900 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010901 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010902}
10903
Takashi Iwai8c927b42009-06-22 10:56:54 +020010904static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec,
10905 const struct auto_pin_cfg *cfg)
10906{
10907 int err;
10908
10909 err = alc880_auto_create_analog_input_ctls(spec, cfg);
10910 if (err < 0)
10911 return err;
10912 /* digital-mic input pin is excluded in alc880_auto_create..()
10913 * because it's under 0x18
10914 */
10915 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
10916 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
10917 struct hda_input_mux *imux = &spec->private_imux[0];
10918 imux->items[imux->num_items].label = "Int Mic";
10919 imux->items[imux->num_items].index = 0x09;
10920 imux->num_items++;
10921 }
10922 return 0;
10923}
10924
Kailang Yangdf694da2005-12-05 19:42:22 +010010925
10926/*
10927 * generic initialization of ADC, input mixers and output mixers
10928 */
10929static struct hda_verb alc262_volume_init_verbs[] = {
10930 /*
10931 * Unmute ADC0-2 and set the default input to mic-in
10932 */
10933 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10934 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10935 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10936 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10937 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10938 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10939
Takashi Iwaicb53c622007-08-10 17:21:45 +020010940 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010941 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010942 * Note: PASD motherboards uses the Line In 2 as the input for
10943 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010944 */
10945 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010946 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10947 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10948 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10949 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10950 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010951
10952 /*
10953 * Set up output mixers (0x0c - 0x0f)
10954 */
10955 /* set vol=0 to output mixers */
10956 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10957 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10958 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010959
Kailang Yangdf694da2005-12-05 19:42:22 +010010960 /* set up input amps for analog loopback */
10961 /* Amp Indices: DAC = 0, mixer = 1 */
10962 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10963 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10964 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10965 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10966 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10967 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10968
10969 /* FIXME: use matrix-type input source selection */
10970 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10971 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10972 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10973 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10974 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10975 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10976 /* Input mixer2 */
10977 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10978 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10979 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10980 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10981 /* Input mixer3 */
10982 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10983 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10984 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10985 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10986
10987 { }
10988};
10989
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010990static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10991 /*
10992 * Unmute ADC0-2 and set the default input to mic-in
10993 */
10994 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10995 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10996 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10997 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10998 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10999 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11000
Takashi Iwaicb53c622007-08-10 17:21:45 +020011001 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011002 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011003 * Note: PASD motherboards uses the Line In 2 as the input for
11004 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011005 */
11006 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011007 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11008 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11009 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11010 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11011 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11012 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11013 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011014
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011015 /*
11016 * Set up output mixers (0x0c - 0x0e)
11017 */
11018 /* set vol=0 to output mixers */
11019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11020 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11021 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11022
11023 /* set up input amps for analog loopback */
11024 /* Amp Indices: DAC = 0, mixer = 1 */
11025 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11027 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11028 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11029 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11030 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11031
Takashi Iwaice875f02008-01-28 18:17:43 +010011032 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011033 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11034 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11035
11036 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11037 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11038
11039 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11040 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11041
11042 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11043 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11044 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11045 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11046 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11047
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011048 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011049 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11050 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011051 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011052 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11053 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11054
11055
11056 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011057 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11058 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011059 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011060 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11062 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11064 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11065 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11066 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11067 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011068 /* Input mixer2 */
11069 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011070 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11071 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11072 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11073 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11074 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11075 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11076 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11077 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011078 /* Input mixer3 */
11079 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011080 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11081 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11082 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11084 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11085 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011088
Takashi Iwaice875f02008-01-28 18:17:43 +010011089 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11090
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011091 { }
11092};
11093
Kailang Yangcd7509a2007-01-26 18:33:17 +010011094static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11095 /*
11096 * Unmute ADC0-2 and set the default input to mic-in
11097 */
11098 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11099 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11100 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11101 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11102 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11103 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11104
Takashi Iwaicb53c622007-08-10 17:21:45 +020011105 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011106 * mixer widget
11107 * Note: PASD motherboards uses the Line In 2 as the input for front
11108 * panel mic (mic 2)
11109 */
11110 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011111 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011119 /*
11120 * Set up output mixers (0x0c - 0x0e)
11121 */
11122 /* set vol=0 to output mixers */
11123 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11124 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11125 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11126
11127 /* set up input amps for analog loopback */
11128 /* Amp Indices: DAC = 0, mixer = 1 */
11129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11130 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11131 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11132 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11133 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11134 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11135
11136
11137 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11138 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11139 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11140 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11141 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11142 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11143 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11144
11145 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11146 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11147
11148 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11149 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11150
11151 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11152 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11153 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11154 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11155 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11156 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11157
11158 /* FIXME: use matrix-type input source selection */
11159 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11160 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11161 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11162 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11163 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11164 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11165 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11166 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11167 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11168 /* Input mixer2 */
11169 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11170 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11171 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11172 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11173 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11174 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11175 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11176 /* Input mixer3 */
11177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11178 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11179 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11180 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11181 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11182 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11183 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11184
Takashi Iwaice875f02008-01-28 18:17:43 +010011185 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11186
Kailang Yangcd7509a2007-01-26 18:33:17 +010011187 { }
11188};
11189
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011190static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11191
11192 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11193 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11194 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11195
11196 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11197 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11198 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11199 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11200
11201 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11202 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11203 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11204 {}
11205};
11206
11207
Takashi Iwaicb53c622007-08-10 17:21:45 +020011208#ifdef CONFIG_SND_HDA_POWER_SAVE
11209#define alc262_loopbacks alc880_loopbacks
11210#endif
11211
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011212/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011213#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11214#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11215#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11216#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11217
11218/*
11219 * BIOS auto configuration
11220 */
11221static int alc262_parse_auto_config(struct hda_codec *codec)
11222{
11223 struct alc_spec *spec = codec->spec;
11224 int err;
11225 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11226
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011227 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11228 alc262_ignore);
11229 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011230 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011231 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011232 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011233 spec->multiout.max_channels = 2;
11234 spec->no_analog = 1;
11235 goto dig_only;
11236 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011237 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011238 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011239 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11240 if (err < 0)
11241 return err;
11242 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
11243 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011244 return err;
11245
11246 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11247
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011248 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011249 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011250 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011251 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011252 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011253 if (spec->autocfg.dig_in_pin)
11254 spec->dig_in_nid = ALC262_DIGIN_NID;
11255
Takashi Iwai603c4012008-07-30 15:01:44 +020011256 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011257 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011258
Takashi Iwaid88897e2008-10-31 15:01:37 +010011259 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011260 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011261 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011262
Takashi Iwai776e1842007-08-29 15:07:11 +020011263 err = alc_auto_add_mic_boost(codec);
11264 if (err < 0)
11265 return err;
11266
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011267 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11268
Kailang Yangdf694da2005-12-05 19:42:22 +010011269 return 1;
11270}
11271
11272#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11273#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11274#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011275#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011276
11277
11278/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011279static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011280{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011281 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011282 alc262_auto_init_multi_out(codec);
11283 alc262_auto_init_hp_out(codec);
11284 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011285 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011286 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011287 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011288}
11289
11290/*
11291 * configuration and preset
11292 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011293static const char *alc262_models[ALC262_MODEL_LAST] = {
11294 [ALC262_BASIC] = "basic",
11295 [ALC262_HIPPO] = "hippo",
11296 [ALC262_HIPPO_1] = "hippo_1",
11297 [ALC262_FUJITSU] = "fujitsu",
11298 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011299 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011300 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011301 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011302 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011303 [ALC262_BENQ_T31] = "benq-t31",
11304 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011305 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011306 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011307 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011308 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011309 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011310 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011311 [ALC262_AUTO] = "auto",
11312};
11313
11314static struct snd_pci_quirk alc262_cfg_tbl[] = {
11315 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011316 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011317 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11318 ALC262_HP_BPC),
11319 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11320 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011321 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11322 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011323 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011324 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011325 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011326 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011327 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011328 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011329 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011330 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011331 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11332 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11333 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011334 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11335 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011336 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011337 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011338 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011339 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011340 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011341 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011342 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11343 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011344 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011345 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011346 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011347 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011348 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011349 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011350 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11351 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011352 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011353 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011354 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011355 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011356 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011357 {}
11358};
11359
11360static struct alc_config_preset alc262_presets[] = {
11361 [ALC262_BASIC] = {
11362 .mixers = { alc262_base_mixer },
11363 .init_verbs = { alc262_init_verbs },
11364 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11365 .dac_nids = alc262_dac_nids,
11366 .hp_nid = 0x03,
11367 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11368 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011369 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011370 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011371 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011372 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020011373 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
11374 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11375 .dac_nids = alc262_dac_nids,
11376 .hp_nid = 0x03,
11377 .dig_out_nid = ALC262_DIGOUT_NID,
11378 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11379 .channel_mode = alc262_modes,
11380 .input_mux = &alc262_capture_source,
11381 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011382 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011383 },
11384 [ALC262_HIPPO_1] = {
11385 .mixers = { alc262_hippo1_mixer },
11386 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11387 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11388 .dac_nids = alc262_dac_nids,
11389 .hp_nid = 0x02,
11390 .dig_out_nid = ALC262_DIGOUT_NID,
11391 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11392 .channel_mode = alc262_modes,
11393 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011394 .unsol_event = alc262_hippo_unsol_event,
11395 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011396 },
Takashi Iwai834be882006-03-01 14:16:17 +010011397 [ALC262_FUJITSU] = {
11398 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011399 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11400 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011401 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11402 .dac_nids = alc262_dac_nids,
11403 .hp_nid = 0x03,
11404 .dig_out_nid = ALC262_DIGOUT_NID,
11405 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11406 .channel_mode = alc262_modes,
11407 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011408 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011409 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011410 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011411 [ALC262_HP_BPC] = {
11412 .mixers = { alc262_HP_BPC_mixer },
11413 .init_verbs = { alc262_HP_BPC_init_verbs },
11414 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11415 .dac_nids = alc262_dac_nids,
11416 .hp_nid = 0x03,
11417 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11418 .channel_mode = alc262_modes,
11419 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011420 .unsol_event = alc262_hp_bpc_unsol_event,
11421 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011422 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011423 [ALC262_HP_BPC_D7000_WF] = {
11424 .mixers = { alc262_HP_BPC_WildWest_mixer },
11425 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11426 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11427 .dac_nids = alc262_dac_nids,
11428 .hp_nid = 0x03,
11429 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11430 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011431 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011432 .unsol_event = alc262_hp_wildwest_unsol_event,
11433 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011434 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011435 [ALC262_HP_BPC_D7000_WL] = {
11436 .mixers = { alc262_HP_BPC_WildWest_mixer,
11437 alc262_HP_BPC_WildWest_option_mixer },
11438 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11439 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11440 .dac_nids = alc262_dac_nids,
11441 .hp_nid = 0x03,
11442 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11443 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011444 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011445 .unsol_event = alc262_hp_wildwest_unsol_event,
11446 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011447 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011448 [ALC262_HP_TC_T5735] = {
11449 .mixers = { alc262_hp_t5735_mixer },
11450 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11451 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11452 .dac_nids = alc262_dac_nids,
11453 .hp_nid = 0x03,
11454 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11455 .channel_mode = alc262_modes,
11456 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011457 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011458 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011459 },
11460 [ALC262_HP_RP5700] = {
11461 .mixers = { alc262_hp_rp5700_mixer },
11462 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11463 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11464 .dac_nids = alc262_dac_nids,
11465 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11466 .channel_mode = alc262_modes,
11467 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011468 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011469 [ALC262_BENQ_ED8] = {
11470 .mixers = { alc262_base_mixer },
11471 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11472 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11473 .dac_nids = alc262_dac_nids,
11474 .hp_nid = 0x03,
11475 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11476 .channel_mode = alc262_modes,
11477 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011478 },
Kailang Yang272a5272007-05-14 11:00:38 +020011479 [ALC262_SONY_ASSAMD] = {
11480 .mixers = { alc262_sony_mixer },
11481 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11482 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11483 .dac_nids = alc262_dac_nids,
11484 .hp_nid = 0x02,
11485 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11486 .channel_mode = alc262_modes,
11487 .input_mux = &alc262_capture_source,
11488 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011489 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011490 },
11491 [ALC262_BENQ_T31] = {
11492 .mixers = { alc262_benq_t31_mixer },
11493 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11494 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11495 .dac_nids = alc262_dac_nids,
11496 .hp_nid = 0x03,
11497 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11498 .channel_mode = alc262_modes,
11499 .input_mux = &alc262_capture_source,
11500 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011501 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011502 },
Tobin Davisf651b502007-10-26 12:40:47 +020011503 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011504 .mixers = { alc262_ultra_mixer },
11505 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011506 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011507 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11508 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011509 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11510 .channel_mode = alc262_modes,
11511 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011512 .adc_nids = alc262_adc_nids, /* ADC0 */
11513 .capsrc_nids = alc262_capsrc_nids,
11514 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011515 .unsol_event = alc262_ultra_unsol_event,
11516 .init_hook = alc262_ultra_automute,
11517 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011518 [ALC262_LENOVO_3000] = {
11519 .mixers = { alc262_lenovo_3000_mixer },
11520 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11521 alc262_lenovo_3000_unsol_verbs },
11522 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11523 .dac_nids = alc262_dac_nids,
11524 .hp_nid = 0x03,
11525 .dig_out_nid = ALC262_DIGOUT_NID,
11526 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11527 .channel_mode = alc262_modes,
11528 .input_mux = &alc262_fujitsu_capture_source,
11529 .unsol_event = alc262_lenovo_3000_unsol_event,
11530 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011531 [ALC262_NEC] = {
11532 .mixers = { alc262_nec_mixer },
11533 .init_verbs = { alc262_nec_verbs },
11534 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11535 .dac_nids = alc262_dac_nids,
11536 .hp_nid = 0x03,
11537 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11538 .channel_mode = alc262_modes,
11539 .input_mux = &alc262_capture_source,
11540 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011541 [ALC262_TOSHIBA_S06] = {
11542 .mixers = { alc262_toshiba_s06_mixer },
11543 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11544 alc262_eapd_verbs },
11545 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11546 .capsrc_nids = alc262_dmic_capsrc_nids,
11547 .dac_nids = alc262_dac_nids,
11548 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011549 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011550 .dig_out_nid = ALC262_DIGOUT_NID,
11551 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11552 .channel_mode = alc262_modes,
11553 .input_mux = &alc262_dmic_capture_source,
11554 .unsol_event = alc262_toshiba_s06_unsol_event,
11555 .init_hook = alc262_toshiba_s06_init_hook,
11556 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011557 [ALC262_TOSHIBA_RX1] = {
11558 .mixers = { alc262_toshiba_rx1_mixer },
11559 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11560 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11561 .dac_nids = alc262_dac_nids,
11562 .hp_nid = 0x03,
11563 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11564 .channel_mode = alc262_modes,
11565 .input_mux = &alc262_capture_source,
11566 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011567 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011568 },
Tony Vroonba340e82009-02-02 19:01:30 +000011569 [ALC262_TYAN] = {
11570 .mixers = { alc262_tyan_mixer },
11571 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11572 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11573 .dac_nids = alc262_dac_nids,
11574 .hp_nid = 0x02,
11575 .dig_out_nid = ALC262_DIGOUT_NID,
11576 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11577 .channel_mode = alc262_modes,
11578 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011579 .unsol_event = alc_automute_amp_unsol_event,
11580 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011581 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011582};
11583
11584static int patch_alc262(struct hda_codec *codec)
11585{
11586 struct alc_spec *spec;
11587 int board_config;
11588 int err;
11589
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011590 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011591 if (spec == NULL)
11592 return -ENOMEM;
11593
11594 codec->spec = spec;
11595#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011596 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11597 * under-run
11598 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011599 {
11600 int tmp;
11601 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11602 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11603 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11604 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11605 }
11606#endif
11607
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011608 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11609
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011610 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11611 alc262_models,
11612 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011613
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011614 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020011615 printk(KERN_INFO "hda_codec: Unknown model for %s, "
11616 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011617 board_config = ALC262_AUTO;
11618 }
11619
11620 if (board_config == ALC262_AUTO) {
11621 /* automatic parse from the BIOS config */
11622 err = alc262_parse_auto_config(codec);
11623 if (err < 0) {
11624 alc_free(codec);
11625 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011626 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011627 printk(KERN_INFO
11628 "hda_codec: Cannot set up configuration "
11629 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011630 board_config = ALC262_BASIC;
11631 }
11632 }
11633
Takashi Iwai07eba612009-02-19 08:06:35 +010011634 if (!spec->no_analog) {
11635 err = snd_hda_attach_beep_device(codec, 0x1);
11636 if (err < 0) {
11637 alc_free(codec);
11638 return err;
11639 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011640 }
11641
Kailang Yangdf694da2005-12-05 19:42:22 +010011642 if (board_config != ALC262_AUTO)
11643 setup_preset(spec, &alc262_presets[board_config]);
11644
Kailang Yangdf694da2005-12-05 19:42:22 +010011645 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11646 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011647
Kailang Yangdf694da2005-12-05 19:42:22 +010011648 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11649 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11650
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011651 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011652 int i;
11653 /* check whether the digital-mic has to be supported */
11654 for (i = 0; i < spec->input_mux->num_items; i++) {
11655 if (spec->input_mux->items[i].index >= 9)
11656 break;
11657 }
11658 if (i < spec->input_mux->num_items) {
11659 /* use only ADC0 */
11660 spec->adc_nids = alc262_dmic_adc_nids;
11661 spec->num_adc_nids = 1;
11662 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011663 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011664 /* all analog inputs */
11665 /* check whether NID 0x07 is valid */
11666 unsigned int wcap = get_wcaps(codec, 0x07);
11667
11668 /* get type */
11669 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
11670 if (wcap != AC_WID_AUD_IN) {
11671 spec->adc_nids = alc262_adc_nids_alt;
11672 spec->num_adc_nids =
11673 ARRAY_SIZE(alc262_adc_nids_alt);
11674 spec->capsrc_nids = alc262_capsrc_nids_alt;
11675 } else {
11676 spec->adc_nids = alc262_adc_nids;
11677 spec->num_adc_nids =
11678 ARRAY_SIZE(alc262_adc_nids);
11679 spec->capsrc_nids = alc262_capsrc_nids;
11680 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011681 }
11682 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011683 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011684 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011685 if (!spec->no_analog)
11686 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011687
Takashi Iwai2134ea42008-01-10 16:53:55 +010011688 spec->vmaster_nid = 0x0c;
11689
Kailang Yangdf694da2005-12-05 19:42:22 +010011690 codec->patch_ops = alc_patch_ops;
11691 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011692 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011693#ifdef CONFIG_SND_HDA_POWER_SAVE
11694 if (!spec->loopback.amplist)
11695 spec->loopback.amplist = alc262_loopbacks;
11696#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011697 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011698
Kailang Yangdf694da2005-12-05 19:42:22 +010011699 return 0;
11700}
11701
Kailang Yangdf694da2005-12-05 19:42:22 +010011702/*
Kailang Yanga361d842007-06-05 12:30:55 +020011703 * ALC268 channel source setting (2 channel)
11704 */
11705#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11706#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011707
Kailang Yanga361d842007-06-05 12:30:55 +020011708static hda_nid_t alc268_dac_nids[2] = {
11709 /* front, hp */
11710 0x02, 0x03
11711};
11712
11713static hda_nid_t alc268_adc_nids[2] = {
11714 /* ADC0-1 */
11715 0x08, 0x07
11716};
11717
11718static hda_nid_t alc268_adc_nids_alt[1] = {
11719 /* ADC0 */
11720 0x08
11721};
11722
Takashi Iwaie1406342008-02-11 18:32:32 +010011723static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11724
Kailang Yanga361d842007-06-05 12:30:55 +020011725static struct snd_kcontrol_new alc268_base_mixer[] = {
11726 /* output mixer control */
11727 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11728 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11729 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11730 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011731 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11732 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11733 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011734 { }
11735};
11736
Takashi Iwai42171c12009-05-08 14:11:43 +020011737static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11738 /* output mixer control */
11739 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11740 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11741 ALC262_HIPPO_MASTER_SWITCH,
11742 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11743 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11744 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11745 { }
11746};
11747
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011748/* bind Beep switches of both NID 0x0f and 0x10 */
11749static struct hda_bind_ctls alc268_bind_beep_sw = {
11750 .ops = &snd_hda_bind_sw,
11751 .values = {
11752 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11753 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11754 0
11755 },
11756};
11757
11758static struct snd_kcontrol_new alc268_beep_mixer[] = {
11759 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11760 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11761 { }
11762};
11763
Kailang Yangd1a991a2007-08-15 16:21:59 +020011764static struct hda_verb alc268_eapd_verbs[] = {
11765 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11766 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11767 { }
11768};
11769
Takashi Iwaid2738092007-08-16 14:59:45 +020011770/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011771static struct hda_verb alc268_toshiba_verbs[] = {
11772 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11773 { } /* end */
11774};
11775
Kailang Yang8ef355d2008-08-26 13:10:22 +020011776static struct hda_input_mux alc268_acer_lc_capture_source = {
11777 .num_items = 2,
11778 .items = {
11779 { "i-Mic", 0x6 },
11780 { "E-Mic", 0x0 },
11781 },
11782};
11783
Takashi Iwaid2738092007-08-16 14:59:45 +020011784/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011785/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011786static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11787 .ops = &snd_hda_bind_vol,
11788 .values = {
11789 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11790 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11791 0
11792 },
11793};
11794
Takashi Iwai889c4392007-08-23 18:56:52 +020011795/* mute/unmute internal speaker according to the hp jack and mute state */
11796static void alc268_acer_automute(struct hda_codec *codec, int force)
11797{
11798 struct alc_spec *spec = codec->spec;
11799 unsigned int mute;
11800
11801 if (force || !spec->sense_updated) {
11802 unsigned int present;
11803 present = snd_hda_codec_read(codec, 0x14, 0,
11804 AC_VERB_GET_PIN_SENSE, 0);
11805 spec->jack_present = (present & 0x80000000) != 0;
11806 spec->sense_updated = 1;
11807 }
11808 if (spec->jack_present)
11809 mute = HDA_AMP_MUTE; /* mute internal speaker */
11810 else /* unmute internal speaker if necessary */
11811 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11812 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11813 HDA_AMP_MUTE, mute);
11814}
11815
11816
11817/* bind hp and internal speaker mute (with plug check) */
11818static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11819 struct snd_ctl_elem_value *ucontrol)
11820{
11821 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11822 long *valp = ucontrol->value.integer.value;
11823 int change;
11824
11825 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11826 HDA_AMP_MUTE,
11827 valp[0] ? 0 : HDA_AMP_MUTE);
11828 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11829 HDA_AMP_MUTE,
11830 valp[1] ? 0 : HDA_AMP_MUTE);
11831 if (change)
11832 alc268_acer_automute(codec, 0);
11833 return change;
11834}
Takashi Iwaid2738092007-08-16 14:59:45 +020011835
Kailang Yang8ef355d2008-08-26 13:10:22 +020011836static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11837 /* output mixer control */
11838 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11839 {
11840 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11841 .name = "Master Playback Switch",
11842 .info = snd_hda_mixer_amp_switch_info,
11843 .get = snd_hda_mixer_amp_switch_get,
11844 .put = alc268_acer_master_sw_put,
11845 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11846 },
11847 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11848 { }
11849};
11850
Takashi Iwaid2738092007-08-16 14:59:45 +020011851static struct snd_kcontrol_new alc268_acer_mixer[] = {
11852 /* output mixer control */
11853 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11854 {
11855 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11856 .name = "Master Playback Switch",
11857 .info = snd_hda_mixer_amp_switch_info,
11858 .get = snd_hda_mixer_amp_switch_get,
11859 .put = alc268_acer_master_sw_put,
11860 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11861 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011862 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11863 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11864 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011865 { }
11866};
11867
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011868static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11869 /* output mixer control */
11870 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11871 {
11872 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11873 .name = "Master Playback Switch",
11874 .info = snd_hda_mixer_amp_switch_info,
11875 .get = snd_hda_mixer_amp_switch_get,
11876 .put = alc268_acer_master_sw_put,
11877 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11878 },
11879 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11880 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11881 { }
11882};
11883
Kailang Yang8ef355d2008-08-26 13:10:22 +020011884static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11885 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11886 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11887 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11888 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11889 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11890 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11891 { }
11892};
11893
Takashi Iwaid2738092007-08-16 14:59:45 +020011894static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011895 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11896 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011897 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11898 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011899 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11900 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011901 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11902 { }
11903};
11904
11905/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011906#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11907#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011908
11909static void alc268_acer_unsol_event(struct hda_codec *codec,
11910 unsigned int res)
11911{
Takashi Iwai889c4392007-08-23 18:56:52 +020011912 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011913 return;
11914 alc268_acer_automute(codec, 1);
11915}
11916
Takashi Iwai889c4392007-08-23 18:56:52 +020011917static void alc268_acer_init_hook(struct hda_codec *codec)
11918{
11919 alc268_acer_automute(codec, 1);
11920}
11921
Kailang Yang8ef355d2008-08-26 13:10:22 +020011922/* toggle speaker-output according to the hp-jack state */
11923static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11924{
11925 unsigned int present;
11926 unsigned char bits;
11927
11928 present = snd_hda_codec_read(codec, 0x15, 0,
11929 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11930 bits = present ? AMP_IN_MUTE(0) : 0;
11931 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11932 AMP_IN_MUTE(0), bits);
11933 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11934 AMP_IN_MUTE(0), bits);
11935}
11936
11937
11938static void alc268_acer_mic_automute(struct hda_codec *codec)
11939{
11940 unsigned int present;
11941
11942 present = snd_hda_codec_read(codec, 0x18, 0,
11943 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11944 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11945 present ? 0x0 : 0x6);
11946}
11947
11948static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11949 unsigned int res)
11950{
11951 if ((res >> 26) == ALC880_HP_EVENT)
11952 alc268_aspire_one_speaker_automute(codec);
11953 if ((res >> 26) == ALC880_MIC_EVENT)
11954 alc268_acer_mic_automute(codec);
11955}
11956
11957static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11958{
11959 alc268_aspire_one_speaker_automute(codec);
11960 alc268_acer_mic_automute(codec);
11961}
11962
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011963static struct snd_kcontrol_new alc268_dell_mixer[] = {
11964 /* output mixer control */
11965 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11966 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11967 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11969 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11970 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11971 { }
11972};
11973
11974static struct hda_verb alc268_dell_verbs[] = {
11975 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11977 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11978 { }
11979};
11980
11981/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011982static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011983{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011984 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011985
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011986 spec->autocfg.hp_pins[0] = 0x15;
11987 spec->autocfg.speaker_pins[0] = 0x14;
11988 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011989}
11990
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011991static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11992 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11993 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11994 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11995 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11996 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11997 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11998 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11999 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12000 { }
12001};
12002
12003static struct hda_verb alc267_quanta_il1_verbs[] = {
12004 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12005 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12006 { }
12007};
12008
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012009static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
12010{
12011 unsigned int present;
12012
12013 present = snd_hda_codec_read(codec, 0x18, 0,
12014 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12015 snd_hda_codec_write(codec, 0x23, 0,
12016 AC_VERB_SET_CONNECT_SEL,
12017 present ? 0x00 : 0x01);
12018}
12019
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012020static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012021{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012022 struct alc_spec *spec = codec->spec;
12023
12024 spec->autocfg.hp_pins[0] = 0x15;
12025 spec->autocfg.speaker_pins[0] = 0x14;
12026 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012027 alc267_quanta_il1_mic_automute(codec);
12028}
12029
12030static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
12031 unsigned int res)
12032{
12033 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012034 case ALC880_MIC_EVENT:
12035 alc267_quanta_il1_mic_automute(codec);
12036 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012037 default:
12038 alc_sku_unsol_event(codec, res);
12039 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012040 }
12041}
12042
Kailang Yanga361d842007-06-05 12:30:55 +020012043/*
12044 * generic initialization of ADC, input mixers and output mixers
12045 */
12046static struct hda_verb alc268_base_init_verbs[] = {
12047 /* Unmute DAC0-1 and set vol = 0 */
12048 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012049 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012050
12051 /*
12052 * Set up output mixers (0x0c - 0x0e)
12053 */
12054 /* set vol=0 to output mixers */
12055 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012056 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12057
12058 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12059 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12060
12061 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12062 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12063 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12064 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12065 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12066 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12067 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12068 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12069
12070 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12071 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12072 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12073 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012074 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012075
12076 /* set PCBEEP vol = 0, mute connections */
12077 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12078 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12079 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012080
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012081 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012082
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012083 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12084 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12085 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12086 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012087
Kailang Yanga361d842007-06-05 12:30:55 +020012088 { }
12089};
12090
12091/*
12092 * generic initialization of ADC, input mixers and output mixers
12093 */
12094static struct hda_verb alc268_volume_init_verbs[] = {
12095 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012096 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12097 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012098
12099 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12100 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12101 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12102 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12103 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12104
Kailang Yanga361d842007-06-05 12:30:55 +020012105 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012106 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12107 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12108
12109 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012110 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012111
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012112 /* set PCBEEP vol = 0, mute connections */
12113 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12114 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12115 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012116
12117 { }
12118};
12119
Kailang Yanga361d842007-06-05 12:30:55 +020012120static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12121 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12122 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12123 {
12124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12125 /* The multiple "Capture Source" controls confuse alsamixer
12126 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012127 */
12128 /* .name = "Capture Source", */
12129 .name = "Input Source",
12130 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012131 .info = alc_mux_enum_info,
12132 .get = alc_mux_enum_get,
12133 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012134 },
12135 { } /* end */
12136};
12137
12138static struct snd_kcontrol_new alc268_capture_mixer[] = {
12139 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12140 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12141 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12142 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12143 {
12144 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12145 /* The multiple "Capture Source" controls confuse alsamixer
12146 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012147 */
12148 /* .name = "Capture Source", */
12149 .name = "Input Source",
12150 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012151 .info = alc_mux_enum_info,
12152 .get = alc_mux_enum_get,
12153 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012154 },
12155 { } /* end */
12156};
12157
12158static struct hda_input_mux alc268_capture_source = {
12159 .num_items = 4,
12160 .items = {
12161 { "Mic", 0x0 },
12162 { "Front Mic", 0x1 },
12163 { "Line", 0x2 },
12164 { "CD", 0x3 },
12165 },
12166};
12167
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012168static struct hda_input_mux alc268_acer_capture_source = {
12169 .num_items = 3,
12170 .items = {
12171 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012172 { "Internal Mic", 0x1 },
12173 { "Line", 0x2 },
12174 },
12175};
12176
12177static struct hda_input_mux alc268_acer_dmic_capture_source = {
12178 .num_items = 3,
12179 .items = {
12180 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012181 { "Internal Mic", 0x6 },
12182 { "Line", 0x2 },
12183 },
12184};
12185
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012186#ifdef CONFIG_SND_DEBUG
12187static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012188 /* Volume widgets */
12189 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12190 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12191 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12192 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12193 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12194 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12195 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12196 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12197 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12198 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12199 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12200 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12201 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012202 /* The below appears problematic on some hardwares */
12203 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012204 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12205 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12206 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12207 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12208
12209 /* Modes for retasking pin widgets */
12210 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12211 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12212 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12213 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12214
12215 /* Controls for GPIO pins, assuming they are configured as outputs */
12216 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12217 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12218 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12219 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12220
12221 /* Switches to allow the digital SPDIF output pin to be enabled.
12222 * The ALC268 does not have an SPDIF input.
12223 */
12224 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12225
12226 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12227 * this output to turn on an external amplifier.
12228 */
12229 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12230 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12231
12232 { } /* end */
12233};
12234#endif
12235
Kailang Yanga361d842007-06-05 12:30:55 +020012236/* create input playback/capture controls for the given pin */
12237static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12238 const char *ctlname, int idx)
12239{
12240 char name[32];
12241 int err;
12242
12243 sprintf(name, "%s Playback Volume", ctlname);
12244 if (nid == 0x14) {
12245 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12246 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
12247 HDA_OUTPUT));
12248 if (err < 0)
12249 return err;
12250 } else if (nid == 0x15) {
12251 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12252 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
12253 HDA_OUTPUT));
12254 if (err < 0)
12255 return err;
12256 } else
12257 return -1;
12258 sprintf(name, "%s Playback Switch", ctlname);
12259 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12260 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
12261 if (err < 0)
12262 return err;
12263 return 0;
12264}
12265
12266/* add playback controls from the parsed DAC table */
12267static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12268 const struct auto_pin_cfg *cfg)
12269{
12270 hda_nid_t nid;
12271 int err;
12272
12273 spec->multiout.num_dacs = 2; /* only use one dac */
12274 spec->multiout.dac_nids = spec->private_dac_nids;
12275 spec->multiout.dac_nids[0] = 2;
12276 spec->multiout.dac_nids[1] = 3;
12277
12278 nid = cfg->line_out_pins[0];
12279 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020012280 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020012281
12282 nid = cfg->speaker_pins[0];
12283 if (nid == 0x1d) {
12284 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12285 "Speaker Playback Volume",
12286 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12287 if (err < 0)
12288 return err;
12289 }
12290 nid = cfg->hp_pins[0];
12291 if (nid)
12292 alc268_new_analog_output(spec, nid, "Headphone", 0);
12293
12294 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12295 if (nid == 0x16) {
12296 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12297 "Mono Playback Switch",
12298 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
12299 if (err < 0)
12300 return err;
12301 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012302 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012303}
12304
12305/* create playback/capture controls for input pins */
12306static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12307 const struct auto_pin_cfg *cfg)
12308{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012309 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012310 int i, idx1;
12311
12312 for (i = 0; i < AUTO_PIN_LAST; i++) {
12313 switch(cfg->input_pins[i]) {
12314 case 0x18:
12315 idx1 = 0; /* Mic 1 */
12316 break;
12317 case 0x19:
12318 idx1 = 1; /* Mic 2 */
12319 break;
12320 case 0x1a:
12321 idx1 = 2; /* Line In */
12322 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012323 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012324 idx1 = 3; /* CD */
12325 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012326 case 0x12:
12327 case 0x13:
12328 idx1 = 6; /* digital mics */
12329 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012330 default:
12331 continue;
12332 }
12333 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12334 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012335 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012336 }
12337 return 0;
12338}
12339
12340static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12341{
12342 struct alc_spec *spec = codec->spec;
12343 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12344 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12345 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12346 unsigned int dac_vol1, dac_vol2;
12347
12348 if (speaker_nid) {
12349 snd_hda_codec_write(codec, speaker_nid, 0,
12350 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12351 snd_hda_codec_write(codec, 0x0f, 0,
12352 AC_VERB_SET_AMP_GAIN_MUTE,
12353 AMP_IN_UNMUTE(1));
12354 snd_hda_codec_write(codec, 0x10, 0,
12355 AC_VERB_SET_AMP_GAIN_MUTE,
12356 AMP_IN_UNMUTE(1));
12357 } else {
12358 snd_hda_codec_write(codec, 0x0f, 0,
12359 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12360 snd_hda_codec_write(codec, 0x10, 0,
12361 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12362 }
12363
12364 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012365 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012366 dac_vol2 = AMP_OUT_ZERO;
12367 else if (line_nid == 0x15)
12368 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012369 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012370 dac_vol2 = AMP_OUT_ZERO;
12371 else if (hp_nid == 0x15)
12372 dac_vol1 = AMP_OUT_ZERO;
12373 if (line_nid != 0x16 || hp_nid != 0x16 ||
12374 spec->autocfg.line_out_pins[1] != 0x16 ||
12375 spec->autocfg.line_out_pins[2] != 0x16)
12376 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12377
12378 snd_hda_codec_write(codec, 0x02, 0,
12379 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12380 snd_hda_codec_write(codec, 0x03, 0,
12381 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12382}
12383
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012384/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012385#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12386#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012387#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012388#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12389
12390/*
12391 * BIOS auto configuration
12392 */
12393static int alc268_parse_auto_config(struct hda_codec *codec)
12394{
12395 struct alc_spec *spec = codec->spec;
12396 int err;
12397 static hda_nid_t alc268_ignore[] = { 0 };
12398
12399 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12400 alc268_ignore);
12401 if (err < 0)
12402 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012403 if (!spec->autocfg.line_outs) {
12404 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12405 spec->multiout.max_channels = 2;
12406 spec->no_analog = 1;
12407 goto dig_only;
12408 }
Kailang Yanga361d842007-06-05 12:30:55 +020012409 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012410 }
Kailang Yanga361d842007-06-05 12:30:55 +020012411 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12412 if (err < 0)
12413 return err;
12414 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12415 if (err < 0)
12416 return err;
12417
12418 spec->multiout.max_channels = 2;
12419
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012420 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012421 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012422 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012423 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012424 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12425 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012426 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012427 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012428
Takashi Iwai892981f2009-03-02 08:04:35 +010012429 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012430 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012431
Takashi Iwaid88897e2008-10-31 15:01:37 +010012432 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012433 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012434 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012435
Takashi Iwai776e1842007-08-29 15:07:11 +020012436 err = alc_auto_add_mic_boost(codec);
12437 if (err < 0)
12438 return err;
12439
Kailang Yanga361d842007-06-05 12:30:55 +020012440 return 1;
12441}
12442
12443#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12444#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12445#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12446
12447/* init callback for auto-configuration model -- overriding the default init */
12448static void alc268_auto_init(struct hda_codec *codec)
12449{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012450 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012451 alc268_auto_init_multi_out(codec);
12452 alc268_auto_init_hp_out(codec);
12453 alc268_auto_init_mono_speaker_out(codec);
12454 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012455 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012456 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012457}
12458
12459/*
12460 * configuration and preset
12461 */
12462static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012463 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012464 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012465 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012466 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012467 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012468 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012469 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012470 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012471#ifdef CONFIG_SND_DEBUG
12472 [ALC268_TEST] = "test",
12473#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012474 [ALC268_AUTO] = "auto",
12475};
12476
12477static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012478 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012479 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012480 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012481 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012482 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012483 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12484 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012485 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012486 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012487 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12488 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012489 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012490 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12491 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12492 ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012493 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012494 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012495 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012496 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012497 {}
12498};
12499
12500static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012501 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012502 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012503 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12504 alc267_quanta_il1_verbs },
12505 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12506 .dac_nids = alc268_dac_nids,
12507 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12508 .adc_nids = alc268_adc_nids_alt,
12509 .hp_nid = 0x03,
12510 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12511 .channel_mode = alc268_modes,
12512 .input_mux = &alc268_capture_source,
12513 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012514 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012515 },
Kailang Yanga361d842007-06-05 12:30:55 +020012516 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012517 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12518 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012519 .init_verbs = { alc268_base_init_verbs },
12520 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12521 .dac_nids = alc268_dac_nids,
12522 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12523 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012524 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012525 .hp_nid = 0x03,
12526 .dig_out_nid = ALC268_DIGOUT_NID,
12527 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12528 .channel_mode = alc268_modes,
12529 .input_mux = &alc268_capture_source,
12530 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012531 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012532 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012533 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012534 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12535 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012536 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12537 .dac_nids = alc268_dac_nids,
12538 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12539 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012540 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012541 .hp_nid = 0x03,
12542 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12543 .channel_mode = alc268_modes,
12544 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012545 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012546 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012547 },
12548 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012549 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12550 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012551 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12552 alc268_acer_verbs },
12553 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12554 .dac_nids = alc268_dac_nids,
12555 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12556 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012557 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012558 .hp_nid = 0x02,
12559 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12560 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012561 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012562 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012563 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012564 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012565 [ALC268_ACER_DMIC] = {
12566 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12567 alc268_beep_mixer },
12568 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12569 alc268_acer_verbs },
12570 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12571 .dac_nids = alc268_dac_nids,
12572 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12573 .adc_nids = alc268_adc_nids_alt,
12574 .capsrc_nids = alc268_capsrc_nids,
12575 .hp_nid = 0x02,
12576 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12577 .channel_mode = alc268_modes,
12578 .input_mux = &alc268_acer_dmic_capture_source,
12579 .unsol_event = alc268_acer_unsol_event,
12580 .init_hook = alc268_acer_init_hook,
12581 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012582 [ALC268_ACER_ASPIRE_ONE] = {
12583 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012584 alc268_beep_mixer,
12585 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012586 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12587 alc268_acer_aspire_one_verbs },
12588 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12589 .dac_nids = alc268_dac_nids,
12590 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12591 .adc_nids = alc268_adc_nids_alt,
12592 .capsrc_nids = alc268_capsrc_nids,
12593 .hp_nid = 0x03,
12594 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12595 .channel_mode = alc268_modes,
12596 .input_mux = &alc268_acer_lc_capture_source,
12597 .unsol_event = alc268_acer_lc_unsol_event,
12598 .init_hook = alc268_acer_lc_init_hook,
12599 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012600 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012601 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012602 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12603 alc268_dell_verbs },
12604 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12605 .dac_nids = alc268_dac_nids,
12606 .hp_nid = 0x02,
12607 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12608 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012609 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012610 .init_hook = alc268_dell_init_hook,
12611 .input_mux = &alc268_capture_source,
12612 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012613 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012614 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12615 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012616 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12617 alc268_toshiba_verbs },
12618 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12619 .dac_nids = alc268_dac_nids,
12620 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12621 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012622 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012623 .hp_nid = 0x03,
12624 .dig_out_nid = ALC268_DIGOUT_NID,
12625 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12626 .channel_mode = alc268_modes,
12627 .input_mux = &alc268_capture_source,
12628 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012629 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012630 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012631#ifdef CONFIG_SND_DEBUG
12632 [ALC268_TEST] = {
12633 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12634 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12635 alc268_volume_init_verbs },
12636 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12637 .dac_nids = alc268_dac_nids,
12638 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12639 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012640 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012641 .hp_nid = 0x03,
12642 .dig_out_nid = ALC268_DIGOUT_NID,
12643 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12644 .channel_mode = alc268_modes,
12645 .input_mux = &alc268_capture_source,
12646 },
12647#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012648};
12649
12650static int patch_alc268(struct hda_codec *codec)
12651{
12652 struct alc_spec *spec;
12653 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012654 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012655
12656 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12657 if (spec == NULL)
12658 return -ENOMEM;
12659
12660 codec->spec = spec;
12661
12662 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12663 alc268_models,
12664 alc268_cfg_tbl);
12665
12666 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020012667 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12668 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012669 board_config = ALC268_AUTO;
12670 }
12671
12672 if (board_config == ALC268_AUTO) {
12673 /* automatic parse from the BIOS config */
12674 err = alc268_parse_auto_config(codec);
12675 if (err < 0) {
12676 alc_free(codec);
12677 return err;
12678 } else if (!err) {
12679 printk(KERN_INFO
12680 "hda_codec: Cannot set up configuration "
12681 "from BIOS. Using base mode...\n");
12682 board_config = ALC268_3ST;
12683 }
12684 }
12685
12686 if (board_config != ALC268_AUTO)
12687 setup_preset(spec, &alc268_presets[board_config]);
12688
Kailang Yanga361d842007-06-05 12:30:55 +020012689 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12690 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012691 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012692
Kailang Yanga361d842007-06-05 12:30:55 +020012693 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12694
Takashi Iwai22971e32009-02-10 11:56:44 +010012695 has_beep = 0;
12696 for (i = 0; i < spec->num_mixers; i++) {
12697 if (spec->mixers[i] == alc268_beep_mixer) {
12698 has_beep = 1;
12699 break;
12700 }
12701 }
12702
12703 if (has_beep) {
12704 err = snd_hda_attach_beep_device(codec, 0x1);
12705 if (err < 0) {
12706 alc_free(codec);
12707 return err;
12708 }
12709 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12710 /* override the amp caps for beep generator */
12711 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012712 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12713 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12714 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12715 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012716 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012717
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012718 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012719 /* check whether NID 0x07 is valid */
12720 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012721 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012722
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012723 /* get type */
12724 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012725 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012726 spec->adc_nids = alc268_adc_nids_alt;
12727 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012728 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012729 } else {
12730 spec->adc_nids = alc268_adc_nids;
12731 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012732 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012733 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012734 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012735 /* set default input source */
12736 for (i = 0; i < spec->num_adc_nids; i++)
12737 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12738 0, AC_VERB_SET_CONNECT_SEL,
12739 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012740 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012741
12742 spec->vmaster_nid = 0x02;
12743
Kailang Yanga361d842007-06-05 12:30:55 +020012744 codec->patch_ops = alc_patch_ops;
12745 if (board_config == ALC268_AUTO)
12746 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012747
Takashi Iwaidaead532008-11-28 12:55:36 +010012748 codec->proc_widget_hook = print_realtek_coef;
12749
Kailang Yanga361d842007-06-05 12:30:55 +020012750 return 0;
12751}
12752
12753/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012754 * ALC269 channel source setting (2 channel)
12755 */
12756#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12757
12758#define alc269_dac_nids alc260_dac_nids
12759
12760static hda_nid_t alc269_adc_nids[1] = {
12761 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012762 0x08,
12763};
12764
Takashi Iwaie01bf502008-08-21 16:25:07 +020012765static hda_nid_t alc269_capsrc_nids[1] = {
12766 0x23,
12767};
12768
12769/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12770 * not a mux!
12771 */
12772
Kailang Yangf53281e2008-07-18 12:36:43 +020012773static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12774 .num_items = 2,
12775 .items = {
12776 { "i-Mic", 0x5 },
12777 { "e-Mic", 0x0 },
12778 },
12779};
12780
12781static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12782 .num_items = 2,
12783 .items = {
12784 { "i-Mic", 0x1 },
12785 { "e-Mic", 0x0 },
12786 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012787};
12788
12789#define alc269_modes alc260_modes
12790#define alc269_capture_source alc880_lg_lw_capture_source
12791
12792static struct snd_kcontrol_new alc269_base_mixer[] = {
12793 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12794 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12795 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12796 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12799 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12800 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12801 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12802 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12803 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12804 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12805 { } /* end */
12806};
12807
Kailang Yang60db6b52008-08-26 13:13:00 +020012808static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12809 /* output mixer control */
12810 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12811 {
12812 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12813 .name = "Master Playback Switch",
12814 .info = snd_hda_mixer_amp_switch_info,
12815 .get = snd_hda_mixer_amp_switch_get,
12816 .put = alc268_acer_master_sw_put,
12817 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12818 },
12819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12821 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12822 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12823 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12824 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012825 { }
12826};
12827
Tony Vroon64154832008-11-06 15:08:49 +000012828static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12829 /* output mixer control */
12830 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12831 {
12832 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12833 .name = "Master Playback Switch",
12834 .info = snd_hda_mixer_amp_switch_info,
12835 .get = snd_hda_mixer_amp_switch_get,
12836 .put = alc268_acer_master_sw_put,
12837 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12838 },
12839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12840 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12841 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12842 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12843 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12844 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12845 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12846 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12847 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012848 { }
12849};
12850
Kailang Yangf53281e2008-07-18 12:36:43 +020012851/* bind volumes of both NID 0x0c and 0x0d */
12852static struct hda_bind_ctls alc269_epc_bind_vol = {
12853 .ops = &snd_hda_bind_vol,
12854 .values = {
12855 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12856 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12857 0
12858 },
12859};
12860
12861static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12862 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12863 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12864 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12865 { } /* end */
12866};
12867
Kailang Yangf6a92242007-12-13 16:52:54 +010012868/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012869static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12870 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12871 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012872 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12873 { } /* end */
12874};
12875
12876/* FSC amilo */
12877static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12878 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12879 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12880 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012881 { } /* end */
12882};
12883
Kailang Yang60db6b52008-08-26 13:13:00 +020012884static struct hda_verb alc269_quanta_fl1_verbs[] = {
12885 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12886 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12887 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12888 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12889 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12890 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12891 { }
12892};
12893
Tony Vroon64154832008-11-06 15:08:49 +000012894static struct hda_verb alc269_lifebook_verbs[] = {
12895 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12896 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12897 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12898 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12899 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12900 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12901 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12902 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12903 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12904 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12905 { }
12906};
12907
Kailang Yang60db6b52008-08-26 13:13:00 +020012908/* toggle speaker-output according to the hp-jack state */
12909static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12910{
12911 unsigned int present;
12912 unsigned char bits;
12913
12914 present = snd_hda_codec_read(codec, 0x15, 0,
12915 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12916 bits = present ? AMP_IN_MUTE(0) : 0;
12917 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12918 AMP_IN_MUTE(0), bits);
12919 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12920 AMP_IN_MUTE(0), bits);
12921
12922 snd_hda_codec_write(codec, 0x20, 0,
12923 AC_VERB_SET_COEF_INDEX, 0x0c);
12924 snd_hda_codec_write(codec, 0x20, 0,
12925 AC_VERB_SET_PROC_COEF, 0x680);
12926
12927 snd_hda_codec_write(codec, 0x20, 0,
12928 AC_VERB_SET_COEF_INDEX, 0x0c);
12929 snd_hda_codec_write(codec, 0x20, 0,
12930 AC_VERB_SET_PROC_COEF, 0x480);
12931}
12932
Tony Vroon64154832008-11-06 15:08:49 +000012933/* toggle speaker-output according to the hp-jacks state */
12934static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12935{
12936 unsigned int present;
12937 unsigned char bits;
12938
12939 /* Check laptop headphone socket */
12940 present = snd_hda_codec_read(codec, 0x15, 0,
12941 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12942
12943 /* Check port replicator headphone socket */
12944 present |= snd_hda_codec_read(codec, 0x1a, 0,
12945 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12946
12947 bits = present ? AMP_IN_MUTE(0) : 0;
12948 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12949 AMP_IN_MUTE(0), bits);
12950 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12951 AMP_IN_MUTE(0), bits);
12952
12953 snd_hda_codec_write(codec, 0x20, 0,
12954 AC_VERB_SET_COEF_INDEX, 0x0c);
12955 snd_hda_codec_write(codec, 0x20, 0,
12956 AC_VERB_SET_PROC_COEF, 0x680);
12957
12958 snd_hda_codec_write(codec, 0x20, 0,
12959 AC_VERB_SET_COEF_INDEX, 0x0c);
12960 snd_hda_codec_write(codec, 0x20, 0,
12961 AC_VERB_SET_PROC_COEF, 0x480);
12962}
12963
Kailang Yang60db6b52008-08-26 13:13:00 +020012964static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12965{
12966 unsigned int present;
12967
12968 present = snd_hda_codec_read(codec, 0x18, 0,
12969 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12970 snd_hda_codec_write(codec, 0x23, 0,
12971 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12972}
12973
Tony Vroon64154832008-11-06 15:08:49 +000012974static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12975{
12976 unsigned int present_laptop;
12977 unsigned int present_dock;
12978
12979 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12980 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12981
12982 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12983 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12984
12985 /* Laptop mic port overrides dock mic port, design decision */
12986 if (present_dock)
12987 snd_hda_codec_write(codec, 0x23, 0,
12988 AC_VERB_SET_CONNECT_SEL, 0x3);
12989 if (present_laptop)
12990 snd_hda_codec_write(codec, 0x23, 0,
12991 AC_VERB_SET_CONNECT_SEL, 0x0);
12992 if (!present_dock && !present_laptop)
12993 snd_hda_codec_write(codec, 0x23, 0,
12994 AC_VERB_SET_CONNECT_SEL, 0x1);
12995}
12996
Kailang Yang60db6b52008-08-26 13:13:00 +020012997static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12998 unsigned int res)
12999{
13000 if ((res >> 26) == ALC880_HP_EVENT)
13001 alc269_quanta_fl1_speaker_automute(codec);
13002 if ((res >> 26) == ALC880_MIC_EVENT)
13003 alc269_quanta_fl1_mic_automute(codec);
13004}
13005
Tony Vroon64154832008-11-06 15:08:49 +000013006static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13007 unsigned int res)
13008{
13009 if ((res >> 26) == ALC880_HP_EVENT)
13010 alc269_lifebook_speaker_automute(codec);
13011 if ((res >> 26) == ALC880_MIC_EVENT)
13012 alc269_lifebook_mic_autoswitch(codec);
13013}
13014
Kailang Yang60db6b52008-08-26 13:13:00 +020013015static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13016{
13017 alc269_quanta_fl1_speaker_automute(codec);
13018 alc269_quanta_fl1_mic_automute(codec);
13019}
13020
Tony Vroon64154832008-11-06 15:08:49 +000013021static void alc269_lifebook_init_hook(struct hda_codec *codec)
13022{
13023 alc269_lifebook_speaker_automute(codec);
13024 alc269_lifebook_mic_autoswitch(codec);
13025}
13026
Kailang Yang60db6b52008-08-26 13:13:00 +020013027static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13028 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13029 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13030 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13031 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13032 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13033 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13034 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13035 {}
13036};
13037
13038static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13039 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13040 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13041 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13042 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13043 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13044 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13045 {}
13046};
13047
13048/* toggle speaker-output according to the hp-jack state */
13049static void alc269_speaker_automute(struct hda_codec *codec)
13050{
13051 unsigned int present;
13052 unsigned char bits;
13053
13054 present = snd_hda_codec_read(codec, 0x15, 0,
13055 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13056 bits = present ? AMP_IN_MUTE(0) : 0;
13057 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13058 AMP_IN_MUTE(0), bits);
13059 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13060 AMP_IN_MUTE(0), bits);
13061}
13062
13063static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
13064{
13065 unsigned int present;
13066
13067 present = snd_hda_codec_read(codec, 0x18, 0,
13068 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13069 snd_hda_codec_write(codec, 0x23, 0,
13070 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
13071}
13072
13073static void alc269_eeepc_amic_automute(struct hda_codec *codec)
13074{
13075 unsigned int present;
13076
13077 present = snd_hda_codec_read(codec, 0x18, 0,
13078 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13079 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13080 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13081 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13082 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13083}
13084
13085/* unsolicited event for HP jack sensing */
13086static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
13087 unsigned int res)
13088{
13089 if ((res >> 26) == ALC880_HP_EVENT)
13090 alc269_speaker_automute(codec);
13091
13092 if ((res >> 26) == ALC880_MIC_EVENT)
13093 alc269_eeepc_dmic_automute(codec);
13094}
13095
13096static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
13097{
13098 alc269_speaker_automute(codec);
13099 alc269_eeepc_dmic_automute(codec);
13100}
13101
13102/* unsolicited event for HP jack sensing */
13103static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
13104 unsigned int res)
13105{
13106 if ((res >> 26) == ALC880_HP_EVENT)
13107 alc269_speaker_automute(codec);
13108
13109 if ((res >> 26) == ALC880_MIC_EVENT)
13110 alc269_eeepc_amic_automute(codec);
13111}
13112
13113static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
13114{
13115 alc269_speaker_automute(codec);
13116 alc269_eeepc_amic_automute(codec);
13117}
13118
Kailang Yangf6a92242007-12-13 16:52:54 +010013119/*
13120 * generic initialization of ADC, input mixers and output mixers
13121 */
13122static struct hda_verb alc269_init_verbs[] = {
13123 /*
13124 * Unmute ADC0 and set the default input to mic-in
13125 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013126 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013127
13128 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13129 * analog-loopback mixer widget
13130 * Note: PASD motherboards uses the Line In 2 as the input for
13131 * front panel mic (mic 2)
13132 */
13133 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13136 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13137 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13138 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13139
13140 /*
13141 * Set up output mixers (0x0c - 0x0e)
13142 */
13143 /* set vol=0 to output mixers */
13144 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13145 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13146
13147 /* set up input amps for analog loopback */
13148 /* Amp Indices: DAC = 0, mixer = 1 */
13149 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13150 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13151 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13152 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13153 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13154 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13155
13156 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13157 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13158 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13159 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13160 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13161 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13162 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13163
13164 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13165 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13166 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13167 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13168 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13169 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13170 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13171
13172 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13173 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13174
13175 /* FIXME: use matrix-type input source selection */
13176 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13177 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013178 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13179 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013180 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13181 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13182
13183 /* set EAPD */
13184 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13185 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13186 { }
13187};
13188
13189/* add playback controls from the parsed DAC table */
13190static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
13191 const struct auto_pin_cfg *cfg)
13192{
13193 hda_nid_t nid;
13194 int err;
13195
13196 spec->multiout.num_dacs = 1; /* only use one dac */
13197 spec->multiout.dac_nids = spec->private_dac_nids;
13198 spec->multiout.dac_nids[0] = 2;
13199
13200 nid = cfg->line_out_pins[0];
13201 if (nid) {
13202 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13203 "Front Playback Volume",
13204 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
13205 if (err < 0)
13206 return err;
13207 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13208 "Front Playback Switch",
13209 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13210 if (err < 0)
13211 return err;
13212 }
13213
13214 nid = cfg->speaker_pins[0];
13215 if (nid) {
13216 if (!cfg->line_out_pins[0]) {
13217 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13218 "Speaker Playback Volume",
13219 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13220 HDA_OUTPUT));
13221 if (err < 0)
13222 return err;
13223 }
13224 if (nid == 0x16) {
13225 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13226 "Speaker Playback Switch",
13227 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13228 HDA_OUTPUT));
13229 if (err < 0)
13230 return err;
13231 } else {
13232 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13233 "Speaker Playback Switch",
13234 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13235 HDA_OUTPUT));
13236 if (err < 0)
13237 return err;
13238 }
13239 }
13240 nid = cfg->hp_pins[0];
13241 if (nid) {
13242 /* spec->multiout.hp_nid = 2; */
13243 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
13244 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13245 "Headphone Playback Volume",
13246 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13247 HDA_OUTPUT));
13248 if (err < 0)
13249 return err;
13250 }
13251 if (nid == 0x16) {
13252 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13253 "Headphone Playback Switch",
13254 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13255 HDA_OUTPUT));
13256 if (err < 0)
13257 return err;
13258 } else {
13259 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13260 "Headphone Playback Switch",
13261 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13262 HDA_OUTPUT));
13263 if (err < 0)
13264 return err;
13265 }
13266 }
13267 return 0;
13268}
13269
Takashi Iwai8c927b42009-06-22 10:56:54 +020013270#define alc269_auto_create_analog_input_ctls \
13271 alc262_auto_create_analog_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013272
13273#ifdef CONFIG_SND_HDA_POWER_SAVE
13274#define alc269_loopbacks alc880_loopbacks
13275#endif
13276
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013277/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013278#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13279#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13280#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13281#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13282
Takashi Iwaif03d3112009-03-05 14:18:16 +010013283static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13284 .substreams = 1,
13285 .channels_min = 2,
13286 .channels_max = 8,
13287 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13288 /* NID is set in alc_build_pcms */
13289 .ops = {
13290 .open = alc880_playback_pcm_open,
13291 .prepare = alc880_playback_pcm_prepare,
13292 .cleanup = alc880_playback_pcm_cleanup
13293 },
13294};
13295
13296static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13297 .substreams = 1,
13298 .channels_min = 2,
13299 .channels_max = 2,
13300 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13301 /* NID is set in alc_build_pcms */
13302};
13303
Kailang Yangf6a92242007-12-13 16:52:54 +010013304/*
13305 * BIOS auto configuration
13306 */
13307static int alc269_parse_auto_config(struct hda_codec *codec)
13308{
13309 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013310 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013311 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13312
13313 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13314 alc269_ignore);
13315 if (err < 0)
13316 return err;
13317
13318 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13319 if (err < 0)
13320 return err;
13321 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13322 if (err < 0)
13323 return err;
13324
13325 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13326
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013327 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013328 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13329
Takashi Iwai603c4012008-07-30 15:01:44 +020013330 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013331 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013332
Takashi Iwaid88897e2008-10-31 15:01:37 +010013333 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013334 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013335 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013336 /* set default input source */
13337 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13338 0, AC_VERB_SET_CONNECT_SEL,
13339 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013340
13341 err = alc_auto_add_mic_boost(codec);
13342 if (err < 0)
13343 return err;
13344
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013345 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013346 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013347
Kailang Yangf6a92242007-12-13 16:52:54 +010013348 return 1;
13349}
13350
13351#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13352#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13353#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13354
13355
13356/* init callback for auto-configuration model -- overriding the default init */
13357static void alc269_auto_init(struct hda_codec *codec)
13358{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013359 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013360 alc269_auto_init_multi_out(codec);
13361 alc269_auto_init_hp_out(codec);
13362 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013363 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013364 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013365}
13366
13367/*
13368 * configuration and preset
13369 */
13370static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013371 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013372 [ALC269_QUANTA_FL1] = "quanta",
13373 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013374 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013375 [ALC269_FUJITSU] = "fujitsu",
13376 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013377};
13378
13379static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013380 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013381 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13382 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013383 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13384 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13385 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13386 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13387 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13388 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013389 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13390 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013391 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13392 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013393 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013394 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013395 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013396 {}
13397};
13398
13399static struct alc_config_preset alc269_presets[] = {
13400 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013401 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013402 .init_verbs = { alc269_init_verbs },
13403 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13404 .dac_nids = alc269_dac_nids,
13405 .hp_nid = 0x03,
13406 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13407 .channel_mode = alc269_modes,
13408 .input_mux = &alc269_capture_source,
13409 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013410 [ALC269_QUANTA_FL1] = {
13411 .mixers = { alc269_quanta_fl1_mixer },
13412 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13413 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13414 .dac_nids = alc269_dac_nids,
13415 .hp_nid = 0x03,
13416 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13417 .channel_mode = alc269_modes,
13418 .input_mux = &alc269_capture_source,
13419 .unsol_event = alc269_quanta_fl1_unsol_event,
13420 .init_hook = alc269_quanta_fl1_init_hook,
13421 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013422 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013423 .mixers = { alc269_eeepc_mixer },
13424 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013425 .init_verbs = { alc269_init_verbs,
13426 alc269_eeepc_amic_init_verbs },
13427 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13428 .dac_nids = alc269_dac_nids,
13429 .hp_nid = 0x03,
13430 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13431 .channel_mode = alc269_modes,
13432 .input_mux = &alc269_eeepc_amic_capture_source,
13433 .unsol_event = alc269_eeepc_amic_unsol_event,
13434 .init_hook = alc269_eeepc_amic_inithook,
13435 },
13436 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013437 .mixers = { alc269_eeepc_mixer },
13438 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013439 .init_verbs = { alc269_init_verbs,
13440 alc269_eeepc_dmic_init_verbs },
13441 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13442 .dac_nids = alc269_dac_nids,
13443 .hp_nid = 0x03,
13444 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13445 .channel_mode = alc269_modes,
13446 .input_mux = &alc269_eeepc_dmic_capture_source,
13447 .unsol_event = alc269_eeepc_dmic_unsol_event,
13448 .init_hook = alc269_eeepc_dmic_inithook,
13449 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013450 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013451 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013452 .cap_mixer = alc269_epc_capture_mixer,
13453 .init_verbs = { alc269_init_verbs,
13454 alc269_eeepc_dmic_init_verbs },
13455 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13456 .dac_nids = alc269_dac_nids,
13457 .hp_nid = 0x03,
13458 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13459 .channel_mode = alc269_modes,
13460 .input_mux = &alc269_eeepc_dmic_capture_source,
13461 .unsol_event = alc269_eeepc_dmic_unsol_event,
13462 .init_hook = alc269_eeepc_dmic_inithook,
13463 },
Tony Vroon64154832008-11-06 15:08:49 +000013464 [ALC269_LIFEBOOK] = {
13465 .mixers = { alc269_lifebook_mixer },
13466 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13467 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13468 .dac_nids = alc269_dac_nids,
13469 .hp_nid = 0x03,
13470 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13471 .channel_mode = alc269_modes,
13472 .input_mux = &alc269_capture_source,
13473 .unsol_event = alc269_lifebook_unsol_event,
13474 .init_hook = alc269_lifebook_init_hook,
13475 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013476};
13477
13478static int patch_alc269(struct hda_codec *codec)
13479{
13480 struct alc_spec *spec;
13481 int board_config;
13482 int err;
13483
13484 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13485 if (spec == NULL)
13486 return -ENOMEM;
13487
13488 codec->spec = spec;
13489
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013490 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13491
Kailang Yangf6a92242007-12-13 16:52:54 +010013492 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13493 alc269_models,
13494 alc269_cfg_tbl);
13495
13496 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020013497 printk(KERN_INFO "hda_codec: Unknown model for %s, "
13498 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013499 board_config = ALC269_AUTO;
13500 }
13501
13502 if (board_config == ALC269_AUTO) {
13503 /* automatic parse from the BIOS config */
13504 err = alc269_parse_auto_config(codec);
13505 if (err < 0) {
13506 alc_free(codec);
13507 return err;
13508 } else if (!err) {
13509 printk(KERN_INFO
13510 "hda_codec: Cannot set up configuration "
13511 "from BIOS. Using base mode...\n");
13512 board_config = ALC269_BASIC;
13513 }
13514 }
13515
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013516 err = snd_hda_attach_beep_device(codec, 0x1);
13517 if (err < 0) {
13518 alc_free(codec);
13519 return err;
13520 }
13521
Kailang Yangf6a92242007-12-13 16:52:54 +010013522 if (board_config != ALC269_AUTO)
13523 setup_preset(spec, &alc269_presets[board_config]);
13524
Takashi Iwaif03d3112009-03-05 14:18:16 +010013525 if (codec->subsystem_id == 0x17aa3bf8) {
13526 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13527 * fix the sample rate of analog I/O to 44.1kHz
13528 */
13529 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13530 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13531 } else {
13532 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13533 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13534 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013535 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13536 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13537
13538 spec->adc_nids = alc269_adc_nids;
13539 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013540 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013541 if (!spec->cap_mixer)
13542 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013543 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013544
13545 codec->patch_ops = alc_patch_ops;
13546 if (board_config == ALC269_AUTO)
13547 spec->init_hook = alc269_auto_init;
13548#ifdef CONFIG_SND_HDA_POWER_SAVE
13549 if (!spec->loopback.amplist)
13550 spec->loopback.amplist = alc269_loopbacks;
13551#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013552 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013553
13554 return 0;
13555}
13556
13557/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013558 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13559 */
13560
13561/*
13562 * set the path ways for 2 channel output
13563 * need to set the codec line out and mic 1 pin widgets to inputs
13564 */
13565static struct hda_verb alc861_threestack_ch2_init[] = {
13566 /* set pin widget 1Ah (line in) for input */
13567 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013568 /* set pin widget 18h (mic1/2) for input, for mic also enable
13569 * the vref
13570 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013571 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13572
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013573 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13574#if 0
13575 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13576 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13577#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013578 { } /* end */
13579};
13580/*
13581 * 6ch mode
13582 * need to set the codec line out and mic 1 pin widgets to outputs
13583 */
13584static struct hda_verb alc861_threestack_ch6_init[] = {
13585 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13586 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13587 /* set pin widget 18h (mic1) for output (CLFE)*/
13588 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13589
13590 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013591 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013592
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013593 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13594#if 0
13595 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13596 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13597#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013598 { } /* end */
13599};
13600
13601static struct hda_channel_mode alc861_threestack_modes[2] = {
13602 { 2, alc861_threestack_ch2_init },
13603 { 6, alc861_threestack_ch6_init },
13604};
Takashi Iwai22309c32006-08-09 16:57:28 +020013605/* Set mic1 as input and unmute the mixer */
13606static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13607 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13608 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13609 { } /* end */
13610};
13611/* Set mic1 as output and mute mixer */
13612static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13613 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13614 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13615 { } /* end */
13616};
13617
13618static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13619 { 2, alc861_uniwill_m31_ch2_init },
13620 { 4, alc861_uniwill_m31_ch4_init },
13621};
Kailang Yangdf694da2005-12-05 19:42:22 +010013622
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013623/* Set mic1 and line-in as input and unmute the mixer */
13624static struct hda_verb alc861_asus_ch2_init[] = {
13625 /* set pin widget 1Ah (line in) for input */
13626 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013627 /* set pin widget 18h (mic1/2) for input, for mic also enable
13628 * the vref
13629 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013630 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13631
13632 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13633#if 0
13634 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13635 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13636#endif
13637 { } /* end */
13638};
13639/* Set mic1 nad line-in as output and mute mixer */
13640static struct hda_verb alc861_asus_ch6_init[] = {
13641 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13642 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13643 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13644 /* set pin widget 18h (mic1) for output (CLFE)*/
13645 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13646 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13647 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13648 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13649
13650 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13651#if 0
13652 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13653 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13654#endif
13655 { } /* end */
13656};
13657
13658static struct hda_channel_mode alc861_asus_modes[2] = {
13659 { 2, alc861_asus_ch2_init },
13660 { 6, alc861_asus_ch6_init },
13661};
13662
Kailang Yangdf694da2005-12-05 19:42:22 +010013663/* patch-ALC861 */
13664
13665static struct snd_kcontrol_new alc861_base_mixer[] = {
13666 /* output mixer control */
13667 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13668 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13669 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13670 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13671 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13672
13673 /*Input mixer control */
13674 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13675 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13676 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13677 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13678 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13679 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13681 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13682 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13683 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013684
Kailang Yangdf694da2005-12-05 19:42:22 +010013685 { } /* end */
13686};
13687
13688static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13689 /* output mixer control */
13690 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13691 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13692 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13693 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13694 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13695
13696 /* Input mixer control */
13697 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13698 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13699 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13700 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13701 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13702 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13703 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13704 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13705 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13706 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013707
Kailang Yangdf694da2005-12-05 19:42:22 +010013708 {
13709 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13710 .name = "Channel Mode",
13711 .info = alc_ch_mode_info,
13712 .get = alc_ch_mode_get,
13713 .put = alc_ch_mode_put,
13714 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13715 },
13716 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013717};
13718
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013719static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013720 /* output mixer control */
13721 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13722 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13723 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013724
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013725 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013726};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013727
Takashi Iwai22309c32006-08-09 16:57:28 +020013728static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13729 /* output mixer control */
13730 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13731 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13732 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13733 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13734 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13735
13736 /* Input mixer control */
13737 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13738 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13739 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13740 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13741 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13742 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13744 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13745 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13746 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013747
Takashi Iwai22309c32006-08-09 16:57:28 +020013748 {
13749 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13750 .name = "Channel Mode",
13751 .info = alc_ch_mode_info,
13752 .get = alc_ch_mode_get,
13753 .put = alc_ch_mode_put,
13754 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13755 },
13756 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013757};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013758
13759static struct snd_kcontrol_new alc861_asus_mixer[] = {
13760 /* output mixer control */
13761 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13762 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13763 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13764 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13765 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13766
13767 /* Input mixer control */
13768 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13769 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13770 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13771 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13772 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13773 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13775 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13776 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013777 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13778
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013779 {
13780 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13781 .name = "Channel Mode",
13782 .info = alc_ch_mode_info,
13783 .get = alc_ch_mode_get,
13784 .put = alc_ch_mode_put,
13785 .private_value = ARRAY_SIZE(alc861_asus_modes),
13786 },
13787 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013788};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013789
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013790/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013791static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013792 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13793 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013794 { }
13795};
13796
Kailang Yangdf694da2005-12-05 19:42:22 +010013797/*
13798 * generic initialization of ADC, input mixers and output mixers
13799 */
13800static struct hda_verb alc861_base_init_verbs[] = {
13801 /*
13802 * Unmute ADC0 and set the default input to mic-in
13803 */
13804 /* port-A for surround (rear panel) */
13805 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13806 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13807 /* port-B for mic-in (rear panel) with vref */
13808 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13809 /* port-C for line-in (rear panel) */
13810 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13811 /* port-D for Front */
13812 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13813 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13814 /* port-E for HP out (front panel) */
13815 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13816 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013817 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013818 /* port-F for mic-in (front panel) with vref */
13819 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13820 /* port-G for CLFE (rear panel) */
13821 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13822 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13823 /* port-H for side (rear panel) */
13824 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13825 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13826 /* CD-in */
13827 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13828 /* route front mic to ADC1*/
13829 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13830 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013831
Kailang Yangdf694da2005-12-05 19:42:22 +010013832 /* Unmute DAC0~3 & spdif out*/
13833 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13834 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13835 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13836 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13837 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013838
Kailang Yangdf694da2005-12-05 19:42:22 +010013839 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13840 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13841 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13842 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13843 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013844
Kailang Yangdf694da2005-12-05 19:42:22 +010013845 /* Unmute Stereo Mixer 15 */
13846 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13847 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13848 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013849 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013850
13851 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13852 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13853 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13854 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13855 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13856 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13857 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13858 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013859 /* hp used DAC 3 (Front) */
13860 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013861 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13862
13863 { }
13864};
13865
13866static struct hda_verb alc861_threestack_init_verbs[] = {
13867 /*
13868 * Unmute ADC0 and set the default input to mic-in
13869 */
13870 /* port-A for surround (rear panel) */
13871 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13872 /* port-B for mic-in (rear panel) with vref */
13873 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13874 /* port-C for line-in (rear panel) */
13875 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13876 /* port-D for Front */
13877 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13878 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13879 /* port-E for HP out (front panel) */
13880 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13881 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013882 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013883 /* port-F for mic-in (front panel) with vref */
13884 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13885 /* port-G for CLFE (rear panel) */
13886 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13887 /* port-H for side (rear panel) */
13888 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13889 /* CD-in */
13890 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13891 /* route front mic to ADC1*/
13892 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13893 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13894 /* Unmute DAC0~3 & spdif out*/
13895 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13896 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13897 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13898 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13899 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013900
Kailang Yangdf694da2005-12-05 19:42:22 +010013901 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13902 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13903 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13904 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13905 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013906
Kailang Yangdf694da2005-12-05 19:42:22 +010013907 /* Unmute Stereo Mixer 15 */
13908 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13909 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13910 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013912
13913 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13914 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13915 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13916 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13917 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13918 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13919 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13920 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013921 /* hp used DAC 3 (Front) */
13922 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013923 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13924 { }
13925};
Takashi Iwai22309c32006-08-09 16:57:28 +020013926
13927static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13928 /*
13929 * Unmute ADC0 and set the default input to mic-in
13930 */
13931 /* port-A for surround (rear panel) */
13932 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13933 /* port-B for mic-in (rear panel) with vref */
13934 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13935 /* port-C for line-in (rear panel) */
13936 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13937 /* port-D for Front */
13938 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13939 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13940 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013941 /* this has to be set to VREF80 */
13942 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013943 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013944 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013945 /* port-F for mic-in (front panel) with vref */
13946 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13947 /* port-G for CLFE (rear panel) */
13948 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13949 /* port-H for side (rear panel) */
13950 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13951 /* CD-in */
13952 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13953 /* route front mic to ADC1*/
13954 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13955 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13956 /* Unmute DAC0~3 & spdif out*/
13957 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13958 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13959 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13960 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13961 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013962
Takashi Iwai22309c32006-08-09 16:57:28 +020013963 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13964 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13965 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13966 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13967 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013968
Takashi Iwai22309c32006-08-09 16:57:28 +020013969 /* Unmute Stereo Mixer 15 */
13970 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13971 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13972 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013973 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013974
13975 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13976 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13977 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13978 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13979 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13980 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13981 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13982 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013983 /* hp used DAC 3 (Front) */
13984 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013985 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13986 { }
13987};
13988
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013989static struct hda_verb alc861_asus_init_verbs[] = {
13990 /*
13991 * Unmute ADC0 and set the default input to mic-in
13992 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013993 /* port-A for surround (rear panel)
13994 * according to codec#0 this is the HP jack
13995 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013996 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13997 /* route front PCM to HP */
13998 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13999 /* port-B for mic-in (rear panel) with vref */
14000 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14001 /* port-C for line-in (rear panel) */
14002 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14003 /* port-D for Front */
14004 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14005 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14006 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014007 /* this has to be set to VREF80 */
14008 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014009 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014010 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014011 /* port-F for mic-in (front panel) with vref */
14012 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14013 /* port-G for CLFE (rear panel) */
14014 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14015 /* port-H for side (rear panel) */
14016 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14017 /* CD-in */
14018 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14019 /* route front mic to ADC1*/
14020 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14021 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14022 /* Unmute DAC0~3 & spdif out*/
14023 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14024 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14025 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14026 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14028 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14029 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14030 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14031 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14032 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014033
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014034 /* Unmute Stereo Mixer 15 */
14035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14037 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014038 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014039
14040 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14041 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14042 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14043 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14044 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14045 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14046 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14047 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014048 /* hp used DAC 3 (Front) */
14049 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014050 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14051 { }
14052};
14053
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014054/* additional init verbs for ASUS laptops */
14055static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14056 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14057 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14058 { }
14059};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014060
Kailang Yangdf694da2005-12-05 19:42:22 +010014061/*
14062 * generic initialization of ADC, input mixers and output mixers
14063 */
14064static struct hda_verb alc861_auto_init_verbs[] = {
14065 /*
14066 * Unmute ADC0 and set the default input to mic-in
14067 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014068 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014069 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014070
Kailang Yangdf694da2005-12-05 19:42:22 +010014071 /* Unmute DAC0~3 & spdif out*/
14072 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14073 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14074 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14075 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14076 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014077
Kailang Yangdf694da2005-12-05 19:42:22 +010014078 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14079 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14080 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14081 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14082 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014083
Kailang Yangdf694da2005-12-05 19:42:22 +010014084 /* Unmute Stereo Mixer 15 */
14085 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14086 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14087 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14088 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14089
14090 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14091 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14092 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14093 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14094 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14095 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14096 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14097 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14098
14099 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14100 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014101 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14102 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014103 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14104 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014105 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14106 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014107
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014108 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014109
14110 { }
14111};
14112
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014113static struct hda_verb alc861_toshiba_init_verbs[] = {
14114 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014115
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014116 { }
14117};
14118
14119/* toggle speaker-output according to the hp-jack state */
14120static void alc861_toshiba_automute(struct hda_codec *codec)
14121{
14122 unsigned int present;
14123
14124 present = snd_hda_codec_read(codec, 0x0f, 0,
14125 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014126 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14127 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14128 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14129 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014130}
14131
14132static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14133 unsigned int res)
14134{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014135 if ((res >> 26) == ALC880_HP_EVENT)
14136 alc861_toshiba_automute(codec);
14137}
14138
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014139/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014140#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14141#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14142#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14143#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14144
14145
14146#define ALC861_DIGOUT_NID 0x07
14147
14148static struct hda_channel_mode alc861_8ch_modes[1] = {
14149 { 8, NULL }
14150};
14151
14152static hda_nid_t alc861_dac_nids[4] = {
14153 /* front, surround, clfe, side */
14154 0x03, 0x06, 0x05, 0x04
14155};
14156
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014157static hda_nid_t alc660_dac_nids[3] = {
14158 /* front, clfe, surround */
14159 0x03, 0x05, 0x06
14160};
14161
Kailang Yangdf694da2005-12-05 19:42:22 +010014162static hda_nid_t alc861_adc_nids[1] = {
14163 /* ADC0-2 */
14164 0x08,
14165};
14166
14167static struct hda_input_mux alc861_capture_source = {
14168 .num_items = 5,
14169 .items = {
14170 { "Mic", 0x0 },
14171 { "Front Mic", 0x3 },
14172 { "Line", 0x1 },
14173 { "CD", 0x4 },
14174 { "Mixer", 0x5 },
14175 },
14176};
14177
14178/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014179static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
14180 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014181{
14182 int i;
14183 hda_nid_t nid;
14184
14185 spec->multiout.dac_nids = spec->private_dac_nids;
14186 for (i = 0; i < cfg->line_outs; i++) {
14187 nid = cfg->line_out_pins[i];
14188 if (nid) {
14189 if (i >= ARRAY_SIZE(alc861_dac_nids))
14190 continue;
14191 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
14192 }
14193 }
14194 spec->multiout.num_dacs = cfg->line_outs;
14195 return 0;
14196}
14197
14198/* add playback controls from the parsed DAC table */
14199static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
14200 const struct auto_pin_cfg *cfg)
14201{
14202 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014203 static const char *chname[4] = {
14204 "Front", "Surround", NULL /*CLFE*/, "Side"
14205 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014206 hda_nid_t nid;
14207 int i, idx, err;
14208
14209 for (i = 0; i < cfg->line_outs; i++) {
14210 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014211 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014212 continue;
14213 if (nid == 0x05) {
14214 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014215 err = add_control(spec, ALC_CTL_BIND_MUTE,
14216 "Center Playback Switch",
14217 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14218 HDA_OUTPUT));
14219 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014220 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014221 err = add_control(spec, ALC_CTL_BIND_MUTE,
14222 "LFE Playback Switch",
14223 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14224 HDA_OUTPUT));
14225 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014226 return err;
14227 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014228 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
14229 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010014230 if (nid == alc861_dac_nids[idx])
14231 break;
14232 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014233 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14234 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14235 HDA_OUTPUT));
14236 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014237 return err;
14238 }
14239 }
14240 return 0;
14241}
14242
14243static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
14244{
14245 int err;
14246 hda_nid_t nid;
14247
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014248 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014249 return 0;
14250
14251 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
14252 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014253 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
14254 "Headphone Playback Switch",
14255 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14256 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014257 return err;
14258 spec->multiout.hp_nid = nid;
14259 }
14260 return 0;
14261}
14262
14263/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014264static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
14265 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014266{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014267 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014268 int i, err, idx, idx1;
14269
14270 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014271 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014272 case 0x0c:
14273 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014274 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014275 break;
14276 case 0x0f:
14277 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014278 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014279 break;
14280 case 0x0d:
14281 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014282 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014283 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014284 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014285 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014286 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014287 break;
14288 case 0x11:
14289 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014290 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014291 break;
14292 default:
14293 continue;
14294 }
14295
Takashi Iwai4a471b72005-12-07 13:56:29 +010014296 err = new_analog_input(spec, cfg->input_pins[i],
14297 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014298 if (err < 0)
14299 return err;
14300
Takashi Iwai4a471b72005-12-07 13:56:29 +010014301 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014302 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014303 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014304 }
14305 return 0;
14306}
14307
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014308static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14309 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010014310 int pin_type, int dac_idx)
14311{
Jacek Luczak564c5be2008-05-03 18:41:23 +020014312 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14313 pin_type);
14314 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14315 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010014316}
14317
14318static void alc861_auto_init_multi_out(struct hda_codec *codec)
14319{
14320 struct alc_spec *spec = codec->spec;
14321 int i;
14322
14323 for (i = 0; i < spec->autocfg.line_outs; i++) {
14324 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014325 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014326 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014327 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014328 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014329 }
14330}
14331
14332static void alc861_auto_init_hp_out(struct hda_codec *codec)
14333{
14334 struct alc_spec *spec = codec->spec;
14335 hda_nid_t pin;
14336
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014337 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014338 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014339 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
14340 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014341 pin = spec->autocfg.speaker_pins[0];
14342 if (pin)
14343 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014344}
14345
14346static void alc861_auto_init_analog_input(struct hda_codec *codec)
14347{
14348 struct alc_spec *spec = codec->spec;
14349 int i;
14350
14351 for (i = 0; i < AUTO_PIN_LAST; i++) {
14352 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014353 if (nid >= 0x0c && nid <= 0x11)
14354 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014355 }
14356}
14357
14358/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014359/* return 1 if successful, 0 if the proper config is not found,
14360 * or a negative error code
14361 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014362static int alc861_parse_auto_config(struct hda_codec *codec)
14363{
14364 struct alc_spec *spec = codec->spec;
14365 int err;
14366 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14367
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014368 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14369 alc861_ignore);
14370 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014371 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014372 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014373 return 0; /* can't find valid BIOS pin config */
14374
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014375 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
14376 if (err < 0)
14377 return err;
14378 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
14379 if (err < 0)
14380 return err;
14381 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
14382 if (err < 0)
14383 return err;
14384 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
14385 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014386 return err;
14387
14388 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14389
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014390 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014391 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14392
Takashi Iwai603c4012008-07-30 15:01:44 +020014393 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014394 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014395
Takashi Iwaid88897e2008-10-31 15:01:37 +010014396 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014397
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014398 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014399 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014400
14401 spec->adc_nids = alc861_adc_nids;
14402 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014403 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014404
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014405 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14406
Kailang Yangdf694da2005-12-05 19:42:22 +010014407 return 1;
14408}
14409
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014410/* additional initialization for auto-configuration model */
14411static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014412{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014413 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014414 alc861_auto_init_multi_out(codec);
14415 alc861_auto_init_hp_out(codec);
14416 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014417 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014418 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014419}
14420
Takashi Iwaicb53c622007-08-10 17:21:45 +020014421#ifdef CONFIG_SND_HDA_POWER_SAVE
14422static struct hda_amp_list alc861_loopbacks[] = {
14423 { 0x15, HDA_INPUT, 0 },
14424 { 0x15, HDA_INPUT, 1 },
14425 { 0x15, HDA_INPUT, 2 },
14426 { 0x15, HDA_INPUT, 3 },
14427 { } /* end */
14428};
14429#endif
14430
Kailang Yangdf694da2005-12-05 19:42:22 +010014431
14432/*
14433 * configuration and preset
14434 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014435static const char *alc861_models[ALC861_MODEL_LAST] = {
14436 [ALC861_3ST] = "3stack",
14437 [ALC660_3ST] = "3stack-660",
14438 [ALC861_3ST_DIG] = "3stack-dig",
14439 [ALC861_6ST_DIG] = "6stack-dig",
14440 [ALC861_UNIWILL_M31] = "uniwill-m31",
14441 [ALC861_TOSHIBA] = "toshiba",
14442 [ALC861_ASUS] = "asus",
14443 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14444 [ALC861_AUTO] = "auto",
14445};
14446
14447static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014448 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014449 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14450 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14451 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014452 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014453 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014454 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014455 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14456 * Any other models that need this preset?
14457 */
14458 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014459 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14460 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014461 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14462 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14463 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14464 /* FIXME: the below seems conflict */
14465 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14466 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14467 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014468 {}
14469};
14470
14471static struct alc_config_preset alc861_presets[] = {
14472 [ALC861_3ST] = {
14473 .mixers = { alc861_3ST_mixer },
14474 .init_verbs = { alc861_threestack_init_verbs },
14475 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14476 .dac_nids = alc861_dac_nids,
14477 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14478 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014479 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014480 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14481 .adc_nids = alc861_adc_nids,
14482 .input_mux = &alc861_capture_source,
14483 },
14484 [ALC861_3ST_DIG] = {
14485 .mixers = { alc861_base_mixer },
14486 .init_verbs = { alc861_threestack_init_verbs },
14487 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14488 .dac_nids = alc861_dac_nids,
14489 .dig_out_nid = ALC861_DIGOUT_NID,
14490 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14491 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014492 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014493 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14494 .adc_nids = alc861_adc_nids,
14495 .input_mux = &alc861_capture_source,
14496 },
14497 [ALC861_6ST_DIG] = {
14498 .mixers = { alc861_base_mixer },
14499 .init_verbs = { alc861_base_init_verbs },
14500 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14501 .dac_nids = alc861_dac_nids,
14502 .dig_out_nid = ALC861_DIGOUT_NID,
14503 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14504 .channel_mode = alc861_8ch_modes,
14505 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14506 .adc_nids = alc861_adc_nids,
14507 .input_mux = &alc861_capture_source,
14508 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014509 [ALC660_3ST] = {
14510 .mixers = { alc861_3ST_mixer },
14511 .init_verbs = { alc861_threestack_init_verbs },
14512 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14513 .dac_nids = alc660_dac_nids,
14514 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14515 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014516 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014517 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14518 .adc_nids = alc861_adc_nids,
14519 .input_mux = &alc861_capture_source,
14520 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014521 [ALC861_UNIWILL_M31] = {
14522 .mixers = { alc861_uniwill_m31_mixer },
14523 .init_verbs = { alc861_uniwill_m31_init_verbs },
14524 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14525 .dac_nids = alc861_dac_nids,
14526 .dig_out_nid = ALC861_DIGOUT_NID,
14527 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14528 .channel_mode = alc861_uniwill_m31_modes,
14529 .need_dac_fix = 1,
14530 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14531 .adc_nids = alc861_adc_nids,
14532 .input_mux = &alc861_capture_source,
14533 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014534 [ALC861_TOSHIBA] = {
14535 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014536 .init_verbs = { alc861_base_init_verbs,
14537 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014538 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14539 .dac_nids = alc861_dac_nids,
14540 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14541 .channel_mode = alc883_3ST_2ch_modes,
14542 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14543 .adc_nids = alc861_adc_nids,
14544 .input_mux = &alc861_capture_source,
14545 .unsol_event = alc861_toshiba_unsol_event,
14546 .init_hook = alc861_toshiba_automute,
14547 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014548 [ALC861_ASUS] = {
14549 .mixers = { alc861_asus_mixer },
14550 .init_verbs = { alc861_asus_init_verbs },
14551 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14552 .dac_nids = alc861_dac_nids,
14553 .dig_out_nid = ALC861_DIGOUT_NID,
14554 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14555 .channel_mode = alc861_asus_modes,
14556 .need_dac_fix = 1,
14557 .hp_nid = 0x06,
14558 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14559 .adc_nids = alc861_adc_nids,
14560 .input_mux = &alc861_capture_source,
14561 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014562 [ALC861_ASUS_LAPTOP] = {
14563 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14564 .init_verbs = { alc861_asus_init_verbs,
14565 alc861_asus_laptop_init_verbs },
14566 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14567 .dac_nids = alc861_dac_nids,
14568 .dig_out_nid = ALC861_DIGOUT_NID,
14569 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14570 .channel_mode = alc883_3ST_2ch_modes,
14571 .need_dac_fix = 1,
14572 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14573 .adc_nids = alc861_adc_nids,
14574 .input_mux = &alc861_capture_source,
14575 },
14576};
Kailang Yangdf694da2005-12-05 19:42:22 +010014577
14578
14579static int patch_alc861(struct hda_codec *codec)
14580{
14581 struct alc_spec *spec;
14582 int board_config;
14583 int err;
14584
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014585 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014586 if (spec == NULL)
14587 return -ENOMEM;
14588
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014589 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014590
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014591 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14592 alc861_models,
14593 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014594
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014595 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020014596 printk(KERN_INFO "hda_codec: Unknown model for %s, "
14597 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014598 board_config = ALC861_AUTO;
14599 }
14600
14601 if (board_config == ALC861_AUTO) {
14602 /* automatic parse from the BIOS config */
14603 err = alc861_parse_auto_config(codec);
14604 if (err < 0) {
14605 alc_free(codec);
14606 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014607 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014608 printk(KERN_INFO
14609 "hda_codec: Cannot set up configuration "
14610 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014611 board_config = ALC861_3ST_DIG;
14612 }
14613 }
14614
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014615 err = snd_hda_attach_beep_device(codec, 0x23);
14616 if (err < 0) {
14617 alc_free(codec);
14618 return err;
14619 }
14620
Kailang Yangdf694da2005-12-05 19:42:22 +010014621 if (board_config != ALC861_AUTO)
14622 setup_preset(spec, &alc861_presets[board_config]);
14623
Kailang Yangdf694da2005-12-05 19:42:22 +010014624 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14625 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14626
Kailang Yangdf694da2005-12-05 19:42:22 +010014627 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14628 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14629
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014630 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14631
Takashi Iwai2134ea42008-01-10 16:53:55 +010014632 spec->vmaster_nid = 0x03;
14633
Kailang Yangdf694da2005-12-05 19:42:22 +010014634 codec->patch_ops = alc_patch_ops;
14635 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014636 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014637#ifdef CONFIG_SND_HDA_POWER_SAVE
14638 if (!spec->loopback.amplist)
14639 spec->loopback.amplist = alc861_loopbacks;
14640#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014641 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014642
Kailang Yangdf694da2005-12-05 19:42:22 +010014643 return 0;
14644}
14645
14646/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014647 * ALC861-VD support
14648 *
14649 * Based on ALC882
14650 *
14651 * In addition, an independent DAC
14652 */
14653#define ALC861VD_DIGOUT_NID 0x06
14654
14655static hda_nid_t alc861vd_dac_nids[4] = {
14656 /* front, surr, clfe, side surr */
14657 0x02, 0x03, 0x04, 0x05
14658};
14659
14660/* dac_nids for ALC660vd are in a different order - according to
14661 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014662 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014663 * of ALC660vd codecs, but for now there is only 3stack mixer
14664 * - and it is the same as in 861vd.
14665 * adc_nids in ALC660vd are (is) the same as in 861vd
14666 */
14667static hda_nid_t alc660vd_dac_nids[3] = {
14668 /* front, rear, clfe, rear_surr */
14669 0x02, 0x04, 0x03
14670};
14671
14672static hda_nid_t alc861vd_adc_nids[1] = {
14673 /* ADC0 */
14674 0x09,
14675};
14676
Takashi Iwaie1406342008-02-11 18:32:32 +010014677static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14678
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014679/* input MUX */
14680/* FIXME: should be a matrix-type input source selection */
14681static struct hda_input_mux alc861vd_capture_source = {
14682 .num_items = 4,
14683 .items = {
14684 { "Mic", 0x0 },
14685 { "Front Mic", 0x1 },
14686 { "Line", 0x2 },
14687 { "CD", 0x4 },
14688 },
14689};
14690
Kailang Yang272a5272007-05-14 11:00:38 +020014691static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014692 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014693 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014694 { "Ext Mic", 0x0 },
14695 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014696 },
14697};
14698
Kailang Yangd1a991a2007-08-15 16:21:59 +020014699static struct hda_input_mux alc861vd_hp_capture_source = {
14700 .num_items = 2,
14701 .items = {
14702 { "Front Mic", 0x0 },
14703 { "ATAPI Mic", 0x1 },
14704 },
14705};
14706
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014707/*
14708 * 2ch mode
14709 */
14710static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14711 { 2, NULL }
14712};
14713
14714/*
14715 * 6ch mode
14716 */
14717static struct hda_verb alc861vd_6stack_ch6_init[] = {
14718 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14719 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14720 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14721 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14722 { } /* end */
14723};
14724
14725/*
14726 * 8ch mode
14727 */
14728static struct hda_verb alc861vd_6stack_ch8_init[] = {
14729 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14730 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14731 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14732 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14733 { } /* end */
14734};
14735
14736static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14737 { 6, alc861vd_6stack_ch6_init },
14738 { 8, alc861vd_6stack_ch8_init },
14739};
14740
14741static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14742 {
14743 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14744 .name = "Channel Mode",
14745 .info = alc_ch_mode_info,
14746 .get = alc_ch_mode_get,
14747 .put = alc_ch_mode_put,
14748 },
14749 { } /* end */
14750};
14751
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014752/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14753 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14754 */
14755static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14756 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14757 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14758
14759 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14760 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14761
14762 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14763 HDA_OUTPUT),
14764 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14765 HDA_OUTPUT),
14766 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14767 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14768
14769 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14770 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14771
14772 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14773
14774 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14775 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14776 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14777
14778 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14779 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14780 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14781
14782 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14783 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14784
14785 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14786 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14787
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014788 { } /* end */
14789};
14790
14791static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14792 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14793 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14794
14795 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14796
14797 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14798 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14799 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14800
14801 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14802 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14803 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14804
14805 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14806 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14807
14808 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14809 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14810
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014811 { } /* end */
14812};
14813
Kailang Yangbdd148a2007-05-08 15:19:08 +020014814static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14815 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14816 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14817 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14818
14819 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14820
14821 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14822 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14823 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14824
14825 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14826 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14827 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14828
14829 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14830 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14831
14832 { } /* end */
14833};
14834
Tobin Davisb419f342008-03-07 11:57:51 +010014835/* Pin assignment: Speaker=0x14, HP = 0x15,
14836 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014837 */
14838static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014839 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14840 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014841 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14842 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014843 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14844 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14845 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14846 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14847 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14848 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014849 { } /* end */
14850};
14851
Kailang Yangd1a991a2007-08-15 16:21:59 +020014852/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14853 * Front Mic=0x18, ATAPI Mic = 0x19,
14854 */
14855static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14856 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14857 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14858 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14859 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14860 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14861 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14862 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14863 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014864
Kailang Yangd1a991a2007-08-15 16:21:59 +020014865 { } /* end */
14866};
14867
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014868/*
14869 * generic initialization of ADC, input mixers and output mixers
14870 */
14871static struct hda_verb alc861vd_volume_init_verbs[] = {
14872 /*
14873 * Unmute ADC0 and set the default input to mic-in
14874 */
14875 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14876 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14877
14878 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14879 * the analog-loopback mixer widget
14880 */
14881 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014882 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14883 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14884 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14885 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14886 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014887
14888 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014889 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14890 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14891 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014892 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014893
14894 /*
14895 * Set up output mixers (0x02 - 0x05)
14896 */
14897 /* set vol=0 to output mixers */
14898 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14899 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14900 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14901 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14902
14903 /* set up input amps for analog loopback */
14904 /* Amp Indices: DAC = 0, mixer = 1 */
14905 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14906 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14907 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14908 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14909 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14910 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14911 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14912 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14913
14914 { }
14915};
14916
14917/*
14918 * 3-stack pin configuration:
14919 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14920 */
14921static struct hda_verb alc861vd_3stack_init_verbs[] = {
14922 /*
14923 * Set pin mode and muting
14924 */
14925 /* set front pin widgets 0x14 for output */
14926 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14927 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14928 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14929
14930 /* Mic (rear) pin: input vref at 80% */
14931 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14932 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14933 /* Front Mic pin: input vref at 80% */
14934 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14935 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14936 /* Line In pin: input */
14937 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14938 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14939 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14940 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14941 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14942 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14943 /* CD pin widget for input */
14944 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14945
14946 { }
14947};
14948
14949/*
14950 * 6-stack pin configuration:
14951 */
14952static struct hda_verb alc861vd_6stack_init_verbs[] = {
14953 /*
14954 * Set pin mode and muting
14955 */
14956 /* set front pin widgets 0x14 for output */
14957 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14958 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14959 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14960
14961 /* Rear Pin: output 1 (0x0d) */
14962 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14963 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14964 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14965 /* CLFE Pin: output 2 (0x0e) */
14966 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14967 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14968 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14969 /* Side Pin: output 3 (0x0f) */
14970 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14971 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14972 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14973
14974 /* Mic (rear) pin: input vref at 80% */
14975 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14976 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14977 /* Front Mic pin: input vref at 80% */
14978 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14979 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14980 /* Line In pin: input */
14981 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14982 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14983 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14984 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14985 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14986 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14987 /* CD pin widget for input */
14988 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14989
14990 { }
14991};
14992
Kailang Yangbdd148a2007-05-08 15:19:08 +020014993static struct hda_verb alc861vd_eapd_verbs[] = {
14994 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14995 { }
14996};
14997
Kailang Yangf9423e72008-05-27 12:32:25 +020014998static struct hda_verb alc660vd_eapd_verbs[] = {
14999 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15000 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15001 { }
15002};
15003
Kailang Yangbdd148a2007-05-08 15:19:08 +020015004static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15005 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15006 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15007 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15008 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015009 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015010 {}
15011};
15012
Kailang Yangbdd148a2007-05-08 15:19:08 +020015013static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15014{
15015 unsigned int present;
15016 unsigned char bits;
15017
15018 present = snd_hda_codec_read(codec, 0x18, 0,
15019 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015020 bits = present ? HDA_AMP_MUTE : 0;
15021 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15022 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015023}
15024
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015025static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015026{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015027 struct alc_spec *spec = codec->spec;
15028
15029 spec->autocfg.hp_pins[0] = 0x1b;
15030 spec->autocfg.speaker_pins[0] = 0x14;
15031 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015032 alc861vd_lenovo_mic_automute(codec);
15033}
15034
15035static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15036 unsigned int res)
15037{
15038 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015039 case ALC880_MIC_EVENT:
15040 alc861vd_lenovo_mic_automute(codec);
15041 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015042 default:
15043 alc_automute_amp_unsol_event(codec, res);
15044 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015045 }
15046}
15047
Kailang Yang272a5272007-05-14 11:00:38 +020015048static struct hda_verb alc861vd_dallas_verbs[] = {
15049 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15050 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15051 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15052 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15053
15054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15056 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15057 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15058 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15059 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15060 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15061 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015062
Kailang Yang272a5272007-05-14 11:00:38 +020015063 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15064 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15065 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15067 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15068 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15069 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15070 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15071
15072 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15073 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15074 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15075 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15076 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15077 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15078 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15079 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15080
15081 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15082 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15084 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15085
15086 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015087 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015088 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15089
15090 { } /* end */
15091};
15092
15093/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015094static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015095{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015096 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015097
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015098 spec->autocfg.hp_pins[0] = 0x15;
15099 spec->autocfg.speaker_pins[0] = 0x14;
15100 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020015101}
15102
Takashi Iwaicb53c622007-08-10 17:21:45 +020015103#ifdef CONFIG_SND_HDA_POWER_SAVE
15104#define alc861vd_loopbacks alc880_loopbacks
15105#endif
15106
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015107/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015108#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15109#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15110#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15111#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15112
15113/*
15114 * configuration and preset
15115 */
15116static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15117 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015118 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015119 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015120 [ALC861VD_3ST] = "3stack",
15121 [ALC861VD_3ST_DIG] = "3stack-digout",
15122 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015123 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015124 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015125 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015126 [ALC861VD_AUTO] = "auto",
15127};
15128
15129static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015130 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15131 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015132 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015133 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010015134 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015135 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015136 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015137 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015138 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020015139 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015140 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015141 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015142 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015143 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015144 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015145 {}
15146};
15147
15148static struct alc_config_preset alc861vd_presets[] = {
15149 [ALC660VD_3ST] = {
15150 .mixers = { alc861vd_3st_mixer },
15151 .init_verbs = { alc861vd_volume_init_verbs,
15152 alc861vd_3stack_init_verbs },
15153 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15154 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015155 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15156 .channel_mode = alc861vd_3stack_2ch_modes,
15157 .input_mux = &alc861vd_capture_source,
15158 },
Mike Crash6963f842007-06-25 12:12:51 +020015159 [ALC660VD_3ST_DIG] = {
15160 .mixers = { alc861vd_3st_mixer },
15161 .init_verbs = { alc861vd_volume_init_verbs,
15162 alc861vd_3stack_init_verbs },
15163 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15164 .dac_nids = alc660vd_dac_nids,
15165 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015166 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15167 .channel_mode = alc861vd_3stack_2ch_modes,
15168 .input_mux = &alc861vd_capture_source,
15169 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015170 [ALC861VD_3ST] = {
15171 .mixers = { alc861vd_3st_mixer },
15172 .init_verbs = { alc861vd_volume_init_verbs,
15173 alc861vd_3stack_init_verbs },
15174 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15175 .dac_nids = alc861vd_dac_nids,
15176 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15177 .channel_mode = alc861vd_3stack_2ch_modes,
15178 .input_mux = &alc861vd_capture_source,
15179 },
15180 [ALC861VD_3ST_DIG] = {
15181 .mixers = { alc861vd_3st_mixer },
15182 .init_verbs = { alc861vd_volume_init_verbs,
15183 alc861vd_3stack_init_verbs },
15184 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15185 .dac_nids = alc861vd_dac_nids,
15186 .dig_out_nid = ALC861VD_DIGOUT_NID,
15187 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15188 .channel_mode = alc861vd_3stack_2ch_modes,
15189 .input_mux = &alc861vd_capture_source,
15190 },
15191 [ALC861VD_6ST_DIG] = {
15192 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15193 .init_verbs = { alc861vd_volume_init_verbs,
15194 alc861vd_6stack_init_verbs },
15195 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15196 .dac_nids = alc861vd_dac_nids,
15197 .dig_out_nid = ALC861VD_DIGOUT_NID,
15198 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15199 .channel_mode = alc861vd_6stack_modes,
15200 .input_mux = &alc861vd_capture_source,
15201 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015202 [ALC861VD_LENOVO] = {
15203 .mixers = { alc861vd_lenovo_mixer },
15204 .init_verbs = { alc861vd_volume_init_verbs,
15205 alc861vd_3stack_init_verbs,
15206 alc861vd_eapd_verbs,
15207 alc861vd_lenovo_unsol_verbs },
15208 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15209 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015210 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15211 .channel_mode = alc861vd_3stack_2ch_modes,
15212 .input_mux = &alc861vd_capture_source,
15213 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015214 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015215 },
Kailang Yang272a5272007-05-14 11:00:38 +020015216 [ALC861VD_DALLAS] = {
15217 .mixers = { alc861vd_dallas_mixer },
15218 .init_verbs = { alc861vd_dallas_verbs },
15219 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15220 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015221 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15222 .channel_mode = alc861vd_3stack_2ch_modes,
15223 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015224 .unsol_event = alc_automute_amp_unsol_event,
15225 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015226 },
15227 [ALC861VD_HP] = {
15228 .mixers = { alc861vd_hp_mixer },
15229 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15230 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15231 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015232 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015233 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15234 .channel_mode = alc861vd_3stack_2ch_modes,
15235 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015236 .unsol_event = alc_automute_amp_unsol_event,
15237 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020015238 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015239 [ALC660VD_ASUS_V1S] = {
15240 .mixers = { alc861vd_lenovo_mixer },
15241 .init_verbs = { alc861vd_volume_init_verbs,
15242 alc861vd_3stack_init_verbs,
15243 alc861vd_eapd_verbs,
15244 alc861vd_lenovo_unsol_verbs },
15245 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15246 .dac_nids = alc660vd_dac_nids,
15247 .dig_out_nid = ALC861VD_DIGOUT_NID,
15248 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15249 .channel_mode = alc861vd_3stack_2ch_modes,
15250 .input_mux = &alc861vd_capture_source,
15251 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015252 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015253 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015254};
15255
15256/*
15257 * BIOS auto configuration
15258 */
15259static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15260 hda_nid_t nid, int pin_type, int dac_idx)
15261{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015262 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015263}
15264
15265static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15266{
15267 struct alc_spec *spec = codec->spec;
15268 int i;
15269
15270 for (i = 0; i <= HDA_SIDE; i++) {
15271 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015272 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015273 if (nid)
15274 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015275 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015276 }
15277}
15278
15279
15280static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15281{
15282 struct alc_spec *spec = codec->spec;
15283 hda_nid_t pin;
15284
15285 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015286 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015287 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015288 pin = spec->autocfg.speaker_pins[0];
15289 if (pin)
15290 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015291}
15292
15293#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15294#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15295
15296static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15297{
15298 struct alc_spec *spec = codec->spec;
15299 int i;
15300
15301 for (i = 0; i < AUTO_PIN_LAST; i++) {
15302 hda_nid_t nid = spec->autocfg.input_pins[i];
15303 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015304 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015305 if (nid != ALC861VD_PIN_CD_NID &&
15306 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015307 snd_hda_codec_write(codec, nid, 0,
15308 AC_VERB_SET_AMP_GAIN_MUTE,
15309 AMP_OUT_MUTE);
15310 }
15311 }
15312}
15313
Takashi Iwaif511b012008-08-15 16:46:42 +020015314#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15315
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015316#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15317#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15318
15319/* add playback controls from the parsed DAC table */
15320/* Based on ALC880 version. But ALC861VD has separate,
15321 * different NIDs for mute/unmute switch and volume control */
15322static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15323 const struct auto_pin_cfg *cfg)
15324{
15325 char name[32];
15326 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15327 hda_nid_t nid_v, nid_s;
15328 int i, err;
15329
15330 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015331 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015332 continue;
15333 nid_v = alc861vd_idx_to_mixer_vol(
15334 alc880_dac_to_idx(
15335 spec->multiout.dac_nids[i]));
15336 nid_s = alc861vd_idx_to_mixer_switch(
15337 alc880_dac_to_idx(
15338 spec->multiout.dac_nids[i]));
15339
15340 if (i == 2) {
15341 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015342 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15343 "Center Playback Volume",
15344 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15345 HDA_OUTPUT));
15346 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015347 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015348 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15349 "LFE Playback Volume",
15350 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15351 HDA_OUTPUT));
15352 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015353 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015354 err = add_control(spec, ALC_CTL_BIND_MUTE,
15355 "Center Playback Switch",
15356 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15357 HDA_INPUT));
15358 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015359 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015360 err = add_control(spec, ALC_CTL_BIND_MUTE,
15361 "LFE Playback Switch",
15362 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15363 HDA_INPUT));
15364 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015365 return err;
15366 } else {
15367 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015368 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15369 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15370 HDA_OUTPUT));
15371 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015372 return err;
15373 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015374 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015375 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015376 HDA_INPUT));
15377 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015378 return err;
15379 }
15380 }
15381 return 0;
15382}
15383
15384/* add playback controls for speaker and HP outputs */
15385/* Based on ALC880 version. But ALC861VD has separate,
15386 * different NIDs for mute/unmute switch and volume control */
15387static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15388 hda_nid_t pin, const char *pfx)
15389{
15390 hda_nid_t nid_v, nid_s;
15391 int err;
15392 char name[32];
15393
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015394 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015395 return 0;
15396
15397 if (alc880_is_fixed_pin(pin)) {
15398 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15399 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015400 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015401 spec->multiout.hp_nid = nid_v;
15402 else
15403 spec->multiout.extra_out_nid[0] = nid_v;
15404 /* control HP volume/switch on the output mixer amp */
15405 nid_v = alc861vd_idx_to_mixer_vol(
15406 alc880_fixed_pin_idx(pin));
15407 nid_s = alc861vd_idx_to_mixer_switch(
15408 alc880_fixed_pin_idx(pin));
15409
15410 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015411 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15412 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15413 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015414 return err;
15415 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015416 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15417 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15418 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015419 return err;
15420 } else if (alc880_is_multi_pin(pin)) {
15421 /* set manual connection */
15422 /* we have only a switch on HP-out PIN */
15423 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015424 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15425 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15426 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015427 return err;
15428 }
15429 return 0;
15430}
15431
15432/* parse the BIOS configuration and set up the alc_spec
15433 * return 1 if successful, 0 if the proper config is not found,
15434 * or a negative error code
15435 * Based on ALC880 version - had to change it to override
15436 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15437static int alc861vd_parse_auto_config(struct hda_codec *codec)
15438{
15439 struct alc_spec *spec = codec->spec;
15440 int err;
15441 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15442
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015443 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15444 alc861vd_ignore);
15445 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015446 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015447 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015448 return 0; /* can't find valid BIOS pin config */
15449
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015450 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15451 if (err < 0)
15452 return err;
15453 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15454 if (err < 0)
15455 return err;
15456 err = alc861vd_auto_create_extra_out(spec,
15457 spec->autocfg.speaker_pins[0],
15458 "Speaker");
15459 if (err < 0)
15460 return err;
15461 err = alc861vd_auto_create_extra_out(spec,
15462 spec->autocfg.hp_pins[0],
15463 "Headphone");
15464 if (err < 0)
15465 return err;
15466 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15467 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015468 return err;
15469
15470 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15471
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015472 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015473 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15474
Takashi Iwai603c4012008-07-30 15:01:44 +020015475 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015476 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015477
Takashi Iwaid88897e2008-10-31 15:01:37 +010015478 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015479
15480 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015481 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015482
Takashi Iwai776e1842007-08-29 15:07:11 +020015483 err = alc_auto_add_mic_boost(codec);
15484 if (err < 0)
15485 return err;
15486
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015487 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15488
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015489 return 1;
15490}
15491
15492/* additional initialization for auto-configuration model */
15493static void alc861vd_auto_init(struct hda_codec *codec)
15494{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015495 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015496 alc861vd_auto_init_multi_out(codec);
15497 alc861vd_auto_init_hp_out(codec);
15498 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015499 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015500 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015501 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015502}
15503
15504static int patch_alc861vd(struct hda_codec *codec)
15505{
15506 struct alc_spec *spec;
15507 int err, board_config;
15508
15509 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15510 if (spec == NULL)
15511 return -ENOMEM;
15512
15513 codec->spec = spec;
15514
15515 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15516 alc861vd_models,
15517 alc861vd_cfg_tbl);
15518
15519 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020015520 printk(KERN_INFO "hda_codec: Unknown model for %s, "
15521 "trying auto-probe from BIOS...\n", codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015522 board_config = ALC861VD_AUTO;
15523 }
15524
15525 if (board_config == ALC861VD_AUTO) {
15526 /* automatic parse from the BIOS config */
15527 err = alc861vd_parse_auto_config(codec);
15528 if (err < 0) {
15529 alc_free(codec);
15530 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015531 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015532 printk(KERN_INFO
15533 "hda_codec: Cannot set up configuration "
15534 "from BIOS. Using base mode...\n");
15535 board_config = ALC861VD_3ST;
15536 }
15537 }
15538
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015539 err = snd_hda_attach_beep_device(codec, 0x23);
15540 if (err < 0) {
15541 alc_free(codec);
15542 return err;
15543 }
15544
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015545 if (board_config != ALC861VD_AUTO)
15546 setup_preset(spec, &alc861vd_presets[board_config]);
15547
Kailang Yang2f893282008-05-27 12:14:47 +020015548 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015549 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015550 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015551 }
15552
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015553 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15554 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15555
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015556 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15557 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15558
15559 spec->adc_nids = alc861vd_adc_nids;
15560 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015561 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015562
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015563 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015564 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015565
Takashi Iwai2134ea42008-01-10 16:53:55 +010015566 spec->vmaster_nid = 0x02;
15567
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015568 codec->patch_ops = alc_patch_ops;
15569
15570 if (board_config == ALC861VD_AUTO)
15571 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015572#ifdef CONFIG_SND_HDA_POWER_SAVE
15573 if (!spec->loopback.amplist)
15574 spec->loopback.amplist = alc861vd_loopbacks;
15575#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015576 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015577
15578 return 0;
15579}
15580
15581/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015582 * ALC662 support
15583 *
15584 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15585 * configuration. Each pin widget can choose any input DACs and a mixer.
15586 * Each ADC is connected from a mixer of all inputs. This makes possible
15587 * 6-channel independent captures.
15588 *
15589 * In addition, an independent DAC for the multi-playback (not used in this
15590 * driver yet).
15591 */
15592#define ALC662_DIGOUT_NID 0x06
15593#define ALC662_DIGIN_NID 0x0a
15594
15595static hda_nid_t alc662_dac_nids[4] = {
15596 /* front, rear, clfe, rear_surr */
15597 0x02, 0x03, 0x04
15598};
15599
Kailang Yang622e84c2009-04-21 07:39:04 +020015600static hda_nid_t alc272_dac_nids[2] = {
15601 0x02, 0x03
15602};
15603
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015604static hda_nid_t alc662_adc_nids[1] = {
15605 /* ADC1-2 */
15606 0x09,
15607};
Takashi Iwaie1406342008-02-11 18:32:32 +010015608
Kailang Yang622e84c2009-04-21 07:39:04 +020015609static hda_nid_t alc272_adc_nids[1] = {
15610 /* ADC1-2 */
15611 0x08,
15612};
15613
Kailang Yang77a261b2008-02-19 11:38:05 +010015614static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015615static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15616
Takashi Iwaie1406342008-02-11 18:32:32 +010015617
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015618/* input MUX */
15619/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015620static struct hda_input_mux alc662_capture_source = {
15621 .num_items = 4,
15622 .items = {
15623 { "Mic", 0x0 },
15624 { "Front Mic", 0x1 },
15625 { "Line", 0x2 },
15626 { "CD", 0x4 },
15627 },
15628};
15629
15630static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15631 .num_items = 2,
15632 .items = {
15633 { "Mic", 0x1 },
15634 { "Line", 0x2 },
15635 },
15636};
Kailang Yang291702f2007-10-16 14:28:03 +020015637
15638static struct hda_input_mux alc662_eeepc_capture_source = {
15639 .num_items = 2,
15640 .items = {
15641 { "i-Mic", 0x1 },
15642 { "e-Mic", 0x0 },
15643 },
15644};
15645
Kailang Yang6dda9f42008-05-27 12:05:31 +020015646static struct hda_input_mux alc663_capture_source = {
15647 .num_items = 3,
15648 .items = {
15649 { "Mic", 0x0 },
15650 { "Front Mic", 0x1 },
15651 { "Line", 0x2 },
15652 },
15653};
15654
15655static struct hda_input_mux alc663_m51va_capture_source = {
15656 .num_items = 2,
15657 .items = {
15658 { "Ext-Mic", 0x0 },
15659 { "D-Mic", 0x9 },
15660 },
15661};
15662
Chris Pockelé9541ba12009-05-12 08:08:53 +020015663#if 1 /* set to 0 for testing other input sources below */
15664static struct hda_input_mux alc272_nc10_capture_source = {
15665 .num_items = 2,
15666 .items = {
15667 { "Autoselect Mic", 0x0 },
15668 { "Internal Mic", 0x1 },
15669 },
15670};
15671#else
15672static struct hda_input_mux alc272_nc10_capture_source = {
15673 .num_items = 16,
15674 .items = {
15675 { "Autoselect Mic", 0x0 },
15676 { "Internal Mic", 0x1 },
15677 { "In-0x02", 0x2 },
15678 { "In-0x03", 0x3 },
15679 { "In-0x04", 0x4 },
15680 { "In-0x05", 0x5 },
15681 { "In-0x06", 0x6 },
15682 { "In-0x07", 0x7 },
15683 { "In-0x08", 0x8 },
15684 { "In-0x09", 0x9 },
15685 { "In-0x0a", 0x0a },
15686 { "In-0x0b", 0x0b },
15687 { "In-0x0c", 0x0c },
15688 { "In-0x0d", 0x0d },
15689 { "In-0x0e", 0x0e },
15690 { "In-0x0f", 0x0f },
15691 },
15692};
15693#endif
15694
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015695/*
15696 * 2ch mode
15697 */
15698static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15699 { 2, NULL }
15700};
15701
15702/*
15703 * 2ch mode
15704 */
15705static struct hda_verb alc662_3ST_ch2_init[] = {
15706 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15707 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15708 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15709 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15710 { } /* end */
15711};
15712
15713/*
15714 * 6ch mode
15715 */
15716static struct hda_verb alc662_3ST_ch6_init[] = {
15717 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15718 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15719 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15720 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15721 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15722 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15723 { } /* end */
15724};
15725
15726static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15727 { 2, alc662_3ST_ch2_init },
15728 { 6, alc662_3ST_ch6_init },
15729};
15730
15731/*
15732 * 2ch mode
15733 */
15734static struct hda_verb alc662_sixstack_ch6_init[] = {
15735 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15736 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15737 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15738 { } /* end */
15739};
15740
15741/*
15742 * 6ch mode
15743 */
15744static struct hda_verb alc662_sixstack_ch8_init[] = {
15745 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15746 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15747 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15748 { } /* end */
15749};
15750
15751static struct hda_channel_mode alc662_5stack_modes[2] = {
15752 { 2, alc662_sixstack_ch6_init },
15753 { 6, alc662_sixstack_ch8_init },
15754};
15755
15756/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15757 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15758 */
15759
15760static struct snd_kcontrol_new alc662_base_mixer[] = {
15761 /* output mixer control */
15762 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015763 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015764 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015765 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015766 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15767 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015768 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15769 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15771
15772 /*Input mixer control */
15773 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15774 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15775 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15776 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15777 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15778 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15779 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15780 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015781 { } /* end */
15782};
15783
15784static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15785 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015786 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015787 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15788 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15789 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15790 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15791 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15792 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15793 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15794 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15795 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015796 { } /* end */
15797};
15798
15799static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15800 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015801 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015802 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015803 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015804 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15805 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015806 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15807 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015808 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15809 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15810 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15811 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15812 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15813 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15814 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15815 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15816 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015817 { } /* end */
15818};
15819
15820static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15821 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15822 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015823 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15824 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015825 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15826 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15827 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15828 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15829 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015830 { } /* end */
15831};
15832
Kailang Yang291702f2007-10-16 14:28:03 +020015833static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015834 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15835 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015836
15837 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15838 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15839 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15840
15841 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15842 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15843 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15844 { } /* end */
15845};
15846
Kailang Yang8c427222008-01-10 13:03:59 +010015847static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015848 ALC262_HIPPO_MASTER_SWITCH,
15849 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015850 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015851 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15852 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015853 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15854 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15855 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15856 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15858 { } /* end */
15859};
15860
Kailang Yangf1d4e282008-08-26 14:03:29 +020015861static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15862 .ops = &snd_hda_bind_vol,
15863 .values = {
15864 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15865 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15866 0
15867 },
15868};
15869
15870static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15871 .ops = &snd_hda_bind_sw,
15872 .values = {
15873 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15874 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15875 0
15876 },
15877};
15878
Kailang Yang6dda9f42008-05-27 12:05:31 +020015879static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015880 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15881 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15882 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15883 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15884 { } /* end */
15885};
15886
15887static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15888 .ops = &snd_hda_bind_sw,
15889 .values = {
15890 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15891 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15892 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15893 0
15894 },
15895};
15896
15897static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15898 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15899 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15900 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15901 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15902 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15903 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15904
15905 { } /* end */
15906};
15907
15908static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15909 .ops = &snd_hda_bind_sw,
15910 .values = {
15911 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15912 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15913 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15914 0
15915 },
15916};
15917
15918static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15919 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15920 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15921 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15922 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15923 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15924 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15925 { } /* end */
15926};
15927
15928static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015929 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15930 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015931 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15932 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15933 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15934 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15935 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15936 { } /* end */
15937};
15938
15939static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15940 .ops = &snd_hda_bind_vol,
15941 .values = {
15942 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15943 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15944 0
15945 },
15946};
15947
15948static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15949 .ops = &snd_hda_bind_sw,
15950 .values = {
15951 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15952 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15953 0
15954 },
15955};
15956
15957static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15958 HDA_BIND_VOL("Master Playback Volume",
15959 &alc663_asus_two_bind_master_vol),
15960 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15961 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015962 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15963 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15964 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015965 { } /* end */
15966};
15967
15968static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15969 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15970 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15971 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15972 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15974 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015975 { } /* end */
15976};
15977
15978static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15979 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15980 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15981 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15982 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15983 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15984
15985 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15986 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15987 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15988 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15989 { } /* end */
15990};
15991
15992static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15993 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15994 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15995 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15996
15997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15999 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16000 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16001 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16002 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16003 { } /* end */
16004};
16005
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016006static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16007 {
16008 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16009 .name = "Channel Mode",
16010 .info = alc_ch_mode_info,
16011 .get = alc_ch_mode_get,
16012 .put = alc_ch_mode_put,
16013 },
16014 { } /* end */
16015};
16016
16017static struct hda_verb alc662_init_verbs[] = {
16018 /* ADC: mute amp left and right */
16019 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16020 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16021 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16022
Takashi Iwaicb53c622007-08-10 17:21:45 +020016023 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16024 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16025 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16026 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16027 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016028
Kailang Yangb60dd392007-09-20 12:50:29 +020016029 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16030 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16031 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16032 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16033 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16034 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016035
16036 /* Front Pin: output 0 (0x0c) */
16037 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16038 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16039
16040 /* Rear Pin: output 1 (0x0d) */
16041 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16042 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16043
16044 /* CLFE Pin: output 2 (0x0e) */
16045 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16046 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16047
16048 /* Mic (rear) pin: input vref at 80% */
16049 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16050 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16051 /* Front Mic pin: input vref at 80% */
16052 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16053 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16054 /* Line In pin: input */
16055 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16056 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16057 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16058 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16059 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16060 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16061 /* CD pin widget for input */
16062 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16063
16064 /* FIXME: use matrix-type input source selection */
16065 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16066 /* Input mixer */
16067 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016069
16070 /* always trun on EAPD */
16071 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16072 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16073
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016074 { }
16075};
16076
16077static struct hda_verb alc662_sue_init_verbs[] = {
16078 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16079 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016080 {}
16081};
16082
16083static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16084 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16085 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16086 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016087};
16088
Kailang Yang8c427222008-01-10 13:03:59 +010016089/* Set Unsolicited Event*/
16090static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16091 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16092 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16093 {}
16094};
16095
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016096/*
16097 * generic initialization of ADC, input mixers and output mixers
16098 */
16099static struct hda_verb alc662_auto_init_verbs[] = {
16100 /*
16101 * Unmute ADC and set the default input to mic-in
16102 */
16103 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16104 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16105
16106 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16107 * mixer widget
16108 * Note: PASD motherboards uses the Line In 2 as the input for front
16109 * panel mic (mic 2)
16110 */
16111 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016117
16118 /*
16119 * Set up output mixers (0x0c - 0x0f)
16120 */
16121 /* set vol=0 to output mixers */
16122 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16123 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16124 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16125
16126 /* set up input amps for analog loopback */
16127 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016128 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16130 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16131 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16132 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16133 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016134
16135
16136 /* FIXME: use matrix-type input source selection */
16137 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16138 /* Input mixer */
16139 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016140 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016141 { }
16142};
16143
Takashi Iwai24fb9172008-09-02 14:48:20 +020016144/* additional verbs for ALC663 */
16145static struct hda_verb alc663_auto_init_verbs[] = {
16146 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16147 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16148 { }
16149};
16150
Kailang Yang6dda9f42008-05-27 12:05:31 +020016151static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016152 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16153 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016154 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16155 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016156 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16157 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16158 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016159 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16160 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16161 {}
16162};
16163
Kailang Yangf1d4e282008-08-26 14:03:29 +020016164static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16165 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16166 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16167 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16168 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16169 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16170 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16171 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16172 {}
16173};
16174
16175static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16176 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16177 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16178 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16179 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16180 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16181 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16182 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16183 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16184 {}
16185};
16186
16187static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16188 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16190 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16191 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16192 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16193 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16194 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16195 {}
16196};
16197
16198static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16199 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16200 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16201 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16202 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16203 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16204 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16205 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16206 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16207 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16208 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16209 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16210 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16211 {}
16212};
16213
16214static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16215 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16216 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16217 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16218 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16219 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16221 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16222 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16223 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16224 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16225 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16226 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16227 {}
16228};
16229
Kailang Yang6dda9f42008-05-27 12:05:31 +020016230static struct hda_verb alc663_g71v_init_verbs[] = {
16231 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16232 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16233 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16234
16235 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16236 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16237 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16238
16239 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16240 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16241 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16242 {}
16243};
16244
16245static struct hda_verb alc663_g50v_init_verbs[] = {
16246 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16247 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16248 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16249
16250 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16251 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16252 {}
16253};
16254
Kailang Yangf1d4e282008-08-26 14:03:29 +020016255static struct hda_verb alc662_ecs_init_verbs[] = {
16256 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16257 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16258 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16259 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16260 {}
16261};
16262
Kailang Yang622e84c2009-04-21 07:39:04 +020016263static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16264 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16265 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16266 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16267 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16268 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16269 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16270 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16271 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16272 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16273 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16274 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16275 {}
16276};
16277
16278static struct hda_verb alc272_dell_init_verbs[] = {
16279 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16280 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16281 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16282 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16283 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16284 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16285 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16286 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16287 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16288 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16289 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16290 {}
16291};
16292
Kailang Yangf1d4e282008-08-26 14:03:29 +020016293static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16294 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16295 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16296 { } /* end */
16297};
16298
Kailang Yang622e84c2009-04-21 07:39:04 +020016299static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16300 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16301 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16302 { } /* end */
16303};
16304
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016305static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16306{
16307 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016308 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016309
16310 present = snd_hda_codec_read(codec, 0x14, 0,
16311 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016312 bits = present ? HDA_AMP_MUTE : 0;
16313 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16314 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016315}
16316
16317static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16318{
16319 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016320 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016321
16322 present = snd_hda_codec_read(codec, 0x1b, 0,
16323 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016324 bits = present ? HDA_AMP_MUTE : 0;
16325 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16326 HDA_AMP_MUTE, bits);
16327 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16328 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016329}
16330
16331static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16332 unsigned int res)
16333{
16334 if ((res >> 26) == ALC880_HP_EVENT)
16335 alc662_lenovo_101e_all_automute(codec);
16336 if ((res >> 26) == ALC880_FRONT_EVENT)
16337 alc662_lenovo_101e_ispeaker_automute(codec);
16338}
16339
Kailang Yang291702f2007-10-16 14:28:03 +020016340static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16341{
16342 unsigned int present;
16343
16344 present = snd_hda_codec_read(codec, 0x18, 0,
16345 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16346 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16347 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16348 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16349 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16350 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16351 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16352 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16353 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16354}
16355
16356/* unsolicited event for HP jack sensing */
16357static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16358 unsigned int res)
16359{
Kailang Yang291702f2007-10-16 14:28:03 +020016360 if ((res >> 26) == ALC880_MIC_EVENT)
16361 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016362 else
16363 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016364}
16365
16366static void alc662_eeepc_inithook(struct hda_codec *codec)
16367{
Takashi Iwai42171c12009-05-08 14:11:43 +020016368 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020016369 alc662_eeepc_mic_automute(codec);
16370}
16371
Kailang Yang8c427222008-01-10 13:03:59 +010016372static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16373{
Takashi Iwai42171c12009-05-08 14:11:43 +020016374 struct alc_spec *spec = codec->spec;
16375
16376 spec->autocfg.hp_pins[0] = 0x14;
16377 spec->autocfg.speaker_pins[0] = 0x1b;
16378 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010016379}
16380
Kailang Yang6dda9f42008-05-27 12:05:31 +020016381static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16382{
16383 unsigned int present;
16384 unsigned char bits;
16385
16386 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016387 AC_VERB_GET_PIN_SENSE, 0)
16388 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016389 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016390 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16391 AMP_IN_MUTE(0), bits);
16392 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16393 AMP_IN_MUTE(0), bits);
16394}
16395
16396static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16397{
16398 unsigned int present;
16399 unsigned char bits;
16400
16401 present = snd_hda_codec_read(codec, 0x21, 0,
16402 AC_VERB_GET_PIN_SENSE, 0)
16403 & AC_PINSENSE_PRESENCE;
16404 bits = present ? HDA_AMP_MUTE : 0;
16405 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16406 AMP_IN_MUTE(0), bits);
16407 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16408 AMP_IN_MUTE(0), bits);
16409 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16410 AMP_IN_MUTE(0), bits);
16411 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16412 AMP_IN_MUTE(0), bits);
16413}
16414
16415static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16416{
16417 unsigned int present;
16418 unsigned char bits;
16419
16420 present = snd_hda_codec_read(codec, 0x15, 0,
16421 AC_VERB_GET_PIN_SENSE, 0)
16422 & AC_PINSENSE_PRESENCE;
16423 bits = present ? HDA_AMP_MUTE : 0;
16424 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16425 AMP_IN_MUTE(0), bits);
16426 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16427 AMP_IN_MUTE(0), bits);
16428 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16429 AMP_IN_MUTE(0), bits);
16430 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16431 AMP_IN_MUTE(0), bits);
16432}
16433
16434static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16435{
16436 unsigned int present;
16437 unsigned char bits;
16438
16439 present = snd_hda_codec_read(codec, 0x1b, 0,
16440 AC_VERB_GET_PIN_SENSE, 0)
16441 & AC_PINSENSE_PRESENCE;
16442 bits = present ? 0 : PIN_OUT;
16443 snd_hda_codec_write(codec, 0x14, 0,
16444 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16445}
16446
16447static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16448{
16449 unsigned int present1, present2;
16450
16451 present1 = snd_hda_codec_read(codec, 0x21, 0,
16452 AC_VERB_GET_PIN_SENSE, 0)
16453 & AC_PINSENSE_PRESENCE;
16454 present2 = snd_hda_codec_read(codec, 0x15, 0,
16455 AC_VERB_GET_PIN_SENSE, 0)
16456 & AC_PINSENSE_PRESENCE;
16457
16458 if (present1 || present2) {
16459 snd_hda_codec_write_cache(codec, 0x14, 0,
16460 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16461 } else {
16462 snd_hda_codec_write_cache(codec, 0x14, 0,
16463 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16464 }
16465}
16466
16467static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16468{
16469 unsigned int present1, present2;
16470
16471 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16472 AC_VERB_GET_PIN_SENSE, 0)
16473 & AC_PINSENSE_PRESENCE;
16474 present2 = snd_hda_codec_read(codec, 0x15, 0,
16475 AC_VERB_GET_PIN_SENSE, 0)
16476 & AC_PINSENSE_PRESENCE;
16477
16478 if (present1 || present2) {
16479 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16480 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16481 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16482 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16483 } else {
16484 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16485 AMP_IN_MUTE(0), 0);
16486 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16487 AMP_IN_MUTE(0), 0);
16488 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016489}
16490
16491static void alc663_m51va_mic_automute(struct hda_codec *codec)
16492{
16493 unsigned int present;
16494
16495 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016496 AC_VERB_GET_PIN_SENSE, 0)
16497 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016498 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016499 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016500 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016501 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016502 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016503 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016504 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016505 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016506}
16507
16508static void alc663_m51va_unsol_event(struct hda_codec *codec,
16509 unsigned int res)
16510{
16511 switch (res >> 26) {
16512 case ALC880_HP_EVENT:
16513 alc663_m51va_speaker_automute(codec);
16514 break;
16515 case ALC880_MIC_EVENT:
16516 alc663_m51va_mic_automute(codec);
16517 break;
16518 }
16519}
16520
16521static void alc663_m51va_inithook(struct hda_codec *codec)
16522{
16523 alc663_m51va_speaker_automute(codec);
16524 alc663_m51va_mic_automute(codec);
16525}
16526
Kailang Yangf1d4e282008-08-26 14:03:29 +020016527/* ***************** Mode1 ******************************/
16528static void alc663_mode1_unsol_event(struct hda_codec *codec,
16529 unsigned int res)
16530{
16531 switch (res >> 26) {
16532 case ALC880_HP_EVENT:
16533 alc663_m51va_speaker_automute(codec);
16534 break;
16535 case ALC880_MIC_EVENT:
16536 alc662_eeepc_mic_automute(codec);
16537 break;
16538 }
16539}
16540
16541static void alc663_mode1_inithook(struct hda_codec *codec)
16542{
16543 alc663_m51va_speaker_automute(codec);
16544 alc662_eeepc_mic_automute(codec);
16545}
16546/* ***************** Mode2 ******************************/
16547static void alc662_mode2_unsol_event(struct hda_codec *codec,
16548 unsigned int res)
16549{
16550 switch (res >> 26) {
16551 case ALC880_HP_EVENT:
16552 alc662_f5z_speaker_automute(codec);
16553 break;
16554 case ALC880_MIC_EVENT:
16555 alc662_eeepc_mic_automute(codec);
16556 break;
16557 }
16558}
16559
16560static void alc662_mode2_inithook(struct hda_codec *codec)
16561{
16562 alc662_f5z_speaker_automute(codec);
16563 alc662_eeepc_mic_automute(codec);
16564}
16565/* ***************** Mode3 ******************************/
16566static void alc663_mode3_unsol_event(struct hda_codec *codec,
16567 unsigned int res)
16568{
16569 switch (res >> 26) {
16570 case ALC880_HP_EVENT:
16571 alc663_two_hp_m1_speaker_automute(codec);
16572 break;
16573 case ALC880_MIC_EVENT:
16574 alc662_eeepc_mic_automute(codec);
16575 break;
16576 }
16577}
16578
16579static void alc663_mode3_inithook(struct hda_codec *codec)
16580{
16581 alc663_two_hp_m1_speaker_automute(codec);
16582 alc662_eeepc_mic_automute(codec);
16583}
16584/* ***************** Mode4 ******************************/
16585static void alc663_mode4_unsol_event(struct hda_codec *codec,
16586 unsigned int res)
16587{
16588 switch (res >> 26) {
16589 case ALC880_HP_EVENT:
16590 alc663_21jd_two_speaker_automute(codec);
16591 break;
16592 case ALC880_MIC_EVENT:
16593 alc662_eeepc_mic_automute(codec);
16594 break;
16595 }
16596}
16597
16598static void alc663_mode4_inithook(struct hda_codec *codec)
16599{
16600 alc663_21jd_two_speaker_automute(codec);
16601 alc662_eeepc_mic_automute(codec);
16602}
16603/* ***************** Mode5 ******************************/
16604static void alc663_mode5_unsol_event(struct hda_codec *codec,
16605 unsigned int res)
16606{
16607 switch (res >> 26) {
16608 case ALC880_HP_EVENT:
16609 alc663_15jd_two_speaker_automute(codec);
16610 break;
16611 case ALC880_MIC_EVENT:
16612 alc662_eeepc_mic_automute(codec);
16613 break;
16614 }
16615}
16616
16617static void alc663_mode5_inithook(struct hda_codec *codec)
16618{
16619 alc663_15jd_two_speaker_automute(codec);
16620 alc662_eeepc_mic_automute(codec);
16621}
16622/* ***************** Mode6 ******************************/
16623static void alc663_mode6_unsol_event(struct hda_codec *codec,
16624 unsigned int res)
16625{
16626 switch (res >> 26) {
16627 case ALC880_HP_EVENT:
16628 alc663_two_hp_m2_speaker_automute(codec);
16629 break;
16630 case ALC880_MIC_EVENT:
16631 alc662_eeepc_mic_automute(codec);
16632 break;
16633 }
16634}
16635
16636static void alc663_mode6_inithook(struct hda_codec *codec)
16637{
16638 alc663_two_hp_m2_speaker_automute(codec);
16639 alc662_eeepc_mic_automute(codec);
16640}
16641
Kailang Yang6dda9f42008-05-27 12:05:31 +020016642static void alc663_g71v_hp_automute(struct hda_codec *codec)
16643{
16644 unsigned int present;
16645 unsigned char bits;
16646
16647 present = snd_hda_codec_read(codec, 0x21, 0,
16648 AC_VERB_GET_PIN_SENSE, 0)
16649 & AC_PINSENSE_PRESENCE;
16650 bits = present ? HDA_AMP_MUTE : 0;
16651 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16652 HDA_AMP_MUTE, bits);
16653 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16654 HDA_AMP_MUTE, bits);
16655}
16656
16657static void alc663_g71v_front_automute(struct hda_codec *codec)
16658{
16659 unsigned int present;
16660 unsigned char bits;
16661
16662 present = snd_hda_codec_read(codec, 0x15, 0,
16663 AC_VERB_GET_PIN_SENSE, 0)
16664 & AC_PINSENSE_PRESENCE;
16665 bits = present ? HDA_AMP_MUTE : 0;
16666 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16667 HDA_AMP_MUTE, bits);
16668}
16669
16670static void alc663_g71v_unsol_event(struct hda_codec *codec,
16671 unsigned int res)
16672{
16673 switch (res >> 26) {
16674 case ALC880_HP_EVENT:
16675 alc663_g71v_hp_automute(codec);
16676 break;
16677 case ALC880_FRONT_EVENT:
16678 alc663_g71v_front_automute(codec);
16679 break;
16680 case ALC880_MIC_EVENT:
16681 alc662_eeepc_mic_automute(codec);
16682 break;
16683 }
16684}
16685
16686static void alc663_g71v_inithook(struct hda_codec *codec)
16687{
16688 alc663_g71v_front_automute(codec);
16689 alc663_g71v_hp_automute(codec);
16690 alc662_eeepc_mic_automute(codec);
16691}
16692
16693static void alc663_g50v_unsol_event(struct hda_codec *codec,
16694 unsigned int res)
16695{
16696 switch (res >> 26) {
16697 case ALC880_HP_EVENT:
16698 alc663_m51va_speaker_automute(codec);
16699 break;
16700 case ALC880_MIC_EVENT:
16701 alc662_eeepc_mic_automute(codec);
16702 break;
16703 }
16704}
16705
16706static void alc663_g50v_inithook(struct hda_codec *codec)
16707{
16708 alc663_m51va_speaker_automute(codec);
16709 alc662_eeepc_mic_automute(codec);
16710}
16711
Kailang Yangf1d4e282008-08-26 14:03:29 +020016712static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16713 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016714 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016715
16716 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16717 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16718 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16719
16720 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16721 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16722 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16723 { } /* end */
16724};
16725
Chris Pockelé9541ba12009-05-12 08:08:53 +020016726static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16727 /* Master Playback automatically created from Speaker and Headphone */
16728 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16729 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16730 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16731 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16732
16733 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16734 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16735 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16736
16737 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16738 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16739 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16740 { } /* end */
16741};
16742
Takashi Iwaicb53c622007-08-10 17:21:45 +020016743#ifdef CONFIG_SND_HDA_POWER_SAVE
16744#define alc662_loopbacks alc880_loopbacks
16745#endif
16746
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016747
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016748/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016749#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16750#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16751#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16752#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16753
16754/*
16755 * configuration and preset
16756 */
16757static const char *alc662_models[ALC662_MODEL_LAST] = {
16758 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16759 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16760 [ALC662_3ST_6ch] = "3stack-6ch",
16761 [ALC662_5ST_DIG] = "6stack-dig",
16762 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016763 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016764 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016765 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016766 [ALC663_ASUS_M51VA] = "m51va",
16767 [ALC663_ASUS_G71V] = "g71v",
16768 [ALC663_ASUS_H13] = "h13",
16769 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016770 [ALC663_ASUS_MODE1] = "asus-mode1",
16771 [ALC662_ASUS_MODE2] = "asus-mode2",
16772 [ALC663_ASUS_MODE3] = "asus-mode3",
16773 [ALC663_ASUS_MODE4] = "asus-mode4",
16774 [ALC663_ASUS_MODE5] = "asus-mode5",
16775 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016776 [ALC272_DELL] = "dell",
16777 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016778 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016779 [ALC662_AUTO] = "auto",
16780};
16781
16782static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016783 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016784 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16785 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016786 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16787 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16788 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16789 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16790 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16791 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16792 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16793 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16794 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16795 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16796 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16797 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016798 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16799 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16800 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016801 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16802 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16803 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16804 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016805 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016806 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16807 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016808 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016809 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16810 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16811 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016812 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16813 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16814 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016815 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16816 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16817 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016818 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016819 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16820 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016821 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016822 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016823 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016824 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16825 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16826 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016827 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016828 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16829 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016830 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016831 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016832 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016833 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016834 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16835 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016836 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016837 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16838 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016839 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016840 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016841 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016842 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016843 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016844 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16845 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016846 {}
16847};
16848
16849static struct alc_config_preset alc662_presets[] = {
16850 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016851 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016852 .init_verbs = { alc662_init_verbs },
16853 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16854 .dac_nids = alc662_dac_nids,
16855 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016856 .dig_in_nid = ALC662_DIGIN_NID,
16857 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16858 .channel_mode = alc662_3ST_2ch_modes,
16859 .input_mux = &alc662_capture_source,
16860 },
16861 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016862 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016863 .init_verbs = { alc662_init_verbs },
16864 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16865 .dac_nids = alc662_dac_nids,
16866 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016867 .dig_in_nid = ALC662_DIGIN_NID,
16868 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16869 .channel_mode = alc662_3ST_6ch_modes,
16870 .need_dac_fix = 1,
16871 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016872 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016873 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016874 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016875 .init_verbs = { alc662_init_verbs },
16876 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16877 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016878 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16879 .channel_mode = alc662_3ST_6ch_modes,
16880 .need_dac_fix = 1,
16881 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016883 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016884 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016885 .init_verbs = { alc662_init_verbs },
16886 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16887 .dac_nids = alc662_dac_nids,
16888 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016889 .dig_in_nid = ALC662_DIGIN_NID,
16890 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16891 .channel_mode = alc662_5stack_modes,
16892 .input_mux = &alc662_capture_source,
16893 },
16894 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016895 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016896 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16897 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16898 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016899 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16900 .channel_mode = alc662_3ST_2ch_modes,
16901 .input_mux = &alc662_lenovo_101e_capture_source,
16902 .unsol_event = alc662_lenovo_101e_unsol_event,
16903 .init_hook = alc662_lenovo_101e_all_automute,
16904 },
Kailang Yang291702f2007-10-16 14:28:03 +020016905 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016906 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016907 .init_verbs = { alc662_init_verbs,
16908 alc662_eeepc_sue_init_verbs },
16909 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16910 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016911 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16912 .channel_mode = alc662_3ST_2ch_modes,
16913 .input_mux = &alc662_eeepc_capture_source,
16914 .unsol_event = alc662_eeepc_unsol_event,
16915 .init_hook = alc662_eeepc_inithook,
16916 },
Kailang Yang8c427222008-01-10 13:03:59 +010016917 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016918 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016919 alc662_chmode_mixer },
16920 .init_verbs = { alc662_init_verbs,
16921 alc662_eeepc_ep20_sue_init_verbs },
16922 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16923 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016924 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16925 .channel_mode = alc662_3ST_6ch_modes,
16926 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016927 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016928 .init_hook = alc662_eeepc_ep20_inithook,
16929 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016930 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016931 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016932 .init_verbs = { alc662_init_verbs,
16933 alc662_ecs_init_verbs },
16934 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16935 .dac_nids = alc662_dac_nids,
16936 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16937 .channel_mode = alc662_3ST_2ch_modes,
16938 .input_mux = &alc662_eeepc_capture_source,
16939 .unsol_event = alc662_eeepc_unsol_event,
16940 .init_hook = alc662_eeepc_inithook,
16941 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016942 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016943 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016944 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16945 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16946 .dac_nids = alc662_dac_nids,
16947 .dig_out_nid = ALC662_DIGOUT_NID,
16948 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16949 .channel_mode = alc662_3ST_2ch_modes,
16950 .input_mux = &alc663_m51va_capture_source,
16951 .unsol_event = alc663_m51va_unsol_event,
16952 .init_hook = alc663_m51va_inithook,
16953 },
16954 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016955 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016956 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16957 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16958 .dac_nids = alc662_dac_nids,
16959 .dig_out_nid = ALC662_DIGOUT_NID,
16960 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16961 .channel_mode = alc662_3ST_2ch_modes,
16962 .input_mux = &alc662_eeepc_capture_source,
16963 .unsol_event = alc663_g71v_unsol_event,
16964 .init_hook = alc663_g71v_inithook,
16965 },
16966 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016967 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016968 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16969 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16970 .dac_nids = alc662_dac_nids,
16971 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16972 .channel_mode = alc662_3ST_2ch_modes,
16973 .input_mux = &alc663_m51va_capture_source,
16974 .unsol_event = alc663_m51va_unsol_event,
16975 .init_hook = alc663_m51va_inithook,
16976 },
16977 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016978 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016979 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16980 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16981 .dac_nids = alc662_dac_nids,
16982 .dig_out_nid = ALC662_DIGOUT_NID,
16983 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16984 .channel_mode = alc662_3ST_6ch_modes,
16985 .input_mux = &alc663_capture_source,
16986 .unsol_event = alc663_g50v_unsol_event,
16987 .init_hook = alc663_g50v_inithook,
16988 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016989 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016990 .mixers = { alc663_m51va_mixer },
16991 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016992 .init_verbs = { alc662_init_verbs,
16993 alc663_21jd_amic_init_verbs },
16994 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16995 .hp_nid = 0x03,
16996 .dac_nids = alc662_dac_nids,
16997 .dig_out_nid = ALC662_DIGOUT_NID,
16998 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16999 .channel_mode = alc662_3ST_2ch_modes,
17000 .input_mux = &alc662_eeepc_capture_source,
17001 .unsol_event = alc663_mode1_unsol_event,
17002 .init_hook = alc663_mode1_inithook,
17003 },
17004 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017005 .mixers = { alc662_1bjd_mixer },
17006 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017007 .init_verbs = { alc662_init_verbs,
17008 alc662_1bjd_amic_init_verbs },
17009 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17010 .dac_nids = alc662_dac_nids,
17011 .dig_out_nid = ALC662_DIGOUT_NID,
17012 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17013 .channel_mode = alc662_3ST_2ch_modes,
17014 .input_mux = &alc662_eeepc_capture_source,
17015 .unsol_event = alc662_mode2_unsol_event,
17016 .init_hook = alc662_mode2_inithook,
17017 },
17018 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017019 .mixers = { alc663_two_hp_m1_mixer },
17020 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017021 .init_verbs = { alc662_init_verbs,
17022 alc663_two_hp_amic_m1_init_verbs },
17023 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17024 .hp_nid = 0x03,
17025 .dac_nids = alc662_dac_nids,
17026 .dig_out_nid = ALC662_DIGOUT_NID,
17027 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17028 .channel_mode = alc662_3ST_2ch_modes,
17029 .input_mux = &alc662_eeepc_capture_source,
17030 .unsol_event = alc663_mode3_unsol_event,
17031 .init_hook = alc663_mode3_inithook,
17032 },
17033 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017034 .mixers = { alc663_asus_21jd_clfe_mixer },
17035 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017036 .init_verbs = { alc662_init_verbs,
17037 alc663_21jd_amic_init_verbs},
17038 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17039 .hp_nid = 0x03,
17040 .dac_nids = alc662_dac_nids,
17041 .dig_out_nid = ALC662_DIGOUT_NID,
17042 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17043 .channel_mode = alc662_3ST_2ch_modes,
17044 .input_mux = &alc662_eeepc_capture_source,
17045 .unsol_event = alc663_mode4_unsol_event,
17046 .init_hook = alc663_mode4_inithook,
17047 },
17048 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017049 .mixers = { alc663_asus_15jd_clfe_mixer },
17050 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017051 .init_verbs = { alc662_init_verbs,
17052 alc663_15jd_amic_init_verbs },
17053 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17054 .hp_nid = 0x03,
17055 .dac_nids = alc662_dac_nids,
17056 .dig_out_nid = ALC662_DIGOUT_NID,
17057 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17058 .channel_mode = alc662_3ST_2ch_modes,
17059 .input_mux = &alc662_eeepc_capture_source,
17060 .unsol_event = alc663_mode5_unsol_event,
17061 .init_hook = alc663_mode5_inithook,
17062 },
17063 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017064 .mixers = { alc663_two_hp_m2_mixer },
17065 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017066 .init_verbs = { alc662_init_verbs,
17067 alc663_two_hp_amic_m2_init_verbs },
17068 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17069 .hp_nid = 0x03,
17070 .dac_nids = alc662_dac_nids,
17071 .dig_out_nid = ALC662_DIGOUT_NID,
17072 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17073 .channel_mode = alc662_3ST_2ch_modes,
17074 .input_mux = &alc662_eeepc_capture_source,
17075 .unsol_event = alc663_mode6_unsol_event,
17076 .init_hook = alc663_mode6_inithook,
17077 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017078 [ALC272_DELL] = {
17079 .mixers = { alc663_m51va_mixer },
17080 .cap_mixer = alc272_auto_capture_mixer,
17081 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17082 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17083 .dac_nids = alc662_dac_nids,
17084 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17085 .adc_nids = alc272_adc_nids,
17086 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17087 .capsrc_nids = alc272_capsrc_nids,
17088 .channel_mode = alc662_3ST_2ch_modes,
17089 .input_mux = &alc663_m51va_capture_source,
17090 .unsol_event = alc663_m51va_unsol_event,
17091 .init_hook = alc663_m51va_inithook,
17092 },
17093 [ALC272_DELL_ZM1] = {
17094 .mixers = { alc663_m51va_mixer },
17095 .cap_mixer = alc662_auto_capture_mixer,
17096 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17097 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17098 .dac_nids = alc662_dac_nids,
17099 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17100 .adc_nids = alc662_adc_nids,
17101 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
17102 .capsrc_nids = alc662_capsrc_nids,
17103 .channel_mode = alc662_3ST_2ch_modes,
17104 .input_mux = &alc663_m51va_capture_source,
17105 .unsol_event = alc663_m51va_unsol_event,
17106 .init_hook = alc663_m51va_inithook,
17107 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017108 [ALC272_SAMSUNG_NC10] = {
17109 .mixers = { alc272_nc10_mixer },
17110 .init_verbs = { alc662_init_verbs,
17111 alc663_21jd_amic_init_verbs },
17112 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17113 .dac_nids = alc272_dac_nids,
17114 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17115 .channel_mode = alc662_3ST_2ch_modes,
17116 .input_mux = &alc272_nc10_capture_source,
17117 .unsol_event = alc663_mode4_unsol_event,
17118 .init_hook = alc663_mode4_inithook,
17119 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017120};
17121
17122
17123/*
17124 * BIOS auto configuration
17125 */
17126
17127/* add playback controls from the parsed DAC table */
17128static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17129 const struct auto_pin_cfg *cfg)
17130{
17131 char name[32];
17132 static const char *chname[4] = {
17133 "Front", "Surround", NULL /*CLFE*/, "Side"
17134 };
17135 hda_nid_t nid;
17136 int i, err;
17137
17138 for (i = 0; i < cfg->line_outs; i++) {
17139 if (!spec->multiout.dac_nids[i])
17140 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020017141 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017142 if (i == 2) {
17143 /* Center/LFE */
17144 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17145 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017146 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17147 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017148 if (err < 0)
17149 return err;
17150 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17151 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017152 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17153 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017154 if (err < 0)
17155 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017156 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017157 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017158 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017159 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017160 if (err < 0)
17161 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017162 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017163 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017164 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017165 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017166 if (err < 0)
17167 return err;
17168 } else {
17169 sprintf(name, "%s Playback Volume", chname[i]);
17170 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017171 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17172 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017173 if (err < 0)
17174 return err;
17175 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017176 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17177 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17178 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017179 if (err < 0)
17180 return err;
17181 }
17182 }
17183 return 0;
17184}
17185
17186/* add playback controls for speaker and HP outputs */
17187static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17188 const char *pfx)
17189{
17190 hda_nid_t nid;
17191 int err;
17192 char name[32];
17193
17194 if (!pin)
17195 return 0;
17196
Takashi Iwai24fb9172008-09-02 14:48:20 +020017197 if (pin == 0x17) {
17198 /* ALC663 has a mono output pin on 0x17 */
17199 sprintf(name, "%s Playback Switch", pfx);
17200 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17201 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17202 return err;
17203 }
17204
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017205 if (alc880_is_fixed_pin(pin)) {
17206 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017207 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017208 /* specify the DAC as the extra output */
17209 if (!spec->multiout.hp_nid)
17210 spec->multiout.hp_nid = nid;
17211 else
17212 spec->multiout.extra_out_nid[0] = nid;
17213 /* control HP volume/switch on the output mixer amp */
17214 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17215 sprintf(name, "%s Playback Volume", pfx);
17216 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17217 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17218 if (err < 0)
17219 return err;
17220 sprintf(name, "%s Playback Switch", pfx);
17221 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17222 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17223 if (err < 0)
17224 return err;
17225 } else if (alc880_is_multi_pin(pin)) {
17226 /* set manual connection */
17227 /* we have only a switch on HP-out PIN */
17228 sprintf(name, "%s Playback Switch", pfx);
17229 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17230 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17231 if (err < 0)
17232 return err;
17233 }
17234 return 0;
17235}
17236
Takashi Iwai2d864c42009-03-20 12:52:47 +010017237/* return the index of the src widget from the connection list of the nid.
17238 * return -1 if not found
17239 */
17240static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
17241 hda_nid_t src)
17242{
17243 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
17244 int i, conns;
17245
17246 conns = snd_hda_get_connections(codec, nid, conn_list,
17247 ARRAY_SIZE(conn_list));
17248 if (conns < 0)
17249 return -1;
17250 for (i = 0; i < conns; i++)
17251 if (conn_list[i] == src)
17252 return i;
17253 return -1;
17254}
17255
17256static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17257{
Takashi Iwai1327a322009-03-23 13:07:47 +010017258 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010017259 return (pincap & AC_PINCAP_IN) != 0;
17260}
17261
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017262/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010017263static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017264 const struct auto_pin_cfg *cfg)
17265{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017266 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017267 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017268 int i, err, idx;
17269
17270 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017271 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
17272 idx = alc662_input_pin_idx(codec, 0x0b,
17273 cfg->input_pins[i]);
17274 if (idx >= 0) {
17275 err = new_analog_input(spec, cfg->input_pins[i],
17276 auto_pin_cfg_labels[i],
17277 idx, 0x0b);
17278 if (err < 0)
17279 return err;
17280 }
17281 idx = alc662_input_pin_idx(codec, 0x22,
17282 cfg->input_pins[i]);
17283 if (idx >= 0) {
17284 imux->items[imux->num_items].label =
17285 auto_pin_cfg_labels[i];
17286 imux->items[imux->num_items].index = idx;
17287 imux->num_items++;
17288 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017289 }
17290 }
17291 return 0;
17292}
17293
17294static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17295 hda_nid_t nid, int pin_type,
17296 int dac_idx)
17297{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017298 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017299 /* need the manual connection? */
17300 if (alc880_is_multi_pin(nid)) {
17301 struct alc_spec *spec = codec->spec;
17302 int idx = alc880_multi_pin_idx(nid);
17303 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17304 AC_VERB_SET_CONNECT_SEL,
17305 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17306 }
17307}
17308
17309static void alc662_auto_init_multi_out(struct hda_codec *codec)
17310{
17311 struct alc_spec *spec = codec->spec;
17312 int i;
17313
17314 for (i = 0; i <= HDA_SIDE; i++) {
17315 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017316 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017317 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017318 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017319 i);
17320 }
17321}
17322
17323static void alc662_auto_init_hp_out(struct hda_codec *codec)
17324{
17325 struct alc_spec *spec = codec->spec;
17326 hda_nid_t pin;
17327
17328 pin = spec->autocfg.hp_pins[0];
17329 if (pin) /* connect to front */
17330 /* use dac 0 */
17331 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017332 pin = spec->autocfg.speaker_pins[0];
17333 if (pin)
17334 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017335}
17336
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017337#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17338
17339static void alc662_auto_init_analog_input(struct hda_codec *codec)
17340{
17341 struct alc_spec *spec = codec->spec;
17342 int i;
17343
17344 for (i = 0; i < AUTO_PIN_LAST; i++) {
17345 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017346 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017347 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017348 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017349 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017350 snd_hda_codec_write(codec, nid, 0,
17351 AC_VERB_SET_AMP_GAIN_MUTE,
17352 AMP_OUT_MUTE);
17353 }
17354 }
17355}
17356
Takashi Iwaif511b012008-08-15 16:46:42 +020017357#define alc662_auto_init_input_src alc882_auto_init_input_src
17358
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017359static int alc662_parse_auto_config(struct hda_codec *codec)
17360{
17361 struct alc_spec *spec = codec->spec;
17362 int err;
17363 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17364
17365 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17366 alc662_ignore);
17367 if (err < 0)
17368 return err;
17369 if (!spec->autocfg.line_outs)
17370 return 0; /* can't find valid BIOS pin config */
17371
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017372 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17373 if (err < 0)
17374 return err;
17375 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17376 if (err < 0)
17377 return err;
17378 err = alc662_auto_create_extra_out(spec,
17379 spec->autocfg.speaker_pins[0],
17380 "Speaker");
17381 if (err < 0)
17382 return err;
17383 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17384 "Headphone");
17385 if (err < 0)
17386 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017387 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017388 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017389 return err;
17390
17391 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17392
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017393 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017394 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17395
Takashi Iwai603c4012008-07-30 15:01:44 +020017396 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017397 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017398
17399 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017400 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017401
Takashi Iwaid88897e2008-10-31 15:01:37 +010017402 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017403 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017404 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017405
17406 err = alc_auto_add_mic_boost(codec);
17407 if (err < 0)
17408 return err;
17409
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017410 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17411
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017412 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017413}
17414
17415/* additional initialization for auto-configuration model */
17416static void alc662_auto_init(struct hda_codec *codec)
17417{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017418 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017419 alc662_auto_init_multi_out(codec);
17420 alc662_auto_init_hp_out(codec);
17421 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017422 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017423 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017424 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017425}
17426
17427static int patch_alc662(struct hda_codec *codec)
17428{
17429 struct alc_spec *spec;
17430 int err, board_config;
17431
17432 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17433 if (!spec)
17434 return -ENOMEM;
17435
17436 codec->spec = spec;
17437
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017438 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17439
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017440 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17441 alc662_models,
17442 alc662_cfg_tbl);
17443 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020017444 printk(KERN_INFO "hda_codec: Unknown model for %s, "
17445 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017446 board_config = ALC662_AUTO;
17447 }
17448
17449 if (board_config == ALC662_AUTO) {
17450 /* automatic parse from the BIOS config */
17451 err = alc662_parse_auto_config(codec);
17452 if (err < 0) {
17453 alc_free(codec);
17454 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017455 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017456 printk(KERN_INFO
17457 "hda_codec: Cannot set up configuration "
17458 "from BIOS. Using base mode...\n");
17459 board_config = ALC662_3ST_2ch_DIG;
17460 }
17461 }
17462
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017463 err = snd_hda_attach_beep_device(codec, 0x1);
17464 if (err < 0) {
17465 alc_free(codec);
17466 return err;
17467 }
17468
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017469 if (board_config != ALC662_AUTO)
17470 setup_preset(spec, &alc662_presets[board_config]);
17471
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017472 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17473 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17474
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017475 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17476 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17477
Takashi Iwaie1406342008-02-11 18:32:32 +010017478 spec->adc_nids = alc662_adc_nids;
17479 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17480 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017481
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017482 if (!spec->cap_mixer)
17483 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017484 if (codec->vendor_id == 0x10ec0662)
17485 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17486 else
17487 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017488
Takashi Iwai2134ea42008-01-10 16:53:55 +010017489 spec->vmaster_nid = 0x02;
17490
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017491 codec->patch_ops = alc_patch_ops;
17492 if (board_config == ALC662_AUTO)
17493 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017494#ifdef CONFIG_SND_HDA_POWER_SAVE
17495 if (!spec->loopback.amplist)
17496 spec->loopback.amplist = alc662_loopbacks;
17497#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017498 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017499
17500 return 0;
17501}
17502
17503/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017504 * patch entries
17505 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017506static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017507 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017508 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017509 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017510 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017511 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017512 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017513 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017514 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017515 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17516 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17517 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017518 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17519 .patch = patch_alc883 },
17520 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17521 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017522 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017523 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017524 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017525 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017526 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17527 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017528 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017529 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017530 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017531 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017532 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17533 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017534 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017535 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017536 {} /* terminator */
17537};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017538
17539MODULE_ALIAS("snd-hda-codec-id:10ec*");
17540
17541MODULE_LICENSE("GPL");
17542MODULE_DESCRIPTION("Realtek HD-audio codec");
17543
17544static struct hda_codec_preset_list realtek_list = {
17545 .preset = snd_hda_preset_realtek,
17546 .owner = THIS_MODULE,
17547};
17548
17549static int __init patch_realtek_init(void)
17550{
17551 return snd_hda_add_codec_preset(&realtek_list);
17552}
17553
17554static void __exit patch_realtek_exit(void)
17555{
17556 snd_hda_delete_codec_preset(&realtek_list);
17557}
17558
17559module_init(patch_realtek_init)
17560module_exit(patch_realtek_exit)