blob: e661b21354beda752a926421ee64b729f412ec43 [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;
Takashi Iwai261c2402009-06-25 08:13:40 +0200948 unsigned int present, pincap;
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
Takashi Iwai261c2402009-06-25 08:13:40 +0200952 pincap = snd_hda_query_pin_caps(codec, nid);
953 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
954 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200955 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200956 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200957 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
958 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
959 nid = spec->autocfg.speaker_pins[i];
960 if (!nid)
961 break;
962 snd_hda_codec_write(codec, nid, 0,
963 AC_VERB_SET_PIN_WIDGET_CONTROL,
964 spec->jack_present ? 0 : PIN_OUT);
965 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200966}
967
Sasha Alexandrdef319f2009-06-16 16:00:15 -0400968#if 0 /* it's broken in some cases -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200969static void alc_mic_automute(struct hda_codec *codec)
970{
971 struct alc_spec *spec = codec->spec;
972 unsigned int present;
973 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
974 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
975 unsigned int mix_nid = spec->capsrc_nids[0];
976 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
977
978 capsrc_idx_mic = mic_nid - 0x18;
979 capsrc_idx_fmic = fmic_nid - 0x18;
980 present = snd_hda_codec_read(codec, mic_nid, 0,
981 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
982 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
983 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
984 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
985 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
986 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
987 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
988}
Takashi Iwai4605b712008-10-31 14:18:24 +0100989#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100990#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100991#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200992
Kailang Yangc9b58002007-10-16 14:30:01 +0200993/* unsolicited event for HP jack sensing */
994static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
995{
996 if (codec->vendor_id == 0x10ec0880)
997 res >>= 28;
998 else
999 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001000 switch (res) {
1001 case ALC880_HP_EVENT:
1002 alc_automute_pin(codec);
1003 break;
1004 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001005 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001006 break;
1007 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001008}
1009
1010static void alc_inithook(struct hda_codec *codec)
1011{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001012 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001013 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001014}
1015
Kailang Yangf9423e72008-05-27 12:32:25 +02001016/* additional initialization for ALC888 variants */
1017static void alc888_coef_init(struct hda_codec *codec)
1018{
1019 unsigned int tmp;
1020
1021 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1022 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1023 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001024 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001025 /* alc888S-VC */
1026 snd_hda_codec_read(codec, 0x20, 0,
1027 AC_VERB_SET_PROC_COEF, 0x830);
1028 else
1029 /* alc888-VB */
1030 snd_hda_codec_read(codec, 0x20, 0,
1031 AC_VERB_SET_PROC_COEF, 0x3030);
1032}
1033
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001034static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001035{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001036 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001037
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001038 switch (type) {
1039 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001040 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1041 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001042 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001043 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1044 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001045 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001046 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1047 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001048 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001049 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001050 case 0x10ec0260:
1051 snd_hda_codec_write(codec, 0x0f, 0,
1052 AC_VERB_SET_EAPD_BTLENABLE, 2);
1053 snd_hda_codec_write(codec, 0x10, 0,
1054 AC_VERB_SET_EAPD_BTLENABLE, 2);
1055 break;
1056 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001057 case 0x10ec0267:
1058 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001059 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001060 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001061 case 0x10ec0660:
1062 case 0x10ec0662:
1063 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001064 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001065 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001066 snd_hda_codec_write(codec, 0x14, 0,
1067 AC_VERB_SET_EAPD_BTLENABLE, 2);
1068 snd_hda_codec_write(codec, 0x15, 0,
1069 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001070 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001071 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001072 switch (codec->vendor_id) {
1073 case 0x10ec0260:
1074 snd_hda_codec_write(codec, 0x1a, 0,
1075 AC_VERB_SET_COEF_INDEX, 7);
1076 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1077 AC_VERB_GET_PROC_COEF, 0);
1078 snd_hda_codec_write(codec, 0x1a, 0,
1079 AC_VERB_SET_COEF_INDEX, 7);
1080 snd_hda_codec_write(codec, 0x1a, 0,
1081 AC_VERB_SET_PROC_COEF,
1082 tmp | 0x2010);
1083 break;
1084 case 0x10ec0262:
1085 case 0x10ec0880:
1086 case 0x10ec0882:
1087 case 0x10ec0883:
1088 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001089 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001090 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001091 snd_hda_codec_write(codec, 0x20, 0,
1092 AC_VERB_SET_COEF_INDEX, 7);
1093 tmp = snd_hda_codec_read(codec, 0x20, 0,
1094 AC_VERB_GET_PROC_COEF, 0);
1095 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001096 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001097 snd_hda_codec_write(codec, 0x20, 0,
1098 AC_VERB_SET_PROC_COEF,
1099 tmp | 0x2010);
1100 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001101 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001102 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001103 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001104 case 0x10ec0267:
1105 case 0x10ec0268:
1106 snd_hda_codec_write(codec, 0x20, 0,
1107 AC_VERB_SET_COEF_INDEX, 7);
1108 tmp = snd_hda_codec_read(codec, 0x20, 0,
1109 AC_VERB_GET_PROC_COEF, 0);
1110 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001111 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001112 snd_hda_codec_write(codec, 0x20, 0,
1113 AC_VERB_SET_PROC_COEF,
1114 tmp | 0x3000);
1115 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001116 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001117 break;
1118 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001119}
Kailang Yangea1fb292008-08-26 12:58:38 +02001120
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001121static void alc_init_auto_hp(struct hda_codec *codec)
1122{
1123 struct alc_spec *spec = codec->spec;
1124
1125 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001126 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001127
Kailang Yangc9b58002007-10-16 14:30:01 +02001128 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001129 if (spec->autocfg.line_out_pins[0] &&
1130 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001131 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001132 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001133 else
1134 return;
1135 }
1136
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001137 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1138 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001139 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1140 AC_VERB_SET_UNSOLICITED_ENABLE,
1141 AC_USRSP_EN | ALC880_HP_EVENT);
1142 spec->unsol_event = alc_sku_unsol_event;
1143}
1144
1145/* check subsystem ID and set up device-specific initialization;
1146 * return 1 if initialized, 0 if invalid SSID
1147 */
1148/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1149 * 31 ~ 16 : Manufacture ID
1150 * 15 ~ 8 : SKU ID
1151 * 7 ~ 0 : Assembly ID
1152 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1153 */
1154static int alc_subsystem_id(struct hda_codec *codec,
1155 hda_nid_t porta, hda_nid_t porte,
1156 hda_nid_t portd)
1157{
1158 unsigned int ass, tmp, i;
1159 unsigned nid;
1160 struct alc_spec *spec = codec->spec;
1161
1162 ass = codec->subsystem_id & 0xffff;
1163 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1164 goto do_sku;
1165
1166 /* invalid SSID, check the special NID pin defcfg instead */
1167 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001168 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001169 * 29~21 : reserve
1170 * 20 : PCBEEP input
1171 * 19~16 : Check sum (15:1)
1172 * 15~1 : Custom
1173 * 0 : override
1174 */
1175 nid = 0x1d;
1176 if (codec->vendor_id == 0x10ec0260)
1177 nid = 0x17;
1178 ass = snd_hda_codec_get_pincfg(codec, nid);
1179 snd_printd("realtek: No valid SSID, "
1180 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001181 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001182 if (!(ass & 1) && !(ass & 0x100000))
1183 return 0;
1184 if ((ass >> 30) != 1) /* no physical connection */
1185 return 0;
1186
1187 /* check sum */
1188 tmp = 0;
1189 for (i = 1; i < 16; i++) {
1190 if ((ass >> i) & 1)
1191 tmp++;
1192 }
1193 if (((ass >> 16) & 0xf) != tmp)
1194 return 0;
1195do_sku:
1196 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1197 ass & 0xffff, codec->vendor_id);
1198 /*
1199 * 0 : override
1200 * 1 : Swap Jack
1201 * 2 : 0 --> Desktop, 1 --> Laptop
1202 * 3~5 : External Amplifier control
1203 * 7~6 : Reserved
1204 */
1205 tmp = (ass & 0x38) >> 3; /* external Amp control */
1206 switch (tmp) {
1207 case 1:
1208 spec->init_amp = ALC_INIT_GPIO1;
1209 break;
1210 case 3:
1211 spec->init_amp = ALC_INIT_GPIO2;
1212 break;
1213 case 7:
1214 spec->init_amp = ALC_INIT_GPIO3;
1215 break;
1216 case 5:
1217 spec->init_amp = ALC_INIT_DEFAULT;
1218 break;
1219 }
1220
1221 /* is laptop or Desktop and enable the function "Mute internal speaker
1222 * when the external headphone out jack is plugged"
1223 */
1224 if (!(ass & 0x8000))
1225 return 1;
1226 /*
1227 * 10~8 : Jack location
1228 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1229 * 14~13: Resvered
1230 * 15 : 1 --> enable the function "Mute internal speaker
1231 * when the external headphone out jack is plugged"
1232 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001233 if (!spec->autocfg.hp_pins[0]) {
1234 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1235 if (tmp == 0)
1236 spec->autocfg.hp_pins[0] = porta;
1237 else if (tmp == 1)
1238 spec->autocfg.hp_pins[0] = porte;
1239 else if (tmp == 2)
1240 spec->autocfg.hp_pins[0] = portd;
1241 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001242 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001243 }
1244
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001245 alc_init_auto_hp(codec);
1246 return 1;
1247}
Kailang Yangea1fb292008-08-26 12:58:38 +02001248
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001249static void alc_ssid_check(struct hda_codec *codec,
1250 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1251{
1252 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1253 struct alc_spec *spec = codec->spec;
1254 snd_printd("realtek: "
1255 "Enable default setup for auto mode as fallback\n");
1256 spec->init_amp = ALC_INIT_DEFAULT;
1257 alc_init_auto_hp(codec);
1258 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001259}
1260
Takashi Iwai41e41f12005-06-08 14:48:49 +02001261/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001262 * Fix-up pin default configurations
1263 */
1264
1265struct alc_pincfg {
1266 hda_nid_t nid;
1267 u32 val;
1268};
1269
1270static void alc_fix_pincfg(struct hda_codec *codec,
1271 const struct snd_pci_quirk *quirk,
1272 const struct alc_pincfg **pinfix)
1273{
1274 const struct alc_pincfg *cfg;
1275
1276 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1277 if (!quirk)
1278 return;
1279
1280 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001281 for (; cfg->nid; cfg++)
1282 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001283}
1284
1285/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001286 * ALC888
1287 */
1288
1289/*
1290 * 2ch mode
1291 */
1292static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1293/* Mic-in jack as mic in */
1294 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1295 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1296/* Line-in jack as Line in */
1297 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1298 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1299/* Line-Out as Front */
1300 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1301 { } /* end */
1302};
1303
1304/*
1305 * 4ch mode
1306 */
1307static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1308/* Mic-in jack as mic in */
1309 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1310 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1311/* Line-in jack as Surround */
1312 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1313 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1314/* Line-Out as Front */
1315 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1316 { } /* end */
1317};
1318
1319/*
1320 * 6ch mode
1321 */
1322static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1323/* Mic-in jack as CLFE */
1324 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1325 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1326/* Line-in jack as Surround */
1327 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1328 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1329/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1330 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1331 { } /* end */
1332};
1333
1334/*
1335 * 8ch mode
1336 */
1337static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1338/* Mic-in jack as CLFE */
1339 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1340 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1341/* Line-in jack as Surround */
1342 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1343 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1344/* Line-Out as Side */
1345 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1346 { } /* end */
1347};
1348
1349static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1350 { 2, alc888_4ST_ch2_intel_init },
1351 { 4, alc888_4ST_ch4_intel_init },
1352 { 6, alc888_4ST_ch6_intel_init },
1353 { 8, alc888_4ST_ch8_intel_init },
1354};
1355
1356/*
1357 * ALC888 Fujitsu Siemens Amillo xa3530
1358 */
1359
1360static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1361/* Front Mic: set to PIN_IN (empty by default) */
1362 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1363/* Connect Internal HP to Front */
1364 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1365 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1366 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1367/* Connect Bass HP to Front */
1368 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1369 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1370 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1371/* Connect Line-Out side jack (SPDIF) to Side */
1372 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1373 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1374 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1375/* Connect Mic jack to CLFE */
1376 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1377 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1378 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1379/* Connect Line-in jack to Surround */
1380 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1381 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1382 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1383/* Connect HP out jack to Front */
1384 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1385 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1386 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1387/* Enable unsolicited event for HP jack and Line-out jack */
1388 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1389 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1390 {}
1391};
1392
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001393static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001394{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001395 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +02001396 unsigned int val, mute, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001397 hda_nid_t nid;
1398 int i;
1399
1400 spec->jack_present = 0;
1401 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1402 nid = spec->autocfg.hp_pins[i];
1403 if (!nid)
1404 break;
Takashi Iwai261c2402009-06-25 08:13:40 +02001405 pincap = snd_hda_query_pin_caps(codec, nid);
1406 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1407 snd_hda_codec_read(codec, nid, 0,
1408 AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001409 val = snd_hda_codec_read(codec, nid, 0,
1410 AC_VERB_GET_PIN_SENSE, 0);
1411 if (val & AC_PINSENSE_PRESENCE) {
1412 spec->jack_present = 1;
1413 break;
1414 }
1415 }
1416
1417 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001418 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001419 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1420 nid = spec->autocfg.speaker_pins[i];
1421 if (!nid)
1422 break;
1423 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1424 HDA_AMP_MUTE, mute);
1425 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001426}
1427
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001428static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1429 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001430{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001431 if (codec->vendor_id == 0x10ec0880)
1432 res >>= 28;
1433 else
1434 res >>= 26;
1435 if (res == ALC880_HP_EVENT)
1436 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001437}
1438
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001439static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1440{
1441 struct alc_spec *spec = codec->spec;
1442
1443 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1444 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1445 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1446 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1447 alc_automute_amp(codec);
1448}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001449
1450/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001451 * ALC888 Acer Aspire 4930G model
1452 */
1453
1454static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1455/* Front Mic: set to PIN_IN (empty by default) */
1456 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1457/* Unselect Front Mic by default in input mixer 3 */
1458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001459/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001460 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1461/* Connect Internal HP to front */
1462 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1464 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1465/* Connect HP out to front */
1466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1468 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1469 { }
1470};
1471
Hector Martin3b315d72009-06-02 10:54:19 +02001472/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001473 * ALC888 Acer Aspire 6530G model
1474 */
1475
1476static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1477/* Bias voltage on for external mic port */
1478 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001479/* Front Mic: set to PIN_IN (empty by default) */
1480 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1481/* Unselect Front Mic by default in input mixer 3 */
1482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001483/* Enable unsolicited event for HP jack */
1484 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1485/* Enable speaker output */
1486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1487 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1488/* Enable headphone output */
1489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1490 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1491 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1492 { }
1493};
1494
1495/*
Hector Martin018df412009-06-04 00:13:40 +02001496 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001497 */
1498
Hector Martin018df412009-06-04 00:13:40 +02001499static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001500/* Front Mic: set to PIN_IN (empty by default) */
1501 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1502/* Unselect Front Mic by default in input mixer 3 */
1503 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1504/* Enable unsolicited event for HP jack */
1505 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1506/* Connect Internal Front to Front */
1507 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1508 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1509 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1510/* Connect Internal Rear to Rear */
1511 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1512 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1513 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1514/* Connect Internal CLFE to CLFE */
1515 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1516 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1517 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1518/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001519 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1521 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1522/* Enable all DACs */
1523/* DAC DISABLE/MUTE 1? */
1524/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1525 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1526 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1527/* DAC DISABLE/MUTE 2? */
1528/* some bit here disables the other DACs. Init=0x4900 */
1529 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1530 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1531/* Enable amplifiers */
1532 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1533 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001534/* DMIC fix
1535 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1536 * which makes the stereo useless. However, either the mic or the ALC889
1537 * makes the signal become a difference/sum signal instead of standard
1538 * stereo, which is annoying. So instead we flip this bit which makes the
1539 * codec replicate the sum signal to both channels, turning it into a
1540 * normal mono mic.
1541 */
1542/* DMIC_CONTROL? Init value = 0x0001 */
1543 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1544 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001545 { }
1546};
1547
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001548static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001549 /* Front mic only available on one ADC */
1550 {
1551 .num_items = 4,
1552 .items = {
1553 { "Mic", 0x0 },
1554 { "Line", 0x2 },
1555 { "CD", 0x4 },
1556 { "Front Mic", 0xb },
1557 },
1558 },
1559 {
1560 .num_items = 3,
1561 .items = {
1562 { "Mic", 0x0 },
1563 { "Line", 0x2 },
1564 { "CD", 0x4 },
1565 },
1566 }
1567};
1568
Tony Vroond2fd4b02009-06-21 00:40:10 +01001569static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1570 /* Interal mic only available on one ADC */
1571 {
Tony Vroon684a8842009-06-26 09:27:50 +01001572 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001573 .items = {
1574 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001575 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001576 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001577 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001578 { "Int Mic", 0xb },
1579 },
1580 },
1581 {
Tony Vroon684a8842009-06-26 09:27:50 +01001582 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001583 .items = {
1584 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001585 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001586 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001587 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001588 },
1589 }
1590};
1591
Hector Martin018df412009-06-04 00:13:40 +02001592static struct hda_input_mux alc889_capture_sources[3] = {
1593 /* Digital mic only available on first "ADC" */
1594 {
1595 .num_items = 5,
1596 .items = {
1597 { "Mic", 0x0 },
1598 { "Line", 0x2 },
1599 { "CD", 0x4 },
1600 { "Front Mic", 0xb },
1601 { "Input Mix", 0xa },
1602 },
1603 },
1604 {
1605 .num_items = 4,
1606 .items = {
1607 { "Mic", 0x0 },
1608 { "Line", 0x2 },
1609 { "CD", 0x4 },
1610 { "Input Mix", 0xa },
1611 },
1612 },
1613 {
1614 .num_items = 4,
1615 .items = {
1616 { "Mic", 0x0 },
1617 { "Line", 0x2 },
1618 { "CD", 0x4 },
1619 { "Input Mix", 0xa },
1620 },
1621 }
1622};
1623
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001624static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001625 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1626 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1627 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1628 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1629 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1630 HDA_OUTPUT),
1631 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1632 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1633 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1634 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1635 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1636 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1637 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1638 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1639 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1640 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1641 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1642 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001643 { } /* end */
1644};
1645
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001646static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001647{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001648 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001649
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001650 spec->autocfg.hp_pins[0] = 0x15;
1651 spec->autocfg.speaker_pins[0] = 0x14;
1652 alc_automute_amp(codec);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001653}
1654
Emilio López320d5922009-06-25 08:18:44 +02001655static void alc888_acer_aspire_6530g_init_hook(struct hda_codec *codec)
1656{
1657 struct alc_spec *spec = codec->spec;
1658
1659 spec->autocfg.hp_pins[0] = 0x15;
1660 spec->autocfg.speaker_pins[0] = 0x14;
1661 spec->autocfg.speaker_pins[1] = 0x16;
1662 spec->autocfg.speaker_pins[2] = 0x17;
1663 alc_automute_amp(codec);
1664}
1665
Hector Martin018df412009-06-04 00:13:40 +02001666static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001667{
1668 struct alc_spec *spec = codec->spec;
1669
1670 spec->autocfg.hp_pins[0] = 0x15;
1671 spec->autocfg.speaker_pins[0] = 0x14;
1672 spec->autocfg.speaker_pins[1] = 0x16;
1673 spec->autocfg.speaker_pins[2] = 0x1b;
1674 alc_automute_amp(codec);
1675}
1676
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001677/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001678 * ALC880 3-stack model
1679 *
1680 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001681 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1682 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683 */
1684
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001685static hda_nid_t alc880_dac_nids[4] = {
1686 /* front, rear, clfe, rear_surr */
1687 0x02, 0x05, 0x04, 0x03
1688};
1689
1690static hda_nid_t alc880_adc_nids[3] = {
1691 /* ADC0-2 */
1692 0x07, 0x08, 0x09,
1693};
1694
1695/* The datasheet says the node 0x07 is connected from inputs,
1696 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001697 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001698 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001699static hda_nid_t alc880_adc_nids_alt[2] = {
1700 /* ADC1-2 */
1701 0x08, 0x09,
1702};
1703
1704#define ALC880_DIGOUT_NID 0x06
1705#define ALC880_DIGIN_NID 0x0a
1706
1707static struct hda_input_mux alc880_capture_source = {
1708 .num_items = 4,
1709 .items = {
1710 { "Mic", 0x0 },
1711 { "Front Mic", 0x3 },
1712 { "Line", 0x2 },
1713 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001714 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001715};
1716
1717/* channel source setting (2/6 channel selection for 3-stack) */
1718/* 2ch mode */
1719static struct hda_verb alc880_threestack_ch2_init[] = {
1720 /* set line-in to input, mute it */
1721 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1722 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1723 /* set mic-in to input vref 80%, mute it */
1724 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1725 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001726 { } /* end */
1727};
1728
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001729/* 6ch mode */
1730static struct hda_verb alc880_threestack_ch6_init[] = {
1731 /* set line-in to output, unmute it */
1732 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1733 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1734 /* set mic-in to output, unmute it */
1735 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1736 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1737 { } /* end */
1738};
1739
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001740static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001741 { 2, alc880_threestack_ch2_init },
1742 { 6, alc880_threestack_ch6_init },
1743};
1744
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001745static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001746 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001747 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001748 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001749 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001750 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1751 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001752 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1753 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001754 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1755 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1756 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1757 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1758 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1759 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1760 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1761 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001762 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001763 {
1764 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1765 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001766 .info = alc_ch_mode_info,
1767 .get = alc_ch_mode_get,
1768 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001769 },
1770 { } /* end */
1771};
1772
1773/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001774static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1775 struct snd_ctl_elem_info *uinfo)
1776{
1777 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1778 struct alc_spec *spec = codec->spec;
1779 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001780
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001781 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001782 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1783 HDA_INPUT);
1784 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001785 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001786 return err;
1787}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001788
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001789static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1790 unsigned int size, unsigned int __user *tlv)
1791{
1792 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1793 struct alc_spec *spec = codec->spec;
1794 int err;
1795
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001796 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001797 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1798 HDA_INPUT);
1799 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001800 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001801 return err;
1802}
1803
1804typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1805 struct snd_ctl_elem_value *ucontrol);
1806
1807static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1808 struct snd_ctl_elem_value *ucontrol,
1809 getput_call_t func)
1810{
1811 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1812 struct alc_spec *spec = codec->spec;
1813 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1814 int err;
1815
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001816 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001817 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1818 3, 0, HDA_INPUT);
1819 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001820 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001821 return err;
1822}
1823
1824static int alc_cap_vol_get(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_volume_get);
1829}
1830
1831static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1832 struct snd_ctl_elem_value *ucontrol)
1833{
1834 return alc_cap_getput_caller(kcontrol, ucontrol,
1835 snd_hda_mixer_amp_volume_put);
1836}
1837
1838/* capture mixer elements */
1839#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1840
1841static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1842 struct snd_ctl_elem_value *ucontrol)
1843{
1844 return alc_cap_getput_caller(kcontrol, ucontrol,
1845 snd_hda_mixer_amp_switch_get);
1846}
1847
1848static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1849 struct snd_ctl_elem_value *ucontrol)
1850{
1851 return alc_cap_getput_caller(kcontrol, ucontrol,
1852 snd_hda_mixer_amp_switch_put);
1853}
1854
Takashi Iwaia23b6882009-03-23 15:21:36 +01001855#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001856 { \
1857 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1858 .name = "Capture Switch", \
1859 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1860 .count = num, \
1861 .info = alc_cap_sw_info, \
1862 .get = alc_cap_sw_get, \
1863 .put = alc_cap_sw_put, \
1864 }, \
1865 { \
1866 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1867 .name = "Capture Volume", \
1868 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1869 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1870 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1871 .count = num, \
1872 .info = alc_cap_vol_info, \
1873 .get = alc_cap_vol_get, \
1874 .put = alc_cap_vol_put, \
1875 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001876 }
1877
1878#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001879 { \
1880 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1881 /* .name = "Capture Source", */ \
1882 .name = "Input Source", \
1883 .count = num, \
1884 .info = alc_mux_enum_info, \
1885 .get = alc_mux_enum_get, \
1886 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001887 }
1888
1889#define DEFINE_CAPMIX(num) \
1890static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1891 _DEFINE_CAPMIX(num), \
1892 _DEFINE_CAPSRC(num), \
1893 { } /* end */ \
1894}
1895
1896#define DEFINE_CAPMIX_NOSRC(num) \
1897static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
1898 _DEFINE_CAPMIX(num), \
1899 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001900}
1901
1902/* up to three ADCs */
1903DEFINE_CAPMIX(1);
1904DEFINE_CAPMIX(2);
1905DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01001906DEFINE_CAPMIX_NOSRC(1);
1907DEFINE_CAPMIX_NOSRC(2);
1908DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001909
1910/*
1911 * ALC880 5-stack model
1912 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001913 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1914 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001915 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1916 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1917 */
1918
1919/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001920static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001921 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001922 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001923 { } /* end */
1924};
1925
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001926/* channel source setting (6/8 channel selection for 5-stack) */
1927/* 6ch mode */
1928static struct hda_verb alc880_fivestack_ch6_init[] = {
1929 /* set line-in to input, mute it */
1930 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1931 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001932 { } /* end */
1933};
1934
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001935/* 8ch mode */
1936static struct hda_verb alc880_fivestack_ch8_init[] = {
1937 /* set line-in to output, unmute it */
1938 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1939 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1940 { } /* end */
1941};
1942
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001943static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001944 { 6, alc880_fivestack_ch6_init },
1945 { 8, alc880_fivestack_ch8_init },
1946};
1947
1948
1949/*
1950 * ALC880 6-stack model
1951 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001952 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1953 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001954 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1955 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1956 */
1957
1958static hda_nid_t alc880_6st_dac_nids[4] = {
1959 /* front, rear, clfe, rear_surr */
1960 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001961};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001962
1963static struct hda_input_mux alc880_6stack_capture_source = {
1964 .num_items = 4,
1965 .items = {
1966 { "Mic", 0x0 },
1967 { "Front Mic", 0x1 },
1968 { "Line", 0x2 },
1969 { "CD", 0x4 },
1970 },
1971};
1972
1973/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001974static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001975 { 8, NULL },
1976};
1977
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001978static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001979 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001980 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001981 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001982 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001983 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1984 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001985 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1986 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001987 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001988 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001989 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1990 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1991 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1992 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1996 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001997 {
1998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1999 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002000 .info = alc_ch_mode_info,
2001 .get = alc_ch_mode_get,
2002 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002003 },
2004 { } /* end */
2005};
2006
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002007
2008/*
2009 * ALC880 W810 model
2010 *
2011 * W810 has rear IO for:
2012 * Front (DAC 02)
2013 * Surround (DAC 03)
2014 * Center/LFE (DAC 04)
2015 * Digital out (06)
2016 *
2017 * The system also has a pair of internal speakers, and a headphone jack.
2018 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002019 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002020 * There is a variable resistor to control the speaker or headphone
2021 * volume. This is a hardware-only device without a software API.
2022 *
2023 * Plugging headphones in will disable the internal speakers. This is
2024 * implemented in hardware, not via the driver using jack sense. In
2025 * a similar fashion, plugging into the rear socket marked "front" will
2026 * disable both the speakers and headphones.
2027 *
2028 * For input, there's a microphone jack, and an "audio in" jack.
2029 * These may not do anything useful with this driver yet, because I
2030 * haven't setup any initialization verbs for these yet...
2031 */
2032
2033static hda_nid_t alc880_w810_dac_nids[3] = {
2034 /* front, rear/surround, clfe */
2035 0x02, 0x03, 0x04
2036};
2037
2038/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002039static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002040 { 6, NULL }
2041};
2042
2043/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002044static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002045 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002046 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002047 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002048 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002049 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2050 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002051 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2052 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002053 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2054 { } /* end */
2055};
2056
2057
2058/*
2059 * Z710V model
2060 *
2061 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002062 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2063 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002064 */
2065
2066static hda_nid_t alc880_z71v_dac_nids[1] = {
2067 0x02
2068};
2069#define ALC880_Z71V_HP_DAC 0x03
2070
2071/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002072static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002073 { 2, NULL }
2074};
2075
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002076static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002077 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002078 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002079 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002080 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002081 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2082 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2083 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2084 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2085 { } /* end */
2086};
2087
2088
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002089/*
2090 * ALC880 F1734 model
2091 *
2092 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2093 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2094 */
2095
2096static hda_nid_t alc880_f1734_dac_nids[1] = {
2097 0x03
2098};
2099#define ALC880_F1734_HP_DAC 0x02
2100
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002101static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002102 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002103 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002104 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2105 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002106 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2107 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2109 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002110 { } /* end */
2111};
2112
Takashi Iwai937b4162008-02-11 14:52:36 +01002113static struct hda_input_mux alc880_f1734_capture_source = {
2114 .num_items = 2,
2115 .items = {
2116 { "Mic", 0x1 },
2117 { "CD", 0x4 },
2118 },
2119};
2120
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002121
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002122/*
2123 * ALC880 ASUS model
2124 *
2125 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2126 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2127 * Mic = 0x18, Line = 0x1a
2128 */
2129
2130#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2131#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2132
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002133static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002134 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002135 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002136 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002137 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002138 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2139 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002140 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2141 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002142 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2143 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2144 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2145 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2146 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2147 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002148 {
2149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2150 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002151 .info = alc_ch_mode_info,
2152 .get = alc_ch_mode_get,
2153 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002154 },
2155 { } /* end */
2156};
2157
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002158/*
2159 * ALC880 ASUS W1V model
2160 *
2161 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2162 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2163 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2164 */
2165
2166/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002167static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002168 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2169 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002170 { } /* end */
2171};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002172
Kailang Yangdf694da2005-12-05 19:42:22 +01002173/* TCL S700 */
2174static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2175 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2176 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2177 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2178 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2179 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2181 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2182 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2183 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002184 { } /* end */
2185};
2186
Kailang Yangccc656c2006-10-17 12:32:26 +02002187/* Uniwill */
2188static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002189 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2190 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2191 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2192 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002193 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2194 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2195 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2196 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2197 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2198 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2199 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2200 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2201 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2202 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2203 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2204 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002205 {
2206 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2207 .name = "Channel Mode",
2208 .info = alc_ch_mode_info,
2209 .get = alc_ch_mode_get,
2210 .put = alc_ch_mode_put,
2211 },
2212 { } /* end */
2213};
2214
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002215static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2216 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2217 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2218 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2219 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2220 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2221 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2222 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2223 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2224 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2225 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2226 { } /* end */
2227};
2228
Kailang Yangccc656c2006-10-17 12:32:26 +02002229static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002230 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2231 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2232 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2233 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002234 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2235 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2236 { } /* end */
2237};
2238
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002240 * virtual master controls
2241 */
2242
2243/*
2244 * slave controls for virtual master
2245 */
2246static const char *alc_slave_vols[] = {
2247 "Front Playback Volume",
2248 "Surround Playback Volume",
2249 "Center Playback Volume",
2250 "LFE Playback Volume",
2251 "Side Playback Volume",
2252 "Headphone Playback Volume",
2253 "Speaker Playback Volume",
2254 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002255 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002256 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002257 NULL,
2258};
2259
2260static const char *alc_slave_sws[] = {
2261 "Front Playback Switch",
2262 "Surround Playback Switch",
2263 "Center Playback Switch",
2264 "LFE Playback Switch",
2265 "Side Playback Switch",
2266 "Headphone Playback Switch",
2267 "Speaker Playback Switch",
2268 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002269 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002270 NULL,
2271};
2272
2273/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002274 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002276
2277static void alc_free_kctls(struct hda_codec *codec);
2278
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002279/* additional beep mixers; the actual parameters are overwritten at build */
2280static struct snd_kcontrol_new alc_beep_mixer[] = {
2281 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2282 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2283 { } /* end */
2284};
2285
Linus Torvalds1da177e2005-04-16 15:20:36 -07002286static int alc_build_controls(struct hda_codec *codec)
2287{
2288 struct alc_spec *spec = codec->spec;
2289 int err;
2290 int i;
2291
2292 for (i = 0; i < spec->num_mixers; i++) {
2293 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2294 if (err < 0)
2295 return err;
2296 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002297 if (spec->cap_mixer) {
2298 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2299 if (err < 0)
2300 return err;
2301 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002302 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002303 err = snd_hda_create_spdif_out_ctls(codec,
2304 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002305 if (err < 0)
2306 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002307 if (!spec->no_analog) {
2308 err = snd_hda_create_spdif_share_sw(codec,
2309 &spec->multiout);
2310 if (err < 0)
2311 return err;
2312 spec->multiout.share_spdif = 1;
2313 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002314 }
2315 if (spec->dig_in_nid) {
2316 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2317 if (err < 0)
2318 return err;
2319 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002320
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002321 /* create beep controls if needed */
2322 if (spec->beep_amp) {
2323 struct snd_kcontrol_new *knew;
2324 for (knew = alc_beep_mixer; knew->name; knew++) {
2325 struct snd_kcontrol *kctl;
2326 kctl = snd_ctl_new1(knew, codec);
2327 if (!kctl)
2328 return -ENOMEM;
2329 kctl->private_value = spec->beep_amp;
2330 err = snd_hda_ctl_add(codec, kctl);
2331 if (err < 0)
2332 return err;
2333 }
2334 }
2335
Takashi Iwai2134ea42008-01-10 16:53:55 +01002336 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002337 if (!spec->no_analog &&
2338 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002339 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002340 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002341 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002342 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002343 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002344 if (err < 0)
2345 return err;
2346 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002347 if (!spec->no_analog &&
2348 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002349 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2350 NULL, alc_slave_sws);
2351 if (err < 0)
2352 return err;
2353 }
2354
Takashi Iwai603c4012008-07-30 15:01:44 +02002355 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356 return 0;
2357}
2358
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002359
Linus Torvalds1da177e2005-04-16 15:20:36 -07002360/*
2361 * initialize the codec volumes, etc
2362 */
2363
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002364/*
2365 * generic initialization of ADC, input mixers and output mixers
2366 */
2367static struct hda_verb alc880_volume_init_verbs[] = {
2368 /*
2369 * Unmute ADC0-2 and set the default input to mic-in
2370 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002371 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002372 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002373 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002374 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002375 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002376 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002378 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2379 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002380 * Note: PASD motherboards uses the Line In 2 as the input for front
2381 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002382 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002383 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002384 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2385 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2387 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2388 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2389 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2390 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002391
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002392 /*
2393 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002394 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002395 /* set vol=0 to output mixers */
2396 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2397 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2398 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2399 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2400 /* set up input amps for analog loopback */
2401 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002402 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002404 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2405 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002406 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2407 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002408 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2409 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002410
2411 { }
2412};
2413
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002414/*
2415 * 3-stack pin configuration:
2416 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2417 */
2418static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2419 /*
2420 * preset connection lists of input pins
2421 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2422 */
2423 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2424 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2425 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2426
2427 /*
2428 * Set pin mode and muting
2429 */
2430 /* set front pin widgets 0x14 for output */
2431 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2432 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2433 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2434 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2435 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2436 /* Mic2 (as headphone out) for HP output */
2437 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2438 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2439 /* Line In pin widget for input */
2440 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2441 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2442 /* Line2 (as front mic) pin widget for input and vref at 80% */
2443 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2444 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2445 /* CD pin widget for input */
2446 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2447
2448 { }
2449};
2450
2451/*
2452 * 5-stack pin configuration:
2453 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2454 * line-in/side = 0x1a, f-mic = 0x1b
2455 */
2456static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2457 /*
2458 * preset connection lists of input pins
2459 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2460 */
2461 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2462 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2463
2464 /*
2465 * Set pin mode and muting
2466 */
2467 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2470 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2471 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002472 /* unmute pins for output (no gain on this amp) */
2473 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2474 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2475 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2476 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2477
Linus Torvalds1da177e2005-04-16 15:20:36 -07002478 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002479 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002480 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2481 /* Mic2 (as headphone out) for HP output */
2482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002484 /* Line In pin widget for input */
2485 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2486 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2487 /* Line2 (as front mic) pin widget for input and vref at 80% */
2488 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2489 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2490 /* CD pin widget for input */
2491 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492
2493 { }
2494};
2495
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002496/*
2497 * W810 pin configuration:
2498 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2499 */
2500static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002501 /* hphone/speaker input selector: front DAC */
2502 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2503
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2506 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2507 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2508 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2509 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2510
2511 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002512 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002513
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514 { }
2515};
2516
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002517/*
2518 * Z71V pin configuration:
2519 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2520 */
2521static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002522 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002523 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002524 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002525 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002526
Takashi Iwai16ded522005-06-10 19:58:24 +02002527 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002528 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002529 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002530 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002531
2532 { }
2533};
2534
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002535/*
2536 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002537 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2538 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002539 */
2540static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2541 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2542
Takashi Iwai16ded522005-06-10 19:58:24 +02002543 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002544 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002545 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002546 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002547 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002548 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002549 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002550 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2551
Takashi Iwai16ded522005-06-10 19:58:24 +02002552 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002553 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002554 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002555 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002556 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002557 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002559 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002560 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002561
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002562 { }
2563};
Takashi Iwai16ded522005-06-10 19:58:24 +02002564
Kailang Yangccc656c2006-10-17 12:32:26 +02002565/*
2566 * Uniwill pin configuration:
2567 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2568 * line = 0x1a
2569 */
2570static struct hda_verb alc880_uniwill_init_verbs[] = {
2571 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2572
2573 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2574 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2577 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2578 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2579 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2580 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2581 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2583 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2584 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2585 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2586 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2587
2588 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2589 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2590 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2591 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2592 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2593 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2594 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2595 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2596 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2597
2598 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2599 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2600
2601 { }
2602};
2603
2604/*
2605* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002606* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002607 */
2608static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2609 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2610
2611 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2612 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2613 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2614 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2615 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2616 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2618 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2619 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2620 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2621 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2622 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2623
2624 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2625 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2626 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2627 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2628 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2629 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2630
2631 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2632 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2633
2634 { }
2635};
2636
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002637static struct hda_verb alc880_beep_init_verbs[] = {
2638 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2639 { }
2640};
2641
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002642/* auto-toggle front mic */
2643static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2644{
2645 unsigned int present;
2646 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002647
2648 present = snd_hda_codec_read(codec, 0x18, 0,
2649 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002650 bits = present ? HDA_AMP_MUTE : 0;
2651 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002652}
2653
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002654static void alc880_uniwill_init_hook(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002655{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002656 struct alc_spec *spec = codec->spec;
2657
2658 spec->autocfg.hp_pins[0] = 0x14;
2659 spec->autocfg.speaker_pins[0] = 0x15;
2660 spec->autocfg.speaker_pins[0] = 0x16;
2661 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002662 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002663}
2664
2665static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2666 unsigned int res)
2667{
2668 /* Looks like the unsol event is incompatible with the standard
2669 * definition. 4bit tag is placed at 28 bit!
2670 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002671 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002672 case ALC880_MIC_EVENT:
2673 alc880_uniwill_mic_automute(codec);
2674 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002675 default:
2676 alc_automute_amp_unsol_event(codec, res);
2677 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002678 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002679}
2680
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002681static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002682{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002683 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002684
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002685 spec->autocfg.hp_pins[0] = 0x14;
2686 spec->autocfg.speaker_pins[0] = 0x15;
2687 alc_automute_amp(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002688}
2689
2690static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2691{
2692 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002693
Kailang Yangccc656c2006-10-17 12:32:26 +02002694 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002695 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2696 present &= HDA_AMP_VOLMASK;
2697 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2698 HDA_AMP_VOLMASK, present);
2699 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2700 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002701}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002702
Kailang Yangccc656c2006-10-17 12:32:26 +02002703static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2704 unsigned int res)
2705{
2706 /* Looks like the unsol event is incompatible with the standard
2707 * definition. 4bit tag is placed at 28 bit!
2708 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002709 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002710 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002711 else
2712 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002713}
2714
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002715/*
2716 * F1734 pin configuration:
2717 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2718 */
2719static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002720 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002721 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2722 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2723 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2724 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2725
2726 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2727 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2728 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2729 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2730
2731 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2732 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002733 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002734 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2735 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2736 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2737 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2738 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2739 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002740
Takashi Iwai937b4162008-02-11 14:52:36 +01002741 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2742 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2743
Takashi Iwai16ded522005-06-10 19:58:24 +02002744 { }
2745};
2746
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002747/*
2748 * ASUS pin configuration:
2749 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2750 */
2751static struct hda_verb alc880_pin_asus_init_verbs[] = {
2752 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2753 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2754 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2755 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2756
2757 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2758 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2759 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2761 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2762 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2763 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2764 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2765
2766 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2767 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2768 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2769 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2770 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2771 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2772 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2773 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2774 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002775
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002776 { }
2777};
2778
2779/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002780#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2781#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002782#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002783
Kailang Yangdf694da2005-12-05 19:42:22 +01002784/* Clevo m520g init */
2785static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2786 /* headphone output */
2787 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2788 /* line-out */
2789 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2790 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2791 /* Line-in */
2792 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2793 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2794 /* CD */
2795 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2796 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2797 /* Mic1 (rear panel) */
2798 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2799 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2800 /* Mic2 (front panel) */
2801 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2802 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2803 /* headphone */
2804 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2805 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2806 /* change to EAPD mode */
2807 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2808 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2809
2810 { }
2811};
2812
2813static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002814 /* change to EAPD mode */
2815 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2816 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2817
Kailang Yangdf694da2005-12-05 19:42:22 +01002818 /* Headphone output */
2819 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2820 /* Front output*/
2821 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2822 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2823
2824 /* Line In pin widget for input */
2825 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2826 /* CD pin widget for input */
2827 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2828 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2829 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2830
2831 /* change to EAPD mode */
2832 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2833 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2834
2835 { }
2836};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002837
2838/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002839 * LG m1 express dual
2840 *
2841 * Pin assignment:
2842 * Rear Line-In/Out (blue): 0x14
2843 * Build-in Mic-In: 0x15
2844 * Speaker-out: 0x17
2845 * HP-Out (green): 0x1b
2846 * Mic-In/Out (red): 0x19
2847 * SPDIF-Out: 0x1e
2848 */
2849
2850/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2851static hda_nid_t alc880_lg_dac_nids[3] = {
2852 0x05, 0x02, 0x03
2853};
2854
2855/* seems analog CD is not working */
2856static struct hda_input_mux alc880_lg_capture_source = {
2857 .num_items = 3,
2858 .items = {
2859 { "Mic", 0x1 },
2860 { "Line", 0x5 },
2861 { "Internal Mic", 0x6 },
2862 },
2863};
2864
2865/* 2,4,6 channel modes */
2866static struct hda_verb alc880_lg_ch2_init[] = {
2867 /* set line-in and mic-in to input */
2868 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2869 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2870 { }
2871};
2872
2873static struct hda_verb alc880_lg_ch4_init[] = {
2874 /* set line-in to out and mic-in to input */
2875 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2876 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2877 { }
2878};
2879
2880static struct hda_verb alc880_lg_ch6_init[] = {
2881 /* set line-in and mic-in to output */
2882 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2883 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2884 { }
2885};
2886
2887static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2888 { 2, alc880_lg_ch2_init },
2889 { 4, alc880_lg_ch4_init },
2890 { 6, alc880_lg_ch6_init },
2891};
2892
2893static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002894 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2895 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002896 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2897 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2898 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2899 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2900 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2901 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2902 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2903 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2904 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2905 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2906 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2907 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2908 {
2909 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2910 .name = "Channel Mode",
2911 .info = alc_ch_mode_info,
2912 .get = alc_ch_mode_get,
2913 .put = alc_ch_mode_put,
2914 },
2915 { } /* end */
2916};
2917
2918static struct hda_verb alc880_lg_init_verbs[] = {
2919 /* set capture source to mic-in */
2920 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2921 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2922 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2923 /* mute all amp mixer inputs */
2924 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002925 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002927 /* line-in to input */
2928 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2929 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2930 /* built-in mic */
2931 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2932 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2933 /* speaker-out */
2934 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2935 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2936 /* mic-in to input */
2937 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2938 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2939 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2940 /* HP-out */
2941 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2942 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2943 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2944 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002945 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002946 { }
2947};
2948
2949/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002950static void alc880_lg_init_hook(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002951{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002952 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002953
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002954 spec->autocfg.hp_pins[0] = 0x1b;
2955 spec->autocfg.speaker_pins[0] = 0x17;
2956 alc_automute_amp(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002957}
2958
2959/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002960 * LG LW20
2961 *
2962 * Pin assignment:
2963 * Speaker-out: 0x14
2964 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002965 * Built-in Mic-In: 0x19
2966 * Line-In: 0x1b
2967 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002968 * SPDIF-Out: 0x1e
2969 */
2970
Takashi Iwaid6815182006-03-23 16:06:23 +01002971static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002972 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002973 .items = {
2974 { "Mic", 0x0 },
2975 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002976 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002977 },
2978};
2979
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002980#define alc880_lg_lw_modes alc880_threestack_modes
2981
Takashi Iwaid6815182006-03-23 16:06:23 +01002982static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002983 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2984 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2985 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2986 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2987 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2988 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2989 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2990 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2991 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2992 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2995 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2996 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002997 {
2998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2999 .name = "Channel Mode",
3000 .info = alc_ch_mode_info,
3001 .get = alc_ch_mode_get,
3002 .put = alc_ch_mode_put,
3003 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003004 { } /* end */
3005};
3006
3007static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003008 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3009 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3010 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3011
Takashi Iwaid6815182006-03-23 16:06:23 +01003012 /* set capture source to mic-in */
3013 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3014 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3015 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003017 /* speaker-out */
3018 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3019 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3020 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003021 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3022 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3023 /* mic-in to input */
3024 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3025 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3026 /* built-in mic */
3027 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3028 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3029 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003030 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003031 { }
3032};
3033
3034/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003035static void alc880_lg_lw_init_hook(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003036{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003037 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003038
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003039 spec->autocfg.hp_pins[0] = 0x1b;
3040 spec->autocfg.speaker_pins[0] = 0x14;
3041 alc_automute_amp(codec);
Takashi Iwaid6815182006-03-23 16:06:23 +01003042}
3043
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003044static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3045 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3046 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3049 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3050 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3051 { } /* end */
3052};
3053
3054static struct hda_input_mux alc880_medion_rim_capture_source = {
3055 .num_items = 2,
3056 .items = {
3057 { "Mic", 0x0 },
3058 { "Internal Mic", 0x1 },
3059 },
3060};
3061
3062static struct hda_verb alc880_medion_rim_init_verbs[] = {
3063 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3064
3065 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3066 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3067
3068 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3069 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3070 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3071 /* Mic2 (as headphone out) for HP output */
3072 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3073 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3074 /* Internal Speaker */
3075 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3076 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3077
3078 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3079 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3080
3081 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3082 { }
3083};
3084
3085/* toggle speaker-output according to the hp-jack state */
3086static void alc880_medion_rim_automute(struct hda_codec *codec)
3087{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003088 struct alc_spec *spec = codec->spec;
3089 alc_automute_amp(codec);
3090 /* toggle EAPD */
3091 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003092 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3093 else
3094 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3095}
3096
3097static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3098 unsigned int res)
3099{
3100 /* Looks like the unsol event is incompatible with the standard
3101 * definition. 4bit tag is placed at 28 bit!
3102 */
3103 if ((res >> 28) == ALC880_HP_EVENT)
3104 alc880_medion_rim_automute(codec);
3105}
3106
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003107static void alc880_medion_rim_init_hook(struct hda_codec *codec)
3108{
3109 struct alc_spec *spec = codec->spec;
3110
3111 spec->autocfg.hp_pins[0] = 0x14;
3112 spec->autocfg.speaker_pins[0] = 0x1b;
3113 alc880_medion_rim_automute(codec);
3114}
3115
Takashi Iwaicb53c622007-08-10 17:21:45 +02003116#ifdef CONFIG_SND_HDA_POWER_SAVE
3117static struct hda_amp_list alc880_loopbacks[] = {
3118 { 0x0b, HDA_INPUT, 0 },
3119 { 0x0b, HDA_INPUT, 1 },
3120 { 0x0b, HDA_INPUT, 2 },
3121 { 0x0b, HDA_INPUT, 3 },
3122 { 0x0b, HDA_INPUT, 4 },
3123 { } /* end */
3124};
3125
3126static struct hda_amp_list alc880_lg_loopbacks[] = {
3127 { 0x0b, HDA_INPUT, 1 },
3128 { 0x0b, HDA_INPUT, 6 },
3129 { 0x0b, HDA_INPUT, 7 },
3130 { } /* end */
3131};
3132#endif
3133
Takashi Iwaid6815182006-03-23 16:06:23 +01003134/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003135 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003136 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003137
Linus Torvalds1da177e2005-04-16 15:20:36 -07003138static int alc_init(struct hda_codec *codec)
3139{
3140 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003141 unsigned int i;
3142
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003143 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003144 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003145
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003146 for (i = 0; i < spec->num_init_verbs; i++)
3147 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003148
3149 if (spec->init_hook)
3150 spec->init_hook(codec);
3151
Linus Torvalds1da177e2005-04-16 15:20:36 -07003152 return 0;
3153}
3154
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003155static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3156{
3157 struct alc_spec *spec = codec->spec;
3158
3159 if (spec->unsol_event)
3160 spec->unsol_event(codec, res);
3161}
3162
Takashi Iwaicb53c622007-08-10 17:21:45 +02003163#ifdef CONFIG_SND_HDA_POWER_SAVE
3164static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3165{
3166 struct alc_spec *spec = codec->spec;
3167 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3168}
3169#endif
3170
Linus Torvalds1da177e2005-04-16 15:20:36 -07003171/*
3172 * Analog playback callbacks
3173 */
3174static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3175 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003176 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003177{
3178 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003179 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3180 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003181}
3182
3183static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3184 struct hda_codec *codec,
3185 unsigned int stream_tag,
3186 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003187 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003188{
3189 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003190 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3191 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003192}
3193
3194static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3195 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003196 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003197{
3198 struct alc_spec *spec = codec->spec;
3199 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3200}
3201
3202/*
3203 * Digital out
3204 */
3205static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3206 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003207 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003208{
3209 struct alc_spec *spec = codec->spec;
3210 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3211}
3212
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003213static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3214 struct hda_codec *codec,
3215 unsigned int stream_tag,
3216 unsigned int format,
3217 struct snd_pcm_substream *substream)
3218{
3219 struct alc_spec *spec = codec->spec;
3220 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3221 stream_tag, format, substream);
3222}
3223
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003224static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3225 struct hda_codec *codec,
3226 struct snd_pcm_substream *substream)
3227{
3228 struct alc_spec *spec = codec->spec;
3229 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3230}
3231
Linus Torvalds1da177e2005-04-16 15:20:36 -07003232static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3233 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 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3238}
3239
3240/*
3241 * Analog capture
3242 */
Takashi Iwai63300792008-01-24 15:31:36 +01003243static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003244 struct hda_codec *codec,
3245 unsigned int stream_tag,
3246 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003247 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003248{
3249 struct alc_spec *spec = codec->spec;
3250
Takashi Iwai63300792008-01-24 15:31:36 +01003251 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003252 stream_tag, 0, format);
3253 return 0;
3254}
3255
Takashi Iwai63300792008-01-24 15:31:36 +01003256static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003257 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003258 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003259{
3260 struct alc_spec *spec = codec->spec;
3261
Takashi Iwai888afa12008-03-18 09:57:50 +01003262 snd_hda_codec_cleanup_stream(codec,
3263 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003264 return 0;
3265}
3266
3267
3268/*
3269 */
3270static struct hda_pcm_stream alc880_pcm_analog_playback = {
3271 .substreams = 1,
3272 .channels_min = 2,
3273 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003274 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003275 .ops = {
3276 .open = alc880_playback_pcm_open,
3277 .prepare = alc880_playback_pcm_prepare,
3278 .cleanup = alc880_playback_pcm_cleanup
3279 },
3280};
3281
3282static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003283 .substreams = 1,
3284 .channels_min = 2,
3285 .channels_max = 2,
3286 /* NID is set in alc_build_pcms */
3287};
3288
3289static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3290 .substreams = 1,
3291 .channels_min = 2,
3292 .channels_max = 2,
3293 /* NID is set in alc_build_pcms */
3294};
3295
3296static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3297 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003298 .channels_min = 2,
3299 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003300 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003301 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003302 .prepare = alc880_alt_capture_pcm_prepare,
3303 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003304 },
3305};
3306
3307static struct hda_pcm_stream alc880_pcm_digital_playback = {
3308 .substreams = 1,
3309 .channels_min = 2,
3310 .channels_max = 2,
3311 /* NID is set in alc_build_pcms */
3312 .ops = {
3313 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003314 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003315 .prepare = alc880_dig_playback_pcm_prepare,
3316 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003317 },
3318};
3319
3320static struct hda_pcm_stream alc880_pcm_digital_capture = {
3321 .substreams = 1,
3322 .channels_min = 2,
3323 .channels_max = 2,
3324 /* NID is set in alc_build_pcms */
3325};
3326
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003327/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003328static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003329 .substreams = 0,
3330 .channels_min = 0,
3331 .channels_max = 0,
3332};
3333
Linus Torvalds1da177e2005-04-16 15:20:36 -07003334static int alc_build_pcms(struct hda_codec *codec)
3335{
3336 struct alc_spec *spec = codec->spec;
3337 struct hda_pcm *info = spec->pcm_rec;
3338 int i;
3339
3340 codec->num_pcms = 1;
3341 codec->pcm_info = info;
3342
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003343 if (spec->no_analog)
3344 goto skip_analog;
3345
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003346 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3347 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003348 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003349
Takashi Iwai4a471b72005-12-07 13:56:29 +01003350 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003351 if (snd_BUG_ON(!spec->multiout.dac_nids))
3352 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003353 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3354 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3355 }
3356 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003357 if (snd_BUG_ON(!spec->adc_nids))
3358 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003359 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3360 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3361 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003362
Takashi Iwai4a471b72005-12-07 13:56:29 +01003363 if (spec->channel_mode) {
3364 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3365 for (i = 0; i < spec->num_channel_mode; i++) {
3366 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3367 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3368 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003369 }
3370 }
3371
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003372 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003373 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003374 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003375 snprintf(spec->stream_name_digital,
3376 sizeof(spec->stream_name_digital),
3377 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003378 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003379 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003380 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003381 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003382 if (spec->dig_out_type)
3383 info->pcm_type = spec->dig_out_type;
3384 else
3385 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003386 if (spec->multiout.dig_out_nid &&
3387 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003388 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3389 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3390 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003391 if (spec->dig_in_nid &&
3392 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003393 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3394 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3395 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003396 /* FIXME: do we need this for all Realtek codec models? */
3397 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003398 }
3399
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003400 if (spec->no_analog)
3401 return 0;
3402
Takashi Iwaie08a0072006-09-07 17:52:14 +02003403 /* If the use of more than one ADC is requested for the current
3404 * model, configure a second analog capture-only PCM.
3405 */
3406 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003407 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3408 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003409 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003410 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003411 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003412 if (spec->alt_dac_nid) {
3413 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3414 *spec->stream_analog_alt_playback;
3415 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3416 spec->alt_dac_nid;
3417 } else {
3418 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3419 alc_pcm_null_stream;
3420 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3421 }
3422 if (spec->num_adc_nids > 1) {
3423 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3424 *spec->stream_analog_alt_capture;
3425 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3426 spec->adc_nids[1];
3427 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3428 spec->num_adc_nids - 1;
3429 } else {
3430 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3431 alc_pcm_null_stream;
3432 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003433 }
3434 }
3435
Linus Torvalds1da177e2005-04-16 15:20:36 -07003436 return 0;
3437}
3438
Takashi Iwai603c4012008-07-30 15:01:44 +02003439static void alc_free_kctls(struct hda_codec *codec)
3440{
3441 struct alc_spec *spec = codec->spec;
3442
3443 if (spec->kctls.list) {
3444 struct snd_kcontrol_new *kctl = spec->kctls.list;
3445 int i;
3446 for (i = 0; i < spec->kctls.used; i++)
3447 kfree(kctl[i].name);
3448 }
3449 snd_array_free(&spec->kctls);
3450}
3451
Linus Torvalds1da177e2005-04-16 15:20:36 -07003452static void alc_free(struct hda_codec *codec)
3453{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003454 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003455
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003456 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003457 return;
3458
Takashi Iwai603c4012008-07-30 15:01:44 +02003459 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003460 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003461 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003462}
3463
Takashi Iwaie044c392008-10-27 16:56:24 +01003464#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003465static int alc_resume(struct hda_codec *codec)
3466{
Takashi Iwaie044c392008-10-27 16:56:24 +01003467 codec->patch_ops.init(codec);
3468 snd_hda_codec_resume_amp(codec);
3469 snd_hda_codec_resume_cache(codec);
3470 return 0;
3471}
Takashi Iwaie044c392008-10-27 16:56:24 +01003472#endif
3473
Linus Torvalds1da177e2005-04-16 15:20:36 -07003474/*
3475 */
3476static struct hda_codec_ops alc_patch_ops = {
3477 .build_controls = alc_build_controls,
3478 .build_pcms = alc_build_pcms,
3479 .init = alc_init,
3480 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003481 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003482#ifdef SND_HDA_NEEDS_RESUME
3483 .resume = alc_resume,
3484#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003485#ifdef CONFIG_SND_HDA_POWER_SAVE
3486 .check_power_status = alc_check_power_status,
3487#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003488};
3489
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003490
3491/*
3492 * Test configuration for debugging
3493 *
3494 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3495 * enum controls.
3496 */
3497#ifdef CONFIG_SND_DEBUG
3498static hda_nid_t alc880_test_dac_nids[4] = {
3499 0x02, 0x03, 0x04, 0x05
3500};
3501
3502static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003503 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003504 .items = {
3505 { "In-1", 0x0 },
3506 { "In-2", 0x1 },
3507 { "In-3", 0x2 },
3508 { "In-4", 0x3 },
3509 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003510 { "Front", 0x5 },
3511 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003512 },
3513};
3514
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003515static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003516 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003517 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003518 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003519 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003520};
3521
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003522static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3523 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003524{
3525 static char *texts[] = {
3526 "N/A", "Line Out", "HP Out",
3527 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3528 };
3529 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3530 uinfo->count = 1;
3531 uinfo->value.enumerated.items = 8;
3532 if (uinfo->value.enumerated.item >= 8)
3533 uinfo->value.enumerated.item = 7;
3534 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3535 return 0;
3536}
3537
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003538static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3539 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003540{
3541 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3542 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3543 unsigned int pin_ctl, item = 0;
3544
3545 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3546 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3547 if (pin_ctl & AC_PINCTL_OUT_EN) {
3548 if (pin_ctl & AC_PINCTL_HP_EN)
3549 item = 2;
3550 else
3551 item = 1;
3552 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3553 switch (pin_ctl & AC_PINCTL_VREFEN) {
3554 case AC_PINCTL_VREF_HIZ: item = 3; break;
3555 case AC_PINCTL_VREF_50: item = 4; break;
3556 case AC_PINCTL_VREF_GRD: item = 5; break;
3557 case AC_PINCTL_VREF_80: item = 6; break;
3558 case AC_PINCTL_VREF_100: item = 7; break;
3559 }
3560 }
3561 ucontrol->value.enumerated.item[0] = item;
3562 return 0;
3563}
3564
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003565static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3566 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003567{
3568 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3569 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3570 static unsigned int ctls[] = {
3571 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3572 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3573 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3574 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3575 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3576 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3577 };
3578 unsigned int old_ctl, new_ctl;
3579
3580 old_ctl = snd_hda_codec_read(codec, nid, 0,
3581 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3582 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3583 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003584 int val;
3585 snd_hda_codec_write_cache(codec, nid, 0,
3586 AC_VERB_SET_PIN_WIDGET_CONTROL,
3587 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003588 val = ucontrol->value.enumerated.item[0] >= 3 ?
3589 HDA_AMP_MUTE : 0;
3590 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3591 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003592 return 1;
3593 }
3594 return 0;
3595}
3596
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003597static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3598 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003599{
3600 static char *texts[] = {
3601 "Front", "Surround", "CLFE", "Side"
3602 };
3603 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3604 uinfo->count = 1;
3605 uinfo->value.enumerated.items = 4;
3606 if (uinfo->value.enumerated.item >= 4)
3607 uinfo->value.enumerated.item = 3;
3608 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3609 return 0;
3610}
3611
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003612static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3613 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003614{
3615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3616 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3617 unsigned int sel;
3618
3619 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3620 ucontrol->value.enumerated.item[0] = sel & 3;
3621 return 0;
3622}
3623
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003624static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3625 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003626{
3627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3628 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3629 unsigned int sel;
3630
3631 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3632 if (ucontrol->value.enumerated.item[0] != sel) {
3633 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003634 snd_hda_codec_write_cache(codec, nid, 0,
3635 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003636 return 1;
3637 }
3638 return 0;
3639}
3640
3641#define PIN_CTL_TEST(xname,nid) { \
3642 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3643 .name = xname, \
3644 .info = alc_test_pin_ctl_info, \
3645 .get = alc_test_pin_ctl_get, \
3646 .put = alc_test_pin_ctl_put, \
3647 .private_value = nid \
3648 }
3649
3650#define PIN_SRC_TEST(xname,nid) { \
3651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3652 .name = xname, \
3653 .info = alc_test_pin_src_info, \
3654 .get = alc_test_pin_src_get, \
3655 .put = alc_test_pin_src_put, \
3656 .private_value = nid \
3657 }
3658
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003659static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003660 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3661 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3662 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3663 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003664 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3665 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3666 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3667 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003668 PIN_CTL_TEST("Front Pin Mode", 0x14),
3669 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3670 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3671 PIN_CTL_TEST("Side Pin Mode", 0x17),
3672 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3673 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3674 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3675 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3676 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3677 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3678 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3679 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3680 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3681 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3682 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3683 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3684 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3685 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3686 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3687 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3688 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3689 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003690 {
3691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3692 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003693 .info = alc_ch_mode_info,
3694 .get = alc_ch_mode_get,
3695 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003696 },
3697 { } /* end */
3698};
3699
3700static struct hda_verb alc880_test_init_verbs[] = {
3701 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003702 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3703 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3704 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3705 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3706 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3707 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3708 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3709 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003710 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3712 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3713 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3714 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003715 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003716 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3717 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3718 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3719 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003720 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003721 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3722 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3723 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3724 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003725 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003726 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3727 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003728 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3730 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003731 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003732 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3733 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3734 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3735 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003736 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003737 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003738 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003739 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003740 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003741 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003742 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003743 /* Analog input/passthru */
3744 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3745 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3746 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3747 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3748 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003749 { }
3750};
3751#endif
3752
Linus Torvalds1da177e2005-04-16 15:20:36 -07003753/*
3754 */
3755
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003756static const char *alc880_models[ALC880_MODEL_LAST] = {
3757 [ALC880_3ST] = "3stack",
3758 [ALC880_TCL_S700] = "tcl",
3759 [ALC880_3ST_DIG] = "3stack-digout",
3760 [ALC880_CLEVO] = "clevo",
3761 [ALC880_5ST] = "5stack",
3762 [ALC880_5ST_DIG] = "5stack-digout",
3763 [ALC880_W810] = "w810",
3764 [ALC880_Z71V] = "z71v",
3765 [ALC880_6ST] = "6stack",
3766 [ALC880_6ST_DIG] = "6stack-digout",
3767 [ALC880_ASUS] = "asus",
3768 [ALC880_ASUS_W1V] = "asus-w1v",
3769 [ALC880_ASUS_DIG] = "asus-dig",
3770 [ALC880_ASUS_DIG2] = "asus-dig2",
3771 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003772 [ALC880_UNIWILL_P53] = "uniwill-p53",
3773 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003774 [ALC880_F1734] = "F1734",
3775 [ALC880_LG] = "lg",
3776 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003777 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003778#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003779 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003780#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003781 [ALC880_AUTO] = "auto",
3782};
3783
3784static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003785 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003786 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3787 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3788 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3789 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3790 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3791 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3792 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3793 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003794 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3795 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003796 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3797 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3798 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3799 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3800 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3801 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3802 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3803 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3804 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3805 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003806 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003807 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3808 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3809 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003810 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003811 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003812 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3813 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003814 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3815 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003816 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3817 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3818 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3819 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003820 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3821 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003822 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003823 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003824 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003825 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003826 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3827 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003828 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003829 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003830 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003831 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003832 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003833 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003834 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003835 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003836 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003837 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3838 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003839 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003840 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3841 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3842 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3843 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003844 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3845 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003846 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003847 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003848 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3849 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003850 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3851 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3852 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003853 /* default Intel */
3854 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003855 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3856 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003857 {}
3858};
3859
Takashi Iwai16ded522005-06-10 19:58:24 +02003860/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003861 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003862 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003863static struct alc_config_preset alc880_presets[] = {
3864 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003865 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003866 .init_verbs = { alc880_volume_init_verbs,
3867 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003868 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003869 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003870 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3871 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003872 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003873 .input_mux = &alc880_capture_source,
3874 },
3875 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003876 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003877 .init_verbs = { alc880_volume_init_verbs,
3878 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003879 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003880 .dac_nids = alc880_dac_nids,
3881 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003882 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3883 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003884 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003885 .input_mux = &alc880_capture_source,
3886 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003887 [ALC880_TCL_S700] = {
3888 .mixers = { alc880_tcl_s700_mixer },
3889 .init_verbs = { alc880_volume_init_verbs,
3890 alc880_pin_tcl_S700_init_verbs,
3891 alc880_gpio2_init_verbs },
3892 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3893 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003894 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3895 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003896 .hp_nid = 0x03,
3897 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3898 .channel_mode = alc880_2_jack_modes,
3899 .input_mux = &alc880_capture_source,
3900 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003901 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003902 .mixers = { alc880_three_stack_mixer,
3903 alc880_five_stack_mixer},
3904 .init_verbs = { alc880_volume_init_verbs,
3905 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003906 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3907 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003908 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3909 .channel_mode = alc880_fivestack_modes,
3910 .input_mux = &alc880_capture_source,
3911 },
3912 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003913 .mixers = { alc880_three_stack_mixer,
3914 alc880_five_stack_mixer },
3915 .init_verbs = { alc880_volume_init_verbs,
3916 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003917 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3918 .dac_nids = alc880_dac_nids,
3919 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003920 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3921 .channel_mode = alc880_fivestack_modes,
3922 .input_mux = &alc880_capture_source,
3923 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003924 [ALC880_6ST] = {
3925 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003926 .init_verbs = { alc880_volume_init_verbs,
3927 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003928 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3929 .dac_nids = alc880_6st_dac_nids,
3930 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3931 .channel_mode = alc880_sixstack_modes,
3932 .input_mux = &alc880_6stack_capture_source,
3933 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003934 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003935 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003936 .init_verbs = { alc880_volume_init_verbs,
3937 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003938 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3939 .dac_nids = alc880_6st_dac_nids,
3940 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003941 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3942 .channel_mode = alc880_sixstack_modes,
3943 .input_mux = &alc880_6stack_capture_source,
3944 },
3945 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003946 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003947 .init_verbs = { alc880_volume_init_verbs,
3948 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003949 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003950 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3951 .dac_nids = alc880_w810_dac_nids,
3952 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003953 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3954 .channel_mode = alc880_w810_modes,
3955 .input_mux = &alc880_capture_source,
3956 },
3957 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003958 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003959 .init_verbs = { alc880_volume_init_verbs,
3960 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003961 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3962 .dac_nids = alc880_z71v_dac_nids,
3963 .dig_out_nid = ALC880_DIGOUT_NID,
3964 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003965 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3966 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003967 .input_mux = &alc880_capture_source,
3968 },
3969 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003970 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003971 .init_verbs = { alc880_volume_init_verbs,
3972 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003973 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3974 .dac_nids = alc880_f1734_dac_nids,
3975 .hp_nid = 0x02,
3976 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3977 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003978 .input_mux = &alc880_f1734_capture_source,
3979 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003980 .init_hook = alc880_uniwill_p53_init_hook,
Takashi Iwai16ded522005-06-10 19:58:24 +02003981 },
3982 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003983 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003984 .init_verbs = { alc880_volume_init_verbs,
3985 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003986 alc880_gpio1_init_verbs },
3987 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3988 .dac_nids = alc880_asus_dac_nids,
3989 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3990 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003991 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003992 .input_mux = &alc880_capture_source,
3993 },
3994 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003995 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003996 .init_verbs = { alc880_volume_init_verbs,
3997 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003998 alc880_gpio1_init_verbs },
3999 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4000 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004001 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004002 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4003 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004004 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004005 .input_mux = &alc880_capture_source,
4006 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004007 [ALC880_ASUS_DIG2] = {
4008 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004009 .init_verbs = { alc880_volume_init_verbs,
4010 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004011 alc880_gpio2_init_verbs }, /* use GPIO2 */
4012 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4013 .dac_nids = alc880_asus_dac_nids,
4014 .dig_out_nid = ALC880_DIGOUT_NID,
4015 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4016 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004017 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004018 .input_mux = &alc880_capture_source,
4019 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004020 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004021 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004022 .init_verbs = { alc880_volume_init_verbs,
4023 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004024 alc880_gpio1_init_verbs },
4025 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4026 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004027 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004028 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4029 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004030 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004031 .input_mux = &alc880_capture_source,
4032 },
4033 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004034 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004035 .init_verbs = { alc880_volume_init_verbs,
4036 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004037 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4038 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004039 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004040 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4041 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004042 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004043 .input_mux = &alc880_capture_source,
4044 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004045 [ALC880_UNIWILL] = {
4046 .mixers = { alc880_uniwill_mixer },
4047 .init_verbs = { alc880_volume_init_verbs,
4048 alc880_uniwill_init_verbs },
4049 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4050 .dac_nids = alc880_asus_dac_nids,
4051 .dig_out_nid = ALC880_DIGOUT_NID,
4052 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4053 .channel_mode = alc880_threestack_modes,
4054 .need_dac_fix = 1,
4055 .input_mux = &alc880_capture_source,
4056 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004057 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004058 },
4059 [ALC880_UNIWILL_P53] = {
4060 .mixers = { alc880_uniwill_p53_mixer },
4061 .init_verbs = { alc880_volume_init_verbs,
4062 alc880_uniwill_p53_init_verbs },
4063 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4064 .dac_nids = alc880_asus_dac_nids,
4065 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004066 .channel_mode = alc880_threestack_modes,
4067 .input_mux = &alc880_capture_source,
4068 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004069 .init_hook = alc880_uniwill_p53_init_hook,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004070 },
4071 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004072 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004073 .init_verbs = { alc880_volume_init_verbs,
4074 alc880_uniwill_p53_init_verbs,
4075 alc880_beep_init_verbs },
4076 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4077 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004078 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004079 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4080 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004081 .input_mux = &alc880_capture_source,
4082 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004083 .init_hook = alc880_uniwill_p53_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004084 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004085 [ALC880_CLEVO] = {
4086 .mixers = { alc880_three_stack_mixer },
4087 .init_verbs = { alc880_volume_init_verbs,
4088 alc880_pin_clevo_init_verbs },
4089 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4090 .dac_nids = alc880_dac_nids,
4091 .hp_nid = 0x03,
4092 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4093 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004094 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004095 .input_mux = &alc880_capture_source,
4096 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004097 [ALC880_LG] = {
4098 .mixers = { alc880_lg_mixer },
4099 .init_verbs = { alc880_volume_init_verbs,
4100 alc880_lg_init_verbs },
4101 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4102 .dac_nids = alc880_lg_dac_nids,
4103 .dig_out_nid = ALC880_DIGOUT_NID,
4104 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4105 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004106 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004107 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004108 .unsol_event = alc_automute_amp_unsol_event,
4109 .init_hook = alc880_lg_init_hook,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004110#ifdef CONFIG_SND_HDA_POWER_SAVE
4111 .loopbacks = alc880_lg_loopbacks,
4112#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004113 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004114 [ALC880_LG_LW] = {
4115 .mixers = { alc880_lg_lw_mixer },
4116 .init_verbs = { alc880_volume_init_verbs,
4117 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004118 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004119 .dac_nids = alc880_dac_nids,
4120 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004121 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4122 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004123 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004124 .unsol_event = alc_automute_amp_unsol_event,
4125 .init_hook = alc880_lg_lw_init_hook,
Takashi Iwaid6815182006-03-23 16:06:23 +01004126 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004127 [ALC880_MEDION_RIM] = {
4128 .mixers = { alc880_medion_rim_mixer },
4129 .init_verbs = { alc880_volume_init_verbs,
4130 alc880_medion_rim_init_verbs,
4131 alc_gpio2_init_verbs },
4132 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4133 .dac_nids = alc880_dac_nids,
4134 .dig_out_nid = ALC880_DIGOUT_NID,
4135 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4136 .channel_mode = alc880_2_jack_modes,
4137 .input_mux = &alc880_medion_rim_capture_source,
4138 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004139 .init_hook = alc880_medion_rim_init_hook,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004140 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004141#ifdef CONFIG_SND_DEBUG
4142 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004143 .mixers = { alc880_test_mixer },
4144 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004145 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4146 .dac_nids = alc880_test_dac_nids,
4147 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004148 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4149 .channel_mode = alc880_test_modes,
4150 .input_mux = &alc880_test_capture_source,
4151 },
4152#endif
4153};
4154
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004155/*
4156 * Automatic parse of I/O pins from the BIOS configuration
4157 */
4158
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004159enum {
4160 ALC_CTL_WIDGET_VOL,
4161 ALC_CTL_WIDGET_MUTE,
4162 ALC_CTL_BIND_MUTE,
4163};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004164static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004165 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4166 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004167 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004168};
4169
4170/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004171static int add_control(struct alc_spec *spec, int type, const char *name,
4172 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004173{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004174 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004175
Takashi Iwai603c4012008-07-30 15:01:44 +02004176 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4177 knew = snd_array_new(&spec->kctls);
4178 if (!knew)
4179 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004180 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004181 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004182 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004183 return -ENOMEM;
4184 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004185 return 0;
4186}
4187
4188#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4189#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4190#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4191#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4192#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4193#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4194#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4195#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4196#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4197#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4198#define ALC880_PIN_CD_NID 0x1c
4199
4200/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004201static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4202 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004203{
4204 hda_nid_t nid;
4205 int assigned[4];
4206 int i, j;
4207
4208 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004209 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004210
4211 /* check the pins hardwired to audio widget */
4212 for (i = 0; i < cfg->line_outs; i++) {
4213 nid = cfg->line_out_pins[i];
4214 if (alc880_is_fixed_pin(nid)) {
4215 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004216 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004217 assigned[idx] = 1;
4218 }
4219 }
4220 /* left pins can be connect to any audio widget */
4221 for (i = 0; i < cfg->line_outs; i++) {
4222 nid = cfg->line_out_pins[i];
4223 if (alc880_is_fixed_pin(nid))
4224 continue;
4225 /* search for an empty channel */
4226 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004227 if (!assigned[j]) {
4228 spec->multiout.dac_nids[i] =
4229 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004230 assigned[j] = 1;
4231 break;
4232 }
4233 }
4234 }
4235 spec->multiout.num_dacs = cfg->line_outs;
4236 return 0;
4237}
4238
4239/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004240static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4241 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004242{
4243 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004244 static const char *chname[4] = {
4245 "Front", "Surround", NULL /*CLFE*/, "Side"
4246 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004247 hda_nid_t nid;
4248 int i, err;
4249
4250 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004251 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004252 continue;
4253 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4254 if (i == 2) {
4255 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004256 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4257 "Center Playback Volume",
4258 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4259 HDA_OUTPUT));
4260 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004261 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004262 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4263 "LFE Playback Volume",
4264 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4265 HDA_OUTPUT));
4266 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004267 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004268 err = add_control(spec, ALC_CTL_BIND_MUTE,
4269 "Center Playback Switch",
4270 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4271 HDA_INPUT));
4272 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004273 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004274 err = add_control(spec, ALC_CTL_BIND_MUTE,
4275 "LFE Playback Switch",
4276 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4277 HDA_INPUT));
4278 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004279 return err;
4280 } else {
4281 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004282 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4283 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4284 HDA_OUTPUT));
4285 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004286 return err;
4287 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004288 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4289 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4290 HDA_INPUT));
4291 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004292 return err;
4293 }
4294 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004295 return 0;
4296}
4297
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004298/* add playback controls for speaker and HP outputs */
4299static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4300 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004301{
4302 hda_nid_t nid;
4303 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004304 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004305
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004306 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004307 return 0;
4308
4309 if (alc880_is_fixed_pin(pin)) {
4310 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004311 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004312 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004313 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004314 else
4315 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004316 /* control HP volume/switch on the output mixer amp */
4317 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004318 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004319 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4320 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4321 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004322 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004323 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004324 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4325 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4326 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004327 return err;
4328 } else if (alc880_is_multi_pin(pin)) {
4329 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004330 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004331 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004332 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4333 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4334 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004335 return err;
4336 }
4337 return 0;
4338}
4339
4340/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004341static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4342 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004343 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004344{
4345 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004346 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004347
4348 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004349 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4350 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4351 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004352 return err;
4353 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004354 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4355 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4356 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004357 return err;
4358 return 0;
4359}
4360
4361/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004362static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4363 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004364{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004365 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004366 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004367
4368 for (i = 0; i < AUTO_PIN_LAST; i++) {
4369 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004370 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004371 err = new_analog_input(spec, cfg->input_pins[i],
4372 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004373 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004374 if (err < 0)
4375 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004376 imux->items[imux->num_items].label =
4377 auto_pin_cfg_labels[i];
4378 imux->items[imux->num_items].index =
4379 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004380 imux->num_items++;
4381 }
4382 }
4383 return 0;
4384}
4385
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004386static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4387 unsigned int pin_type)
4388{
4389 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4390 pin_type);
4391 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004392 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4393 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004394}
4395
Kailang Yangdf694da2005-12-05 19:42:22 +01004396static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4397 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004398 int dac_idx)
4399{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004400 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004401 /* need the manual connection? */
4402 if (alc880_is_multi_pin(nid)) {
4403 struct alc_spec *spec = codec->spec;
4404 int idx = alc880_multi_pin_idx(nid);
4405 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4406 AC_VERB_SET_CONNECT_SEL,
4407 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4408 }
4409}
4410
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004411static int get_pin_type(int line_out_type)
4412{
4413 if (line_out_type == AUTO_PIN_HP_OUT)
4414 return PIN_HP;
4415 else
4416 return PIN_OUT;
4417}
4418
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004419static void alc880_auto_init_multi_out(struct hda_codec *codec)
4420{
4421 struct alc_spec *spec = codec->spec;
4422 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004423
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004424 for (i = 0; i < spec->autocfg.line_outs; i++) {
4425 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004426 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4427 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004428 }
4429}
4430
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004431static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004432{
4433 struct alc_spec *spec = codec->spec;
4434 hda_nid_t pin;
4435
Takashi Iwai82bc9552006-03-21 11:24:42 +01004436 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004437 if (pin) /* connect to front */
4438 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004439 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004440 if (pin) /* connect to front */
4441 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4442}
4443
4444static void alc880_auto_init_analog_input(struct hda_codec *codec)
4445{
4446 struct alc_spec *spec = codec->spec;
4447 int i;
4448
4449 for (i = 0; i < AUTO_PIN_LAST; i++) {
4450 hda_nid_t nid = spec->autocfg.input_pins[i];
4451 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004452 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004453 if (nid != ALC880_PIN_CD_NID &&
4454 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004455 snd_hda_codec_write(codec, nid, 0,
4456 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004457 AMP_OUT_MUTE);
4458 }
4459 }
4460}
4461
4462/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004463/* return 1 if successful, 0 if the proper config is not found,
4464 * or a negative error code
4465 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004466static int alc880_parse_auto_config(struct hda_codec *codec)
4467{
4468 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004469 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004470 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004471
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004472 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4473 alc880_ignore);
4474 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004475 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004476 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004477 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004478
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004479 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4480 if (err < 0)
4481 return err;
4482 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4483 if (err < 0)
4484 return err;
4485 err = alc880_auto_create_extra_out(spec,
4486 spec->autocfg.speaker_pins[0],
4487 "Speaker");
4488 if (err < 0)
4489 return err;
4490 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4491 "Headphone");
4492 if (err < 0)
4493 return err;
4494 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4495 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004496 return err;
4497
4498 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4499
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004500 /* check multiple SPDIF-out (for recent codecs) */
4501 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4502 hda_nid_t dig_nid;
4503 err = snd_hda_get_connections(codec,
4504 spec->autocfg.dig_out_pins[i],
4505 &dig_nid, 1);
4506 if (err < 0)
4507 continue;
4508 if (!i)
4509 spec->multiout.dig_out_nid = dig_nid;
4510 else {
4511 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4512 spec->slave_dig_outs[i - 1] = dig_nid;
4513 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4514 break;
4515 }
4516 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004517 if (spec->autocfg.dig_in_pin)
4518 spec->dig_in_nid = ALC880_DIGIN_NID;
4519
Takashi Iwai603c4012008-07-30 15:01:44 +02004520 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004521 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004522
Takashi Iwaid88897e2008-10-31 15:01:37 +01004523 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004524
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004525 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004526 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004527
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004528 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4529
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004530 return 1;
4531}
4532
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004533/* additional initialization for auto-configuration model */
4534static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004535{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004536 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004537 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004538 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004539 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004540 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004541 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004542}
4543
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004544static void set_capture_mixer(struct alc_spec *spec)
4545{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004546 static struct snd_kcontrol_new *caps[2][3] = {
4547 { alc_capture_mixer_nosrc1,
4548 alc_capture_mixer_nosrc2,
4549 alc_capture_mixer_nosrc3 },
4550 { alc_capture_mixer1,
4551 alc_capture_mixer2,
4552 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004553 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004554 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4555 int mux;
4556 if (spec->input_mux && spec->input_mux->num_items > 1)
4557 mux = 1;
4558 else
4559 mux = 0;
4560 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4561 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004562}
4563
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004564#define set_beep_amp(spec, nid, idx, dir) \
4565 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4566
4567/*
4568 * OK, here we have finally the patch for ALC880
4569 */
4570
Linus Torvalds1da177e2005-04-16 15:20:36 -07004571static int patch_alc880(struct hda_codec *codec)
4572{
4573 struct alc_spec *spec;
4574 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004575 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004576
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004577 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004578 if (spec == NULL)
4579 return -ENOMEM;
4580
4581 codec->spec = spec;
4582
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004583 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4584 alc880_models,
4585 alc880_cfg_tbl);
4586 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02004587 printk(KERN_INFO "hda_codec: Unknown model for %s, "
4588 "trying auto-probe from BIOS...\n", codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004589 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004590 }
4591
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004592 if (board_config == ALC880_AUTO) {
4593 /* automatic parse from the BIOS config */
4594 err = alc880_parse_auto_config(codec);
4595 if (err < 0) {
4596 alc_free(codec);
4597 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004598 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004599 printk(KERN_INFO
4600 "hda_codec: Cannot set up configuration "
4601 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004602 board_config = ALC880_3ST;
4603 }
4604 }
4605
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004606 err = snd_hda_attach_beep_device(codec, 0x1);
4607 if (err < 0) {
4608 alc_free(codec);
4609 return err;
4610 }
4611
Kailang Yangdf694da2005-12-05 19:42:22 +01004612 if (board_config != ALC880_AUTO)
4613 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004614
Linus Torvalds1da177e2005-04-16 15:20:36 -07004615 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4616 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004617 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004618
Linus Torvalds1da177e2005-04-16 15:20:36 -07004619 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4620 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4621
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004622 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004623 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004624 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004625 /* get type */
4626 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004627 if (wcap != AC_WID_AUD_IN) {
4628 spec->adc_nids = alc880_adc_nids_alt;
4629 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004630 } else {
4631 spec->adc_nids = alc880_adc_nids;
4632 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004633 }
4634 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004635 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004636 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004637
Takashi Iwai2134ea42008-01-10 16:53:55 +01004638 spec->vmaster_nid = 0x0c;
4639
Linus Torvalds1da177e2005-04-16 15:20:36 -07004640 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004641 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004642 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004643#ifdef CONFIG_SND_HDA_POWER_SAVE
4644 if (!spec->loopback.amplist)
4645 spec->loopback.amplist = alc880_loopbacks;
4646#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004647 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004648
4649 return 0;
4650}
4651
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004652
Linus Torvalds1da177e2005-04-16 15:20:36 -07004653/*
4654 * ALC260 support
4655 */
4656
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004657static hda_nid_t alc260_dac_nids[1] = {
4658 /* front */
4659 0x02,
4660};
4661
4662static hda_nid_t alc260_adc_nids[1] = {
4663 /* ADC0 */
4664 0x04,
4665};
4666
Kailang Yangdf694da2005-12-05 19:42:22 +01004667static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004668 /* ADC1 */
4669 0x05,
4670};
4671
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004672/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4673 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4674 */
4675static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004676 /* ADC0, ADC1 */
4677 0x04, 0x05
4678};
4679
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004680#define ALC260_DIGOUT_NID 0x03
4681#define ALC260_DIGIN_NID 0x06
4682
4683static struct hda_input_mux alc260_capture_source = {
4684 .num_items = 4,
4685 .items = {
4686 { "Mic", 0x0 },
4687 { "Front Mic", 0x1 },
4688 { "Line", 0x2 },
4689 { "CD", 0x4 },
4690 },
4691};
4692
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004693/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004694 * headphone jack and the internal CD lines since these are the only pins at
4695 * which audio can appear. For flexibility, also allow the option of
4696 * recording the mixer output on the second ADC (ADC0 doesn't have a
4697 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004698 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004699static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4700 {
4701 .num_items = 3,
4702 .items = {
4703 { "Mic/Line", 0x0 },
4704 { "CD", 0x4 },
4705 { "Headphone", 0x2 },
4706 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004707 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004708 {
4709 .num_items = 4,
4710 .items = {
4711 { "Mic/Line", 0x0 },
4712 { "CD", 0x4 },
4713 { "Headphone", 0x2 },
4714 { "Mixer", 0x5 },
4715 },
4716 },
4717
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004718};
4719
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004720/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4721 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004722 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004723static struct hda_input_mux alc260_acer_capture_sources[2] = {
4724 {
4725 .num_items = 4,
4726 .items = {
4727 { "Mic", 0x0 },
4728 { "Line", 0x2 },
4729 { "CD", 0x4 },
4730 { "Headphone", 0x5 },
4731 },
4732 },
4733 {
4734 .num_items = 5,
4735 .items = {
4736 { "Mic", 0x0 },
4737 { "Line", 0x2 },
4738 { "CD", 0x4 },
4739 { "Headphone", 0x6 },
4740 { "Mixer", 0x5 },
4741 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004742 },
4743};
Michael Schwingencc959482009-02-22 18:58:45 +01004744
4745/* Maxdata Favorit 100XS */
4746static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4747 {
4748 .num_items = 2,
4749 .items = {
4750 { "Line/Mic", 0x0 },
4751 { "CD", 0x4 },
4752 },
4753 },
4754 {
4755 .num_items = 3,
4756 .items = {
4757 { "Line/Mic", 0x0 },
4758 { "CD", 0x4 },
4759 { "Mixer", 0x5 },
4760 },
4761 },
4762};
4763
Linus Torvalds1da177e2005-04-16 15:20:36 -07004764/*
4765 * This is just place-holder, so there's something for alc_build_pcms to look
4766 * at when it calculates the maximum number of channels. ALC260 has no mixer
4767 * element which allows changing the channel mode, so the verb list is
4768 * never used.
4769 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004770static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004771 { 2, NULL },
4772};
4773
Kailang Yangdf694da2005-12-05 19:42:22 +01004774
4775/* Mixer combinations
4776 *
4777 * basic: base_output + input + pc_beep + capture
4778 * HP: base_output + input + capture_alt
4779 * HP_3013: hp_3013 + input + capture
4780 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004781 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004782 */
4783
4784static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004785 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004786 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004787 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4788 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4789 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4790 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4791 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004792};
Kailang Yangdf694da2005-12-05 19:42:22 +01004793
4794static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004795 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4796 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4797 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4798 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4800 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4801 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4802 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004803 { } /* end */
4804};
4805
Takashi Iwaibec15c32008-01-28 18:16:30 +01004806/* update HP, line and mono out pins according to the master switch */
4807static void alc260_hp_master_update(struct hda_codec *codec,
4808 hda_nid_t hp, hda_nid_t line,
4809 hda_nid_t mono)
4810{
4811 struct alc_spec *spec = codec->spec;
4812 unsigned int val = spec->master_sw ? PIN_HP : 0;
4813 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004814 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004815 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004816 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004817 val);
4818 /* mono (speaker) depending on the HP jack sense */
4819 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004820 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004821 val);
4822}
4823
4824static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4825 struct snd_ctl_elem_value *ucontrol)
4826{
4827 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4828 struct alc_spec *spec = codec->spec;
4829 *ucontrol->value.integer.value = spec->master_sw;
4830 return 0;
4831}
4832
4833static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4834 struct snd_ctl_elem_value *ucontrol)
4835{
4836 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4837 struct alc_spec *spec = codec->spec;
4838 int val = !!*ucontrol->value.integer.value;
4839 hda_nid_t hp, line, mono;
4840
4841 if (val == spec->master_sw)
4842 return 0;
4843 spec->master_sw = val;
4844 hp = (kcontrol->private_value >> 16) & 0xff;
4845 line = (kcontrol->private_value >> 8) & 0xff;
4846 mono = kcontrol->private_value & 0xff;
4847 alc260_hp_master_update(codec, hp, line, mono);
4848 return 1;
4849}
4850
4851static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4852 {
4853 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4854 .name = "Master Playback Switch",
4855 .info = snd_ctl_boolean_mono_info,
4856 .get = alc260_hp_master_sw_get,
4857 .put = alc260_hp_master_sw_put,
4858 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4859 },
4860 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4861 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4862 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4863 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4864 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4865 HDA_OUTPUT),
4866 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4867 { } /* end */
4868};
4869
4870static struct hda_verb alc260_hp_unsol_verbs[] = {
4871 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4872 {},
4873};
4874
4875static void alc260_hp_automute(struct hda_codec *codec)
4876{
4877 struct alc_spec *spec = codec->spec;
4878 unsigned int present;
4879
4880 present = snd_hda_codec_read(codec, 0x10, 0,
4881 AC_VERB_GET_PIN_SENSE, 0);
4882 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4883 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4884}
4885
4886static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4887{
4888 if ((res >> 26) == ALC880_HP_EVENT)
4889 alc260_hp_automute(codec);
4890}
4891
Kailang Yangdf694da2005-12-05 19:42:22 +01004892static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004893 {
4894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4895 .name = "Master Playback Switch",
4896 .info = snd_ctl_boolean_mono_info,
4897 .get = alc260_hp_master_sw_get,
4898 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004899 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004900 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004901 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4902 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4903 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4904 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4905 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4906 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004907 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4908 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004909 { } /* end */
4910};
4911
Kailang Yang3f878302008-08-26 13:02:23 +02004912static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4913 .ops = &snd_hda_bind_vol,
4914 .values = {
4915 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4916 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4917 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4918 0
4919 },
4920};
4921
4922static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4923 .ops = &snd_hda_bind_sw,
4924 .values = {
4925 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4926 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4927 0
4928 },
4929};
4930
4931static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4932 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4933 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4934 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4935 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4936 { } /* end */
4937};
4938
Takashi Iwaibec15c32008-01-28 18:16:30 +01004939static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4940 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4941 {},
4942};
4943
4944static void alc260_hp_3013_automute(struct hda_codec *codec)
4945{
4946 struct alc_spec *spec = codec->spec;
4947 unsigned int present;
4948
4949 present = snd_hda_codec_read(codec, 0x15, 0,
4950 AC_VERB_GET_PIN_SENSE, 0);
4951 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004952 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004953}
4954
4955static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4956 unsigned int res)
4957{
4958 if ((res >> 26) == ALC880_HP_EVENT)
4959 alc260_hp_3013_automute(codec);
4960}
4961
Kailang Yang3f878302008-08-26 13:02:23 +02004962static void alc260_hp_3012_automute(struct hda_codec *codec)
4963{
4964 unsigned int present, bits;
4965
4966 present = snd_hda_codec_read(codec, 0x10, 0,
4967 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4968
4969 bits = present ? 0 : PIN_OUT;
4970 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4971 bits);
4972 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4973 bits);
4974 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4975 bits);
4976}
4977
4978static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4979 unsigned int res)
4980{
4981 if ((res >> 26) == ALC880_HP_EVENT)
4982 alc260_hp_3012_automute(codec);
4983}
4984
4985/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004986 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4987 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004988static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004989 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004990 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004991 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004992 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4993 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4994 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4995 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004996 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004997 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4998 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004999 { } /* end */
5000};
5001
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005002/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5003 * versions of the ALC260 don't act on requests to enable mic bias from NID
5004 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5005 * datasheet doesn't mention this restriction. At this stage it's not clear
5006 * whether this behaviour is intentional or is a hardware bug in chip
5007 * revisions available in early 2006. Therefore for now allow the
5008 * "Headphone Jack Mode" control to span all choices, but if it turns out
5009 * that the lack of mic bias for this NID is intentional we could change the
5010 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5011 *
5012 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5013 * don't appear to make the mic bias available from the "line" jack, even
5014 * though the NID used for this jack (0x14) can supply it. The theory is
5015 * that perhaps Acer have included blocking capacitors between the ALC260
5016 * and the output jack. If this turns out to be the case for all such
5017 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5018 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005019 *
5020 * The C20x Tablet series have a mono internal speaker which is controlled
5021 * via the chip's Mono sum widget and pin complex, so include the necessary
5022 * controls for such models. On models without a "mono speaker" the control
5023 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005024 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005025static struct snd_kcontrol_new alc260_acer_mixer[] = {
5026 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5027 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005028 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005029 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005030 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005031 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005032 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005033 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5034 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5035 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5036 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5037 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5038 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5039 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5040 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005041 { } /* end */
5042};
5043
Michael Schwingencc959482009-02-22 18:58:45 +01005044/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5045 */
5046static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5047 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5048 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5049 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5050 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5051 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5052 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5053 { } /* end */
5054};
5055
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005056/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5057 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5058 */
5059static struct snd_kcontrol_new alc260_will_mixer[] = {
5060 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5061 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5063 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5064 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5065 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5066 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5067 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5068 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5069 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005070 { } /* end */
5071};
5072
5073/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5074 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5075 */
5076static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5077 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5078 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5079 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5080 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5081 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5082 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5083 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5084 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5085 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5086 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5087 { } /* end */
5088};
5089
Kailang Yangdf694da2005-12-05 19:42:22 +01005090/*
5091 * initialization verbs
5092 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005093static struct hda_verb alc260_init_verbs[] = {
5094 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005095 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005096 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005097 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005098 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005099 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005100 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005101 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005102 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005103 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005104 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005105 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005106 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005107 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005108 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005109 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005110 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005111 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5112 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005113 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005114 /* set connection select to line in (default select for this ADC) */
5115 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005116 /* mute capture amp left and right */
5117 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5118 /* set connection select to line in (default select for this ADC) */
5119 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005120 /* set vol=0 Line-Out mixer amp left and right */
5121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5122 /* unmute pin widget amp left and right (no gain on this amp) */
5123 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5124 /* set vol=0 HP mixer amp left and right */
5125 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5126 /* unmute pin widget amp left and right (no gain on this amp) */
5127 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5128 /* set vol=0 Mono mixer amp left and right */
5129 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5130 /* unmute pin widget amp left and right (no gain on this amp) */
5131 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5132 /* unmute LINE-2 out pin */
5133 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005134 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5135 * Line In 2 = 0x03
5136 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005137 /* mute analog inputs */
5138 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5139 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5140 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5141 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5142 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005143 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005144 /* mute Front out path */
5145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5146 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5147 /* mute Headphone out path */
5148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5149 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5150 /* mute Mono out path */
5151 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5152 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005153 { }
5154};
5155
Takashi Iwai474167d2006-05-17 17:17:43 +02005156#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005157static struct hda_verb alc260_hp_init_verbs[] = {
5158 /* Headphone and output */
5159 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5160 /* mono output */
5161 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5162 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5163 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5164 /* Mic2 (front panel) pin widget for input and vref at 80% */
5165 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5166 /* Line In pin widget for input */
5167 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5168 /* Line-2 pin widget for output */
5169 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5170 /* CD pin widget for input */
5171 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5172 /* unmute amp left and right */
5173 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5174 /* set connection select to line in (default select for this ADC) */
5175 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5176 /* unmute Line-Out mixer amp left and right (volume = 0) */
5177 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5178 /* mute pin widget amp left and right (no gain on this amp) */
5179 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5180 /* unmute HP mixer amp left and right (volume = 0) */
5181 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5182 /* mute pin widget amp left and right (no gain on this amp) */
5183 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005184 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5185 * Line In 2 = 0x03
5186 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005187 /* mute analog inputs */
5188 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5189 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5190 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5192 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005193 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5194 /* Unmute Front out path */
5195 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5197 /* Unmute Headphone out path */
5198 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5199 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5200 /* Unmute Mono out path */
5201 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5202 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5203 { }
5204};
Takashi Iwai474167d2006-05-17 17:17:43 +02005205#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005206
5207static struct hda_verb alc260_hp_3013_init_verbs[] = {
5208 /* Line out and output */
5209 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5210 /* mono output */
5211 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5212 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5213 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5214 /* Mic2 (front panel) pin widget for input and vref at 80% */
5215 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5216 /* Line In pin widget for input */
5217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5218 /* Headphone pin widget for output */
5219 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5220 /* CD pin widget for input */
5221 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5222 /* unmute amp left and right */
5223 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5224 /* set connection select to line in (default select for this ADC) */
5225 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5226 /* unmute Line-Out mixer amp left and right (volume = 0) */
5227 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5228 /* mute pin widget amp left and right (no gain on this amp) */
5229 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5230 /* unmute HP mixer amp left and right (volume = 0) */
5231 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5232 /* mute pin widget amp left and right (no gain on this amp) */
5233 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005234 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5235 * Line In 2 = 0x03
5236 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005237 /* mute analog inputs */
5238 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5239 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5240 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5242 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005243 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5244 /* Unmute Front out path */
5245 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5246 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5247 /* Unmute Headphone out path */
5248 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5249 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5250 /* Unmute Mono out path */
5251 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5252 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5253 { }
5254};
5255
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005256/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005257 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5258 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005259 */
5260static struct hda_verb alc260_fujitsu_init_verbs[] = {
5261 /* Disable all GPIOs */
5262 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5263 /* Internal speaker is connected to headphone pin */
5264 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5265 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005267 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5268 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5269 /* Ensure all other unused pins are disabled and muted. */
5270 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5271 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005272 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005273 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005274 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005275 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5276 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5277 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005278
Jonathan Woithef7ace402006-02-28 11:46:14 +01005279 /* Disable digital (SPDIF) pins */
5280 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5281 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005282
Kailang Yangea1fb292008-08-26 12:58:38 +02005283 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005284 * when acting as an output.
5285 */
5286 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5287
5288 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005289 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5290 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5291 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5292 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5293 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5294 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5295 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5296 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5297 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005298
Jonathan Woithef7ace402006-02-28 11:46:14 +01005299 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5300 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5301 /* Unmute Line1 pin widget output buffer since it starts as an output.
5302 * If the pin mode is changed by the user the pin mode control will
5303 * take care of enabling the pin's input/output buffers as needed.
5304 * Therefore there's no need to enable the input buffer at this
5305 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005306 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005307 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005308 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005309 * mixer ctrl)
5310 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005311 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005312
Jonathan Woithef7ace402006-02-28 11:46:14 +01005313 /* Mute capture amp left and right */
5314 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005315 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005316 * in (on mic1 pin)
5317 */
5318 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005319
Jonathan Woithef7ace402006-02-28 11:46:14 +01005320 /* Do the same for the second ADC: mute capture input amp and
5321 * set ADC connection to line in (on mic1 pin)
5322 */
5323 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5324 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005325
Jonathan Woithef7ace402006-02-28 11:46:14 +01005326 /* Mute all inputs to mixer widget (even unconnected ones) */
5327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5329 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005335
5336 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005337};
5338
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005339/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5340 * similar laptops (adapted from Fujitsu init verbs).
5341 */
5342static struct hda_verb alc260_acer_init_verbs[] = {
5343 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5344 * the headphone jack. Turn this on and rely on the standard mute
5345 * methods whenever the user wants to turn these outputs off.
5346 */
5347 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5348 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5349 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5350 /* Internal speaker/Headphone jack is connected to Line-out pin */
5351 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5352 /* Internal microphone/Mic jack is connected to Mic1 pin */
5353 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5354 /* Line In jack is connected to Line1 pin */
5355 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005356 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5357 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005358 /* Ensure all other unused pins are disabled and muted. */
5359 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5360 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005361 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5362 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5363 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5364 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5365 /* Disable digital (SPDIF) pins */
5366 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5367 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5368
Kailang Yangea1fb292008-08-26 12:58:38 +02005369 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005370 * bus when acting as outputs.
5371 */
5372 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5373 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5374
5375 /* Start with output sum widgets muted and their output gains at min */
5376 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5377 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5378 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5379 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5380 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5381 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5382 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5383 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5384 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5385
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005386 /* Unmute Line-out pin widget amp left and right
5387 * (no equiv mixer ctrl)
5388 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005389 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005390 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5391 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005392 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5393 * inputs. If the pin mode is changed by the user the pin mode control
5394 * will take care of enabling the pin's input/output buffers as needed.
5395 * Therefore there's no need to enable the input buffer at this
5396 * stage.
5397 */
5398 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5399 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5400
5401 /* Mute capture amp left and right */
5402 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5403 /* Set ADC connection select to match default mixer setting - mic
5404 * (on mic1 pin)
5405 */
5406 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5407
5408 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005409 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005410 */
5411 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005412 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005413
5414 /* Mute all inputs to mixer widget (even unconnected ones) */
5415 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5416 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5418 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5419 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5420 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5421 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5422 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5423
5424 { }
5425};
5426
Michael Schwingencc959482009-02-22 18:58:45 +01005427/* Initialisation sequence for Maxdata Favorit 100XS
5428 * (adapted from Acer init verbs).
5429 */
5430static struct hda_verb alc260_favorit100_init_verbs[] = {
5431 /* GPIO 0 enables the output jack.
5432 * Turn this on and rely on the standard mute
5433 * methods whenever the user wants to turn these outputs off.
5434 */
5435 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5436 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5437 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5438 /* Line/Mic input jack is connected to Mic1 pin */
5439 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5440 /* Ensure all other unused pins are disabled and muted. */
5441 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5442 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5443 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5444 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5445 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5446 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5447 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5448 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5449 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5451 /* Disable digital (SPDIF) pins */
5452 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5453 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5454
5455 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5456 * bus when acting as outputs.
5457 */
5458 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5459 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5460
5461 /* Start with output sum widgets muted and their output gains at min */
5462 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5463 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5464 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5465 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5466 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5468 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5469 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5470 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5471
5472 /* Unmute Line-out pin widget amp left and right
5473 * (no equiv mixer ctrl)
5474 */
5475 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5476 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5477 * inputs. If the pin mode is changed by the user the pin mode control
5478 * will take care of enabling the pin's input/output buffers as needed.
5479 * Therefore there's no need to enable the input buffer at this
5480 * stage.
5481 */
5482 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5483
5484 /* Mute capture amp left and right */
5485 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5486 /* Set ADC connection select to match default mixer setting - mic
5487 * (on mic1 pin)
5488 */
5489 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5490
5491 /* Do similar with the second ADC: mute capture input amp and
5492 * set ADC connection to mic to match ALSA's default state.
5493 */
5494 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5495 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5496
5497 /* Mute all inputs to mixer widget (even unconnected ones) */
5498 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5499 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5500 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5501 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5502 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5505 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5506
5507 { }
5508};
5509
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005510static struct hda_verb alc260_will_verbs[] = {
5511 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5512 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5513 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5514 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5515 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5516 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5517 {}
5518};
5519
5520static struct hda_verb alc260_replacer_672v_verbs[] = {
5521 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5522 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5523 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5524
5525 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5526 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5527 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5528
5529 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5530 {}
5531};
5532
5533/* toggle speaker-output according to the hp-jack state */
5534static void alc260_replacer_672v_automute(struct hda_codec *codec)
5535{
5536 unsigned int present;
5537
5538 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5539 present = snd_hda_codec_read(codec, 0x0f, 0,
5540 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5541 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005542 snd_hda_codec_write_cache(codec, 0x01, 0,
5543 AC_VERB_SET_GPIO_DATA, 1);
5544 snd_hda_codec_write_cache(codec, 0x0f, 0,
5545 AC_VERB_SET_PIN_WIDGET_CONTROL,
5546 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005547 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005548 snd_hda_codec_write_cache(codec, 0x01, 0,
5549 AC_VERB_SET_GPIO_DATA, 0);
5550 snd_hda_codec_write_cache(codec, 0x0f, 0,
5551 AC_VERB_SET_PIN_WIDGET_CONTROL,
5552 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005553 }
5554}
5555
5556static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5557 unsigned int res)
5558{
5559 if ((res >> 26) == ALC880_HP_EVENT)
5560 alc260_replacer_672v_automute(codec);
5561}
5562
Kailang Yang3f878302008-08-26 13:02:23 +02005563static struct hda_verb alc260_hp_dc7600_verbs[] = {
5564 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5565 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5566 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5567 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5568 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5569 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5570 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5571 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5572 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5573 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5574 {}
5575};
5576
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005577/* Test configuration for debugging, modelled after the ALC880 test
5578 * configuration.
5579 */
5580#ifdef CONFIG_SND_DEBUG
5581static hda_nid_t alc260_test_dac_nids[1] = {
5582 0x02,
5583};
5584static hda_nid_t alc260_test_adc_nids[2] = {
5585 0x04, 0x05,
5586};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005587/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005588 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005589 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005590 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005591static struct hda_input_mux alc260_test_capture_sources[2] = {
5592 {
5593 .num_items = 7,
5594 .items = {
5595 { "MIC1 pin", 0x0 },
5596 { "MIC2 pin", 0x1 },
5597 { "LINE1 pin", 0x2 },
5598 { "LINE2 pin", 0x3 },
5599 { "CD pin", 0x4 },
5600 { "LINE-OUT pin", 0x5 },
5601 { "HP-OUT pin", 0x6 },
5602 },
5603 },
5604 {
5605 .num_items = 8,
5606 .items = {
5607 { "MIC1 pin", 0x0 },
5608 { "MIC2 pin", 0x1 },
5609 { "LINE1 pin", 0x2 },
5610 { "LINE2 pin", 0x3 },
5611 { "CD pin", 0x4 },
5612 { "Mixer", 0x5 },
5613 { "LINE-OUT pin", 0x6 },
5614 { "HP-OUT pin", 0x7 },
5615 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005616 },
5617};
5618static struct snd_kcontrol_new alc260_test_mixer[] = {
5619 /* Output driver widgets */
5620 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5621 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5622 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5623 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5624 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5625 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5626
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005627 /* Modes for retasking pin widgets
5628 * Note: the ALC260 doesn't seem to act on requests to enable mic
5629 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5630 * mention this restriction. At this stage it's not clear whether
5631 * this behaviour is intentional or is a hardware bug in chip
5632 * revisions available at least up until early 2006. Therefore for
5633 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5634 * choices, but if it turns out that the lack of mic bias for these
5635 * NIDs is intentional we could change their modes from
5636 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5637 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005638 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5639 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5640 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5641 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5642 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5643 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5644
5645 /* Loopback mixer controls */
5646 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5647 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5648 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5649 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5650 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5651 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5652 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5653 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5654 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5655 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005656 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5657 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5658 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5659 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005660
5661 /* Controls for GPIO pins, assuming they are configured as outputs */
5662 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5663 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5664 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5665 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5666
Jonathan Woithe92621f12006-02-28 11:47:47 +01005667 /* Switches to allow the digital IO pins to be enabled. The datasheet
5668 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005669 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005670 */
5671 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5672 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5673
Jonathan Woithef8225f62008-01-08 12:16:54 +01005674 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5675 * this output to turn on an external amplifier.
5676 */
5677 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5678 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5679
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005680 { } /* end */
5681};
5682static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005683 /* Enable all GPIOs as outputs with an initial value of 0 */
5684 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5685 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5686 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5687
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005688 /* Enable retasking pins as output, initially without power amp */
5689 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5690 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5691 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5692 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5693 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5694 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5695
Jonathan Woithe92621f12006-02-28 11:47:47 +01005696 /* Disable digital (SPDIF) pins initially, but users can enable
5697 * them via a mixer switch. In the case of SPDIF-out, this initverb
5698 * payload also sets the generation to 0, output to be in "consumer"
5699 * PCM format, copyright asserted, no pre-emphasis and no validity
5700 * control.
5701 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005702 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5703 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5704
Kailang Yangea1fb292008-08-26 12:58:38 +02005705 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005706 * OUT1 sum bus when acting as an output.
5707 */
5708 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5709 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5710 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5711 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5712
5713 /* Start with output sum widgets muted and their output gains at min */
5714 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5715 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5716 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5717 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5718 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5719 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5720 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5721 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5722 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5723
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005724 /* Unmute retasking pin widget output buffers since the default
5725 * state appears to be output. As the pin mode is changed by the
5726 * user the pin mode control will take care of enabling the pin's
5727 * input/output buffers as needed.
5728 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005729 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5730 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5731 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5732 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5733 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5734 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5735 /* Also unmute the mono-out pin widget */
5736 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5737
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005738 /* Mute capture amp left and right */
5739 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005740 /* Set ADC connection select to match default mixer setting (mic1
5741 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005742 */
5743 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5744
5745 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005746 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005747 */
5748 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5749 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5750
5751 /* Mute all inputs to mixer widget (even unconnected ones) */
5752 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5753 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5754 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5755 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5756 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5757 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5758 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5759 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5760
5761 { }
5762};
5763#endif
5764
Takashi Iwai63300792008-01-24 15:31:36 +01005765#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5766#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005767
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005768#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5769#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5770
Kailang Yangdf694da2005-12-05 19:42:22 +01005771/*
5772 * for BIOS auto-configuration
5773 */
5774
5775static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005776 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005777{
5778 hda_nid_t nid_vol;
5779 unsigned long vol_val, sw_val;
5780 char name[32];
5781 int err;
5782
5783 if (nid >= 0x0f && nid < 0x11) {
5784 nid_vol = nid - 0x7;
5785 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5786 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5787 } else if (nid == 0x11) {
5788 nid_vol = nid - 0x7;
5789 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5790 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5791 } else if (nid >= 0x12 && nid <= 0x15) {
5792 nid_vol = 0x08;
5793 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5794 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5795 } else
5796 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005797
Takashi Iwai863b4512008-10-21 17:01:47 +02005798 if (!(*vol_bits & (1 << nid_vol))) {
5799 /* first control for the volume widget */
5800 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5801 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5802 if (err < 0)
5803 return err;
5804 *vol_bits |= (1 << nid_vol);
5805 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005806 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005807 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5808 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005809 return err;
5810 return 1;
5811}
5812
5813/* add playback controls from the parsed DAC table */
5814static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5815 const struct auto_pin_cfg *cfg)
5816{
5817 hda_nid_t nid;
5818 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005819 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005820
5821 spec->multiout.num_dacs = 1;
5822 spec->multiout.dac_nids = spec->private_dac_nids;
5823 spec->multiout.dac_nids[0] = 0x02;
5824
5825 nid = cfg->line_out_pins[0];
5826 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005827 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005828 if (err < 0)
5829 return err;
5830 }
5831
Takashi Iwai82bc9552006-03-21 11:24:42 +01005832 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005833 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005834 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005835 if (err < 0)
5836 return err;
5837 }
5838
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005839 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005840 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005841 err = alc260_add_playback_controls(spec, nid, "Headphone",
5842 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005843 if (err < 0)
5844 return err;
5845 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005846 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005847}
5848
5849/* create playback/capture controls for input pins */
5850static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5851 const struct auto_pin_cfg *cfg)
5852{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005853 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005854 int i, err, idx;
5855
5856 for (i = 0; i < AUTO_PIN_LAST; i++) {
5857 if (cfg->input_pins[i] >= 0x12) {
5858 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005859 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005860 auto_pin_cfg_labels[i], idx,
5861 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005862 if (err < 0)
5863 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005864 imux->items[imux->num_items].label =
5865 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005866 imux->items[imux->num_items].index = idx;
5867 imux->num_items++;
5868 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005869 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005870 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005871 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005872 auto_pin_cfg_labels[i], idx,
5873 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005874 if (err < 0)
5875 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005876 imux->items[imux->num_items].label =
5877 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005878 imux->items[imux->num_items].index = idx;
5879 imux->num_items++;
5880 }
5881 }
5882 return 0;
5883}
5884
5885static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5886 hda_nid_t nid, int pin_type,
5887 int sel_idx)
5888{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005889 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005890 /* need the manual connection? */
5891 if (nid >= 0x12) {
5892 int idx = nid - 0x12;
5893 snd_hda_codec_write(codec, idx + 0x0b, 0,
5894 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005895 }
5896}
5897
5898static void alc260_auto_init_multi_out(struct hda_codec *codec)
5899{
5900 struct alc_spec *spec = codec->spec;
5901 hda_nid_t nid;
5902
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005903 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005904 if (nid) {
5905 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5906 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5907 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005908
Takashi Iwai82bc9552006-03-21 11:24:42 +01005909 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005910 if (nid)
5911 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5912
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005913 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005914 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005915 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005916}
Kailang Yangdf694da2005-12-05 19:42:22 +01005917
5918#define ALC260_PIN_CD_NID 0x16
5919static void alc260_auto_init_analog_input(struct hda_codec *codec)
5920{
5921 struct alc_spec *spec = codec->spec;
5922 int i;
5923
5924 for (i = 0; i < AUTO_PIN_LAST; i++) {
5925 hda_nid_t nid = spec->autocfg.input_pins[i];
5926 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005927 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005928 if (nid != ALC260_PIN_CD_NID &&
5929 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005930 snd_hda_codec_write(codec, nid, 0,
5931 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005932 AMP_OUT_MUTE);
5933 }
5934 }
5935}
5936
5937/*
5938 * generic initialization of ADC, input mixers and output mixers
5939 */
5940static struct hda_verb alc260_volume_init_verbs[] = {
5941 /*
5942 * Unmute ADC0-1 and set the default input to mic-in
5943 */
5944 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5945 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5946 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5947 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005948
Kailang Yangdf694da2005-12-05 19:42:22 +01005949 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5950 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005951 * Note: PASD motherboards uses the Line In 2 as the input for
5952 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005953 */
5954 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005955 /* mute analog inputs */
5956 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5957 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5958 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5959 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5960 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005961
5962 /*
5963 * Set up output mixers (0x08 - 0x0a)
5964 */
5965 /* set vol=0 to output mixers */
5966 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5967 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5968 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5969 /* set up input amps for analog loopback */
5970 /* Amp Indices: DAC = 0, mixer = 1 */
5971 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5972 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5973 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5974 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5975 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5976 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005977
Kailang Yangdf694da2005-12-05 19:42:22 +01005978 { }
5979};
5980
5981static int alc260_parse_auto_config(struct hda_codec *codec)
5982{
5983 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005984 int err;
5985 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5986
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005987 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5988 alc260_ignore);
5989 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005990 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005991 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5992 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005993 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005994 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005995 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005996 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5997 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005998 return err;
5999
6000 spec->multiout.max_channels = 2;
6001
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006002 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006003 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006004 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006005 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006006
Takashi Iwaid88897e2008-10-31 15:01:37 +01006007 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006008
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006009 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006010 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006011
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006012 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6013
Kailang Yangdf694da2005-12-05 19:42:22 +01006014 return 1;
6015}
6016
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006017/* additional initialization for auto-configuration model */
6018static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006019{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006020 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006021 alc260_auto_init_multi_out(codec);
6022 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006023 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006024 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006025}
6026
Takashi Iwaicb53c622007-08-10 17:21:45 +02006027#ifdef CONFIG_SND_HDA_POWER_SAVE
6028static struct hda_amp_list alc260_loopbacks[] = {
6029 { 0x07, HDA_INPUT, 0 },
6030 { 0x07, HDA_INPUT, 1 },
6031 { 0x07, HDA_INPUT, 2 },
6032 { 0x07, HDA_INPUT, 3 },
6033 { 0x07, HDA_INPUT, 4 },
6034 { } /* end */
6035};
6036#endif
6037
Kailang Yangdf694da2005-12-05 19:42:22 +01006038/*
6039 * ALC260 configurations
6040 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006041static const char *alc260_models[ALC260_MODEL_LAST] = {
6042 [ALC260_BASIC] = "basic",
6043 [ALC260_HP] = "hp",
6044 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006045 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006046 [ALC260_FUJITSU_S702X] = "fujitsu",
6047 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006048 [ALC260_WILL] = "will",
6049 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006050 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006051#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006052 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006053#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006054 [ALC260_AUTO] = "auto",
6055};
6056
6057static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006058 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006059 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006060 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006061 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006062 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006063 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006064 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006065 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006066 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6067 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6068 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6069 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6070 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6071 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6072 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6073 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6074 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006075 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006076 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006077 {}
6078};
6079
Kailang Yangdf694da2005-12-05 19:42:22 +01006080static struct alc_config_preset alc260_presets[] = {
6081 [ALC260_BASIC] = {
6082 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006083 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006084 .init_verbs = { alc260_init_verbs },
6085 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6086 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006087 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006088 .adc_nids = alc260_adc_nids,
6089 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6090 .channel_mode = alc260_modes,
6091 .input_mux = &alc260_capture_source,
6092 },
6093 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006094 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006095 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006096 .init_verbs = { alc260_init_verbs,
6097 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006098 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6099 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006100 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6101 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006102 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6103 .channel_mode = alc260_modes,
6104 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006105 .unsol_event = alc260_hp_unsol_event,
6106 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006107 },
Kailang Yang3f878302008-08-26 13:02:23 +02006108 [ALC260_HP_DC7600] = {
6109 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006110 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006111 .init_verbs = { alc260_init_verbs,
6112 alc260_hp_dc7600_verbs },
6113 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6114 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006115 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6116 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006117 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6118 .channel_mode = alc260_modes,
6119 .input_mux = &alc260_capture_source,
6120 .unsol_event = alc260_hp_3012_unsol_event,
6121 .init_hook = alc260_hp_3012_automute,
6122 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006123 [ALC260_HP_3013] = {
6124 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006125 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006126 .init_verbs = { alc260_hp_3013_init_verbs,
6127 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006128 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6129 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006130 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6131 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006132 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6133 .channel_mode = alc260_modes,
6134 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006135 .unsol_event = alc260_hp_3013_unsol_event,
6136 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006137 },
6138 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006139 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006140 .init_verbs = { alc260_fujitsu_init_verbs },
6141 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6142 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006143 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6144 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006145 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6146 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006147 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6148 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006149 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006150 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006151 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006152 .init_verbs = { alc260_acer_init_verbs },
6153 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6154 .dac_nids = alc260_dac_nids,
6155 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6156 .adc_nids = alc260_dual_adc_nids,
6157 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6158 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006159 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6160 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006161 },
Michael Schwingencc959482009-02-22 18:58:45 +01006162 [ALC260_FAVORIT100] = {
6163 .mixers = { alc260_favorit100_mixer },
6164 .init_verbs = { alc260_favorit100_init_verbs },
6165 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6166 .dac_nids = alc260_dac_nids,
6167 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6168 .adc_nids = alc260_dual_adc_nids,
6169 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6170 .channel_mode = alc260_modes,
6171 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6172 .input_mux = alc260_favorit100_capture_sources,
6173 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006174 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006175 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006176 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6177 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6178 .dac_nids = alc260_dac_nids,
6179 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6180 .adc_nids = alc260_adc_nids,
6181 .dig_out_nid = ALC260_DIGOUT_NID,
6182 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6183 .channel_mode = alc260_modes,
6184 .input_mux = &alc260_capture_source,
6185 },
6186 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006187 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006188 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6189 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6190 .dac_nids = alc260_dac_nids,
6191 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6192 .adc_nids = alc260_adc_nids,
6193 .dig_out_nid = ALC260_DIGOUT_NID,
6194 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6195 .channel_mode = alc260_modes,
6196 .input_mux = &alc260_capture_source,
6197 .unsol_event = alc260_replacer_672v_unsol_event,
6198 .init_hook = alc260_replacer_672v_automute,
6199 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006200#ifdef CONFIG_SND_DEBUG
6201 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006202 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006203 .init_verbs = { alc260_test_init_verbs },
6204 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6205 .dac_nids = alc260_test_dac_nids,
6206 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6207 .adc_nids = alc260_test_adc_nids,
6208 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6209 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006210 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6211 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006212 },
6213#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006214};
6215
Linus Torvalds1da177e2005-04-16 15:20:36 -07006216static int patch_alc260(struct hda_codec *codec)
6217{
6218 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006219 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006220
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006221 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006222 if (spec == NULL)
6223 return -ENOMEM;
6224
6225 codec->spec = spec;
6226
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006227 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6228 alc260_models,
6229 alc260_cfg_tbl);
6230 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02006231 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, "
6232 "trying auto-probe from BIOS...\n",
6233 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006234 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006235 }
6236
Kailang Yangdf694da2005-12-05 19:42:22 +01006237 if (board_config == ALC260_AUTO) {
6238 /* automatic parse from the BIOS config */
6239 err = alc260_parse_auto_config(codec);
6240 if (err < 0) {
6241 alc_free(codec);
6242 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006243 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006244 printk(KERN_INFO
6245 "hda_codec: Cannot set up configuration "
6246 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006247 board_config = ALC260_BASIC;
6248 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006249 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006250
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006251 err = snd_hda_attach_beep_device(codec, 0x1);
6252 if (err < 0) {
6253 alc_free(codec);
6254 return err;
6255 }
6256
Kailang Yangdf694da2005-12-05 19:42:22 +01006257 if (board_config != ALC260_AUTO)
6258 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006259
Linus Torvalds1da177e2005-04-16 15:20:36 -07006260 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6261 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6262
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006263 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6264 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6265
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006266 if (!spec->adc_nids && spec->input_mux) {
6267 /* check whether NID 0x04 is valid */
6268 unsigned int wcap = get_wcaps(codec, 0x04);
6269 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6270 /* get type */
6271 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6272 spec->adc_nids = alc260_adc_nids_alt;
6273 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6274 } else {
6275 spec->adc_nids = alc260_adc_nids;
6276 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6277 }
6278 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006279 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006280 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006281
Takashi Iwai2134ea42008-01-10 16:53:55 +01006282 spec->vmaster_nid = 0x08;
6283
Linus Torvalds1da177e2005-04-16 15:20:36 -07006284 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006285 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006286 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006287#ifdef CONFIG_SND_HDA_POWER_SAVE
6288 if (!spec->loopback.amplist)
6289 spec->loopback.amplist = alc260_loopbacks;
6290#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006291 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006292
6293 return 0;
6294}
6295
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006296
Linus Torvalds1da177e2005-04-16 15:20:36 -07006297/*
6298 * ALC882 support
6299 *
6300 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6301 * configuration. Each pin widget can choose any input DACs and a mixer.
6302 * Each ADC is connected from a mixer of all inputs. This makes possible
6303 * 6-channel independent captures.
6304 *
6305 * In addition, an independent DAC for the multi-playback (not used in this
6306 * driver yet).
6307 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006308#define ALC882_DIGOUT_NID 0x06
6309#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006310
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006311static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006312 { 8, NULL }
6313};
6314
6315static hda_nid_t alc882_dac_nids[4] = {
6316 /* front, rear, clfe, rear_surr */
6317 0x02, 0x03, 0x04, 0x05
6318};
6319
Kailang Yangdf694da2005-12-05 19:42:22 +01006320/* identical with ALC880 */
6321#define alc882_adc_nids alc880_adc_nids
6322#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006323
Takashi Iwaie1406342008-02-11 18:32:32 +01006324static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6325static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6326
Linus Torvalds1da177e2005-04-16 15:20:36 -07006327/* input MUX */
6328/* FIXME: should be a matrix-type input source selection */
6329
6330static struct hda_input_mux alc882_capture_source = {
6331 .num_items = 4,
6332 .items = {
6333 { "Mic", 0x0 },
6334 { "Front Mic", 0x1 },
6335 { "Line", 0x2 },
6336 { "CD", 0x4 },
6337 },
6338};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006339
6340static struct hda_input_mux mb5_capture_source = {
6341 .num_items = 3,
6342 .items = {
6343 { "Mic", 0x1 },
6344 { "Line", 0x2 },
6345 { "CD", 0x4 },
6346 },
6347};
6348
Kailang Yangdf694da2005-12-05 19:42:22 +01006349/*
Kailang Yang272a5272007-05-14 11:00:38 +02006350 * 2ch mode
6351 */
6352static struct hda_verb alc882_3ST_ch2_init[] = {
6353 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6354 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6355 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6356 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6357 { } /* end */
6358};
6359
6360/*
6361 * 6ch mode
6362 */
6363static struct hda_verb alc882_3ST_ch6_init[] = {
6364 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6365 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6366 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6367 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6368 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6369 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6370 { } /* end */
6371};
6372
6373static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6374 { 2, alc882_3ST_ch2_init },
6375 { 6, alc882_3ST_ch6_init },
6376};
6377
6378/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006379 * 6ch mode
6380 */
6381static struct hda_verb alc882_sixstack_ch6_init[] = {
6382 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6383 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6384 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6385 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6386 { } /* end */
6387};
6388
6389/*
6390 * 8ch mode
6391 */
6392static struct hda_verb alc882_sixstack_ch8_init[] = {
6393 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6394 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6395 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6396 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6397 { } /* end */
6398};
6399
6400static struct hda_channel_mode alc882_sixstack_modes[2] = {
6401 { 6, alc882_sixstack_ch6_init },
6402 { 8, alc882_sixstack_ch8_init },
6403};
6404
Takashi Iwai87350ad2007-08-16 18:19:38 +02006405/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006406 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006407 */
6408
6409/*
6410 * 2ch mode
6411 */
6412static struct hda_verb alc885_mbp_ch2_init[] = {
6413 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6414 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6415 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6416 { } /* end */
6417};
6418
6419/*
6420 * 6ch mode
6421 */
6422static struct hda_verb alc885_mbp_ch6_init[] = {
6423 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6424 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6425 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6426 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6427 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6428 { } /* end */
6429};
6430
6431static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6432 { 2, alc885_mbp_ch2_init },
6433 { 6, alc885_mbp_ch6_init },
6434};
6435
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006436/*
6437 * 2ch
6438 * Speakers/Woofer/HP = Front
6439 * LineIn = Input
6440 */
6441static struct hda_verb alc885_mb5_ch2_init[] = {
6442 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6443 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6444 { } /* end */
6445};
6446
6447/*
6448 * 6ch mode
6449 * Speakers/HP = Front
6450 * Woofer = LFE
6451 * LineIn = Surround
6452 */
6453static struct hda_verb alc885_mb5_ch6_init[] = {
6454 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6455 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6456 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6457 { } /* end */
6458};
6459
6460static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6461 { 2, alc885_mb5_ch2_init },
6462 { 6, alc885_mb5_ch6_init },
6463};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006464
Linus Torvalds1da177e2005-04-16 15:20:36 -07006465/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6466 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6467 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006468static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006469 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006470 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006471 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006472 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006473 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6474 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006475 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6476 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006477 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006478 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006479 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6480 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6481 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6482 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6483 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006485 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006486 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6487 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006488 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006489 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006490 { } /* end */
6491};
6492
Takashi Iwai87350ad2007-08-16 18:19:38 +02006493static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006494 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6495 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6496 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6497 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6498 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6499 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006500 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6501 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006502 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006503 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6504 { } /* end */
6505};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006506
6507static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006508 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6509 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6510 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6511 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6512 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6513 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6514 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6515 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006516 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6517 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6518 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6519 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6520 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6521 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6522 { } /* end */
6523};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006524
Kailang Yangbdd148a2007-05-08 15:19:08 +02006525static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6526 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6527 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6528 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6529 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6530 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6531 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6532 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6533 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6534 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006535 { } /* end */
6536};
6537
Kailang Yang272a5272007-05-14 11:00:38 +02006538static struct snd_kcontrol_new alc882_targa_mixer[] = {
6539 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6540 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6541 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6542 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6543 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6544 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6545 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6546 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6547 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006548 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006549 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6550 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006551 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006552 { } /* end */
6553};
6554
6555/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6556 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6557 */
6558static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6559 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6560 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6561 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6562 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6563 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6564 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6565 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6566 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6567 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6568 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6569 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6570 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006571 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006572 { } /* end */
6573};
6574
Takashi Iwai914759b2007-09-06 14:52:04 +02006575static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6576 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6577 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6578 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6579 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6580 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6581 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6582 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6583 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6584 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6585 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006586 { } /* end */
6587};
6588
Kailang Yangdf694da2005-12-05 19:42:22 +01006589static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6590 {
6591 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6592 .name = "Channel Mode",
6593 .info = alc_ch_mode_info,
6594 .get = alc_ch_mode_get,
6595 .put = alc_ch_mode_put,
6596 },
6597 { } /* end */
6598};
6599
Linus Torvalds1da177e2005-04-16 15:20:36 -07006600static struct hda_verb alc882_init_verbs[] = {
6601 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006602 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6603 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6604 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006605 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006606 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6607 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6608 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006609 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006610 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6611 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6612 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006613 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006614 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6615 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6616 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006617
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006618 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006619 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006620 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006621 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006622 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006623 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006625 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006626 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006627 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006628 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006629 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006630 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006631 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006632 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006633 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006634 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006635 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006636 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6637 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006638 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006639 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6640 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006641 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006642 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6643 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6644 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6645 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6646 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006647 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006648 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006649
6650 /* FIXME: use matrix-type input source selection */
6651 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6652 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006653 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6654 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6655 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6656 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006657 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006658 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6659 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6660 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6661 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006662 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006663 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6664 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6665 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6666 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6667 /* ADC1: mute amp left and right */
6668 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006669 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006670 /* ADC2: mute amp left and right */
6671 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006672 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006673 /* ADC3: mute amp left and right */
6674 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006675 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006676
6677 { }
6678};
6679
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006680static struct hda_verb alc882_eapd_verbs[] = {
6681 /* change to EAPD mode */
6682 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006683 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006684 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006685};
6686
Tobin Davis9102cd12006-12-15 10:02:12 +01006687/* Mac Pro test */
6688static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6689 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6690 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6691 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6692 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6693 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006694 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006695 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6696 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006697 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006698 { } /* end */
6699};
6700
6701static struct hda_verb alc882_macpro_init_verbs[] = {
6702 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6703 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6705 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6706 /* Front Pin: output 0 (0x0c) */
6707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6709 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6710 /* Front Mic pin: input vref at 80% */
6711 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6712 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6713 /* Speaker: output */
6714 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6715 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6716 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6717 /* Headphone output (output 0 - 0x0c) */
6718 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6719 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6720 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6721
6722 /* FIXME: use matrix-type input source selection */
6723 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6724 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6725 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6726 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6727 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6728 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6729 /* Input mixer2 */
6730 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6731 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6732 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6733 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6734 /* Input mixer3 */
6735 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6737 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6738 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6739 /* ADC1: mute amp left and right */
6740 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6741 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6742 /* ADC2: mute amp left and right */
6743 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6744 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6745 /* ADC3: mute amp left and right */
6746 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6747 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6748
6749 { }
6750};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006751
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006752/* Macbook 5,1 */
6753static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006754 /* DACs */
6755 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6756 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6757 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6758 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006759 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006760 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6761 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6762 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006763 /* Surround mixer */
6764 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6765 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6766 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6767 /* LFE mixer */
6768 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6769 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6770 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6771 /* HP mixer */
6772 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6773 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6774 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6775 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006776 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6777 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006778 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6779 /* LFE Pin (0x0e) */
6780 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6781 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6782 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
6783 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006784 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6785 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006786 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006787 /* Front Mic pin: input vref at 80% */
6788 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6789 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6790 /* Line In pin */
6791 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6793
6794 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6795 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6796 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6797 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6798 { }
6799};
6800
Takashi Iwai87350ad2007-08-16 18:19:38 +02006801/* Macbook Pro rev3 */
6802static struct hda_verb alc885_mbp3_init_verbs[] = {
6803 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6805 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6806 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6807 /* Rear mixer */
6808 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6809 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6810 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6811 /* Front Pin: output 0 (0x0c) */
6812 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6813 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6814 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6815 /* HP Pin: output 0 (0x0d) */
6816 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6817 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6818 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6819 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6820 /* Mic (rear) pin: input vref at 80% */
6821 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6822 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6823 /* Front Mic pin: input vref at 80% */
6824 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6825 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6826 /* Line In pin: use output 1 when in LineOut mode */
6827 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6828 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6829 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6830
6831 /* FIXME: use matrix-type input source selection */
6832 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6833 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6834 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6835 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6836 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6837 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6838 /* Input mixer2 */
6839 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6840 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6841 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6842 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6843 /* Input mixer3 */
6844 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6845 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6846 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6847 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6848 /* ADC1: mute amp left and right */
6849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6850 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6851 /* ADC2: mute amp left and right */
6852 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6853 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6854 /* ADC3: mute amp left and right */
6855 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6856 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6857
6858 { }
6859};
6860
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006861/* iMac 24 mixer. */
6862static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6863 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6864 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6865 { } /* end */
6866};
6867
6868/* iMac 24 init verbs. */
6869static struct hda_verb alc885_imac24_init_verbs[] = {
6870 /* Internal speakers: output 0 (0x0c) */
6871 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6872 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6873 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6874 /* Internal speakers: output 0 (0x0c) */
6875 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6876 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6877 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6878 /* Headphone: output 0 (0x0c) */
6879 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6881 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6882 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6883 /* Front Mic: input vref at 80% */
6884 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6885 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6886 { }
6887};
6888
6889/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006890static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006891{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006892 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006893
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006894 spec->autocfg.hp_pins[0] = 0x14;
6895 spec->autocfg.speaker_pins[0] = 0x18;
6896 spec->autocfg.speaker_pins[1] = 0x1a;
6897 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006898}
6899
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006900static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006901{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006902 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006903
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006904 spec->autocfg.hp_pins[0] = 0x15;
6905 spec->autocfg.speaker_pins[0] = 0x14;
6906 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02006907}
6908
6909
Kailang Yang272a5272007-05-14 11:00:38 +02006910static struct hda_verb alc882_targa_verbs[] = {
6911 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6912 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6913
6914 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6915 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006916
Kailang Yang272a5272007-05-14 11:00:38 +02006917 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6918 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6919 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6920
6921 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6922 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6923 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6924 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6925 { } /* end */
6926};
6927
6928/* toggle speaker-output according to the hp-jack state */
6929static void alc882_targa_automute(struct hda_codec *codec)
6930{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006931 struct alc_spec *spec = codec->spec;
6932 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006933 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006934 spec->jack_present ? 1 : 3);
6935}
6936
6937static void alc882_targa_init_hook(struct hda_codec *codec)
6938{
6939 struct alc_spec *spec = codec->spec;
6940
6941 spec->autocfg.hp_pins[0] = 0x14;
6942 spec->autocfg.speaker_pins[0] = 0x1b;
6943 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006944}
6945
6946static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6947{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006948 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02006949 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006950}
6951
6952static struct hda_verb alc882_asus_a7j_verbs[] = {
6953 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6954 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6955
6956 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6957 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6958 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006959
Kailang Yang272a5272007-05-14 11:00:38 +02006960 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6961 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6962 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6963
6964 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6965 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6966 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6967 { } /* end */
6968};
6969
Takashi Iwai914759b2007-09-06 14:52:04 +02006970static struct hda_verb alc882_asus_a7m_verbs[] = {
6971 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6972 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6973
6974 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6975 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6976 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006977
Takashi Iwai914759b2007-09-06 14:52:04 +02006978 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6979 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6980 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6981
6982 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6983 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6984 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6985 { } /* end */
6986};
6987
Tobin Davis9102cd12006-12-15 10:02:12 +01006988static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6989{
6990 unsigned int gpiostate, gpiomask, gpiodir;
6991
6992 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6993 AC_VERB_GET_GPIO_DATA, 0);
6994
6995 if (!muted)
6996 gpiostate |= (1 << pin);
6997 else
6998 gpiostate &= ~(1 << pin);
6999
7000 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7001 AC_VERB_GET_GPIO_MASK, 0);
7002 gpiomask |= (1 << pin);
7003
7004 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7005 AC_VERB_GET_GPIO_DIRECTION, 0);
7006 gpiodir |= (1 << pin);
7007
7008
7009 snd_hda_codec_write(codec, codec->afg, 0,
7010 AC_VERB_SET_GPIO_MASK, gpiomask);
7011 snd_hda_codec_write(codec, codec->afg, 0,
7012 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7013
7014 msleep(1);
7015
7016 snd_hda_codec_write(codec, codec->afg, 0,
7017 AC_VERB_SET_GPIO_DATA, gpiostate);
7018}
7019
Takashi Iwai7debbe52007-08-16 15:01:03 +02007020/* set up GPIO at initialization */
7021static void alc885_macpro_init_hook(struct hda_codec *codec)
7022{
7023 alc882_gpio_mute(codec, 0, 0);
7024 alc882_gpio_mute(codec, 1, 0);
7025}
7026
7027/* set up GPIO and update auto-muting at initialization */
7028static void alc885_imac24_init_hook(struct hda_codec *codec)
7029{
7030 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007031 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007032}
7033
Kailang Yangdf694da2005-12-05 19:42:22 +01007034/*
7035 * generic initialization of ADC, input mixers and output mixers
7036 */
7037static struct hda_verb alc882_auto_init_verbs[] = {
7038 /*
7039 * Unmute ADC0-2 and set the default input to mic-in
7040 */
7041 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7042 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7043 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7044 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7045 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7046 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7047
Takashi Iwaicb53c622007-08-10 17:21:45 +02007048 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007049 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007050 * Note: PASD motherboards uses the Line In 2 as the input for
7051 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007052 */
7053 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007054 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7055 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7056 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7057 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7058 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007059
7060 /*
7061 * Set up output mixers (0x0c - 0x0f)
7062 */
7063 /* set vol=0 to output mixers */
7064 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7065 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7066 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7067 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7068 /* set up input amps for analog loopback */
7069 /* Amp Indices: DAC = 0, mixer = 1 */
7070 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7072 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7076 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7078 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7079 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7080
7081 /* FIXME: use matrix-type input source selection */
7082 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7083 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7084 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7085 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7086 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7087 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7088 /* Input mixer2 */
7089 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7090 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7091 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7092 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7093 /* Input mixer3 */
7094 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7095 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7096 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7098
7099 { }
7100};
7101
Takashi Iwaicb53c622007-08-10 17:21:45 +02007102#ifdef CONFIG_SND_HDA_POWER_SAVE
7103#define alc882_loopbacks alc880_loopbacks
7104#endif
7105
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007106/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007107#define alc882_pcm_analog_playback alc880_pcm_analog_playback
7108#define alc882_pcm_analog_capture alc880_pcm_analog_capture
7109#define alc882_pcm_digital_playback alc880_pcm_digital_playback
7110#define alc882_pcm_digital_capture alc880_pcm_digital_capture
7111
7112/*
7113 * configuration and preset
7114 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007115static const char *alc882_models[ALC882_MODEL_LAST] = {
7116 [ALC882_3ST_DIG] = "3stack-dig",
7117 [ALC882_6ST_DIG] = "6stack-dig",
7118 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02007119 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02007120 [ALC882_TARGA] = "targa",
7121 [ALC882_ASUS_A7J] = "asus-a7j",
7122 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01007123 [ALC885_MACPRO] = "macpro",
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007124 [ALC885_MB5] = "mb5",
Takashi Iwai87350ad2007-08-16 18:19:38 +02007125 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007126 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007127 [ALC882_AUTO] = "auto",
7128};
7129
7130static struct snd_pci_quirk alc882_cfg_tbl[] = {
7131 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02007132 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02007133 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02007134 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007135 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02007136 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01007137 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007138 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01007139 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007140 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
7141 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
7142 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01007143 {}
7144};
7145
7146static struct alc_config_preset alc882_presets[] = {
7147 [ALC882_3ST_DIG] = {
7148 .mixers = { alc882_base_mixer },
7149 .init_verbs = { alc882_init_verbs },
7150 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7151 .dac_nids = alc882_dac_nids,
7152 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007153 .dig_in_nid = ALC882_DIGIN_NID,
7154 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7155 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007156 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007157 .input_mux = &alc882_capture_source,
7158 },
7159 [ALC882_6ST_DIG] = {
7160 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7161 .init_verbs = { alc882_init_verbs },
7162 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7163 .dac_nids = alc882_dac_nids,
7164 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007165 .dig_in_nid = ALC882_DIGIN_NID,
7166 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7167 .channel_mode = alc882_sixstack_modes,
7168 .input_mux = &alc882_capture_source,
7169 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007170 [ALC882_ARIMA] = {
7171 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7172 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
7173 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7174 .dac_nids = alc882_dac_nids,
7175 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7176 .channel_mode = alc882_sixstack_modes,
7177 .input_mux = &alc882_capture_source,
7178 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02007179 [ALC882_W2JC] = {
7180 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
7181 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7182 alc880_gpio1_init_verbs },
7183 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7184 .dac_nids = alc882_dac_nids,
7185 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7186 .channel_mode = alc880_threestack_modes,
7187 .need_dac_fix = 1,
7188 .input_mux = &alc882_capture_source,
7189 .dig_out_nid = ALC882_DIGOUT_NID,
7190 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007191 [ALC885_MBP3] = {
7192 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
7193 .init_verbs = { alc885_mbp3_init_verbs,
7194 alc880_gpio1_init_verbs },
7195 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7196 .dac_nids = alc882_dac_nids,
7197 .channel_mode = alc885_mbp_6ch_modes,
7198 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
7199 .input_mux = &alc882_capture_source,
7200 .dig_out_nid = ALC882_DIGOUT_NID,
7201 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007202 .unsol_event = alc_automute_amp_unsol_event,
7203 .init_hook = alc885_mbp3_init_hook,
Takashi Iwai87350ad2007-08-16 18:19:38 +02007204 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007205 [ALC885_MB5] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007206 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007207 .init_verbs = { alc885_mb5_init_verbs,
7208 alc880_gpio1_init_verbs },
7209 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7210 .dac_nids = alc882_dac_nids,
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007211 .channel_mode = alc885_mb5_6ch_modes,
7212 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007213 .input_mux = &mb5_capture_source,
7214 .dig_out_nid = ALC882_DIGOUT_NID,
7215 .dig_in_nid = ALC882_DIGIN_NID,
7216 },
Tobin Davis9102cd12006-12-15 10:02:12 +01007217 [ALC885_MACPRO] = {
7218 .mixers = { alc882_macpro_mixer },
7219 .init_verbs = { alc882_macpro_init_verbs },
7220 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7221 .dac_nids = alc882_dac_nids,
7222 .dig_out_nid = ALC882_DIGOUT_NID,
7223 .dig_in_nid = ALC882_DIGIN_NID,
7224 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7225 .channel_mode = alc882_ch_modes,
7226 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007227 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01007228 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007229 [ALC885_IMAC24] = {
7230 .mixers = { alc885_imac24_mixer },
7231 .init_verbs = { alc885_imac24_init_verbs },
7232 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7233 .dac_nids = alc882_dac_nids,
7234 .dig_out_nid = ALC882_DIGOUT_NID,
7235 .dig_in_nid = ALC882_DIGIN_NID,
7236 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7237 .channel_mode = alc882_ch_modes,
7238 .input_mux = &alc882_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007239 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007240 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007241 },
Kailang Yang272a5272007-05-14 11:00:38 +02007242 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007243 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007244 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
7245 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7246 .dac_nids = alc882_dac_nids,
7247 .dig_out_nid = ALC882_DIGOUT_NID,
7248 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7249 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007250 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007251 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7252 .channel_mode = alc882_3ST_6ch_modes,
7253 .need_dac_fix = 1,
7254 .input_mux = &alc882_capture_source,
7255 .unsol_event = alc882_targa_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007256 .init_hook = alc882_targa_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02007257 },
7258 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007259 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007260 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7261 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7262 .dac_nids = alc882_dac_nids,
7263 .dig_out_nid = ALC882_DIGOUT_NID,
7264 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7265 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007266 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007267 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7268 .channel_mode = alc882_3ST_6ch_modes,
7269 .need_dac_fix = 1,
7270 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007271 },
Takashi Iwai914759b2007-09-06 14:52:04 +02007272 [ALC882_ASUS_A7M] = {
7273 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7274 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7275 alc880_gpio1_init_verbs,
7276 alc882_asus_a7m_verbs },
7277 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7278 .dac_nids = alc882_dac_nids,
7279 .dig_out_nid = ALC882_DIGOUT_NID,
7280 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7281 .channel_mode = alc880_threestack_modes,
7282 .need_dac_fix = 1,
7283 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007284 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007285};
7286
7287
7288/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007289 * Pin config fixes
7290 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007291enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007292 PINFIX_ABIT_AW9D_MAX
7293};
7294
7295static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7296 { 0x15, 0x01080104 }, /* side */
7297 { 0x16, 0x01011012 }, /* rear */
7298 { 0x17, 0x01016011 }, /* clfe */
7299 { }
7300};
7301
7302static const struct alc_pincfg *alc882_pin_fixes[] = {
7303 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7304};
7305
7306static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7307 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7308 {}
7309};
7310
7311/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007312 * BIOS auto configuration
7313 */
7314static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7315 hda_nid_t nid, int pin_type,
7316 int dac_idx)
7317{
7318 /* set as output */
7319 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007320 int idx;
7321
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007322 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007323 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7324 idx = 4;
7325 else
7326 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007327 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7328
7329}
7330
7331static void alc882_auto_init_multi_out(struct hda_codec *codec)
7332{
7333 struct alc_spec *spec = codec->spec;
7334 int i;
7335
7336 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007337 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007338 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007339 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007340 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007341 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007342 }
7343}
7344
7345static void alc882_auto_init_hp_out(struct hda_codec *codec)
7346{
7347 struct alc_spec *spec = codec->spec;
7348 hda_nid_t pin;
7349
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007350 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007351 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007352 /* use dac 0 */
7353 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007354 pin = spec->autocfg.speaker_pins[0];
7355 if (pin)
7356 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007357}
7358
7359#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7360#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7361
7362static void alc882_auto_init_analog_input(struct hda_codec *codec)
7363{
7364 struct alc_spec *spec = codec->spec;
7365 int i;
7366
7367 for (i = 0; i < AUTO_PIN_LAST; i++) {
7368 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007369 if (!nid)
7370 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007371 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007372 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7373 snd_hda_codec_write(codec, nid, 0,
7374 AC_VERB_SET_AMP_GAIN_MUTE,
7375 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007376 }
7377}
7378
Takashi Iwaif511b012008-08-15 16:46:42 +02007379static void alc882_auto_init_input_src(struct hda_codec *codec)
7380{
7381 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007382 int c;
7383
7384 for (c = 0; c < spec->num_adc_nids; c++) {
7385 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7386 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007387 unsigned int mux_idx;
7388 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007389 int conns, mute, idx, item;
7390
7391 conns = snd_hda_get_connections(codec, nid, conn_list,
7392 ARRAY_SIZE(conn_list));
7393 if (conns < 0)
7394 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007395 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7396 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007397 for (idx = 0; idx < conns; idx++) {
7398 /* if the current connection is the selected one,
7399 * unmute it as default - otherwise mute it
7400 */
7401 mute = AMP_IN_MUTE(idx);
7402 for (item = 0; item < imux->num_items; item++) {
7403 if (imux->items[item].index == idx) {
7404 if (spec->cur_mux[c] == item)
7405 mute = AMP_IN_UNMUTE(idx);
7406 break;
7407 }
7408 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007409 /* check if we have a selector or mixer
7410 * we could check for the widget type instead, but
7411 * just check for Amp-In presence (in case of mixer
7412 * without amp-in there is something wrong, this
7413 * function shouldn't be used or capsrc nid is wrong)
7414 */
7415 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7416 snd_hda_codec_write(codec, nid, 0,
7417 AC_VERB_SET_AMP_GAIN_MUTE,
7418 mute);
7419 else if (mute != AMP_IN_MUTE(idx))
7420 snd_hda_codec_write(codec, nid, 0,
7421 AC_VERB_SET_CONNECT_SEL,
7422 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007423 }
7424 }
7425}
7426
Takashi Iwai776e1842007-08-29 15:07:11 +02007427/* add mic boosts if needed */
7428static int alc_auto_add_mic_boost(struct hda_codec *codec)
7429{
7430 struct alc_spec *spec = codec->spec;
7431 int err;
7432 hda_nid_t nid;
7433
7434 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007435 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007436 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7437 "Mic Boost",
7438 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7439 if (err < 0)
7440 return err;
7441 }
7442 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007443 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007444 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7445 "Front Mic Boost",
7446 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7447 if (err < 0)
7448 return err;
7449 }
7450 return 0;
7451}
7452
Kailang Yangdf694da2005-12-05 19:42:22 +01007453/* almost identical with ALC880 parser... */
7454static int alc882_parse_auto_config(struct hda_codec *codec)
7455{
7456 struct alc_spec *spec = codec->spec;
7457 int err = alc880_parse_auto_config(codec);
7458
7459 if (err < 0)
7460 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007461 else if (!err)
7462 return 0; /* no config found */
7463
7464 err = alc_auto_add_mic_boost(codec);
7465 if (err < 0)
7466 return err;
7467
7468 /* hack - override the init verbs */
7469 spec->init_verbs[0] = alc882_auto_init_verbs;
7470
7471 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007472}
7473
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007474/* additional initialization for auto-configuration model */
7475static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007476{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007477 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007478 alc882_auto_init_multi_out(codec);
7479 alc882_auto_init_hp_out(codec);
7480 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007481 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007482 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007483 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007484}
7485
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007486static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7487
Linus Torvalds1da177e2005-04-16 15:20:36 -07007488static int patch_alc882(struct hda_codec *codec)
7489{
7490 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007491 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007492
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007493 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007494 if (spec == NULL)
7495 return -ENOMEM;
7496
Linus Torvalds1da177e2005-04-16 15:20:36 -07007497 codec->spec = spec;
7498
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007499 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7500 alc882_models,
7501 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007502
Kailang Yangdf694da2005-12-05 19:42:22 +01007503 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007504 /* Pick up systems that don't supply PCI SSID */
7505 switch (codec->subsystem_id) {
7506 case 0x106b0c00: /* Mac Pro */
7507 board_config = ALC885_MACPRO;
7508 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007509 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007510 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007511 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007512 board_config = ALC885_IMAC24;
7513 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007514 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007515 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007516 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007517 case 0x106b2c00: /* Macbook Pro rev3 */
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007518 /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */
Luke Yelavich2a884642009-01-28 15:58:38 +11007519 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007520 board_config = ALC885_MBP3;
7521 break;
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007522 case 0x106b3f00: /* Macbook 5,1 */
Takashi Iwai7442f9d2009-05-14 18:20:33 +02007523 case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense
7524 * seems not working, so apparently
7525 * no perfect solution yet
7526 */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007527 board_config = ALC885_MB5;
7528 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007529 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007530 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007531 if (codec->revision_id == 0x100101 ||
7532 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007533 alc_free(codec);
7534 return patch_alc883(codec);
7535 }
Takashi Iwai6c627f32009-05-18 12:33:36 +02007536 printk(KERN_INFO "hda_codec: Unknown model for %s, "
7537 "trying auto-probe from BIOS...\n",
7538 codec->chip_name);
Tobin Davis081d17c2007-02-15 17:46:18 +01007539 board_config = ALC882_AUTO;
7540 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007541 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007542
Takashi Iwaif95474e2007-07-10 00:47:43 +02007543 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7544
Kailang Yangdf694da2005-12-05 19:42:22 +01007545 if (board_config == ALC882_AUTO) {
7546 /* automatic parse from the BIOS config */
7547 err = alc882_parse_auto_config(codec);
7548 if (err < 0) {
7549 alc_free(codec);
7550 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007551 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007552 printk(KERN_INFO
7553 "hda_codec: Cannot set up configuration "
7554 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007555 board_config = ALC882_3ST_DIG;
7556 }
7557 }
7558
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007559 err = snd_hda_attach_beep_device(codec, 0x1);
7560 if (err < 0) {
7561 alc_free(codec);
7562 return err;
7563 }
7564
Kailang Yangdf694da2005-12-05 19:42:22 +01007565 if (board_config != ALC882_AUTO)
7566 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007567
Kailang Yangdf694da2005-12-05 19:42:22 +01007568 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7569 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007570 /* FIXME: setup DAC5 */
7571 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7572 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007573
Kailang Yangdf694da2005-12-05 19:42:22 +01007574 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7575 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007576
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007577 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007578 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007579 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007580 /* get type */
7581 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007582 if (wcap != AC_WID_AUD_IN) {
7583 spec->adc_nids = alc882_adc_nids_alt;
7584 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007585 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007586 } else {
7587 spec->adc_nids = alc882_adc_nids;
7588 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007589 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007590 }
7591 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007592 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007593 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007594
Takashi Iwai2134ea42008-01-10 16:53:55 +01007595 spec->vmaster_nid = 0x0c;
7596
Linus Torvalds1da177e2005-04-16 15:20:36 -07007597 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007598 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007599 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007600#ifdef CONFIG_SND_HDA_POWER_SAVE
7601 if (!spec->loopback.amplist)
7602 spec->loopback.amplist = alc882_loopbacks;
7603#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007604 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007605
7606 return 0;
7607}
7608
7609/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007610 * ALC883 support
7611 *
7612 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7613 * configuration. Each pin widget can choose any input DACs and a mixer.
7614 * Each ADC is connected from a mixer of all inputs. This makes possible
7615 * 6-channel independent captures.
7616 *
7617 * In addition, an independent DAC for the multi-playback (not used in this
7618 * driver yet).
7619 */
7620#define ALC883_DIGOUT_NID 0x06
7621#define ALC883_DIGIN_NID 0x0a
7622
Wu Fengguang3ab90932008-11-17 09:51:09 +01007623#define ALC1200_DIGOUT_NID 0x10
7624
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007625static hda_nid_t alc883_dac_nids[4] = {
7626 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007627 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007628};
7629
7630static hda_nid_t alc883_adc_nids[2] = {
7631 /* ADC1-2 */
7632 0x08, 0x09,
7633};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007634
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007635static hda_nid_t alc883_adc_nids_alt[1] = {
7636 /* ADC1 */
7637 0x08,
7638};
7639
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007640static hda_nid_t alc883_adc_nids_rev[2] = {
7641 /* ADC2-1 */
7642 0x09, 0x08
7643};
7644
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007645#define alc889_adc_nids alc880_adc_nids
7646
Takashi Iwaie1406342008-02-11 18:32:32 +01007647static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7648
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007649static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7650
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007651#define alc889_capsrc_nids alc882_capsrc_nids
7652
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007653/* input MUX */
7654/* FIXME: should be a matrix-type input source selection */
7655
7656static struct hda_input_mux alc883_capture_source = {
7657 .num_items = 4,
7658 .items = {
7659 { "Mic", 0x0 },
7660 { "Front Mic", 0x1 },
7661 { "Line", 0x2 },
7662 { "CD", 0x4 },
7663 },
7664};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007665
Jiang zhe17bba1b2008-06-04 12:11:07 +02007666static struct hda_input_mux alc883_3stack_6ch_intel = {
7667 .num_items = 4,
7668 .items = {
7669 { "Mic", 0x1 },
7670 { "Front Mic", 0x0 },
7671 { "Line", 0x2 },
7672 { "CD", 0x4 },
7673 },
7674};
7675
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007676static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7677 .num_items = 2,
7678 .items = {
7679 { "Mic", 0x1 },
7680 { "Line", 0x2 },
7681 },
7682};
7683
Kailang Yang272a5272007-05-14 11:00:38 +02007684static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7685 .num_items = 4,
7686 .items = {
7687 { "Mic", 0x0 },
7688 { "iMic", 0x1 },
7689 { "Line", 0x2 },
7690 { "CD", 0x4 },
7691 },
7692};
7693
Jiang zhefb97dc62008-03-06 11:07:11 +01007694static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7695 .num_items = 2,
7696 .items = {
7697 { "Mic", 0x0 },
7698 { "Int Mic", 0x1 },
7699 },
7700};
7701
Kailang Yange2757d52008-08-26 13:17:46 +02007702static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7703 .num_items = 3,
7704 .items = {
7705 { "Mic", 0x0 },
7706 { "Front Mic", 0x1 },
7707 { "Line", 0x4 },
7708 },
7709};
7710
7711static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7712 .num_items = 2,
7713 .items = {
7714 { "Mic", 0x0 },
7715 { "Line", 0x2 },
7716 },
7717};
7718
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007719static struct hda_input_mux alc889A_mb31_capture_source = {
7720 .num_items = 2,
7721 .items = {
7722 { "Mic", 0x0 },
7723 /* Front Mic (0x01) unused */
7724 { "Line", 0x2 },
7725 /* Line 2 (0x03) unused */
7726 /* CD (0x04) unsused? */
7727 },
7728};
7729
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007730/*
7731 * 2ch mode
7732 */
7733static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7734 { 2, NULL }
7735};
7736
7737/*
7738 * 2ch mode
7739 */
7740static struct hda_verb alc883_3ST_ch2_init[] = {
7741 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7742 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7743 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7744 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7745 { } /* end */
7746};
7747
7748/*
Tobin Davisb2011312007-09-17 12:45:11 +02007749 * 4ch mode
7750 */
7751static struct hda_verb alc883_3ST_ch4_init[] = {
7752 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7753 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7754 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7755 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7756 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7757 { } /* end */
7758};
7759
7760/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007761 * 6ch mode
7762 */
7763static struct hda_verb alc883_3ST_ch6_init[] = {
7764 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7765 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7766 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7767 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7768 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7769 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7770 { } /* end */
7771};
7772
Tobin Davisb2011312007-09-17 12:45:11 +02007773static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007774 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007775 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007776 { 6, alc883_3ST_ch6_init },
7777};
7778
David Heidelberger64a8be72009-06-08 16:15:18 +02007779
7780/*
7781 * 2ch mode
7782 */
7783static struct hda_verb alc883_4ST_ch2_init[] = {
Takashi Iwaif03ecf52009-06-08 16:38:17 +02007784 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
David Heidelberger64a8be72009-06-08 16:15:18 +02007785 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7786 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7787 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7788 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7789 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7790 { } /* end */
7791};
7792
7793/*
7794 * 4ch mode
7795 */
7796static struct hda_verb alc883_4ST_ch4_init[] = {
7797 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7798 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7799 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7800 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7801 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7802 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7803 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7804 { } /* end */
7805};
7806
7807/*
7808 * 6ch mode
7809 */
7810static struct hda_verb alc883_4ST_ch6_init[] = {
7811 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7812 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7813 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7814 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7815 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7816 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7817 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7818 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7819 { } /* end */
7820};
7821
7822/*
7823 * 8ch mode
7824 */
7825static struct hda_verb alc883_4ST_ch8_init[] = {
7826 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7827 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7828 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7829 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7830 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7831 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7832 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7833 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7834 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7835 { } /* end */
7836};
7837
7838static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7839 { 2, alc883_4ST_ch2_init },
7840 { 4, alc883_4ST_ch4_init },
7841 { 6, alc883_4ST_ch6_init },
7842 { 8, alc883_4ST_ch8_init },
7843};
7844
7845
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007846/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007847 * 2ch mode
7848 */
7849static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7850 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7851 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7852 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7853 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7854 { } /* end */
7855};
7856
7857/*
7858 * 4ch mode
7859 */
7860static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7861 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7862 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7863 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7864 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7865 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7866 { } /* end */
7867};
7868
7869/*
7870 * 6ch mode
7871 */
7872static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7873 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7874 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7875 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7876 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7877 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7878 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7879 { } /* end */
7880};
7881
7882static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7883 { 2, alc883_3ST_ch2_intel_init },
7884 { 4, alc883_3ST_ch4_intel_init },
7885 { 6, alc883_3ST_ch6_intel_init },
7886};
7887
7888/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007889 * 6ch mode
7890 */
7891static struct hda_verb alc883_sixstack_ch6_init[] = {
7892 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7893 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7894 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7895 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7896 { } /* end */
7897};
7898
7899/*
7900 * 8ch mode
7901 */
7902static struct hda_verb alc883_sixstack_ch8_init[] = {
7903 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7904 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7905 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7906 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7907 { } /* end */
7908};
7909
7910static struct hda_channel_mode alc883_sixstack_modes[2] = {
7911 { 6, alc883_sixstack_ch6_init },
7912 { 8, alc883_sixstack_ch8_init },
7913};
7914
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007915/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7916static struct hda_verb alc889A_mb31_ch2_init[] = {
7917 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7918 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7919 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7920 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7921 { } /* end */
7922};
7923
7924/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7925static struct hda_verb alc889A_mb31_ch4_init[] = {
7926 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7927 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7928 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7929 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7930 { } /* end */
7931};
7932
7933/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7934static struct hda_verb alc889A_mb31_ch5_init[] = {
7935 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7936 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7937 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7938 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7939 { } /* end */
7940};
7941
7942/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7943static struct hda_verb alc889A_mb31_ch6_init[] = {
7944 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7945 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7946 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7947 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7948 { } /* end */
7949};
7950
7951static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7952 { 2, alc889A_mb31_ch2_init },
7953 { 4, alc889A_mb31_ch4_init },
7954 { 5, alc889A_mb31_ch5_init },
7955 { 6, alc889A_mb31_ch6_init },
7956};
7957
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007958static struct hda_verb alc883_medion_eapd_verbs[] = {
7959 /* eanable EAPD on medion laptop */
7960 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7961 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7962 { }
7963};
7964
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007965/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7966 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7967 */
7968
7969static struct snd_kcontrol_new alc883_base_mixer[] = {
7970 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7971 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7972 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7973 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7974 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7975 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7976 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7977 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7978 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7979 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7980 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7981 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7982 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7983 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7984 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7985 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007986 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007987 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7988 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007989 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007990 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007991 { } /* end */
7992};
7993
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007994static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7995 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7996 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7997 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7998 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7999 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8000 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8001 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8002 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8003 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8004 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8005 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8006 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8007 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008008 { } /* end */
8009};
8010
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008011static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008012 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8013 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8014 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8015 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8016 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8017 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8018 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8019 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8020 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8021 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008022 { } /* end */
8023};
8024
Jiang zhefb97dc62008-03-06 11:07:11 +01008025static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8026 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8027 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8028 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8029 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8030 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8031 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8032 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8033 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8034 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8035 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008036 { } /* end */
8037};
8038
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008039static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8040 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8041 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8042 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8043 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8044 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8045 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8046 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008048 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008049 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8050 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008051 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008052 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008053 { } /* end */
8054};
8055
8056static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8057 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8058 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8059 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8060 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8061 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, 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", 0x1b, 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, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008071 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008072 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8073 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008074 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008075 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008076 { } /* end */
8077};
8078
Jiang zhe17bba1b2008-06-04 12:11:07 +02008079static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8080 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8081 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8082 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8083 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8084 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8085 HDA_OUTPUT),
8086 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8087 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8088 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8089 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8090 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8091 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8092 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8093 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8094 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8095 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8096 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8097 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8098 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8099 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008100 { } /* end */
8101};
8102
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008103static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008104 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008105 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008106 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008107 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008108 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),
Takashi Iwai0701e062008-06-27 16:30:57 +02008110 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),
Tobin Davisc07584c2006-10-13 12:32:16 +02008112 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8113 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8114 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8115 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8116 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8117 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008118 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008119 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8120 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008121 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008122 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008123 { } /* end */
8124};
8125
Sasha Alexandrc2592492009-06-16 14:52:54 -04008126static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008127 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8128 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8129 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8130 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8131 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8132 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8133 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8134 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8135 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8136 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8137 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8138 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8139 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008141 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008142 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008143 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008144};
Kailang Yangccc656c2006-10-17 12:32:26 +02008145
Sasha Alexandrc2592492009-06-16 14:52:54 -04008146static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008147 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8148 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8149 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8150 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8151 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008153 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008155 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8156 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8157 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008158 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008159};
Kailang Yangccc656c2006-10-17 12:32:26 +02008160
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008161static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8162 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8163 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008164 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8165 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008166 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8167 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8168 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8169 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008170 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008171};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008172
Kailang Yang272a5272007-05-14 11:00:38 +02008173static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8174 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8175 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8177 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8178 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8179 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8180 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8181 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8182 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008183 { } /* end */
8184};
8185
8186static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8187 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8188 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8189 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8190 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8191 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8193 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8194 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8195 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008196 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008197};
Kailang Yang272a5272007-05-14 11:00:38 +02008198
Tobin Davis2880a862007-08-07 11:50:26 +02008199static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008200 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8201 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008202 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008203 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8204 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008205 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8206 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8207 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008208 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008209};
Tobin Davis2880a862007-08-07 11:50:26 +02008210
Tony Vroond2fd4b02009-06-21 00:40:10 +01008211static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8212 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8213 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8214 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8215 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008216 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8217 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008218 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8219 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8220 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8221 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8222 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8223 { } /* end */
8224};
8225
Kailang Yange2757d52008-08-26 13:17:46 +02008226static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8227 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8228 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8229 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8230 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8231 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8232 0x0d, 1, 0x0, HDA_OUTPUT),
8233 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8234 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8235 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8236 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8237 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008238 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8239 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8240 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8241 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8243 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8245 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8246 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8247 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008248 { } /* end */
8249};
8250
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008251static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8252 /* Output mixers */
8253 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8254 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8255 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8256 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8257 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8258 HDA_OUTPUT),
8259 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8260 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8261 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8262 /* Output switches */
8263 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8264 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8265 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8266 /* Boost mixers */
8267 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8268 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8269 /* Input mixers */
8270 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8271 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8272 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8273 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8274 { } /* end */
8275};
8276
Guido Günther3e1647c52009-06-05 00:47:26 +02008277static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8278 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8279 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8280 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8281 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8282 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8283 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8284 { } /* end */
8285};
8286
Kailang Yange2757d52008-08-26 13:17:46 +02008287static struct hda_bind_ctls alc883_bind_cap_vol = {
8288 .ops = &snd_hda_bind_vol,
8289 .values = {
8290 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8291 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8292 0
8293 },
8294};
8295
8296static struct hda_bind_ctls alc883_bind_cap_switch = {
8297 .ops = &snd_hda_bind_sw,
8298 .values = {
8299 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8300 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8301 0
8302 },
8303};
8304
8305static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8306 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8307 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8308 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8309 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8310 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8311 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8312 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8313 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008314 { } /* end */
8315};
8316
8317static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008318 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8319 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8320 {
8321 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8322 /* .name = "Capture Source", */
8323 .name = "Input Source",
8324 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008325 .info = alc_mux_enum_info,
8326 .get = alc_mux_enum_get,
8327 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008328 },
8329 { } /* end */
8330};
8331
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008332static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8333 {
8334 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8335 .name = "Channel Mode",
8336 .info = alc_ch_mode_info,
8337 .get = alc_ch_mode_get,
8338 .put = alc_ch_mode_put,
8339 },
8340 { } /* end */
8341};
8342
8343static struct hda_verb alc883_init_verbs[] = {
8344 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02008345 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008346 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8347 /* ADC2: mute amp left and right */
8348 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8349 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8350 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8351 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8352 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8353 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8354 /* Rear mixer */
8355 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8356 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8357 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8358 /* CLFE mixer */
8359 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8360 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8361 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8362 /* Side mixer */
8363 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8364 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8365 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8366
Takashi Iwaicb53c622007-08-10 17:21:45 +02008367 /* mute analog input loopbacks */
8368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8371 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8372 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008373
8374 /* Front Pin: output 0 (0x0c) */
8375 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8376 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8377 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8378 /* Rear Pin: output 1 (0x0d) */
8379 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8380 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8381 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8382 /* CLFE Pin: output 2 (0x0e) */
8383 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8384 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8385 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8386 /* Side Pin: output 3 (0x0f) */
8387 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8388 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8389 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8390 /* Mic (rear) pin: input vref at 80% */
8391 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8392 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8393 /* Front Mic pin: input vref at 80% */
8394 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8395 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8396 /* Line In pin: input */
8397 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8398 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8399 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8400 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8401 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8402 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8403 /* CD pin widget for input */
8404 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8405
8406 /* FIXME: use matrix-type input source selection */
8407 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8408 /* Input mixer2 */
8409 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008410 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8411 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8412 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008413 /* Input mixer3 */
8414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008415 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8417 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008418 { }
8419};
8420
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008421/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008422static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008423{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008424 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008425
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008426 spec->autocfg.hp_pins[0] = 0x15;
8427 spec->autocfg.speaker_pins[0] = 0x14;
8428 spec->autocfg.speaker_pins[1] = 0x17;
8429 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008430}
8431
8432/* auto-toggle front mic */
8433/*
8434static void alc883_mitac_mic_automute(struct hda_codec *codec)
8435{
8436 unsigned int present;
8437 unsigned char bits;
8438
8439 present = snd_hda_codec_read(codec, 0x18, 0,
8440 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8441 bits = present ? HDA_AMP_MUTE : 0;
8442 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8443}
8444*/
8445
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008446static struct hda_verb alc883_mitac_verbs[] = {
8447 /* HP */
8448 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8449 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8450 /* Subwoofer */
8451 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8452 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8453
8454 /* enable unsolicited event */
8455 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8456 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8457
8458 { } /* end */
8459};
8460
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008461static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008462 /* HP */
8463 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8465 /* Int speaker */
8466 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8467 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8468
8469 /* enable unsolicited event */
8470 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008471 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008472
8473 { } /* end */
8474};
8475
Jiang zhefb97dc62008-03-06 11:07:11 +01008476static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8477 /* HP */
8478 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8479 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8480 /* Subwoofer */
8481 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8483
8484 /* enable unsolicited event */
8485 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8486
8487 { } /* end */
8488};
8489
Sasha Alexandrc2592492009-06-16 14:52:54 -04008490static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8492 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8493
8494 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8495 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008496
David Heidelberger64a8be72009-06-08 16:15:18 +02008497/* Connect Line-Out side jack (SPDIF) to Side */
8498 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8499 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8500 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8501/* Connect Mic jack to CLFE */
8502 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8503 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8504 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8505/* Connect Line-in jack to Surround */
8506 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8507 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8508 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8509/* Connect HP out jack to Front */
8510 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8511 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8512 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008513
8514 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008515
8516 { } /* end */
8517};
8518
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008519static struct hda_verb alc883_lenovo_101e_verbs[] = {
8520 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8521 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8522 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8523 { } /* end */
8524};
8525
Kailang Yang272a5272007-05-14 11:00:38 +02008526static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8527 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8528 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8529 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8530 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8531 { } /* end */
8532};
8533
8534static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8535 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8537 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8538 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8539 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8540 { } /* end */
8541};
8542
Kailang Yang189609a2007-08-20 11:31:23 +02008543static struct hda_verb alc883_haier_w66_verbs[] = {
8544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8546
8547 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8548
8549 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8550 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8551 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8552 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8553 { } /* end */
8554};
8555
Kailang Yange2757d52008-08-26 13:17:46 +02008556static struct hda_verb alc888_lenovo_sky_verbs[] = {
8557 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8558 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8559 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8560 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8561 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8562 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8563 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8564 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8565 { } /* end */
8566};
8567
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008568static struct hda_verb alc888_6st_dell_verbs[] = {
8569 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8570 { }
8571};
8572
Guido Günther3e1647c52009-06-05 00:47:26 +02008573static struct hda_verb alc883_vaiott_verbs[] = {
8574 /* HP */
8575 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8576 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8577
8578 /* enable unsolicited event */
8579 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8580
8581 { } /* end */
8582};
8583
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008584static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008585{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008586 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008587
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008588 spec->autocfg.hp_pins[0] = 0x1b;
8589 spec->autocfg.speaker_pins[0] = 0x14;
8590 spec->autocfg.speaker_pins[1] = 0x16;
8591 spec->autocfg.speaker_pins[2] = 0x18;
8592 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008593}
8594
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008595static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008596 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008597 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8598 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008599 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008600 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008601};
8602
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008603/*
8604 * 2ch mode
8605 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008606static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008607 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8608 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8609 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8610 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008611 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008612};
8613
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008614/*
8615 * 4ch mode
8616 */
8617static struct hda_verb alc888_3st_hp_4ch_init[] = {
8618 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8619 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8620 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8621 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8622 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8623 { } /* end */
8624};
8625
8626/*
8627 * 6ch mode
8628 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008629static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008630 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8631 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008632 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008633 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8634 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008635 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8636 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008637};
8638
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008639static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008640 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008641 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008642 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008643};
8644
Kailang Yang272a5272007-05-14 11:00:38 +02008645/* toggle front-jack and RCA according to the hp-jack state */
8646static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8647{
8648 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008649
Kailang Yang272a5272007-05-14 11:00:38 +02008650 present = snd_hda_codec_read(codec, 0x1b, 0,
8651 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008652 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8653 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8654 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8655 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008656}
8657
8658/* toggle RCA according to the front-jack state */
8659static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8660{
8661 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008662
Kailang Yang272a5272007-05-14 11:00:38 +02008663 present = snd_hda_codec_read(codec, 0x14, 0,
8664 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008665 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8666 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008667}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008668
Kailang Yang272a5272007-05-14 11:00:38 +02008669static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8670 unsigned int res)
8671{
8672 if ((res >> 26) == ALC880_HP_EVENT)
8673 alc888_lenovo_ms7195_front_automute(codec);
8674 if ((res >> 26) == ALC880_FRONT_EVENT)
8675 alc888_lenovo_ms7195_rca_automute(codec);
8676}
8677
8678static struct hda_verb alc883_medion_md2_verbs[] = {
8679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8680 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8681
8682 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8683
8684 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8685 { } /* end */
8686};
8687
8688/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008689static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008690{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008691 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008692
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008693 spec->autocfg.hp_pins[0] = 0x14;
8694 spec->autocfg.speaker_pins[0] = 0x15;
8695 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008696}
8697
Kailang Yangccc656c2006-10-17 12:32:26 +02008698/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008699#define alc883_targa_init_hook alc882_targa_init_hook
8700#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008701
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008702static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8703{
8704 unsigned int present;
8705
8706 present = snd_hda_codec_read(codec, 0x18, 0,
8707 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8708 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8709 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8710}
8711
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008712static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008713{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008714 struct alc_spec *spec = codec->spec;
8715
8716 spec->autocfg.hp_pins[0] = 0x15;
8717 spec->autocfg.speaker_pins[0] = 0x14;
8718 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008719 alc883_clevo_m720_mic_automute(codec);
8720}
8721
8722static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008723 unsigned int res)
8724{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008725 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008726 case ALC880_MIC_EVENT:
8727 alc883_clevo_m720_mic_automute(codec);
8728 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008729 default:
8730 alc_automute_amp_unsol_event(codec, res);
8731 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008732 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008733}
8734
Jiang zhefb97dc62008-03-06 11:07:11 +01008735/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008736static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008737{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008738 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008739
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008740 spec->autocfg.hp_pins[0] = 0x14;
8741 spec->autocfg.speaker_pins[0] = 0x15;
8742 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008743}
8744
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008745static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008746{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008747 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008748
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008749 spec->autocfg.hp_pins[0] = 0x1b;
8750 spec->autocfg.speaker_pins[0] = 0x14;
8751 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008752}
8753
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008754static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8755{
8756 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008757 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008758
David Heidelberger64a8be72009-06-08 16:15:18 +02008759 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8760 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008761 bits = present ? HDA_AMP_MUTE : 0;
8762 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8763 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008764}
8765
8766static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8767{
8768 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008769 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008770
8771 present = snd_hda_codec_read(codec, 0x1b, 0,
8772 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008773 bits = present ? HDA_AMP_MUTE : 0;
8774 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8775 HDA_AMP_MUTE, bits);
8776 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8777 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008778}
8779
8780static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8781 unsigned int res)
8782{
8783 if ((res >> 26) == ALC880_HP_EVENT)
8784 alc883_lenovo_101e_all_automute(codec);
8785 if ((res >> 26) == ALC880_FRONT_EVENT)
8786 alc883_lenovo_101e_ispeaker_automute(codec);
8787}
8788
Takashi Iwai676a9b52007-08-16 15:23:35 +02008789/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008790static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008791{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008792 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008793
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008794 spec->autocfg.hp_pins[0] = 0x14;
8795 spec->autocfg.speaker_pins[0] = 0x15;
8796 spec->autocfg.speaker_pins[1] = 0x16;
8797 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008798}
8799
Kailang Yangd1a991a2007-08-15 16:21:59 +02008800static struct hda_verb alc883_acer_eapd_verbs[] = {
8801 /* HP Pin: output 0 (0x0c) */
8802 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8803 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8804 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8805 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008806 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8807 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008808 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008809 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8810 /* eanable EAPD on medion laptop */
8811 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8812 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008813 /* enable unsolicited event */
8814 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008815 { }
8816};
8817
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008818static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008819{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008820 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008821
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008822 spec->autocfg.hp_pins[0] = 0x1b;
8823 spec->autocfg.speaker_pins[0] = 0x14;
8824 spec->autocfg.speaker_pins[1] = 0x15;
8825 spec->autocfg.speaker_pins[2] = 0x16;
8826 spec->autocfg.speaker_pins[3] = 0x17;
8827 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008828}
8829
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008830static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008831{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008832 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008833
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008834 spec->autocfg.hp_pins[0] = 0x1b;
8835 spec->autocfg.speaker_pins[0] = 0x14;
8836 spec->autocfg.speaker_pins[1] = 0x15;
8837 spec->autocfg.speaker_pins[2] = 0x16;
8838 spec->autocfg.speaker_pins[3] = 0x17;
8839 spec->autocfg.speaker_pins[4] = 0x1a;
8840 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008841}
8842
Guido Günther3e1647c52009-06-05 00:47:26 +02008843static void alc883_vaiott_init_hook(struct hda_codec *codec)
8844{
8845 struct alc_spec *spec = codec->spec;
8846
8847 spec->autocfg.hp_pins[0] = 0x15;
8848 spec->autocfg.speaker_pins[0] = 0x14;
8849 spec->autocfg.speaker_pins[1] = 0x17;
8850 alc_automute_amp(codec);
8851}
8852
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008853/*
8854 * generic initialization of ADC, input mixers and output mixers
8855 */
8856static struct hda_verb alc883_auto_init_verbs[] = {
8857 /*
8858 * Unmute ADC0-2 and set the default input to mic-in
8859 */
8860 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8861 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8862 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8863 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8864
Takashi Iwaicb53c622007-08-10 17:21:45 +02008865 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008866 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008867 * Note: PASD motherboards uses the Line In 2 as the input for
8868 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008869 */
8870 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8873 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8874 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8875 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008876
8877 /*
8878 * Set up output mixers (0x0c - 0x0f)
8879 */
8880 /* set vol=0 to output mixers */
8881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8882 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8883 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8884 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8885 /* set up input amps for analog loopback */
8886 /* Amp Indices: DAC = 0, mixer = 1 */
8887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8889 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8890 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8891 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8892 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8893 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8894 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8895 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8896 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8897
8898 /* FIXME: use matrix-type input source selection */
8899 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8900 /* Input mixer1 */
8901 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8902 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8903 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008904 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008905 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8906 /* Input mixer2 */
8907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8909 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008910 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008911 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008912
8913 { }
8914};
8915
Kailang Yange2757d52008-08-26 13:17:46 +02008916static struct hda_verb alc888_asus_m90v_verbs[] = {
8917 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8918 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8919 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8920 /* enable unsolicited event */
8921 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8922 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8923 { } /* end */
8924};
8925
8926static void alc883_nb_mic_automute(struct hda_codec *codec)
8927{
8928 unsigned int present;
8929
8930 present = snd_hda_codec_read(codec, 0x18, 0,
8931 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8932 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8933 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8934 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8935 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8936}
8937
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008938static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008939{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008940 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008941
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008942 spec->autocfg.hp_pins[0] = 0x1b;
8943 spec->autocfg.speaker_pins[0] = 0x14;
8944 spec->autocfg.speaker_pins[1] = 0x15;
8945 spec->autocfg.speaker_pins[2] = 0x16;
8946 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008947}
8948
8949static void alc883_mode2_unsol_event(struct hda_codec *codec,
8950 unsigned int res)
8951{
8952 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008953 case ALC880_MIC_EVENT:
8954 alc883_nb_mic_automute(codec);
8955 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008956 default:
8957 alc_sku_unsol_event(codec, res);
8958 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008959 }
8960}
8961
8962static void alc883_mode2_inithook(struct hda_codec *codec)
8963{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008964 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008965 alc883_nb_mic_automute(codec);
8966}
8967
8968static struct hda_verb alc888_asus_eee1601_verbs[] = {
8969 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8970 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8971 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8972 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8973 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8974 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8975 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8976 /* enable unsolicited event */
8977 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8978 { } /* end */
8979};
8980
Kailang Yange2757d52008-08-26 13:17:46 +02008981static void alc883_eee1601_inithook(struct hda_codec *codec)
8982{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008983 struct alc_spec *spec = codec->spec;
8984
8985 spec->autocfg.hp_pins[0] = 0x14;
8986 spec->autocfg.speaker_pins[0] = 0x1b;
8987 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008988}
8989
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008990static struct hda_verb alc889A_mb31_verbs[] = {
8991 /* Init rear pin (used as headphone output) */
8992 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8993 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8994 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8995 /* Init line pin (used as output in 4ch and 6ch mode) */
8996 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8997 /* Init line 2 pin (used as headphone out by default) */
8998 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8999 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9000 { } /* end */
9001};
9002
9003/* Mute speakers according to the headphone jack state */
9004static void alc889A_mb31_automute(struct hda_codec *codec)
9005{
9006 unsigned int present;
9007
9008 /* Mute only in 2ch or 4ch mode */
9009 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9010 == 0x00) {
9011 present = snd_hda_codec_read(codec, 0x15, 0,
9012 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
9013 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9014 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9015 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9016 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9017 }
9018}
9019
9020static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9021{
9022 if ((res >> 26) == ALC880_HP_EVENT)
9023 alc889A_mb31_automute(codec);
9024}
9025
Takashi Iwaicb53c622007-08-10 17:21:45 +02009026#ifdef CONFIG_SND_HDA_POWER_SAVE
9027#define alc883_loopbacks alc880_loopbacks
9028#endif
9029
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009030/* pcm configuration: identical with ALC880 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009031#define alc883_pcm_analog_playback alc880_pcm_analog_playback
9032#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01009033#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009034#define alc883_pcm_digital_playback alc880_pcm_digital_playback
9035#define alc883_pcm_digital_capture alc880_pcm_digital_capture
9036
9037/*
9038 * configuration and preset
9039 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009040static const char *alc883_models[ALC883_MODEL_LAST] = {
9041 [ALC883_3ST_2ch_DIG] = "3stack-dig",
9042 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9043 [ALC883_3ST_6ch] = "3stack-6ch",
9044 [ALC883_6ST_DIG] = "6stack-dig",
9045 [ALC883_TARGA_DIG] = "targa-dig",
9046 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009047 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009048 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009049 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009050 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009051 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009052 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009053 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009054 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009055 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009056 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009057 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9058 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009059 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009060 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009061 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009062 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009063 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009064 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009065 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009066 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009067 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009068 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009069 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c52009-06-05 00:47:26 +02009070 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009071 [ALC883_AUTO] = "auto",
9072};
9073
9074static struct snd_pci_quirk alc883_cfg_tbl[] = {
9075 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009076 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009077 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009078 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009079 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9080 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009081 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009082 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9083 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009084 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
9085 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009086 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9087 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009088 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9089 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01009090 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01009091 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009092 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009093 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009094 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009095 ALC888_ACER_ASPIRE_6530G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009096 /* default Acer -- disabled as it causes more problems.
9097 * model=auto should work fine now
9098 */
9099 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009100 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02009101 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009102 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9103 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009104 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009105 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009106 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009107 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009108 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009109 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009110 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009111 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02009112 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009113 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009114 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009115 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9116 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009117 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009118 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02009119 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009120 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9121 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9122 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02009123 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009124 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009125 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009126 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9127 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9128 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9129 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9130 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9131 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
9132 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9133 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9134 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009135 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009136 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9137 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009138 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009139 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009140 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009141 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009142 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009143 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009144 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009145 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009146 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9147 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009148 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009149 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009150 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009151 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009152 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009153 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009154 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009155 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009156 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009157 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9158 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009159 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009160 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009161 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009162 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009163 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009164 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9165 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009166 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08009167 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009168 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Guido Günther3e1647c52009-06-05 00:47:26 +02009169 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009170 {}
9171};
9172
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009173static hda_nid_t alc883_slave_dig_outs[] = {
9174 ALC1200_DIGOUT_NID, 0,
9175};
9176
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009177static hda_nid_t alc1200_slave_dig_outs[] = {
9178 ALC883_DIGOUT_NID, 0,
9179};
9180
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009181static struct alc_config_preset alc883_presets[] = {
9182 [ALC883_3ST_2ch_DIG] = {
9183 .mixers = { alc883_3ST_2ch_mixer },
9184 .init_verbs = { alc883_init_verbs },
9185 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9186 .dac_nids = alc883_dac_nids,
9187 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009188 .dig_in_nid = ALC883_DIGIN_NID,
9189 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9190 .channel_mode = alc883_3ST_2ch_modes,
9191 .input_mux = &alc883_capture_source,
9192 },
9193 [ALC883_3ST_6ch_DIG] = {
9194 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9195 .init_verbs = { alc883_init_verbs },
9196 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9197 .dac_nids = alc883_dac_nids,
9198 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009199 .dig_in_nid = ALC883_DIGIN_NID,
9200 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9201 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009202 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009203 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009204 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009205 [ALC883_3ST_6ch] = {
9206 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9207 .init_verbs = { alc883_init_verbs },
9208 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9209 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009210 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9211 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009212 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009213 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009214 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009215 [ALC883_3ST_6ch_INTEL] = {
9216 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9217 .init_verbs = { alc883_init_verbs },
9218 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9219 .dac_nids = alc883_dac_nids,
9220 .dig_out_nid = ALC883_DIGOUT_NID,
9221 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009222 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009223 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9224 .channel_mode = alc883_3ST_6ch_intel_modes,
9225 .need_dac_fix = 1,
9226 .input_mux = &alc883_3stack_6ch_intel,
9227 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009228 [ALC883_6ST_DIG] = {
9229 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9230 .init_verbs = { alc883_init_verbs },
9231 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9232 .dac_nids = alc883_dac_nids,
9233 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009234 .dig_in_nid = ALC883_DIGIN_NID,
9235 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9236 .channel_mode = alc883_sixstack_modes,
9237 .input_mux = &alc883_capture_source,
9238 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009239 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009240 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
9241 .init_verbs = { alc883_init_verbs, alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009242 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9243 .dac_nids = alc883_dac_nids,
9244 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009245 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9246 .channel_mode = alc883_3ST_6ch_modes,
9247 .need_dac_fix = 1,
9248 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009249 .unsol_event = alc883_targa_unsol_event,
9250 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009251 },
9252 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009253 .mixers = { alc883_targa_2ch_mixer},
9254 .init_verbs = { alc883_init_verbs, alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009255 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9256 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009257 .adc_nids = alc883_adc_nids_alt,
9258 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009259 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009260 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9261 .channel_mode = alc883_3ST_2ch_modes,
9262 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009263 .unsol_event = alc883_targa_unsol_event,
9264 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009265 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009266 [ALC883_TARGA_8ch_DIG] = {
9267 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9268 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009269 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009270 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9271 .dac_nids = alc883_dac_nids,
9272 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9273 .adc_nids = alc883_adc_nids_rev,
9274 .capsrc_nids = alc883_capsrc_nids_rev,
9275 .dig_out_nid = ALC883_DIGOUT_NID,
9276 .dig_in_nid = ALC883_DIGIN_NID,
9277 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9278 .channel_mode = alc883_4ST_8ch_modes,
9279 .need_dac_fix = 1,
9280 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009281 .unsol_event = alc883_targa_unsol_event,
9282 .init_hook = alc883_targa_init_hook,
David Heidelberger64a8be72009-06-08 16:15:18 +02009283 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009284 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009285 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009286 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9287 * and the headphone jack. Turn this on and rely on the
9288 * standard mute methods whenever the user wants to turn
9289 * these outputs off.
9290 */
9291 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9292 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9293 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009294 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9295 .channel_mode = alc883_3ST_2ch_modes,
9296 .input_mux = &alc883_capture_source,
9297 },
Tobin Davis2880a862007-08-07 11:50:26 +02009298 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009299 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009300 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009301 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9302 .dac_nids = alc883_dac_nids,
9303 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009304 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9305 .channel_mode = alc883_3ST_2ch_modes,
9306 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009307 .unsol_event = alc_automute_amp_unsol_event,
9308 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009309 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009310 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009311 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009312 alc883_chmode_mixer },
9313 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9314 alc888_acer_aspire_4930g_verbs },
9315 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9316 .dac_nids = alc883_dac_nids,
9317 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9318 .adc_nids = alc883_adc_nids_rev,
9319 .capsrc_nids = alc883_capsrc_nids_rev,
9320 .dig_out_nid = ALC883_DIGOUT_NID,
9321 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9322 .channel_mode = alc883_3ST_6ch_modes,
9323 .need_dac_fix = 1,
9324 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009325 ARRAY_SIZE(alc888_2_capture_sources),
9326 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009327 .unsol_event = alc_automute_amp_unsol_event,
9328 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009329 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009330 [ALC888_ACER_ASPIRE_6530G] = {
9331 .mixers = { alc888_acer_aspire_6530_mixer },
9332 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9333 alc888_acer_aspire_6530g_verbs },
9334 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9335 .dac_nids = alc883_dac_nids,
9336 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9337 .adc_nids = alc883_adc_nids_rev,
9338 .capsrc_nids = alc883_capsrc_nids_rev,
9339 .dig_out_nid = ALC883_DIGOUT_NID,
9340 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9341 .channel_mode = alc883_3ST_2ch_modes,
9342 .num_mux_defs =
9343 ARRAY_SIZE(alc888_2_capture_sources),
9344 .input_mux = alc888_acer_aspire_6530_sources,
9345 .unsol_event = alc_automute_amp_unsol_event,
Emilio López320d5922009-06-25 08:18:44 +02009346 .init_hook = alc888_acer_aspire_6530g_init_hook,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009347 },
Hector Martin3b315d72009-06-02 10:54:19 +02009348 [ALC888_ACER_ASPIRE_8930G] = {
9349 .mixers = { alc888_base_mixer,
9350 alc883_chmode_mixer },
9351 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009352 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009353 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9354 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009355 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9356 .adc_nids = alc889_adc_nids,
9357 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009358 .dig_out_nid = ALC883_DIGOUT_NID,
9359 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9360 .channel_mode = alc883_3ST_6ch_modes,
9361 .need_dac_fix = 1,
9362 .const_channel_count = 6,
9363 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009364 ARRAY_SIZE(alc889_capture_sources),
9365 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009366 .unsol_event = alc_automute_amp_unsol_event,
Hector Martin018df412009-06-04 00:13:40 +02009367 .init_hook = alc889_acer_aspire_8930g_init_hook,
Hector Martin3b315d72009-06-02 10:54:19 +02009368 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009369 [ALC883_MEDION] = {
9370 .mixers = { alc883_fivestack_mixer,
9371 alc883_chmode_mixer },
9372 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009373 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009374 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9375 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009376 .adc_nids = alc883_adc_nids_alt,
9377 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009378 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9379 .channel_mode = alc883_sixstack_modes,
9380 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009381 },
Kailang Yang272a5272007-05-14 11:00:38 +02009382 [ALC883_MEDION_MD2] = {
9383 .mixers = { alc883_medion_md2_mixer},
9384 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9385 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9386 .dac_nids = alc883_dac_nids,
9387 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009388 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9389 .channel_mode = alc883_3ST_2ch_modes,
9390 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009391 .unsol_event = alc_automute_amp_unsol_event,
9392 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02009393 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009394 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009395 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009396 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9397 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9398 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009399 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9400 .channel_mode = alc883_3ST_2ch_modes,
9401 .input_mux = &alc883_capture_source,
9402 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009403 [ALC883_CLEVO_M720] = {
9404 .mixers = { alc883_clevo_m720_mixer },
9405 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009406 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9407 .dac_nids = alc883_dac_nids,
9408 .dig_out_nid = ALC883_DIGOUT_NID,
9409 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9410 .channel_mode = alc883_3ST_2ch_modes,
9411 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009412 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009413 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009414 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009415 [ALC883_LENOVO_101E_2ch] = {
9416 .mixers = { alc883_lenovo_101e_2ch_mixer},
9417 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9418 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9419 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009420 .adc_nids = alc883_adc_nids_alt,
9421 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009422 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9423 .channel_mode = alc883_3ST_2ch_modes,
9424 .input_mux = &alc883_lenovo_101e_capture_source,
9425 .unsol_event = alc883_lenovo_101e_unsol_event,
9426 .init_hook = alc883_lenovo_101e_all_automute,
9427 },
Kailang Yang272a5272007-05-14 11:00:38 +02009428 [ALC883_LENOVO_NB0763] = {
9429 .mixers = { alc883_lenovo_nb0763_mixer },
9430 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9431 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9432 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009433 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9434 .channel_mode = alc883_3ST_2ch_modes,
9435 .need_dac_fix = 1,
9436 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009437 .unsol_event = alc_automute_amp_unsol_event,
9438 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02009439 },
9440 [ALC888_LENOVO_MS7195_DIG] = {
9441 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9442 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9443 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9444 .dac_nids = alc883_dac_nids,
9445 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009446 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9447 .channel_mode = alc883_3ST_6ch_modes,
9448 .need_dac_fix = 1,
9449 .input_mux = &alc883_capture_source,
9450 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9451 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009452 },
9453 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009454 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009455 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9456 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9457 .dac_nids = alc883_dac_nids,
9458 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009459 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9460 .channel_mode = alc883_3ST_2ch_modes,
9461 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009462 .unsol_event = alc_automute_amp_unsol_event,
9463 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009464 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009465 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009466 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009467 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009468 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9469 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009470 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9471 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009472 .need_dac_fix = 1,
9473 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009474 .unsol_event = alc_automute_amp_unsol_event,
9475 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009476 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009477 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009478 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009479 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9480 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9481 .dac_nids = alc883_dac_nids,
9482 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009483 .dig_in_nid = ALC883_DIGIN_NID,
9484 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9485 .channel_mode = alc883_sixstack_modes,
9486 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009487 .unsol_event = alc_automute_amp_unsol_event,
9488 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009489 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009490 [ALC883_MITAC] = {
9491 .mixers = { alc883_mitac_mixer },
9492 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9493 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9494 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009495 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9496 .channel_mode = alc883_3ST_2ch_modes,
9497 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009498 .unsol_event = alc_automute_amp_unsol_event,
9499 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009500 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009501 [ALC883_FUJITSU_PI2515] = {
9502 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9503 .init_verbs = { alc883_init_verbs,
9504 alc883_2ch_fujitsu_pi2515_verbs},
9505 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9506 .dac_nids = alc883_dac_nids,
9507 .dig_out_nid = ALC883_DIGOUT_NID,
9508 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9509 .channel_mode = alc883_3ST_2ch_modes,
9510 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009511 .unsol_event = alc_automute_amp_unsol_event,
9512 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01009513 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009514 [ALC888_FUJITSU_XA3530] = {
9515 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9516 .init_verbs = { alc883_init_verbs,
9517 alc888_fujitsu_xa3530_verbs },
9518 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9519 .dac_nids = alc883_dac_nids,
9520 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9521 .adc_nids = alc883_adc_nids_rev,
9522 .capsrc_nids = alc883_capsrc_nids_rev,
9523 .dig_out_nid = ALC883_DIGOUT_NID,
9524 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9525 .channel_mode = alc888_4ST_8ch_intel_modes,
9526 .num_mux_defs =
9527 ARRAY_SIZE(alc888_2_capture_sources),
9528 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009529 .unsol_event = alc_automute_amp_unsol_event,
9530 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009531 },
Kailang Yange2757d52008-08-26 13:17:46 +02009532 [ALC888_LENOVO_SKY] = {
9533 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9534 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9535 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9536 .dac_nids = alc883_dac_nids,
9537 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009538 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9539 .channel_mode = alc883_sixstack_modes,
9540 .need_dac_fix = 1,
9541 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009542 .unsol_event = alc_automute_amp_unsol_event,
9543 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009544 },
9545 [ALC888_ASUS_M90V] = {
9546 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9547 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9548 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9549 .dac_nids = alc883_dac_nids,
9550 .dig_out_nid = ALC883_DIGOUT_NID,
9551 .dig_in_nid = ALC883_DIGIN_NID,
9552 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9553 .channel_mode = alc883_3ST_6ch_modes,
9554 .need_dac_fix = 1,
9555 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9556 .unsol_event = alc883_mode2_unsol_event,
9557 .init_hook = alc883_mode2_inithook,
9558 },
9559 [ALC888_ASUS_EEE1601] = {
9560 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009561 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009562 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9563 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9564 .dac_nids = alc883_dac_nids,
9565 .dig_out_nid = ALC883_DIGOUT_NID,
9566 .dig_in_nid = ALC883_DIGIN_NID,
9567 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9568 .channel_mode = alc883_3ST_2ch_modes,
9569 .need_dac_fix = 1,
9570 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009571 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009572 .init_hook = alc883_eee1601_inithook,
9573 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009574 [ALC1200_ASUS_P5Q] = {
9575 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9576 .init_verbs = { alc883_init_verbs },
9577 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9578 .dac_nids = alc883_dac_nids,
9579 .dig_out_nid = ALC1200_DIGOUT_NID,
9580 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009581 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009582 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9583 .channel_mode = alc883_sixstack_modes,
9584 .input_mux = &alc883_capture_source,
9585 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009586 [ALC889A_MB31] = {
9587 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9588 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9589 alc880_gpio1_init_verbs },
9590 .adc_nids = alc883_adc_nids,
9591 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9592 .dac_nids = alc883_dac_nids,
9593 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9594 .channel_mode = alc889A_mb31_6ch_modes,
9595 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9596 .input_mux = &alc889A_mb31_capture_source,
9597 .dig_out_nid = ALC883_DIGOUT_NID,
9598 .unsol_event = alc889A_mb31_unsol_event,
9599 .init_hook = alc889A_mb31_automute,
9600 },
Guido Günther3e1647c52009-06-05 00:47:26 +02009601 [ALC883_SONY_VAIO_TT] = {
9602 .mixers = { alc883_vaiott_mixer },
9603 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9604 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9605 .dac_nids = alc883_dac_nids,
9606 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9607 .channel_mode = alc883_3ST_2ch_modes,
9608 .input_mux = &alc883_capture_source,
9609 .unsol_event = alc_automute_amp_unsol_event,
9610 .init_hook = alc883_vaiott_init_hook,
9611 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009612};
9613
9614
9615/*
9616 * BIOS auto configuration
9617 */
9618static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9619 hda_nid_t nid, int pin_type,
9620 int dac_idx)
9621{
9622 /* set as output */
9623 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009624 int idx;
9625
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009626 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009627 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9628 idx = 4;
9629 else
9630 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009631 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9632
9633}
9634
9635static void alc883_auto_init_multi_out(struct hda_codec *codec)
9636{
9637 struct alc_spec *spec = codec->spec;
9638 int i;
9639
9640 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009641 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009642 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009643 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009644 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009645 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009646 }
9647}
9648
9649static void alc883_auto_init_hp_out(struct hda_codec *codec)
9650{
9651 struct alc_spec *spec = codec->spec;
9652 hda_nid_t pin;
9653
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009654 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009655 if (pin) /* connect to front */
9656 /* use dac 0 */
9657 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009658 pin = spec->autocfg.speaker_pins[0];
9659 if (pin)
9660 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009661}
9662
9663#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9664#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9665
9666static void alc883_auto_init_analog_input(struct hda_codec *codec)
9667{
9668 struct alc_spec *spec = codec->spec;
9669 int i;
9670
9671 for (i = 0; i < AUTO_PIN_LAST; i++) {
9672 hda_nid_t nid = spec->autocfg.input_pins[i];
9673 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009674 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009675 if (nid != ALC883_PIN_CD_NID &&
9676 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009677 snd_hda_codec_write(codec, nid, 0,
9678 AC_VERB_SET_AMP_GAIN_MUTE,
9679 AMP_OUT_MUTE);
9680 }
9681 }
9682}
9683
Takashi Iwaif511b012008-08-15 16:46:42 +02009684#define alc883_auto_init_input_src alc882_auto_init_input_src
9685
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009686/* almost identical with ALC880 parser... */
9687static int alc883_parse_auto_config(struct hda_codec *codec)
9688{
9689 struct alc_spec *spec = codec->spec;
9690 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009691 struct auto_pin_cfg *cfg = &spec->autocfg;
9692 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009693
9694 if (err < 0)
9695 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009696 else if (!err)
9697 return 0; /* no config found */
9698
9699 err = alc_auto_add_mic_boost(codec);
9700 if (err < 0)
9701 return err;
9702
9703 /* hack - override the init verbs */
9704 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009705
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009706 /* setup input_mux for ALC889 */
9707 if (codec->vendor_id == 0x10ec0889) {
9708 /* digital-mic input pin is excluded in alc880_auto_create..()
9709 * because it's under 0x18
9710 */
9711 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9712 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9713 struct hda_input_mux *imux = &spec->private_imux[0];
9714 for (i = 1; i < 3; i++)
9715 memcpy(&spec->private_imux[i],
9716 &spec->private_imux[0],
9717 sizeof(spec->private_imux[0]));
9718 imux->items[imux->num_items].label = "Int DMic";
9719 imux->items[imux->num_items].index = 0x0b;
9720 imux->num_items++;
9721 spec->num_mux_defs = 3;
9722 spec->input_mux = spec->private_imux;
9723 }
9724 }
9725
Takashi Iwai776e1842007-08-29 15:07:11 +02009726 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009727}
9728
9729/* additional initialization for auto-configuration model */
9730static void alc883_auto_init(struct hda_codec *codec)
9731{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009732 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009733 alc883_auto_init_multi_out(codec);
9734 alc883_auto_init_hp_out(codec);
9735 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009736 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009737 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009738 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009739}
9740
9741static int patch_alc883(struct hda_codec *codec)
9742{
9743 struct alc_spec *spec;
9744 int err, board_config;
9745
9746 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9747 if (spec == NULL)
9748 return -ENOMEM;
9749
9750 codec->spec = spec;
9751
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009752 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9753
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009754 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9755 alc883_models,
9756 alc883_cfg_tbl);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009757 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
9758 /* Pick up systems that don't supply PCI SSID */
9759 switch (codec->subsystem_id) {
9760 case 0x106b3600: /* Macbook 3.1 */
9761 board_config = ALC889A_MB31;
9762 break;
9763 default:
9764 printk(KERN_INFO
9765 "hda_codec: Unknown model for %s, trying "
9766 "auto-probe from BIOS...\n", codec->chip_name);
9767 board_config = ALC883_AUTO;
9768 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009769 }
9770
9771 if (board_config == ALC883_AUTO) {
9772 /* automatic parse from the BIOS config */
9773 err = alc883_parse_auto_config(codec);
9774 if (err < 0) {
9775 alc_free(codec);
9776 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009777 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009778 printk(KERN_INFO
9779 "hda_codec: Cannot set up configuration "
9780 "from BIOS. Using base mode...\n");
9781 board_config = ALC883_3ST_2ch_DIG;
9782 }
9783 }
9784
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009785 err = snd_hda_attach_beep_device(codec, 0x1);
9786 if (err < 0) {
9787 alc_free(codec);
9788 return err;
9789 }
9790
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009791 if (board_config != ALC883_AUTO)
9792 setup_preset(spec, &alc883_presets[board_config]);
9793
Kailang Yang2f893282008-05-27 12:14:47 +02009794 switch (codec->vendor_id) {
9795 case 0x10ec0888:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009796 if (!spec->num_adc_nids) {
9797 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9798 spec->adc_nids = alc883_adc_nids;
9799 }
9800 if (!spec->capsrc_nids)
9801 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009802 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009803 break;
9804 case 0x10ec0889:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009805 if (!spec->num_adc_nids) {
9806 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9807 spec->adc_nids = alc889_adc_nids;
9808 }
9809 if (!spec->capsrc_nids)
9810 spec->capsrc_nids = alc889_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009811 break;
9812 default:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009813 if (!spec->num_adc_nids) {
9814 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9815 spec->adc_nids = alc883_adc_nids;
9816 }
9817 if (!spec->capsrc_nids)
9818 spec->capsrc_nids = alc883_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009819 break;
9820 }
9821
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009822 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9823 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009824 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009825
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009826 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9827 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9828
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009829 if (!spec->cap_mixer)
9830 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009831 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009832
Takashi Iwai2134ea42008-01-10 16:53:55 +01009833 spec->vmaster_nid = 0x0c;
9834
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009835 codec->patch_ops = alc_patch_ops;
9836 if (board_config == ALC883_AUTO)
9837 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009838
Takashi Iwaicb53c622007-08-10 17:21:45 +02009839#ifdef CONFIG_SND_HDA_POWER_SAVE
9840 if (!spec->loopback.amplist)
9841 spec->loopback.amplist = alc883_loopbacks;
9842#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009843 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009844
9845 return 0;
9846}
9847
9848/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009849 * ALC262 support
9850 */
9851
9852#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9853#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9854
9855#define alc262_dac_nids alc260_dac_nids
9856#define alc262_adc_nids alc882_adc_nids
9857#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009858#define alc262_capsrc_nids alc882_capsrc_nids
9859#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009860
9861#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009862#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009863
Kailang Yang4e555fe2008-08-26 13:05:55 +02009864static hda_nid_t alc262_dmic_adc_nids[1] = {
9865 /* ADC0 */
9866 0x09
9867};
9868
9869static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9870
Kailang Yangdf694da2005-12-05 19:42:22 +01009871static struct snd_kcontrol_new alc262_base_mixer[] = {
9872 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9873 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9874 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9875 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9876 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9877 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009880 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009881 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9882 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009883 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009884 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9885 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9886 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9887 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009888 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009889};
9890
Takashi Iwaice875f02008-01-28 18:17:43 +01009891/* update HP, line and mono-out pins according to the master switch */
9892static void alc262_hp_master_update(struct hda_codec *codec)
9893{
9894 struct alc_spec *spec = codec->spec;
9895 int val = spec->master_sw;
9896
9897 /* HP & line-out */
9898 snd_hda_codec_write_cache(codec, 0x1b, 0,
9899 AC_VERB_SET_PIN_WIDGET_CONTROL,
9900 val ? PIN_HP : 0);
9901 snd_hda_codec_write_cache(codec, 0x15, 0,
9902 AC_VERB_SET_PIN_WIDGET_CONTROL,
9903 val ? PIN_HP : 0);
9904 /* mono (speaker) depending on the HP jack sense */
9905 val = val && !spec->jack_present;
9906 snd_hda_codec_write_cache(codec, 0x16, 0,
9907 AC_VERB_SET_PIN_WIDGET_CONTROL,
9908 val ? PIN_OUT : 0);
9909}
9910
9911static void alc262_hp_bpc_automute(struct hda_codec *codec)
9912{
9913 struct alc_spec *spec = codec->spec;
9914 unsigned int presence;
9915 presence = snd_hda_codec_read(codec, 0x1b, 0,
9916 AC_VERB_GET_PIN_SENSE, 0);
9917 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9918 alc262_hp_master_update(codec);
9919}
9920
9921static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9922{
9923 if ((res >> 26) != ALC880_HP_EVENT)
9924 return;
9925 alc262_hp_bpc_automute(codec);
9926}
9927
9928static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9929{
9930 struct alc_spec *spec = codec->spec;
9931 unsigned int presence;
9932 presence = snd_hda_codec_read(codec, 0x15, 0,
9933 AC_VERB_GET_PIN_SENSE, 0);
9934 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9935 alc262_hp_master_update(codec);
9936}
9937
9938static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9939 unsigned int res)
9940{
9941 if ((res >> 26) != ALC880_HP_EVENT)
9942 return;
9943 alc262_hp_wildwest_automute(codec);
9944}
9945
Takashi Iwaib72519b2009-05-08 14:31:55 +02009946#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009947
9948static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9949 struct snd_ctl_elem_value *ucontrol)
9950{
9951 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9952 struct alc_spec *spec = codec->spec;
9953 int val = !!*ucontrol->value.integer.value;
9954
9955 if (val == spec->master_sw)
9956 return 0;
9957 spec->master_sw = val;
9958 alc262_hp_master_update(codec);
9959 return 1;
9960}
9961
Takashi Iwaib72519b2009-05-08 14:31:55 +02009962#define ALC262_HP_MASTER_SWITCH \
9963 { \
9964 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9965 .name = "Master Playback Switch", \
9966 .info = snd_ctl_boolean_mono_info, \
9967 .get = alc262_hp_master_sw_get, \
9968 .put = alc262_hp_master_sw_put, \
9969 }
9970
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009971static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009972 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009973 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9974 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9975 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009976 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9977 HDA_OUTPUT),
9978 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9979 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009980 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9981 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009982 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009983 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9984 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009985 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009986 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9987 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9988 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9989 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009990 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9991 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9992 { } /* end */
9993};
9994
Kailang Yangcd7509a2007-01-26 18:33:17 +01009995static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009996 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009997 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9998 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9999 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10000 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010001 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10002 HDA_OUTPUT),
10003 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10004 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010005 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10006 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010007 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010008 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10009 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10010 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10011 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010012 { } /* end */
10013};
10014
10015static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10016 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10017 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010018 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010019 { } /* end */
10020};
10021
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010022/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010023static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010024{
10025 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010026
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010027 spec->autocfg.hp_pins[0] = 0x15;
10028 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
10029 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010030}
10031
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010032static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010033 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10034 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010035 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10036 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10037 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10038 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10039 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10040 { } /* end */
10041};
10042
10043static struct hda_verb alc262_hp_t5735_verbs[] = {
10044 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10045 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10046
10047 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10048 { }
10049};
10050
Kailang Yang8c427222008-01-10 13:03:59 +010010051static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010052 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10053 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010054 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10055 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10057 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10058 { } /* end */
10059};
10060
10061static struct hda_verb alc262_hp_rp5700_verbs[] = {
10062 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10063 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10064 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10065 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10066 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10067 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10069 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10070 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10071 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10072 {}
10073};
10074
10075static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10076 .num_items = 1,
10077 .items = {
10078 { "Line", 0x1 },
10079 },
10080};
10081
Takashi Iwai42171c12009-05-08 14:11:43 +020010082/* bind hp and internal speaker mute (with plug check) as master switch */
10083static void alc262_hippo_master_update(struct hda_codec *codec)
10084{
10085 struct alc_spec *spec = codec->spec;
10086 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10087 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10088 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10089 unsigned int mute;
10090
10091 /* HP */
10092 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10093 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10094 HDA_AMP_MUTE, mute);
10095 /* mute internal speaker per jack sense */
10096 if (spec->jack_present)
10097 mute = HDA_AMP_MUTE;
10098 if (line_nid)
10099 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10100 HDA_AMP_MUTE, mute);
10101 if (speaker_nid && speaker_nid != line_nid)
10102 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10103 HDA_AMP_MUTE, mute);
10104}
10105
10106#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10107
10108static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10109 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010110{
10111 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010112 struct alc_spec *spec = codec->spec;
10113 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010114
Takashi Iwai42171c12009-05-08 14:11:43 +020010115 if (val == spec->master_sw)
10116 return 0;
10117 spec->master_sw = val;
10118 alc262_hippo_master_update(codec);
10119 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010120}
Takashi Iwai5b319542007-07-26 11:49:22 +020010121
Takashi Iwai42171c12009-05-08 14:11:43 +020010122#define ALC262_HIPPO_MASTER_SWITCH \
10123 { \
10124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10125 .name = "Master Playback Switch", \
10126 .info = snd_ctl_boolean_mono_info, \
10127 .get = alc262_hippo_master_sw_get, \
10128 .put = alc262_hippo_master_sw_put, \
10129 }
10130
10131static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10132 ALC262_HIPPO_MASTER_SWITCH,
10133 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10134 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10135 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10136 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10137 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10138 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10139 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10140 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10141 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10142 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10143 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10144 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10145 { } /* end */
10146};
10147
10148static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10149 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10150 ALC262_HIPPO_MASTER_SWITCH,
10151 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10152 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10153 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10154 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10155 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10156 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10157 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10158 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10159 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10160 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10161 { } /* end */
10162};
10163
10164/* mute/unmute internal speaker according to the hp jack and mute state */
10165static void alc262_hippo_automute(struct hda_codec *codec)
10166{
10167 struct alc_spec *spec = codec->spec;
10168 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10169 unsigned int present;
10170
10171 /* need to execute and sync at first */
10172 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10173 present = snd_hda_codec_read(codec, hp_nid, 0,
10174 AC_VERB_GET_PIN_SENSE, 0);
10175 spec->jack_present = (present & 0x80000000) != 0;
10176 alc262_hippo_master_update(codec);
10177}
10178
10179static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10180{
10181 if ((res >> 26) != ALC880_HP_EVENT)
10182 return;
10183 alc262_hippo_automute(codec);
10184}
10185
10186static void alc262_hippo_init_hook(struct hda_codec *codec)
10187{
10188 struct alc_spec *spec = codec->spec;
10189
10190 spec->autocfg.hp_pins[0] = 0x15;
10191 spec->autocfg.speaker_pins[0] = 0x14;
10192 alc262_hippo_automute(codec);
10193}
10194
10195static void alc262_hippo1_init_hook(struct hda_codec *codec)
10196{
10197 struct alc_spec *spec = codec->spec;
10198
10199 spec->autocfg.hp_pins[0] = 0x1b;
10200 spec->autocfg.speaker_pins[0] = 0x14;
10201 alc262_hippo_automute(codec);
10202}
10203
10204
Kailang Yang272a5272007-05-14 11:00:38 +020010205static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010206 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010207 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010208 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10209 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10210 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10211 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10212 { } /* end */
10213};
10214
Kailang Yang83c34212007-07-05 11:43:05 +020010215static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010216 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10217 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010218 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10219 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10220 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10221 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10222 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10223 { } /* end */
10224};
Kailang Yang272a5272007-05-14 11:00:38 +020010225
Tony Vroonba340e82009-02-02 19:01:30 +000010226static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10227 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10228 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10229 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10230 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10231 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10232 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10234 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10235 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10236 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10237 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10238 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10239 { } /* end */
10240};
10241
10242static struct hda_verb alc262_tyan_verbs[] = {
10243 /* Headphone automute */
10244 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10245 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10246 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10247
10248 /* P11 AUX_IN, white 4-pin connector */
10249 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10250 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10251 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10252 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10253
10254 {}
10255};
10256
10257/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010258static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010259{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010260 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010261
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010262 spec->autocfg.hp_pins[0] = 0x1b;
10263 spec->autocfg.speaker_pins[0] = 0x15;
10264 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +000010265}
10266
Tony Vroonba340e82009-02-02 19:01:30 +000010267
Kailang Yangdf694da2005-12-05 19:42:22 +010010268#define alc262_capture_mixer alc882_capture_mixer
10269#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10270
10271/*
10272 * generic initialization of ADC, input mixers and output mixers
10273 */
10274static struct hda_verb alc262_init_verbs[] = {
10275 /*
10276 * Unmute ADC0-2 and set the default input to mic-in
10277 */
10278 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10279 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10280 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10281 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10282 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10283 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10284
Takashi Iwaicb53c622007-08-10 17:21:45 +020010285 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010286 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010287 * Note: PASD motherboards uses the Line In 2 as the input for
10288 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010289 */
10290 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10295 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010296
10297 /*
10298 * Set up output mixers (0x0c - 0x0e)
10299 */
10300 /* set vol=0 to output mixers */
10301 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10302 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10303 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10304 /* set up input amps for analog loopback */
10305 /* Amp Indices: DAC = 0, mixer = 1 */
10306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10308 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10309 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10310 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10311 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10312
10313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10314 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10315 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10316 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10317 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10318 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10319
10320 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10321 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10322 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10323 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10324 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010325
Kailang Yangdf694da2005-12-05 19:42:22 +010010326 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10327 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010328
Kailang Yangdf694da2005-12-05 19:42:22 +010010329 /* FIXME: use matrix-type input source selection */
10330 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10331 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10333 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10334 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10335 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10336 /* Input mixer2 */
10337 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10338 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10339 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10340 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10341 /* Input mixer3 */
10342 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10343 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10344 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010345 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010346
10347 { }
10348};
10349
Kailang Yang4e555fe2008-08-26 13:05:55 +020010350static struct hda_verb alc262_eapd_verbs[] = {
10351 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10352 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10353 { }
10354};
10355
Kailang Yangccc656c2006-10-17 12:32:26 +020010356static struct hda_verb alc262_hippo_unsol_verbs[] = {
10357 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10358 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10359 {}
10360};
10361
10362static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10363 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10364 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10365 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10366
10367 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10368 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10369 {}
10370};
10371
Kailang Yang272a5272007-05-14 11:00:38 +020010372static struct hda_verb alc262_sony_unsol_verbs[] = {
10373 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10374 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10375 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10376
10377 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10378 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010379 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010380};
10381
Kailang Yang4e555fe2008-08-26 13:05:55 +020010382static struct hda_input_mux alc262_dmic_capture_source = {
10383 .num_items = 2,
10384 .items = {
10385 { "Int DMic", 0x9 },
10386 { "Mic", 0x0 },
10387 },
10388};
10389
10390static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10391 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10392 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10393 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10395 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010396 { } /* end */
10397};
10398
10399static struct hda_verb alc262_toshiba_s06_verbs[] = {
10400 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10401 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10402 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10403 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10404 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10405 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10406 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10407 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10408 {}
10409};
10410
10411static void alc262_dmic_automute(struct hda_codec *codec)
10412{
10413 unsigned int present;
10414
10415 present = snd_hda_codec_read(codec, 0x18, 0,
10416 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10417 snd_hda_codec_write(codec, 0x22, 0,
10418 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10419}
10420
Kailang Yang4e555fe2008-08-26 13:05:55 +020010421
10422/* unsolicited event for HP jack sensing */
10423static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10424 unsigned int res)
10425{
Kailang Yang4e555fe2008-08-26 13:05:55 +020010426 if ((res >> 26) == ALC880_MIC_EVENT)
10427 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010428 else
10429 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010430}
10431
10432static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10433{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010434 struct alc_spec *spec = codec->spec;
10435
10436 spec->autocfg.hp_pins[0] = 0x15;
10437 spec->autocfg.speaker_pins[0] = 0x14;
10438 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010439 alc262_dmic_automute(codec);
10440}
10441
Takashi Iwai834be882006-03-01 14:16:17 +010010442/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010443 * nec model
10444 * 0x15 = headphone
10445 * 0x16 = internal speaker
10446 * 0x18 = external mic
10447 */
10448
10449static struct snd_kcontrol_new alc262_nec_mixer[] = {
10450 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10451 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10452
10453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10454 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10455 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10456
10457 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10458 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10459 { } /* end */
10460};
10461
10462static struct hda_verb alc262_nec_verbs[] = {
10463 /* Unmute Speaker */
10464 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10465
10466 /* Headphone */
10467 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10468 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10469
10470 /* External mic to headphone */
10471 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10472 /* External mic to speaker */
10473 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10474 {}
10475};
10476
10477/*
Takashi Iwai834be882006-03-01 14:16:17 +010010478 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010479 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10480 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010481 */
10482
10483#define ALC_HP_EVENT 0x37
10484
10485static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10486 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10487 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010488 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10489 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010490 {}
10491};
10492
Jiang zhe0e31daf2008-03-20 12:12:39 +010010493static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10494 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10495 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10496 {}
10497};
10498
Takashi Iwai834be882006-03-01 14:16:17 +010010499static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010500 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010501 .items = {
10502 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010503 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010504 { "CD", 0x4 },
10505 },
10506};
10507
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010508static struct hda_input_mux alc262_HP_capture_source = {
10509 .num_items = 5,
10510 .items = {
10511 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010512 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010513 { "Line", 0x2 },
10514 { "CD", 0x4 },
10515 { "AUX IN", 0x6 },
10516 },
10517};
10518
zhejiangaccbe492007-08-31 12:36:05 +020010519static struct hda_input_mux alc262_HP_D7000_capture_source = {
10520 .num_items = 4,
10521 .items = {
10522 { "Mic", 0x0 },
10523 { "Front Mic", 0x2 },
10524 { "Line", 0x1 },
10525 { "CD", 0x4 },
10526 },
10527};
10528
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010529/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010530static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10531{
10532 struct alc_spec *spec = codec->spec;
10533 unsigned int mute;
10534
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010535 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010536 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010537 /* need to execute and sync at first */
10538 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010539 /* check laptop HP jack */
10540 present = snd_hda_codec_read(codec, 0x14, 0,
10541 AC_VERB_GET_PIN_SENSE, 0);
10542 /* need to execute and sync at first */
10543 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10544 /* check docking HP jack */
10545 present |= snd_hda_codec_read(codec, 0x1b, 0,
10546 AC_VERB_GET_PIN_SENSE, 0);
10547 if (present & AC_PINSENSE_PRESENCE)
10548 spec->jack_present = 1;
10549 else
10550 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010551 spec->sense_updated = 1;
10552 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010553 /* unmute internal speaker only if both HPs are unplugged and
10554 * master switch is on
10555 */
10556 if (spec->jack_present)
10557 mute = HDA_AMP_MUTE;
10558 else
Takashi Iwai834be882006-03-01 14:16:17 +010010559 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010560 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10561 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010562}
10563
10564/* unsolicited event for HP jack sensing */
10565static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10566 unsigned int res)
10567{
10568 if ((res >> 26) != ALC_HP_EVENT)
10569 return;
10570 alc262_fujitsu_automute(codec, 1);
10571}
10572
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010573static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10574{
10575 alc262_fujitsu_automute(codec, 1);
10576}
10577
Takashi Iwai834be882006-03-01 14:16:17 +010010578/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010579static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10580 .ops = &snd_hda_bind_vol,
10581 .values = {
10582 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10583 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10584 0
10585 },
10586};
Takashi Iwai834be882006-03-01 14:16:17 +010010587
Jiang zhe0e31daf2008-03-20 12:12:39 +010010588/* mute/unmute internal speaker according to the hp jack and mute state */
10589static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10590{
10591 struct alc_spec *spec = codec->spec;
10592 unsigned int mute;
10593
10594 if (force || !spec->sense_updated) {
10595 unsigned int present_int_hp;
10596 /* need to execute and sync at first */
10597 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10598 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10599 AC_VERB_GET_PIN_SENSE, 0);
10600 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10601 spec->sense_updated = 1;
10602 }
10603 if (spec->jack_present) {
10604 /* mute internal speaker */
10605 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10606 HDA_AMP_MUTE, HDA_AMP_MUTE);
10607 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10608 HDA_AMP_MUTE, HDA_AMP_MUTE);
10609 } else {
10610 /* unmute internal speaker if necessary */
10611 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10612 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10613 HDA_AMP_MUTE, mute);
10614 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10615 HDA_AMP_MUTE, mute);
10616 }
10617}
10618
10619/* unsolicited event for HP jack sensing */
10620static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10621 unsigned int res)
10622{
10623 if ((res >> 26) != ALC_HP_EVENT)
10624 return;
10625 alc262_lenovo_3000_automute(codec, 1);
10626}
10627
Takashi Iwai834be882006-03-01 14:16:17 +010010628/* bind hp and internal speaker mute (with plug check) */
10629static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10630 struct snd_ctl_elem_value *ucontrol)
10631{
10632 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10633 long *valp = ucontrol->value.integer.value;
10634 int change;
10635
Tony Vroon5d9fab22008-03-14 17:09:18 +010010636 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10637 HDA_AMP_MUTE,
10638 valp ? 0 : HDA_AMP_MUTE);
10639 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10640 HDA_AMP_MUTE,
10641 valp ? 0 : HDA_AMP_MUTE);
10642
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010643 if (change)
10644 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010645 return change;
10646}
10647
10648static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010649 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010650 {
10651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10652 .name = "Master Playback Switch",
10653 .info = snd_hda_mixer_amp_switch_info,
10654 .get = snd_hda_mixer_amp_switch_get,
10655 .put = alc262_fujitsu_master_sw_put,
10656 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10657 },
10658 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10659 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10660 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10661 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10662 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010663 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10664 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10665 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010666 { } /* end */
10667};
10668
Jiang zhe0e31daf2008-03-20 12:12:39 +010010669/* bind hp and internal speaker mute (with plug check) */
10670static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10671 struct snd_ctl_elem_value *ucontrol)
10672{
10673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10674 long *valp = ucontrol->value.integer.value;
10675 int change;
10676
10677 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10678 HDA_AMP_MUTE,
10679 valp ? 0 : HDA_AMP_MUTE);
10680
10681 if (change)
10682 alc262_lenovo_3000_automute(codec, 0);
10683 return change;
10684}
10685
10686static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10687 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10688 {
10689 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10690 .name = "Master Playback Switch",
10691 .info = snd_hda_mixer_amp_switch_info,
10692 .get = snd_hda_mixer_amp_switch_get,
10693 .put = alc262_lenovo_3000_master_sw_put,
10694 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10695 },
10696 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10697 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10698 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10699 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10700 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10701 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10702 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10703 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10704 { } /* end */
10705};
10706
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010707static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10708 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010709 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010710 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10711 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10712 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10713 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10714 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10715 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10716 { } /* end */
10717};
10718
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010719/* additional init verbs for Benq laptops */
10720static struct hda_verb alc262_EAPD_verbs[] = {
10721 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10722 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10723 {}
10724};
10725
Kailang Yang83c34212007-07-05 11:43:05 +020010726static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10727 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10728 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10729
10730 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10731 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10732 {}
10733};
10734
Tobin Davisf651b502007-10-26 12:40:47 +020010735/* Samsung Q1 Ultra Vista model setup */
10736static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010737 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10738 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010739 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10740 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10741 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010742 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010743 { } /* end */
10744};
10745
10746static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010747 /* output mixer */
10748 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10749 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10751 /* speaker */
10752 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10753 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10754 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10755 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10756 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010757 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010758 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10759 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10760 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10761 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10762 /* internal mic */
10763 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10765 /* ADC, choose mic */
10766 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10767 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10768 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10769 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10770 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10771 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10772 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10773 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10774 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10775 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010776 {}
10777};
10778
Tobin Davisf651b502007-10-26 12:40:47 +020010779/* mute/unmute internal speaker according to the hp jack and mute state */
10780static void alc262_ultra_automute(struct hda_codec *codec)
10781{
10782 struct alc_spec *spec = codec->spec;
10783 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010784
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010785 mute = 0;
10786 /* auto-mute only when HP is used as HP */
10787 if (!spec->cur_mux[0]) {
10788 unsigned int present;
10789 /* need to execute and sync at first */
10790 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10791 present = snd_hda_codec_read(codec, 0x15, 0,
10792 AC_VERB_GET_PIN_SENSE, 0);
10793 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10794 if (spec->jack_present)
10795 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010796 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010797 /* mute/unmute internal speaker */
10798 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10799 HDA_AMP_MUTE, mute);
10800 /* mute/unmute HP */
10801 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10802 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010803}
10804
10805/* unsolicited event for HP jack sensing */
10806static void alc262_ultra_unsol_event(struct hda_codec *codec,
10807 unsigned int res)
10808{
10809 if ((res >> 26) != ALC880_HP_EVENT)
10810 return;
10811 alc262_ultra_automute(codec);
10812}
10813
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010814static struct hda_input_mux alc262_ultra_capture_source = {
10815 .num_items = 2,
10816 .items = {
10817 { "Mic", 0x1 },
10818 { "Headphone", 0x7 },
10819 },
10820};
10821
10822static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10823 struct snd_ctl_elem_value *ucontrol)
10824{
10825 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10826 struct alc_spec *spec = codec->spec;
10827 int ret;
10828
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010829 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010830 if (!ret)
10831 return 0;
10832 /* reprogram the HP pin as mic or HP according to the input source */
10833 snd_hda_codec_write_cache(codec, 0x15, 0,
10834 AC_VERB_SET_PIN_WIDGET_CONTROL,
10835 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10836 alc262_ultra_automute(codec); /* mute/unmute HP */
10837 return ret;
10838}
10839
10840static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10841 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10842 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10843 {
10844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10845 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010846 .info = alc_mux_enum_info,
10847 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010848 .put = alc262_ultra_mux_enum_put,
10849 },
10850 { } /* end */
10851};
10852
Kailang Yangdf694da2005-12-05 19:42:22 +010010853/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010854static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10855 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010856{
10857 hda_nid_t nid;
10858 int err;
10859
10860 spec->multiout.num_dacs = 1; /* only use one dac */
10861 spec->multiout.dac_nids = spec->private_dac_nids;
10862 spec->multiout.dac_nids[0] = 2;
10863
10864 nid = cfg->line_out_pins[0];
10865 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010866 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10867 "Front Playback Volume",
10868 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10869 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010870 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010871 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10872 "Front Playback Switch",
10873 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10874 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010875 return err;
10876 }
10877
Takashi Iwai82bc9552006-03-21 11:24:42 +010010878 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010879 if (nid) {
10880 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010881 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10882 "Speaker Playback Volume",
10883 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10884 HDA_OUTPUT));
10885 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010886 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010887 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10888 "Speaker Playback Switch",
10889 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10890 HDA_OUTPUT));
10891 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010892 return err;
10893 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010894 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10895 "Speaker Playback Switch",
10896 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10897 HDA_OUTPUT));
10898 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010899 return err;
10900 }
10901 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010902 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010903 if (nid) {
10904 /* spec->multiout.hp_nid = 2; */
10905 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010906 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10907 "Headphone Playback Volume",
10908 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10909 HDA_OUTPUT));
10910 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010911 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010912 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10913 "Headphone Playback Switch",
10914 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10915 HDA_OUTPUT));
10916 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010917 return err;
10918 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010919 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10920 "Headphone Playback Switch",
10921 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10922 HDA_OUTPUT));
10923 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010924 return err;
10925 }
10926 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010927 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010928}
10929
Takashi Iwai8c927b42009-06-22 10:56:54 +020010930static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec,
10931 const struct auto_pin_cfg *cfg)
10932{
10933 int err;
10934
10935 err = alc880_auto_create_analog_input_ctls(spec, cfg);
10936 if (err < 0)
10937 return err;
10938 /* digital-mic input pin is excluded in alc880_auto_create..()
10939 * because it's under 0x18
10940 */
10941 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
10942 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
10943 struct hda_input_mux *imux = &spec->private_imux[0];
10944 imux->items[imux->num_items].label = "Int Mic";
10945 imux->items[imux->num_items].index = 0x09;
10946 imux->num_items++;
10947 }
10948 return 0;
10949}
10950
Kailang Yangdf694da2005-12-05 19:42:22 +010010951
10952/*
10953 * generic initialization of ADC, input mixers and output mixers
10954 */
10955static struct hda_verb alc262_volume_init_verbs[] = {
10956 /*
10957 * Unmute ADC0-2 and set the default input to mic-in
10958 */
10959 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10960 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10961 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10962 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10963 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10964 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10965
Takashi Iwaicb53c622007-08-10 17:21:45 +020010966 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010967 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010968 * Note: PASD motherboards uses the Line In 2 as the input for
10969 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010970 */
10971 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010972 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10973 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10974 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10975 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10976 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010977
10978 /*
10979 * Set up output mixers (0x0c - 0x0f)
10980 */
10981 /* set vol=0 to output mixers */
10982 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10983 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10984 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010985
Kailang Yangdf694da2005-12-05 19:42:22 +010010986 /* set up input amps for analog loopback */
10987 /* Amp Indices: DAC = 0, mixer = 1 */
10988 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10989 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10990 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10991 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10992 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10993 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10994
10995 /* FIXME: use matrix-type input source selection */
10996 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10997 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10998 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10999 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11000 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11001 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11002 /* Input mixer2 */
11003 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11004 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11005 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11006 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11007 /* Input mixer3 */
11008 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11009 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11010 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11012
11013 { }
11014};
11015
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011016static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11017 /*
11018 * Unmute ADC0-2 and set the default input to mic-in
11019 */
11020 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11021 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11022 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11023 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11024 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11025 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11026
Takashi Iwaicb53c622007-08-10 17:21:45 +020011027 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011028 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011029 * Note: PASD motherboards uses the Line In 2 as the input for
11030 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011031 */
11032 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011033 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11034 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11035 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11036 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11038 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011040
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011041 /*
11042 * Set up output mixers (0x0c - 0x0e)
11043 */
11044 /* set vol=0 to output mixers */
11045 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11046 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11047 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11048
11049 /* set up input amps for analog loopback */
11050 /* Amp Indices: DAC = 0, mixer = 1 */
11051 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11052 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11053 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11054 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11055 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11056 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11057
Takashi Iwaice875f02008-01-28 18:17:43 +010011058 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011059 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11060 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11061
11062 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11063 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11064
11065 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11066 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11067
11068 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11069 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11070 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11071 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11072 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11073
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011074 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011075 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011077 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011078 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11079 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11080
11081
11082 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011083 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11084 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011085 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011086 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11087 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11088 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11089 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11090 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11091 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11092 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11093 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011094 /* Input mixer2 */
11095 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011096 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11097 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11098 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11099 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11102 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11103 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011104 /* Input mixer3 */
11105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11112 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11113 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011114
Takashi Iwaice875f02008-01-28 18:17:43 +010011115 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11116
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011117 { }
11118};
11119
Kailang Yangcd7509a2007-01-26 18:33:17 +010011120static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11121 /*
11122 * Unmute ADC0-2 and set the default input to mic-in
11123 */
11124 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11125 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11126 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11127 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11128 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11129 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11130
Takashi Iwaicb53c622007-08-10 17:21:45 +020011131 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011132 * mixer widget
11133 * Note: PASD motherboards uses the Line In 2 as the input for front
11134 * panel mic (mic 2)
11135 */
11136 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011137 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11138 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11139 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11140 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11141 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11142 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11143 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11144 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011145 /*
11146 * Set up output mixers (0x0c - 0x0e)
11147 */
11148 /* set vol=0 to output mixers */
11149 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11150 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11151 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11152
11153 /* set up input amps for analog loopback */
11154 /* Amp Indices: DAC = 0, mixer = 1 */
11155 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11156 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11157 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11158 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11159 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11160 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11161
11162
11163 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11164 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11165 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11166 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11167 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11168 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11169 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11170
11171 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11172 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11173
11174 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11175 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11176
11177 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11178 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11179 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11180 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11181 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11182 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11183
11184 /* FIXME: use matrix-type input source selection */
11185 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11186 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11187 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11188 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11189 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11190 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11191 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11192 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11194 /* Input mixer2 */
11195 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11196 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11197 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11198 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11199 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11200 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11201 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11202 /* Input mixer3 */
11203 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11204 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11205 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11206 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11207 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11208 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11209 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11210
Takashi Iwaice875f02008-01-28 18:17:43 +010011211 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11212
Kailang Yangcd7509a2007-01-26 18:33:17 +010011213 { }
11214};
11215
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011216static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11217
11218 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11219 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11220 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11221
11222 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11223 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11224 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11225 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11226
11227 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11228 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11229 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11230 {}
11231};
11232
11233
Takashi Iwaicb53c622007-08-10 17:21:45 +020011234#ifdef CONFIG_SND_HDA_POWER_SAVE
11235#define alc262_loopbacks alc880_loopbacks
11236#endif
11237
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011238/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011239#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11240#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11241#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11242#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11243
11244/*
11245 * BIOS auto configuration
11246 */
11247static int alc262_parse_auto_config(struct hda_codec *codec)
11248{
11249 struct alc_spec *spec = codec->spec;
11250 int err;
11251 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11252
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011253 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11254 alc262_ignore);
11255 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011256 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011257 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011258 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011259 spec->multiout.max_channels = 2;
11260 spec->no_analog = 1;
11261 goto dig_only;
11262 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011263 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011264 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011265 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11266 if (err < 0)
11267 return err;
11268 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
11269 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011270 return err;
11271
11272 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11273
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011274 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011275 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011276 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011277 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011278 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011279 if (spec->autocfg.dig_in_pin)
11280 spec->dig_in_nid = ALC262_DIGIN_NID;
11281
Takashi Iwai603c4012008-07-30 15:01:44 +020011282 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011283 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011284
Takashi Iwaid88897e2008-10-31 15:01:37 +010011285 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011286 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011287 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011288
Takashi Iwai776e1842007-08-29 15:07:11 +020011289 err = alc_auto_add_mic_boost(codec);
11290 if (err < 0)
11291 return err;
11292
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011293 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11294
Kailang Yangdf694da2005-12-05 19:42:22 +010011295 return 1;
11296}
11297
11298#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11299#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11300#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011301#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011302
11303
11304/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011305static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011306{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011307 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011308 alc262_auto_init_multi_out(codec);
11309 alc262_auto_init_hp_out(codec);
11310 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011311 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011312 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011313 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011314}
11315
11316/*
11317 * configuration and preset
11318 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011319static const char *alc262_models[ALC262_MODEL_LAST] = {
11320 [ALC262_BASIC] = "basic",
11321 [ALC262_HIPPO] = "hippo",
11322 [ALC262_HIPPO_1] = "hippo_1",
11323 [ALC262_FUJITSU] = "fujitsu",
11324 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011325 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011326 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011327 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011328 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011329 [ALC262_BENQ_T31] = "benq-t31",
11330 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011331 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011332 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011333 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011334 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011335 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011336 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011337 [ALC262_AUTO] = "auto",
11338};
11339
11340static struct snd_pci_quirk alc262_cfg_tbl[] = {
11341 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011342 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011343 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11344 ALC262_HP_BPC),
11345 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11346 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011347 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11348 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011349 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011350 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011351 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011352 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011353 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011354 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011355 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011356 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011357 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11358 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11359 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011360 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11361 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011362 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011363 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011364 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011365 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011366 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011367 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011368 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11369 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011370 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011371 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011372 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011373 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011374 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011375 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011376 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11377 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011378 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011379 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011380 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011381 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011382 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011383 {}
11384};
11385
11386static struct alc_config_preset alc262_presets[] = {
11387 [ALC262_BASIC] = {
11388 .mixers = { alc262_base_mixer },
11389 .init_verbs = { alc262_init_verbs },
11390 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11391 .dac_nids = alc262_dac_nids,
11392 .hp_nid = 0x03,
11393 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11394 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011395 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011396 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011397 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011398 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020011399 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
11400 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11401 .dac_nids = alc262_dac_nids,
11402 .hp_nid = 0x03,
11403 .dig_out_nid = ALC262_DIGOUT_NID,
11404 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11405 .channel_mode = alc262_modes,
11406 .input_mux = &alc262_capture_source,
11407 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011408 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011409 },
11410 [ALC262_HIPPO_1] = {
11411 .mixers = { alc262_hippo1_mixer },
11412 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11413 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11414 .dac_nids = alc262_dac_nids,
11415 .hp_nid = 0x02,
11416 .dig_out_nid = ALC262_DIGOUT_NID,
11417 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11418 .channel_mode = alc262_modes,
11419 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011420 .unsol_event = alc262_hippo_unsol_event,
11421 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011422 },
Takashi Iwai834be882006-03-01 14:16:17 +010011423 [ALC262_FUJITSU] = {
11424 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011425 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11426 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011427 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11428 .dac_nids = alc262_dac_nids,
11429 .hp_nid = 0x03,
11430 .dig_out_nid = ALC262_DIGOUT_NID,
11431 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11432 .channel_mode = alc262_modes,
11433 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011434 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011435 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011436 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011437 [ALC262_HP_BPC] = {
11438 .mixers = { alc262_HP_BPC_mixer },
11439 .init_verbs = { alc262_HP_BPC_init_verbs },
11440 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11441 .dac_nids = alc262_dac_nids,
11442 .hp_nid = 0x03,
11443 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11444 .channel_mode = alc262_modes,
11445 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011446 .unsol_event = alc262_hp_bpc_unsol_event,
11447 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011448 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011449 [ALC262_HP_BPC_D7000_WF] = {
11450 .mixers = { alc262_HP_BPC_WildWest_mixer },
11451 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11452 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11453 .dac_nids = alc262_dac_nids,
11454 .hp_nid = 0x03,
11455 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11456 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011457 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011458 .unsol_event = alc262_hp_wildwest_unsol_event,
11459 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011460 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011461 [ALC262_HP_BPC_D7000_WL] = {
11462 .mixers = { alc262_HP_BPC_WildWest_mixer,
11463 alc262_HP_BPC_WildWest_option_mixer },
11464 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11465 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11466 .dac_nids = alc262_dac_nids,
11467 .hp_nid = 0x03,
11468 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11469 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011470 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011471 .unsol_event = alc262_hp_wildwest_unsol_event,
11472 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011473 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011474 [ALC262_HP_TC_T5735] = {
11475 .mixers = { alc262_hp_t5735_mixer },
11476 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11477 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11478 .dac_nids = alc262_dac_nids,
11479 .hp_nid = 0x03,
11480 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11481 .channel_mode = alc262_modes,
11482 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011483 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011484 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011485 },
11486 [ALC262_HP_RP5700] = {
11487 .mixers = { alc262_hp_rp5700_mixer },
11488 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11489 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11490 .dac_nids = alc262_dac_nids,
11491 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11492 .channel_mode = alc262_modes,
11493 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011494 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011495 [ALC262_BENQ_ED8] = {
11496 .mixers = { alc262_base_mixer },
11497 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11498 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11499 .dac_nids = alc262_dac_nids,
11500 .hp_nid = 0x03,
11501 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11502 .channel_mode = alc262_modes,
11503 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011504 },
Kailang Yang272a5272007-05-14 11:00:38 +020011505 [ALC262_SONY_ASSAMD] = {
11506 .mixers = { alc262_sony_mixer },
11507 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11508 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11509 .dac_nids = alc262_dac_nids,
11510 .hp_nid = 0x02,
11511 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11512 .channel_mode = alc262_modes,
11513 .input_mux = &alc262_capture_source,
11514 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011515 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011516 },
11517 [ALC262_BENQ_T31] = {
11518 .mixers = { alc262_benq_t31_mixer },
11519 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11520 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11521 .dac_nids = alc262_dac_nids,
11522 .hp_nid = 0x03,
11523 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11524 .channel_mode = alc262_modes,
11525 .input_mux = &alc262_capture_source,
11526 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011527 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011528 },
Tobin Davisf651b502007-10-26 12:40:47 +020011529 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011530 .mixers = { alc262_ultra_mixer },
11531 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011532 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011533 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11534 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011535 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11536 .channel_mode = alc262_modes,
11537 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011538 .adc_nids = alc262_adc_nids, /* ADC0 */
11539 .capsrc_nids = alc262_capsrc_nids,
11540 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011541 .unsol_event = alc262_ultra_unsol_event,
11542 .init_hook = alc262_ultra_automute,
11543 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011544 [ALC262_LENOVO_3000] = {
11545 .mixers = { alc262_lenovo_3000_mixer },
11546 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11547 alc262_lenovo_3000_unsol_verbs },
11548 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11549 .dac_nids = alc262_dac_nids,
11550 .hp_nid = 0x03,
11551 .dig_out_nid = ALC262_DIGOUT_NID,
11552 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11553 .channel_mode = alc262_modes,
11554 .input_mux = &alc262_fujitsu_capture_source,
11555 .unsol_event = alc262_lenovo_3000_unsol_event,
11556 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011557 [ALC262_NEC] = {
11558 .mixers = { alc262_nec_mixer },
11559 .init_verbs = { alc262_nec_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 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011567 [ALC262_TOSHIBA_S06] = {
11568 .mixers = { alc262_toshiba_s06_mixer },
11569 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11570 alc262_eapd_verbs },
11571 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11572 .capsrc_nids = alc262_dmic_capsrc_nids,
11573 .dac_nids = alc262_dac_nids,
11574 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011575 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011576 .dig_out_nid = ALC262_DIGOUT_NID,
11577 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11578 .channel_mode = alc262_modes,
11579 .input_mux = &alc262_dmic_capture_source,
11580 .unsol_event = alc262_toshiba_s06_unsol_event,
11581 .init_hook = alc262_toshiba_s06_init_hook,
11582 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011583 [ALC262_TOSHIBA_RX1] = {
11584 .mixers = { alc262_toshiba_rx1_mixer },
11585 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11586 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11587 .dac_nids = alc262_dac_nids,
11588 .hp_nid = 0x03,
11589 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11590 .channel_mode = alc262_modes,
11591 .input_mux = &alc262_capture_source,
11592 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011593 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011594 },
Tony Vroonba340e82009-02-02 19:01:30 +000011595 [ALC262_TYAN] = {
11596 .mixers = { alc262_tyan_mixer },
11597 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11598 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11599 .dac_nids = alc262_dac_nids,
11600 .hp_nid = 0x02,
11601 .dig_out_nid = ALC262_DIGOUT_NID,
11602 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11603 .channel_mode = alc262_modes,
11604 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011605 .unsol_event = alc_automute_amp_unsol_event,
11606 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011607 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011608};
11609
11610static int patch_alc262(struct hda_codec *codec)
11611{
11612 struct alc_spec *spec;
11613 int board_config;
11614 int err;
11615
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011616 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011617 if (spec == NULL)
11618 return -ENOMEM;
11619
11620 codec->spec = spec;
11621#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011622 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11623 * under-run
11624 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011625 {
11626 int tmp;
11627 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11628 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11629 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11630 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11631 }
11632#endif
11633
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011634 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11635
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011636 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11637 alc262_models,
11638 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011639
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011640 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020011641 printk(KERN_INFO "hda_codec: Unknown model for %s, "
11642 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011643 board_config = ALC262_AUTO;
11644 }
11645
11646 if (board_config == ALC262_AUTO) {
11647 /* automatic parse from the BIOS config */
11648 err = alc262_parse_auto_config(codec);
11649 if (err < 0) {
11650 alc_free(codec);
11651 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011652 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011653 printk(KERN_INFO
11654 "hda_codec: Cannot set up configuration "
11655 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011656 board_config = ALC262_BASIC;
11657 }
11658 }
11659
Takashi Iwai07eba612009-02-19 08:06:35 +010011660 if (!spec->no_analog) {
11661 err = snd_hda_attach_beep_device(codec, 0x1);
11662 if (err < 0) {
11663 alc_free(codec);
11664 return err;
11665 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011666 }
11667
Kailang Yangdf694da2005-12-05 19:42:22 +010011668 if (board_config != ALC262_AUTO)
11669 setup_preset(spec, &alc262_presets[board_config]);
11670
Kailang Yangdf694da2005-12-05 19:42:22 +010011671 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11672 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011673
Kailang Yangdf694da2005-12-05 19:42:22 +010011674 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11675 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11676
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011677 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011678 int i;
11679 /* check whether the digital-mic has to be supported */
11680 for (i = 0; i < spec->input_mux->num_items; i++) {
11681 if (spec->input_mux->items[i].index >= 9)
11682 break;
11683 }
11684 if (i < spec->input_mux->num_items) {
11685 /* use only ADC0 */
11686 spec->adc_nids = alc262_dmic_adc_nids;
11687 spec->num_adc_nids = 1;
11688 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011689 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011690 /* all analog inputs */
11691 /* check whether NID 0x07 is valid */
11692 unsigned int wcap = get_wcaps(codec, 0x07);
11693
11694 /* get type */
11695 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
11696 if (wcap != AC_WID_AUD_IN) {
11697 spec->adc_nids = alc262_adc_nids_alt;
11698 spec->num_adc_nids =
11699 ARRAY_SIZE(alc262_adc_nids_alt);
11700 spec->capsrc_nids = alc262_capsrc_nids_alt;
11701 } else {
11702 spec->adc_nids = alc262_adc_nids;
11703 spec->num_adc_nids =
11704 ARRAY_SIZE(alc262_adc_nids);
11705 spec->capsrc_nids = alc262_capsrc_nids;
11706 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011707 }
11708 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011709 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011710 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011711 if (!spec->no_analog)
11712 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011713
Takashi Iwai2134ea42008-01-10 16:53:55 +010011714 spec->vmaster_nid = 0x0c;
11715
Kailang Yangdf694da2005-12-05 19:42:22 +010011716 codec->patch_ops = alc_patch_ops;
11717 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011718 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011719#ifdef CONFIG_SND_HDA_POWER_SAVE
11720 if (!spec->loopback.amplist)
11721 spec->loopback.amplist = alc262_loopbacks;
11722#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011723 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011724
Kailang Yangdf694da2005-12-05 19:42:22 +010011725 return 0;
11726}
11727
Kailang Yangdf694da2005-12-05 19:42:22 +010011728/*
Kailang Yanga361d842007-06-05 12:30:55 +020011729 * ALC268 channel source setting (2 channel)
11730 */
11731#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11732#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011733
Kailang Yanga361d842007-06-05 12:30:55 +020011734static hda_nid_t alc268_dac_nids[2] = {
11735 /* front, hp */
11736 0x02, 0x03
11737};
11738
11739static hda_nid_t alc268_adc_nids[2] = {
11740 /* ADC0-1 */
11741 0x08, 0x07
11742};
11743
11744static hda_nid_t alc268_adc_nids_alt[1] = {
11745 /* ADC0 */
11746 0x08
11747};
11748
Takashi Iwaie1406342008-02-11 18:32:32 +010011749static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11750
Kailang Yanga361d842007-06-05 12:30:55 +020011751static struct snd_kcontrol_new alc268_base_mixer[] = {
11752 /* output mixer control */
11753 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11754 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11755 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11756 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011757 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11758 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11759 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011760 { }
11761};
11762
Takashi Iwai42171c12009-05-08 14:11:43 +020011763static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11764 /* output mixer control */
11765 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11766 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11767 ALC262_HIPPO_MASTER_SWITCH,
11768 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11769 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11770 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11771 { }
11772};
11773
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011774/* bind Beep switches of both NID 0x0f and 0x10 */
11775static struct hda_bind_ctls alc268_bind_beep_sw = {
11776 .ops = &snd_hda_bind_sw,
11777 .values = {
11778 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11779 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11780 0
11781 },
11782};
11783
11784static struct snd_kcontrol_new alc268_beep_mixer[] = {
11785 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11786 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11787 { }
11788};
11789
Kailang Yangd1a991a2007-08-15 16:21:59 +020011790static struct hda_verb alc268_eapd_verbs[] = {
11791 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11792 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11793 { }
11794};
11795
Takashi Iwaid2738092007-08-16 14:59:45 +020011796/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011797static struct hda_verb alc268_toshiba_verbs[] = {
11798 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11799 { } /* end */
11800};
11801
Kailang Yang8ef355d2008-08-26 13:10:22 +020011802static struct hda_input_mux alc268_acer_lc_capture_source = {
11803 .num_items = 2,
11804 .items = {
11805 { "i-Mic", 0x6 },
11806 { "E-Mic", 0x0 },
11807 },
11808};
11809
Takashi Iwaid2738092007-08-16 14:59:45 +020011810/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011811/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011812static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11813 .ops = &snd_hda_bind_vol,
11814 .values = {
11815 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11816 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11817 0
11818 },
11819};
11820
Takashi Iwai889c4392007-08-23 18:56:52 +020011821/* mute/unmute internal speaker according to the hp jack and mute state */
11822static void alc268_acer_automute(struct hda_codec *codec, int force)
11823{
11824 struct alc_spec *spec = codec->spec;
11825 unsigned int mute;
11826
11827 if (force || !spec->sense_updated) {
11828 unsigned int present;
11829 present = snd_hda_codec_read(codec, 0x14, 0,
11830 AC_VERB_GET_PIN_SENSE, 0);
11831 spec->jack_present = (present & 0x80000000) != 0;
11832 spec->sense_updated = 1;
11833 }
11834 if (spec->jack_present)
11835 mute = HDA_AMP_MUTE; /* mute internal speaker */
11836 else /* unmute internal speaker if necessary */
11837 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11838 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11839 HDA_AMP_MUTE, mute);
11840}
11841
11842
11843/* bind hp and internal speaker mute (with plug check) */
11844static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11845 struct snd_ctl_elem_value *ucontrol)
11846{
11847 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11848 long *valp = ucontrol->value.integer.value;
11849 int change;
11850
11851 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11852 HDA_AMP_MUTE,
11853 valp[0] ? 0 : HDA_AMP_MUTE);
11854 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11855 HDA_AMP_MUTE,
11856 valp[1] ? 0 : HDA_AMP_MUTE);
11857 if (change)
11858 alc268_acer_automute(codec, 0);
11859 return change;
11860}
Takashi Iwaid2738092007-08-16 14:59:45 +020011861
Kailang Yang8ef355d2008-08-26 13:10:22 +020011862static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11863 /* output mixer control */
11864 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11865 {
11866 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11867 .name = "Master Playback Switch",
11868 .info = snd_hda_mixer_amp_switch_info,
11869 .get = snd_hda_mixer_amp_switch_get,
11870 .put = alc268_acer_master_sw_put,
11871 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11872 },
11873 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11874 { }
11875};
11876
Takashi Iwaid2738092007-08-16 14:59:45 +020011877static struct snd_kcontrol_new alc268_acer_mixer[] = {
11878 /* output mixer control */
11879 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11880 {
11881 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11882 .name = "Master Playback Switch",
11883 .info = snd_hda_mixer_amp_switch_info,
11884 .get = snd_hda_mixer_amp_switch_get,
11885 .put = alc268_acer_master_sw_put,
11886 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11887 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011888 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11889 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11890 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011891 { }
11892};
11893
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011894static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11895 /* output mixer control */
11896 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11897 {
11898 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11899 .name = "Master Playback Switch",
11900 .info = snd_hda_mixer_amp_switch_info,
11901 .get = snd_hda_mixer_amp_switch_get,
11902 .put = alc268_acer_master_sw_put,
11903 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11904 },
11905 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11906 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11907 { }
11908};
11909
Kailang Yang8ef355d2008-08-26 13:10:22 +020011910static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11911 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11912 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11913 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11914 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11915 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11916 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11917 { }
11918};
11919
Takashi Iwaid2738092007-08-16 14:59:45 +020011920static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011921 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11922 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011923 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11924 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011925 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11926 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011927 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11928 { }
11929};
11930
11931/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011932#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11933#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011934
11935static void alc268_acer_unsol_event(struct hda_codec *codec,
11936 unsigned int res)
11937{
Takashi Iwai889c4392007-08-23 18:56:52 +020011938 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011939 return;
11940 alc268_acer_automute(codec, 1);
11941}
11942
Takashi Iwai889c4392007-08-23 18:56:52 +020011943static void alc268_acer_init_hook(struct hda_codec *codec)
11944{
11945 alc268_acer_automute(codec, 1);
11946}
11947
Kailang Yang8ef355d2008-08-26 13:10:22 +020011948/* toggle speaker-output according to the hp-jack state */
11949static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11950{
11951 unsigned int present;
11952 unsigned char bits;
11953
11954 present = snd_hda_codec_read(codec, 0x15, 0,
11955 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11956 bits = present ? AMP_IN_MUTE(0) : 0;
11957 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11958 AMP_IN_MUTE(0), bits);
11959 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11960 AMP_IN_MUTE(0), bits);
11961}
11962
11963
11964static void alc268_acer_mic_automute(struct hda_codec *codec)
11965{
11966 unsigned int present;
11967
11968 present = snd_hda_codec_read(codec, 0x18, 0,
11969 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11970 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11971 present ? 0x0 : 0x6);
11972}
11973
11974static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11975 unsigned int res)
11976{
11977 if ((res >> 26) == ALC880_HP_EVENT)
11978 alc268_aspire_one_speaker_automute(codec);
11979 if ((res >> 26) == ALC880_MIC_EVENT)
11980 alc268_acer_mic_automute(codec);
11981}
11982
11983static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11984{
11985 alc268_aspire_one_speaker_automute(codec);
11986 alc268_acer_mic_automute(codec);
11987}
11988
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011989static struct snd_kcontrol_new alc268_dell_mixer[] = {
11990 /* output mixer control */
11991 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11992 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11993 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11995 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11996 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11997 { }
11998};
11999
12000static struct hda_verb alc268_dell_verbs[] = {
12001 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12002 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12003 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12004 { }
12005};
12006
12007/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012008static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012009{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012010 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012011
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012012 spec->autocfg.hp_pins[0] = 0x15;
12013 spec->autocfg.speaker_pins[0] = 0x14;
12014 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012015}
12016
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012017static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12018 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12019 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12020 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12021 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12022 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12023 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12024 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12025 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12026 { }
12027};
12028
12029static struct hda_verb alc267_quanta_il1_verbs[] = {
12030 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12031 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12032 { }
12033};
12034
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012035static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
12036{
12037 unsigned int present;
12038
12039 present = snd_hda_codec_read(codec, 0x18, 0,
12040 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12041 snd_hda_codec_write(codec, 0x23, 0,
12042 AC_VERB_SET_CONNECT_SEL,
12043 present ? 0x00 : 0x01);
12044}
12045
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012046static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012047{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012048 struct alc_spec *spec = codec->spec;
12049
12050 spec->autocfg.hp_pins[0] = 0x15;
12051 spec->autocfg.speaker_pins[0] = 0x14;
12052 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012053 alc267_quanta_il1_mic_automute(codec);
12054}
12055
12056static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
12057 unsigned int res)
12058{
12059 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012060 case ALC880_MIC_EVENT:
12061 alc267_quanta_il1_mic_automute(codec);
12062 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012063 default:
12064 alc_sku_unsol_event(codec, res);
12065 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012066 }
12067}
12068
Kailang Yanga361d842007-06-05 12:30:55 +020012069/*
12070 * generic initialization of ADC, input mixers and output mixers
12071 */
12072static struct hda_verb alc268_base_init_verbs[] = {
12073 /* Unmute DAC0-1 and set vol = 0 */
12074 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012075 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012076
12077 /*
12078 * Set up output mixers (0x0c - 0x0e)
12079 */
12080 /* set vol=0 to output mixers */
12081 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012082 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12083
12084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12085 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12086
12087 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12088 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12089 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12090 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12091 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12092 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12093 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12094 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12095
12096 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12097 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12098 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12099 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012100 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012101
12102 /* set PCBEEP vol = 0, mute connections */
12103 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12104 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12105 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012106
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012107 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012108
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012109 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12110 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12111 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12112 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012113
Kailang Yanga361d842007-06-05 12:30:55 +020012114 { }
12115};
12116
12117/*
12118 * generic initialization of ADC, input mixers and output mixers
12119 */
12120static struct hda_verb alc268_volume_init_verbs[] = {
12121 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012122 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12123 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012124
12125 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12126 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12127 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12128 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12129 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12130
Kailang Yanga361d842007-06-05 12:30:55 +020012131 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012132 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12133 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12134
12135 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012136 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012137
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012138 /* set PCBEEP vol = 0, mute connections */
12139 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12140 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12141 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012142
12143 { }
12144};
12145
Kailang Yanga361d842007-06-05 12:30:55 +020012146static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12147 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12148 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12149 {
12150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12151 /* The multiple "Capture Source" controls confuse alsamixer
12152 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012153 */
12154 /* .name = "Capture Source", */
12155 .name = "Input Source",
12156 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012157 .info = alc_mux_enum_info,
12158 .get = alc_mux_enum_get,
12159 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012160 },
12161 { } /* end */
12162};
12163
12164static struct snd_kcontrol_new alc268_capture_mixer[] = {
12165 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12166 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12167 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12168 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12169 {
12170 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12171 /* The multiple "Capture Source" controls confuse alsamixer
12172 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012173 */
12174 /* .name = "Capture Source", */
12175 .name = "Input Source",
12176 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012177 .info = alc_mux_enum_info,
12178 .get = alc_mux_enum_get,
12179 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012180 },
12181 { } /* end */
12182};
12183
12184static struct hda_input_mux alc268_capture_source = {
12185 .num_items = 4,
12186 .items = {
12187 { "Mic", 0x0 },
12188 { "Front Mic", 0x1 },
12189 { "Line", 0x2 },
12190 { "CD", 0x3 },
12191 },
12192};
12193
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012194static struct hda_input_mux alc268_acer_capture_source = {
12195 .num_items = 3,
12196 .items = {
12197 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012198 { "Internal Mic", 0x1 },
12199 { "Line", 0x2 },
12200 },
12201};
12202
12203static struct hda_input_mux alc268_acer_dmic_capture_source = {
12204 .num_items = 3,
12205 .items = {
12206 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012207 { "Internal Mic", 0x6 },
12208 { "Line", 0x2 },
12209 },
12210};
12211
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012212#ifdef CONFIG_SND_DEBUG
12213static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012214 /* Volume widgets */
12215 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12216 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12217 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12218 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12219 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12220 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12221 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12222 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12223 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12224 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12225 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12226 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12227 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012228 /* The below appears problematic on some hardwares */
12229 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012230 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12231 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12232 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12233 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12234
12235 /* Modes for retasking pin widgets */
12236 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12237 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12238 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12239 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12240
12241 /* Controls for GPIO pins, assuming they are configured as outputs */
12242 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12243 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12244 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12245 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12246
12247 /* Switches to allow the digital SPDIF output pin to be enabled.
12248 * The ALC268 does not have an SPDIF input.
12249 */
12250 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12251
12252 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12253 * this output to turn on an external amplifier.
12254 */
12255 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12256 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12257
12258 { } /* end */
12259};
12260#endif
12261
Kailang Yanga361d842007-06-05 12:30:55 +020012262/* create input playback/capture controls for the given pin */
12263static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12264 const char *ctlname, int idx)
12265{
12266 char name[32];
12267 int err;
12268
12269 sprintf(name, "%s Playback Volume", ctlname);
12270 if (nid == 0x14) {
12271 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12272 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
12273 HDA_OUTPUT));
12274 if (err < 0)
12275 return err;
12276 } else if (nid == 0x15) {
12277 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12278 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
12279 HDA_OUTPUT));
12280 if (err < 0)
12281 return err;
12282 } else
12283 return -1;
12284 sprintf(name, "%s Playback Switch", ctlname);
12285 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12286 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
12287 if (err < 0)
12288 return err;
12289 return 0;
12290}
12291
12292/* add playback controls from the parsed DAC table */
12293static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12294 const struct auto_pin_cfg *cfg)
12295{
12296 hda_nid_t nid;
12297 int err;
12298
12299 spec->multiout.num_dacs = 2; /* only use one dac */
12300 spec->multiout.dac_nids = spec->private_dac_nids;
12301 spec->multiout.dac_nids[0] = 2;
12302 spec->multiout.dac_nids[1] = 3;
12303
12304 nid = cfg->line_out_pins[0];
12305 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020012306 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020012307
12308 nid = cfg->speaker_pins[0];
12309 if (nid == 0x1d) {
12310 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12311 "Speaker Playback Volume",
12312 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12313 if (err < 0)
12314 return err;
12315 }
12316 nid = cfg->hp_pins[0];
12317 if (nid)
12318 alc268_new_analog_output(spec, nid, "Headphone", 0);
12319
12320 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12321 if (nid == 0x16) {
12322 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12323 "Mono Playback Switch",
12324 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
12325 if (err < 0)
12326 return err;
12327 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012328 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012329}
12330
12331/* create playback/capture controls for input pins */
12332static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12333 const struct auto_pin_cfg *cfg)
12334{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012335 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012336 int i, idx1;
12337
12338 for (i = 0; i < AUTO_PIN_LAST; i++) {
12339 switch(cfg->input_pins[i]) {
12340 case 0x18:
12341 idx1 = 0; /* Mic 1 */
12342 break;
12343 case 0x19:
12344 idx1 = 1; /* Mic 2 */
12345 break;
12346 case 0x1a:
12347 idx1 = 2; /* Line In */
12348 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012349 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012350 idx1 = 3; /* CD */
12351 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012352 case 0x12:
12353 case 0x13:
12354 idx1 = 6; /* digital mics */
12355 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012356 default:
12357 continue;
12358 }
12359 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12360 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012361 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012362 }
12363 return 0;
12364}
12365
12366static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12367{
12368 struct alc_spec *spec = codec->spec;
12369 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12370 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12371 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12372 unsigned int dac_vol1, dac_vol2;
12373
12374 if (speaker_nid) {
12375 snd_hda_codec_write(codec, speaker_nid, 0,
12376 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12377 snd_hda_codec_write(codec, 0x0f, 0,
12378 AC_VERB_SET_AMP_GAIN_MUTE,
12379 AMP_IN_UNMUTE(1));
12380 snd_hda_codec_write(codec, 0x10, 0,
12381 AC_VERB_SET_AMP_GAIN_MUTE,
12382 AMP_IN_UNMUTE(1));
12383 } else {
12384 snd_hda_codec_write(codec, 0x0f, 0,
12385 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12386 snd_hda_codec_write(codec, 0x10, 0,
12387 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12388 }
12389
12390 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012391 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012392 dac_vol2 = AMP_OUT_ZERO;
12393 else if (line_nid == 0x15)
12394 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012395 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012396 dac_vol2 = AMP_OUT_ZERO;
12397 else if (hp_nid == 0x15)
12398 dac_vol1 = AMP_OUT_ZERO;
12399 if (line_nid != 0x16 || hp_nid != 0x16 ||
12400 spec->autocfg.line_out_pins[1] != 0x16 ||
12401 spec->autocfg.line_out_pins[2] != 0x16)
12402 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12403
12404 snd_hda_codec_write(codec, 0x02, 0,
12405 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12406 snd_hda_codec_write(codec, 0x03, 0,
12407 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12408}
12409
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012410/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012411#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12412#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012413#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012414#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12415
12416/*
12417 * BIOS auto configuration
12418 */
12419static int alc268_parse_auto_config(struct hda_codec *codec)
12420{
12421 struct alc_spec *spec = codec->spec;
12422 int err;
12423 static hda_nid_t alc268_ignore[] = { 0 };
12424
12425 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12426 alc268_ignore);
12427 if (err < 0)
12428 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012429 if (!spec->autocfg.line_outs) {
12430 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12431 spec->multiout.max_channels = 2;
12432 spec->no_analog = 1;
12433 goto dig_only;
12434 }
Kailang Yanga361d842007-06-05 12:30:55 +020012435 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012436 }
Kailang Yanga361d842007-06-05 12:30:55 +020012437 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12438 if (err < 0)
12439 return err;
12440 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12441 if (err < 0)
12442 return err;
12443
12444 spec->multiout.max_channels = 2;
12445
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012446 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012447 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012448 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012449 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012450 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12451 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012452 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012453 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012454
Takashi Iwai892981f2009-03-02 08:04:35 +010012455 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012456 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012457
Takashi Iwaid88897e2008-10-31 15:01:37 +010012458 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012459 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012460 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012461
Takashi Iwai776e1842007-08-29 15:07:11 +020012462 err = alc_auto_add_mic_boost(codec);
12463 if (err < 0)
12464 return err;
12465
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012466 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12467
Kailang Yanga361d842007-06-05 12:30:55 +020012468 return 1;
12469}
12470
12471#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12472#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12473#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12474
12475/* init callback for auto-configuration model -- overriding the default init */
12476static void alc268_auto_init(struct hda_codec *codec)
12477{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012478 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012479 alc268_auto_init_multi_out(codec);
12480 alc268_auto_init_hp_out(codec);
12481 alc268_auto_init_mono_speaker_out(codec);
12482 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012483 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012484 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012485}
12486
12487/*
12488 * configuration and preset
12489 */
12490static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012491 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012492 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012493 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012494 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012495 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012496 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012497 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012498 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012499#ifdef CONFIG_SND_DEBUG
12500 [ALC268_TEST] = "test",
12501#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012502 [ALC268_AUTO] = "auto",
12503};
12504
12505static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012506 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012507 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012508 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012509 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012510 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012511 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12512 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012513 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012514 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012515 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12516 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012517 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012518 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12519 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12520 ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012521 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012522 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012523 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012524 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012525 {}
12526};
12527
12528static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012529 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012530 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012531 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12532 alc267_quanta_il1_verbs },
12533 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12534 .dac_nids = alc268_dac_nids,
12535 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12536 .adc_nids = alc268_adc_nids_alt,
12537 .hp_nid = 0x03,
12538 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12539 .channel_mode = alc268_modes,
12540 .input_mux = &alc268_capture_source,
12541 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012542 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012543 },
Kailang Yanga361d842007-06-05 12:30:55 +020012544 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012545 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12546 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012547 .init_verbs = { alc268_base_init_verbs },
12548 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12549 .dac_nids = alc268_dac_nids,
12550 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12551 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012552 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012553 .hp_nid = 0x03,
12554 .dig_out_nid = ALC268_DIGOUT_NID,
12555 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12556 .channel_mode = alc268_modes,
12557 .input_mux = &alc268_capture_source,
12558 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012559 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012560 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012561 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012562 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12563 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012564 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12565 .dac_nids = alc268_dac_nids,
12566 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12567 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012568 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012569 .hp_nid = 0x03,
12570 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12571 .channel_mode = alc268_modes,
12572 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012573 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012574 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012575 },
12576 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012577 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12578 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012579 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12580 alc268_acer_verbs },
12581 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12582 .dac_nids = alc268_dac_nids,
12583 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12584 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012585 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012586 .hp_nid = 0x02,
12587 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12588 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012589 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012590 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012591 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012592 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012593 [ALC268_ACER_DMIC] = {
12594 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12595 alc268_beep_mixer },
12596 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12597 alc268_acer_verbs },
12598 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12599 .dac_nids = alc268_dac_nids,
12600 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12601 .adc_nids = alc268_adc_nids_alt,
12602 .capsrc_nids = alc268_capsrc_nids,
12603 .hp_nid = 0x02,
12604 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12605 .channel_mode = alc268_modes,
12606 .input_mux = &alc268_acer_dmic_capture_source,
12607 .unsol_event = alc268_acer_unsol_event,
12608 .init_hook = alc268_acer_init_hook,
12609 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012610 [ALC268_ACER_ASPIRE_ONE] = {
12611 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012612 alc268_beep_mixer,
12613 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012614 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12615 alc268_acer_aspire_one_verbs },
12616 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12617 .dac_nids = alc268_dac_nids,
12618 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12619 .adc_nids = alc268_adc_nids_alt,
12620 .capsrc_nids = alc268_capsrc_nids,
12621 .hp_nid = 0x03,
12622 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12623 .channel_mode = alc268_modes,
12624 .input_mux = &alc268_acer_lc_capture_source,
12625 .unsol_event = alc268_acer_lc_unsol_event,
12626 .init_hook = alc268_acer_lc_init_hook,
12627 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012628 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012629 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012630 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12631 alc268_dell_verbs },
12632 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12633 .dac_nids = alc268_dac_nids,
12634 .hp_nid = 0x02,
12635 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12636 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012637 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012638 .init_hook = alc268_dell_init_hook,
12639 .input_mux = &alc268_capture_source,
12640 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012641 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012642 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12643 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012644 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12645 alc268_toshiba_verbs },
12646 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12647 .dac_nids = alc268_dac_nids,
12648 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12649 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012650 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012651 .hp_nid = 0x03,
12652 .dig_out_nid = ALC268_DIGOUT_NID,
12653 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12654 .channel_mode = alc268_modes,
12655 .input_mux = &alc268_capture_source,
12656 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012657 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012658 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012659#ifdef CONFIG_SND_DEBUG
12660 [ALC268_TEST] = {
12661 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12662 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12663 alc268_volume_init_verbs },
12664 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12665 .dac_nids = alc268_dac_nids,
12666 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12667 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012668 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012669 .hp_nid = 0x03,
12670 .dig_out_nid = ALC268_DIGOUT_NID,
12671 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12672 .channel_mode = alc268_modes,
12673 .input_mux = &alc268_capture_source,
12674 },
12675#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012676};
12677
12678static int patch_alc268(struct hda_codec *codec)
12679{
12680 struct alc_spec *spec;
12681 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012682 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012683
12684 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12685 if (spec == NULL)
12686 return -ENOMEM;
12687
12688 codec->spec = spec;
12689
12690 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12691 alc268_models,
12692 alc268_cfg_tbl);
12693
12694 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020012695 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12696 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012697 board_config = ALC268_AUTO;
12698 }
12699
12700 if (board_config == ALC268_AUTO) {
12701 /* automatic parse from the BIOS config */
12702 err = alc268_parse_auto_config(codec);
12703 if (err < 0) {
12704 alc_free(codec);
12705 return err;
12706 } else if (!err) {
12707 printk(KERN_INFO
12708 "hda_codec: Cannot set up configuration "
12709 "from BIOS. Using base mode...\n");
12710 board_config = ALC268_3ST;
12711 }
12712 }
12713
12714 if (board_config != ALC268_AUTO)
12715 setup_preset(spec, &alc268_presets[board_config]);
12716
Kailang Yanga361d842007-06-05 12:30:55 +020012717 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12718 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012719 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012720
Kailang Yanga361d842007-06-05 12:30:55 +020012721 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12722
Takashi Iwai22971e32009-02-10 11:56:44 +010012723 has_beep = 0;
12724 for (i = 0; i < spec->num_mixers; i++) {
12725 if (spec->mixers[i] == alc268_beep_mixer) {
12726 has_beep = 1;
12727 break;
12728 }
12729 }
12730
12731 if (has_beep) {
12732 err = snd_hda_attach_beep_device(codec, 0x1);
12733 if (err < 0) {
12734 alc_free(codec);
12735 return err;
12736 }
12737 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12738 /* override the amp caps for beep generator */
12739 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012740 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12741 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12742 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12743 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012744 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012745
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012746 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012747 /* check whether NID 0x07 is valid */
12748 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012749 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012750
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012751 /* get type */
12752 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012753 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012754 spec->adc_nids = alc268_adc_nids_alt;
12755 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012756 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012757 } else {
12758 spec->adc_nids = alc268_adc_nids;
12759 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012760 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012761 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012762 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012763 /* set default input source */
12764 for (i = 0; i < spec->num_adc_nids; i++)
12765 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12766 0, AC_VERB_SET_CONNECT_SEL,
12767 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012768 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012769
12770 spec->vmaster_nid = 0x02;
12771
Kailang Yanga361d842007-06-05 12:30:55 +020012772 codec->patch_ops = alc_patch_ops;
12773 if (board_config == ALC268_AUTO)
12774 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012775
Takashi Iwaidaead532008-11-28 12:55:36 +010012776 codec->proc_widget_hook = print_realtek_coef;
12777
Kailang Yanga361d842007-06-05 12:30:55 +020012778 return 0;
12779}
12780
12781/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012782 * ALC269 channel source setting (2 channel)
12783 */
12784#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12785
12786#define alc269_dac_nids alc260_dac_nids
12787
12788static hda_nid_t alc269_adc_nids[1] = {
12789 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012790 0x08,
12791};
12792
Takashi Iwaie01bf502008-08-21 16:25:07 +020012793static hda_nid_t alc269_capsrc_nids[1] = {
12794 0x23,
12795};
12796
12797/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12798 * not a mux!
12799 */
12800
Kailang Yangf53281e2008-07-18 12:36:43 +020012801static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12802 .num_items = 2,
12803 .items = {
12804 { "i-Mic", 0x5 },
12805 { "e-Mic", 0x0 },
12806 },
12807};
12808
12809static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12810 .num_items = 2,
12811 .items = {
12812 { "i-Mic", 0x1 },
12813 { "e-Mic", 0x0 },
12814 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012815};
12816
12817#define alc269_modes alc260_modes
12818#define alc269_capture_source alc880_lg_lw_capture_source
12819
12820static struct snd_kcontrol_new alc269_base_mixer[] = {
12821 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12822 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12823 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12824 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12826 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12827 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12828 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12829 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12830 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12831 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12832 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12833 { } /* end */
12834};
12835
Kailang Yang60db6b52008-08-26 13:13:00 +020012836static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12837 /* output mixer control */
12838 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12839 {
12840 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12841 .name = "Master Playback Switch",
12842 .info = snd_hda_mixer_amp_switch_info,
12843 .get = snd_hda_mixer_amp_switch_get,
12844 .put = alc268_acer_master_sw_put,
12845 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12846 },
12847 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12848 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12849 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12850 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12851 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12852 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012853 { }
12854};
12855
Tony Vroon64154832008-11-06 15:08:49 +000012856static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12857 /* output mixer control */
12858 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12859 {
12860 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12861 .name = "Master Playback Switch",
12862 .info = snd_hda_mixer_amp_switch_info,
12863 .get = snd_hda_mixer_amp_switch_get,
12864 .put = alc268_acer_master_sw_put,
12865 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12866 },
12867 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12868 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12869 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12870 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12871 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12872 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12873 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12874 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12875 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012876 { }
12877};
12878
Kailang Yangf53281e2008-07-18 12:36:43 +020012879static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012880 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12881 HDA_CODEC_MUTE("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12883 HDA_CODEC_MUTE("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012884 { } /* end */
12885};
12886
Kailang Yangf6a92242007-12-13 16:52:54 +010012887/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012888static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12889 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12890 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012891 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12892 { } /* end */
12893};
12894
12895/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012896#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012897
Kailang Yang60db6b52008-08-26 13:13:00 +020012898static struct hda_verb alc269_quanta_fl1_verbs[] = {
12899 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12900 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12901 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12902 {0x15, 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
Tony Vroon64154832008-11-06 15:08:49 +000012908static struct hda_verb alc269_lifebook_verbs[] = {
12909 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12910 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12911 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12912 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12913 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12914 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12915 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12916 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12917 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12918 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12919 { }
12920};
12921
Kailang Yang60db6b52008-08-26 13:13:00 +020012922/* toggle speaker-output according to the hp-jack state */
12923static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12924{
12925 unsigned int present;
12926 unsigned char bits;
12927
12928 present = snd_hda_codec_read(codec, 0x15, 0,
12929 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12930 bits = present ? AMP_IN_MUTE(0) : 0;
12931 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12932 AMP_IN_MUTE(0), bits);
12933 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12934 AMP_IN_MUTE(0), bits);
12935
12936 snd_hda_codec_write(codec, 0x20, 0,
12937 AC_VERB_SET_COEF_INDEX, 0x0c);
12938 snd_hda_codec_write(codec, 0x20, 0,
12939 AC_VERB_SET_PROC_COEF, 0x680);
12940
12941 snd_hda_codec_write(codec, 0x20, 0,
12942 AC_VERB_SET_COEF_INDEX, 0x0c);
12943 snd_hda_codec_write(codec, 0x20, 0,
12944 AC_VERB_SET_PROC_COEF, 0x480);
12945}
12946
Tony Vroon64154832008-11-06 15:08:49 +000012947/* toggle speaker-output according to the hp-jacks state */
12948static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12949{
12950 unsigned int present;
12951 unsigned char bits;
12952
12953 /* Check laptop headphone socket */
12954 present = snd_hda_codec_read(codec, 0x15, 0,
12955 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12956
12957 /* Check port replicator headphone socket */
12958 present |= snd_hda_codec_read(codec, 0x1a, 0,
12959 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12960
12961 bits = present ? AMP_IN_MUTE(0) : 0;
12962 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12963 AMP_IN_MUTE(0), bits);
12964 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12965 AMP_IN_MUTE(0), bits);
12966
12967 snd_hda_codec_write(codec, 0x20, 0,
12968 AC_VERB_SET_COEF_INDEX, 0x0c);
12969 snd_hda_codec_write(codec, 0x20, 0,
12970 AC_VERB_SET_PROC_COEF, 0x680);
12971
12972 snd_hda_codec_write(codec, 0x20, 0,
12973 AC_VERB_SET_COEF_INDEX, 0x0c);
12974 snd_hda_codec_write(codec, 0x20, 0,
12975 AC_VERB_SET_PROC_COEF, 0x480);
12976}
12977
Kailang Yang60db6b52008-08-26 13:13:00 +020012978static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12979{
12980 unsigned int present;
12981
12982 present = snd_hda_codec_read(codec, 0x18, 0,
12983 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12984 snd_hda_codec_write(codec, 0x23, 0,
12985 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12986}
12987
Tony Vroon64154832008-11-06 15:08:49 +000012988static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12989{
12990 unsigned int present_laptop;
12991 unsigned int present_dock;
12992
12993 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12994 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12995
12996 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12997 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12998
12999 /* Laptop mic port overrides dock mic port, design decision */
13000 if (present_dock)
13001 snd_hda_codec_write(codec, 0x23, 0,
13002 AC_VERB_SET_CONNECT_SEL, 0x3);
13003 if (present_laptop)
13004 snd_hda_codec_write(codec, 0x23, 0,
13005 AC_VERB_SET_CONNECT_SEL, 0x0);
13006 if (!present_dock && !present_laptop)
13007 snd_hda_codec_write(codec, 0x23, 0,
13008 AC_VERB_SET_CONNECT_SEL, 0x1);
13009}
13010
Kailang Yang60db6b52008-08-26 13:13:00 +020013011static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13012 unsigned int res)
13013{
13014 if ((res >> 26) == ALC880_HP_EVENT)
13015 alc269_quanta_fl1_speaker_automute(codec);
13016 if ((res >> 26) == ALC880_MIC_EVENT)
13017 alc269_quanta_fl1_mic_automute(codec);
13018}
13019
Tony Vroon64154832008-11-06 15:08:49 +000013020static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13021 unsigned int res)
13022{
13023 if ((res >> 26) == ALC880_HP_EVENT)
13024 alc269_lifebook_speaker_automute(codec);
13025 if ((res >> 26) == ALC880_MIC_EVENT)
13026 alc269_lifebook_mic_autoswitch(codec);
13027}
13028
Kailang Yang60db6b52008-08-26 13:13:00 +020013029static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13030{
13031 alc269_quanta_fl1_speaker_automute(codec);
13032 alc269_quanta_fl1_mic_automute(codec);
13033}
13034
Tony Vroon64154832008-11-06 15:08:49 +000013035static void alc269_lifebook_init_hook(struct hda_codec *codec)
13036{
13037 alc269_lifebook_speaker_automute(codec);
13038 alc269_lifebook_mic_autoswitch(codec);
13039}
13040
Kailang Yang60db6b52008-08-26 13:13:00 +020013041static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13042 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13043 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13044 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13045 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13046 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13047 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13048 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13049 {}
13050};
13051
13052static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13053 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13054 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13055 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13056 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13057 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13058 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13059 {}
13060};
13061
13062/* toggle speaker-output according to the hp-jack state */
13063static void alc269_speaker_automute(struct hda_codec *codec)
13064{
13065 unsigned int present;
13066 unsigned char bits;
13067
13068 present = snd_hda_codec_read(codec, 0x15, 0,
13069 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13070 bits = present ? AMP_IN_MUTE(0) : 0;
13071 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13072 AMP_IN_MUTE(0), bits);
13073 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13074 AMP_IN_MUTE(0), bits);
13075}
13076
13077static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
13078{
13079 unsigned int present;
13080
13081 present = snd_hda_codec_read(codec, 0x18, 0,
13082 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13083 snd_hda_codec_write(codec, 0x23, 0,
13084 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
13085}
13086
13087static void alc269_eeepc_amic_automute(struct hda_codec *codec)
13088{
13089 unsigned int present;
13090
13091 present = snd_hda_codec_read(codec, 0x18, 0,
13092 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13093 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13094 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13095 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13096 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13097}
13098
13099/* unsolicited event for HP jack sensing */
13100static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
13101 unsigned int res)
13102{
13103 if ((res >> 26) == ALC880_HP_EVENT)
13104 alc269_speaker_automute(codec);
13105
13106 if ((res >> 26) == ALC880_MIC_EVENT)
13107 alc269_eeepc_dmic_automute(codec);
13108}
13109
13110static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
13111{
13112 alc269_speaker_automute(codec);
13113 alc269_eeepc_dmic_automute(codec);
13114}
13115
13116/* unsolicited event for HP jack sensing */
13117static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
13118 unsigned int res)
13119{
13120 if ((res >> 26) == ALC880_HP_EVENT)
13121 alc269_speaker_automute(codec);
13122
13123 if ((res >> 26) == ALC880_MIC_EVENT)
13124 alc269_eeepc_amic_automute(codec);
13125}
13126
13127static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
13128{
13129 alc269_speaker_automute(codec);
13130 alc269_eeepc_amic_automute(codec);
13131}
13132
Kailang Yangf6a92242007-12-13 16:52:54 +010013133/*
13134 * generic initialization of ADC, input mixers and output mixers
13135 */
13136static struct hda_verb alc269_init_verbs[] = {
13137 /*
13138 * Unmute ADC0 and set the default input to mic-in
13139 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013140 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013141
13142 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13143 * analog-loopback mixer widget
13144 * Note: PASD motherboards uses the Line In 2 as the input for
13145 * front panel mic (mic 2)
13146 */
13147 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13149 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13151 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13152 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13153
13154 /*
13155 * Set up output mixers (0x0c - 0x0e)
13156 */
13157 /* set vol=0 to output mixers */
13158 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13159 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13160
13161 /* set up input amps for analog loopback */
13162 /* Amp Indices: DAC = 0, mixer = 1 */
13163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13164 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13165 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13166 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13167 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13168 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13169
13170 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13171 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13172 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13173 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13174 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13175 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13176 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13177
13178 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13179 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13180 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13181 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13182 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13183 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13184 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13185
13186 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13187 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13188
13189 /* FIXME: use matrix-type input source selection */
13190 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13191 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013192 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013194 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13196
13197 /* set EAPD */
13198 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13199 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13200 { }
13201};
13202
13203/* add playback controls from the parsed DAC table */
13204static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
13205 const struct auto_pin_cfg *cfg)
13206{
13207 hda_nid_t nid;
13208 int err;
13209
13210 spec->multiout.num_dacs = 1; /* only use one dac */
13211 spec->multiout.dac_nids = spec->private_dac_nids;
13212 spec->multiout.dac_nids[0] = 2;
13213
13214 nid = cfg->line_out_pins[0];
13215 if (nid) {
13216 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13217 "Front Playback Volume",
13218 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
13219 if (err < 0)
13220 return err;
13221 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13222 "Front Playback Switch",
13223 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13224 if (err < 0)
13225 return err;
13226 }
13227
13228 nid = cfg->speaker_pins[0];
13229 if (nid) {
13230 if (!cfg->line_out_pins[0]) {
13231 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13232 "Speaker Playback Volume",
13233 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13234 HDA_OUTPUT));
13235 if (err < 0)
13236 return err;
13237 }
13238 if (nid == 0x16) {
13239 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13240 "Speaker Playback Switch",
13241 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13242 HDA_OUTPUT));
13243 if (err < 0)
13244 return err;
13245 } else {
13246 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13247 "Speaker Playback Switch",
13248 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13249 HDA_OUTPUT));
13250 if (err < 0)
13251 return err;
13252 }
13253 }
13254 nid = cfg->hp_pins[0];
13255 if (nid) {
13256 /* spec->multiout.hp_nid = 2; */
13257 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
13258 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13259 "Headphone Playback Volume",
13260 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13261 HDA_OUTPUT));
13262 if (err < 0)
13263 return err;
13264 }
13265 if (nid == 0x16) {
13266 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13267 "Headphone Playback Switch",
13268 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13269 HDA_OUTPUT));
13270 if (err < 0)
13271 return err;
13272 } else {
13273 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13274 "Headphone Playback Switch",
13275 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13276 HDA_OUTPUT));
13277 if (err < 0)
13278 return err;
13279 }
13280 }
13281 return 0;
13282}
13283
Takashi Iwai8c927b42009-06-22 10:56:54 +020013284#define alc269_auto_create_analog_input_ctls \
13285 alc262_auto_create_analog_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013286
13287#ifdef CONFIG_SND_HDA_POWER_SAVE
13288#define alc269_loopbacks alc880_loopbacks
13289#endif
13290
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013291/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013292#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13293#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13294#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13295#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13296
Takashi Iwaif03d3112009-03-05 14:18:16 +010013297static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13298 .substreams = 1,
13299 .channels_min = 2,
13300 .channels_max = 8,
13301 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13302 /* NID is set in alc_build_pcms */
13303 .ops = {
13304 .open = alc880_playback_pcm_open,
13305 .prepare = alc880_playback_pcm_prepare,
13306 .cleanup = alc880_playback_pcm_cleanup
13307 },
13308};
13309
13310static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13311 .substreams = 1,
13312 .channels_min = 2,
13313 .channels_max = 2,
13314 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13315 /* NID is set in alc_build_pcms */
13316};
13317
Kailang Yangf6a92242007-12-13 16:52:54 +010013318/*
13319 * BIOS auto configuration
13320 */
13321static int alc269_parse_auto_config(struct hda_codec *codec)
13322{
13323 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013324 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013325 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13326
13327 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13328 alc269_ignore);
13329 if (err < 0)
13330 return err;
13331
13332 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13333 if (err < 0)
13334 return err;
13335 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13336 if (err < 0)
13337 return err;
13338
13339 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13340
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013341 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013342 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13343
Takashi Iwai603c4012008-07-30 15:01:44 +020013344 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013345 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013346
Takashi Iwaid88897e2008-10-31 15:01:37 +010013347 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013348 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013349 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013350 /* set default input source */
13351 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13352 0, AC_VERB_SET_CONNECT_SEL,
13353 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013354
13355 err = alc_auto_add_mic_boost(codec);
13356 if (err < 0)
13357 return err;
13358
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013359 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013360 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013361
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013362 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13363
Kailang Yangf6a92242007-12-13 16:52:54 +010013364 return 1;
13365}
13366
13367#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13368#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13369#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13370
13371
13372/* init callback for auto-configuration model -- overriding the default init */
13373static void alc269_auto_init(struct hda_codec *codec)
13374{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013375 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013376 alc269_auto_init_multi_out(codec);
13377 alc269_auto_init_hp_out(codec);
13378 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013379 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013380 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013381}
13382
13383/*
13384 * configuration and preset
13385 */
13386static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013387 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013388 [ALC269_QUANTA_FL1] = "quanta",
13389 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013390 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013391 [ALC269_FUJITSU] = "fujitsu",
13392 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013393};
13394
13395static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013396 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013397 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13398 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013399 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13400 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13401 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13402 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13403 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13404 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013405 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13406 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013407 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13408 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013409 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013410 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013411 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013412 {}
13413};
13414
13415static struct alc_config_preset alc269_presets[] = {
13416 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013417 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013418 .init_verbs = { alc269_init_verbs },
13419 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13420 .dac_nids = alc269_dac_nids,
13421 .hp_nid = 0x03,
13422 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13423 .channel_mode = alc269_modes,
13424 .input_mux = &alc269_capture_source,
13425 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013426 [ALC269_QUANTA_FL1] = {
13427 .mixers = { alc269_quanta_fl1_mixer },
13428 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13429 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13430 .dac_nids = alc269_dac_nids,
13431 .hp_nid = 0x03,
13432 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13433 .channel_mode = alc269_modes,
13434 .input_mux = &alc269_capture_source,
13435 .unsol_event = alc269_quanta_fl1_unsol_event,
13436 .init_hook = alc269_quanta_fl1_init_hook,
13437 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013438 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013439 .mixers = { alc269_eeepc_mixer },
13440 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013441 .init_verbs = { alc269_init_verbs,
13442 alc269_eeepc_amic_init_verbs },
13443 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13444 .dac_nids = alc269_dac_nids,
13445 .hp_nid = 0x03,
13446 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13447 .channel_mode = alc269_modes,
13448 .input_mux = &alc269_eeepc_amic_capture_source,
13449 .unsol_event = alc269_eeepc_amic_unsol_event,
13450 .init_hook = alc269_eeepc_amic_inithook,
13451 },
13452 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013453 .mixers = { alc269_eeepc_mixer },
13454 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013455 .init_verbs = { alc269_init_verbs,
13456 alc269_eeepc_dmic_init_verbs },
13457 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13458 .dac_nids = alc269_dac_nids,
13459 .hp_nid = 0x03,
13460 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13461 .channel_mode = alc269_modes,
13462 .input_mux = &alc269_eeepc_dmic_capture_source,
13463 .unsol_event = alc269_eeepc_dmic_unsol_event,
13464 .init_hook = alc269_eeepc_dmic_inithook,
13465 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013466 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013467 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013468 .cap_mixer = alc269_epc_capture_mixer,
13469 .init_verbs = { alc269_init_verbs,
13470 alc269_eeepc_dmic_init_verbs },
13471 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13472 .dac_nids = alc269_dac_nids,
13473 .hp_nid = 0x03,
13474 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13475 .channel_mode = alc269_modes,
13476 .input_mux = &alc269_eeepc_dmic_capture_source,
13477 .unsol_event = alc269_eeepc_dmic_unsol_event,
13478 .init_hook = alc269_eeepc_dmic_inithook,
13479 },
Tony Vroon64154832008-11-06 15:08:49 +000013480 [ALC269_LIFEBOOK] = {
13481 .mixers = { alc269_lifebook_mixer },
13482 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13483 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13484 .dac_nids = alc269_dac_nids,
13485 .hp_nid = 0x03,
13486 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13487 .channel_mode = alc269_modes,
13488 .input_mux = &alc269_capture_source,
13489 .unsol_event = alc269_lifebook_unsol_event,
13490 .init_hook = alc269_lifebook_init_hook,
13491 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013492};
13493
13494static int patch_alc269(struct hda_codec *codec)
13495{
13496 struct alc_spec *spec;
13497 int board_config;
13498 int err;
13499
13500 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13501 if (spec == NULL)
13502 return -ENOMEM;
13503
13504 codec->spec = spec;
13505
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013506 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13507
Kailang Yangf6a92242007-12-13 16:52:54 +010013508 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13509 alc269_models,
13510 alc269_cfg_tbl);
13511
13512 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020013513 printk(KERN_INFO "hda_codec: Unknown model for %s, "
13514 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013515 board_config = ALC269_AUTO;
13516 }
13517
13518 if (board_config == ALC269_AUTO) {
13519 /* automatic parse from the BIOS config */
13520 err = alc269_parse_auto_config(codec);
13521 if (err < 0) {
13522 alc_free(codec);
13523 return err;
13524 } else if (!err) {
13525 printk(KERN_INFO
13526 "hda_codec: Cannot set up configuration "
13527 "from BIOS. Using base mode...\n");
13528 board_config = ALC269_BASIC;
13529 }
13530 }
13531
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013532 err = snd_hda_attach_beep_device(codec, 0x1);
13533 if (err < 0) {
13534 alc_free(codec);
13535 return err;
13536 }
13537
Kailang Yangf6a92242007-12-13 16:52:54 +010013538 if (board_config != ALC269_AUTO)
13539 setup_preset(spec, &alc269_presets[board_config]);
13540
Takashi Iwaif03d3112009-03-05 14:18:16 +010013541 if (codec->subsystem_id == 0x17aa3bf8) {
13542 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13543 * fix the sample rate of analog I/O to 44.1kHz
13544 */
13545 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13546 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13547 } else {
13548 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13549 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13550 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013551 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13552 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13553
13554 spec->adc_nids = alc269_adc_nids;
13555 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013556 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013557 if (!spec->cap_mixer)
13558 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013559 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013560
13561 codec->patch_ops = alc_patch_ops;
13562 if (board_config == ALC269_AUTO)
13563 spec->init_hook = alc269_auto_init;
13564#ifdef CONFIG_SND_HDA_POWER_SAVE
13565 if (!spec->loopback.amplist)
13566 spec->loopback.amplist = alc269_loopbacks;
13567#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013568 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013569
13570 return 0;
13571}
13572
13573/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013574 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13575 */
13576
13577/*
13578 * set the path ways for 2 channel output
13579 * need to set the codec line out and mic 1 pin widgets to inputs
13580 */
13581static struct hda_verb alc861_threestack_ch2_init[] = {
13582 /* set pin widget 1Ah (line in) for input */
13583 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013584 /* set pin widget 18h (mic1/2) for input, for mic also enable
13585 * the vref
13586 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013587 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13588
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013589 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13590#if 0
13591 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13592 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13593#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013594 { } /* end */
13595};
13596/*
13597 * 6ch mode
13598 * need to set the codec line out and mic 1 pin widgets to outputs
13599 */
13600static struct hda_verb alc861_threestack_ch6_init[] = {
13601 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13602 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13603 /* set pin widget 18h (mic1) for output (CLFE)*/
13604 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13605
13606 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013607 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013608
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013609 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13610#if 0
13611 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13612 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13613#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013614 { } /* end */
13615};
13616
13617static struct hda_channel_mode alc861_threestack_modes[2] = {
13618 { 2, alc861_threestack_ch2_init },
13619 { 6, alc861_threestack_ch6_init },
13620};
Takashi Iwai22309c32006-08-09 16:57:28 +020013621/* Set mic1 as input and unmute the mixer */
13622static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13623 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13624 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13625 { } /* end */
13626};
13627/* Set mic1 as output and mute mixer */
13628static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13629 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13630 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13631 { } /* end */
13632};
13633
13634static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13635 { 2, alc861_uniwill_m31_ch2_init },
13636 { 4, alc861_uniwill_m31_ch4_init },
13637};
Kailang Yangdf694da2005-12-05 19:42:22 +010013638
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013639/* Set mic1 and line-in as input and unmute the mixer */
13640static struct hda_verb alc861_asus_ch2_init[] = {
13641 /* set pin widget 1Ah (line in) for input */
13642 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013643 /* set pin widget 18h (mic1/2) for input, for mic also enable
13644 * the vref
13645 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013646 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13647
13648 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13649#if 0
13650 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13651 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13652#endif
13653 { } /* end */
13654};
13655/* Set mic1 nad line-in as output and mute mixer */
13656static struct hda_verb alc861_asus_ch6_init[] = {
13657 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13658 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13659 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13660 /* set pin widget 18h (mic1) for output (CLFE)*/
13661 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13662 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13663 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13664 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13665
13666 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13667#if 0
13668 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13669 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13670#endif
13671 { } /* end */
13672};
13673
13674static struct hda_channel_mode alc861_asus_modes[2] = {
13675 { 2, alc861_asus_ch2_init },
13676 { 6, alc861_asus_ch6_init },
13677};
13678
Kailang Yangdf694da2005-12-05 19:42:22 +010013679/* patch-ALC861 */
13680
13681static struct snd_kcontrol_new alc861_base_mixer[] = {
13682 /* output mixer control */
13683 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13684 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13685 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13686 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13687 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13688
13689 /*Input mixer control */
13690 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13691 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13692 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13693 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13694 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13695 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13696 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13697 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13698 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13699 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013700
Kailang Yangdf694da2005-12-05 19:42:22 +010013701 { } /* end */
13702};
13703
13704static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13705 /* output mixer control */
13706 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13707 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13708 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13709 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13710 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13711
13712 /* Input mixer control */
13713 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13714 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13715 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13716 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13717 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13718 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13719 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13720 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13721 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13722 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013723
Kailang Yangdf694da2005-12-05 19:42:22 +010013724 {
13725 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13726 .name = "Channel Mode",
13727 .info = alc_ch_mode_info,
13728 .get = alc_ch_mode_get,
13729 .put = alc_ch_mode_put,
13730 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13731 },
13732 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013733};
13734
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013735static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013736 /* output mixer control */
13737 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13738 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13739 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013740
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013741 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013742};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013743
Takashi Iwai22309c32006-08-09 16:57:28 +020013744static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13745 /* output mixer control */
13746 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13747 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13748 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13749 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13750 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13751
13752 /* Input mixer control */
13753 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13754 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13755 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13756 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13757 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13758 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13760 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13761 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13762 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013763
Takashi Iwai22309c32006-08-09 16:57:28 +020013764 {
13765 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13766 .name = "Channel Mode",
13767 .info = alc_ch_mode_info,
13768 .get = alc_ch_mode_get,
13769 .put = alc_ch_mode_put,
13770 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13771 },
13772 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013773};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013774
13775static struct snd_kcontrol_new alc861_asus_mixer[] = {
13776 /* output mixer control */
13777 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13778 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13779 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13780 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13781 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13782
13783 /* Input mixer control */
13784 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13785 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13786 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13787 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13788 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13789 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13790 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13791 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13792 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013793 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13794
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013795 {
13796 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13797 .name = "Channel Mode",
13798 .info = alc_ch_mode_info,
13799 .get = alc_ch_mode_get,
13800 .put = alc_ch_mode_put,
13801 .private_value = ARRAY_SIZE(alc861_asus_modes),
13802 },
13803 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013804};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013805
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013806/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013807static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013808 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13809 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013810 { }
13811};
13812
Kailang Yangdf694da2005-12-05 19:42:22 +010013813/*
13814 * generic initialization of ADC, input mixers and output mixers
13815 */
13816static struct hda_verb alc861_base_init_verbs[] = {
13817 /*
13818 * Unmute ADC0 and set the default input to mic-in
13819 */
13820 /* port-A for surround (rear panel) */
13821 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13822 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13823 /* port-B for mic-in (rear panel) with vref */
13824 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13825 /* port-C for line-in (rear panel) */
13826 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13827 /* port-D for Front */
13828 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13829 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13830 /* port-E for HP out (front panel) */
13831 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13832 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013833 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013834 /* port-F for mic-in (front panel) with vref */
13835 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13836 /* port-G for CLFE (rear panel) */
13837 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13838 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13839 /* port-H for side (rear panel) */
13840 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13841 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13842 /* CD-in */
13843 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13844 /* route front mic to ADC1*/
13845 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13846 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013847
Kailang Yangdf694da2005-12-05 19:42:22 +010013848 /* Unmute DAC0~3 & spdif out*/
13849 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13850 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13851 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13852 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013854
Kailang Yangdf694da2005-12-05 19:42:22 +010013855 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13856 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13857 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13858 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13859 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013860
Kailang Yangdf694da2005-12-05 19:42:22 +010013861 /* Unmute Stereo Mixer 15 */
13862 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013866
13867 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13868 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13869 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13870 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13871 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13872 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13873 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13874 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013875 /* hp used DAC 3 (Front) */
13876 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013877 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13878
13879 { }
13880};
13881
13882static struct hda_verb alc861_threestack_init_verbs[] = {
13883 /*
13884 * Unmute ADC0 and set the default input to mic-in
13885 */
13886 /* port-A for surround (rear panel) */
13887 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13888 /* port-B for mic-in (rear panel) with vref */
13889 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13890 /* port-C for line-in (rear panel) */
13891 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13892 /* port-D for Front */
13893 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13894 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13895 /* port-E for HP out (front panel) */
13896 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13897 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013898 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013899 /* port-F for mic-in (front panel) with vref */
13900 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13901 /* port-G for CLFE (rear panel) */
13902 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13903 /* port-H for side (rear panel) */
13904 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13905 /* CD-in */
13906 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13907 /* route front mic to ADC1*/
13908 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13909 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13910 /* Unmute DAC0~3 & spdif out*/
13911 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13912 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13913 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13914 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13915 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013916
Kailang Yangdf694da2005-12-05 19:42:22 +010013917 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13918 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13919 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13920 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13921 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013922
Kailang Yangdf694da2005-12-05 19:42:22 +010013923 /* Unmute Stereo Mixer 15 */
13924 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13925 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13926 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013927 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013928
13929 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13930 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13931 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13932 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13933 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13934 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13935 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13936 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013937 /* hp used DAC 3 (Front) */
13938 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013939 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13940 { }
13941};
Takashi Iwai22309c32006-08-09 16:57:28 +020013942
13943static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13944 /*
13945 * Unmute ADC0 and set the default input to mic-in
13946 */
13947 /* port-A for surround (rear panel) */
13948 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13949 /* port-B for mic-in (rear panel) with vref */
13950 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13951 /* port-C for line-in (rear panel) */
13952 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13953 /* port-D for Front */
13954 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13955 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13956 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013957 /* this has to be set to VREF80 */
13958 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013959 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013960 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013961 /* port-F for mic-in (front panel) with vref */
13962 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13963 /* port-G for CLFE (rear panel) */
13964 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13965 /* port-H for side (rear panel) */
13966 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13967 /* CD-in */
13968 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13969 /* route front mic to ADC1*/
13970 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13971 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13972 /* Unmute DAC0~3 & spdif out*/
13973 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13974 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13975 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13976 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13977 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013978
Takashi Iwai22309c32006-08-09 16:57:28 +020013979 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13980 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13981 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13982 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13983 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013984
Takashi Iwai22309c32006-08-09 16:57:28 +020013985 /* Unmute Stereo Mixer 15 */
13986 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13987 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13988 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013989 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013990
13991 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13992 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13993 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13994 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13995 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13996 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13997 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13998 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013999 /* hp used DAC 3 (Front) */
14000 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014001 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14002 { }
14003};
14004
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014005static struct hda_verb alc861_asus_init_verbs[] = {
14006 /*
14007 * Unmute ADC0 and set the default input to mic-in
14008 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014009 /* port-A for surround (rear panel)
14010 * according to codec#0 this is the HP jack
14011 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014012 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14013 /* route front PCM to HP */
14014 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14015 /* port-B for mic-in (rear panel) with vref */
14016 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14017 /* port-C for line-in (rear panel) */
14018 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14019 /* port-D for Front */
14020 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14021 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14022 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014023 /* this has to be set to VREF80 */
14024 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014025 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014026 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014027 /* port-F for mic-in (front panel) with vref */
14028 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14029 /* port-G for CLFE (rear panel) */
14030 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14031 /* port-H for side (rear panel) */
14032 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14033 /* CD-in */
14034 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14035 /* route front mic to ADC1*/
14036 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14037 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14038 /* Unmute DAC0~3 & spdif out*/
14039 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14040 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14041 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14042 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14043 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14044 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14045 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14046 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14047 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14048 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014049
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014050 /* Unmute Stereo Mixer 15 */
14051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14052 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14053 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014054 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014055
14056 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14057 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14058 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14059 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14060 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14061 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14062 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14063 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014064 /* hp used DAC 3 (Front) */
14065 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014066 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14067 { }
14068};
14069
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014070/* additional init verbs for ASUS laptops */
14071static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14072 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14073 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14074 { }
14075};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014076
Kailang Yangdf694da2005-12-05 19:42:22 +010014077/*
14078 * generic initialization of ADC, input mixers and output mixers
14079 */
14080static struct hda_verb alc861_auto_init_verbs[] = {
14081 /*
14082 * Unmute ADC0 and set the default input to mic-in
14083 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014084 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014085 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014086
Kailang Yangdf694da2005-12-05 19:42:22 +010014087 /* Unmute DAC0~3 & spdif out*/
14088 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14089 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14090 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14091 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14092 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014093
Kailang Yangdf694da2005-12-05 19:42:22 +010014094 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14095 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14096 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14097 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14098 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014099
Kailang Yangdf694da2005-12-05 19:42:22 +010014100 /* Unmute Stereo Mixer 15 */
14101 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14102 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14103 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14104 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14105
14106 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14107 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14108 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14109 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14110 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14111 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14112 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14113 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14114
14115 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14116 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014117 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14118 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014119 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14120 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014121 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14122 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014123
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014124 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014125
14126 { }
14127};
14128
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014129static struct hda_verb alc861_toshiba_init_verbs[] = {
14130 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014131
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014132 { }
14133};
14134
14135/* toggle speaker-output according to the hp-jack state */
14136static void alc861_toshiba_automute(struct hda_codec *codec)
14137{
14138 unsigned int present;
14139
14140 present = snd_hda_codec_read(codec, 0x0f, 0,
14141 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014142 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14143 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14144 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14145 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014146}
14147
14148static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14149 unsigned int res)
14150{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014151 if ((res >> 26) == ALC880_HP_EVENT)
14152 alc861_toshiba_automute(codec);
14153}
14154
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014155/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014156#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14157#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14158#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14159#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14160
14161
14162#define ALC861_DIGOUT_NID 0x07
14163
14164static struct hda_channel_mode alc861_8ch_modes[1] = {
14165 { 8, NULL }
14166};
14167
14168static hda_nid_t alc861_dac_nids[4] = {
14169 /* front, surround, clfe, side */
14170 0x03, 0x06, 0x05, 0x04
14171};
14172
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014173static hda_nid_t alc660_dac_nids[3] = {
14174 /* front, clfe, surround */
14175 0x03, 0x05, 0x06
14176};
14177
Kailang Yangdf694da2005-12-05 19:42:22 +010014178static hda_nid_t alc861_adc_nids[1] = {
14179 /* ADC0-2 */
14180 0x08,
14181};
14182
14183static struct hda_input_mux alc861_capture_source = {
14184 .num_items = 5,
14185 .items = {
14186 { "Mic", 0x0 },
14187 { "Front Mic", 0x3 },
14188 { "Line", 0x1 },
14189 { "CD", 0x4 },
14190 { "Mixer", 0x5 },
14191 },
14192};
14193
14194/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014195static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
14196 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014197{
14198 int i;
14199 hda_nid_t nid;
14200
14201 spec->multiout.dac_nids = spec->private_dac_nids;
14202 for (i = 0; i < cfg->line_outs; i++) {
14203 nid = cfg->line_out_pins[i];
14204 if (nid) {
14205 if (i >= ARRAY_SIZE(alc861_dac_nids))
14206 continue;
14207 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
14208 }
14209 }
14210 spec->multiout.num_dacs = cfg->line_outs;
14211 return 0;
14212}
14213
14214/* add playback controls from the parsed DAC table */
14215static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
14216 const struct auto_pin_cfg *cfg)
14217{
14218 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014219 static const char *chname[4] = {
14220 "Front", "Surround", NULL /*CLFE*/, "Side"
14221 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014222 hda_nid_t nid;
14223 int i, idx, err;
14224
14225 for (i = 0; i < cfg->line_outs; i++) {
14226 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014227 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014228 continue;
14229 if (nid == 0x05) {
14230 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014231 err = add_control(spec, ALC_CTL_BIND_MUTE,
14232 "Center Playback Switch",
14233 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14234 HDA_OUTPUT));
14235 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014236 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014237 err = add_control(spec, ALC_CTL_BIND_MUTE,
14238 "LFE Playback Switch",
14239 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14240 HDA_OUTPUT));
14241 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014242 return err;
14243 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014244 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
14245 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010014246 if (nid == alc861_dac_nids[idx])
14247 break;
14248 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014249 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14250 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14251 HDA_OUTPUT));
14252 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014253 return err;
14254 }
14255 }
14256 return 0;
14257}
14258
14259static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
14260{
14261 int err;
14262 hda_nid_t nid;
14263
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014264 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014265 return 0;
14266
14267 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
14268 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014269 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
14270 "Headphone Playback Switch",
14271 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14272 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014273 return err;
14274 spec->multiout.hp_nid = nid;
14275 }
14276 return 0;
14277}
14278
14279/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014280static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
14281 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014282{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014283 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014284 int i, err, idx, idx1;
14285
14286 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014287 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014288 case 0x0c:
14289 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014290 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014291 break;
14292 case 0x0f:
14293 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014294 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014295 break;
14296 case 0x0d:
14297 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014298 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014299 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014300 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014301 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014302 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014303 break;
14304 case 0x11:
14305 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014306 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014307 break;
14308 default:
14309 continue;
14310 }
14311
Takashi Iwai4a471b72005-12-07 13:56:29 +010014312 err = new_analog_input(spec, cfg->input_pins[i],
14313 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014314 if (err < 0)
14315 return err;
14316
Takashi Iwai4a471b72005-12-07 13:56:29 +010014317 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014318 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014319 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014320 }
14321 return 0;
14322}
14323
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014324static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14325 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010014326 int pin_type, int dac_idx)
14327{
Jacek Luczak564c5be2008-05-03 18:41:23 +020014328 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14329 pin_type);
14330 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14331 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010014332}
14333
14334static void alc861_auto_init_multi_out(struct hda_codec *codec)
14335{
14336 struct alc_spec *spec = codec->spec;
14337 int i;
14338
14339 for (i = 0; i < spec->autocfg.line_outs; i++) {
14340 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014341 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014342 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014343 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014344 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014345 }
14346}
14347
14348static void alc861_auto_init_hp_out(struct hda_codec *codec)
14349{
14350 struct alc_spec *spec = codec->spec;
14351 hda_nid_t pin;
14352
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014353 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014354 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014355 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
14356 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014357 pin = spec->autocfg.speaker_pins[0];
14358 if (pin)
14359 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014360}
14361
14362static void alc861_auto_init_analog_input(struct hda_codec *codec)
14363{
14364 struct alc_spec *spec = codec->spec;
14365 int i;
14366
14367 for (i = 0; i < AUTO_PIN_LAST; i++) {
14368 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014369 if (nid >= 0x0c && nid <= 0x11)
14370 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014371 }
14372}
14373
14374/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014375/* return 1 if successful, 0 if the proper config is not found,
14376 * or a negative error code
14377 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014378static int alc861_parse_auto_config(struct hda_codec *codec)
14379{
14380 struct alc_spec *spec = codec->spec;
14381 int err;
14382 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14383
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014384 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14385 alc861_ignore);
14386 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014387 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014388 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014389 return 0; /* can't find valid BIOS pin config */
14390
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014391 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
14392 if (err < 0)
14393 return err;
14394 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
14395 if (err < 0)
14396 return err;
14397 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
14398 if (err < 0)
14399 return err;
14400 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
14401 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014402 return err;
14403
14404 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14405
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014406 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014407 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14408
Takashi Iwai603c4012008-07-30 15:01:44 +020014409 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014410 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014411
Takashi Iwaid88897e2008-10-31 15:01:37 +010014412 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014413
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014414 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014415 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014416
14417 spec->adc_nids = alc861_adc_nids;
14418 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014419 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014420
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014421 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14422
Kailang Yangdf694da2005-12-05 19:42:22 +010014423 return 1;
14424}
14425
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014426/* additional initialization for auto-configuration model */
14427static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014428{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014429 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014430 alc861_auto_init_multi_out(codec);
14431 alc861_auto_init_hp_out(codec);
14432 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014433 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014434 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014435}
14436
Takashi Iwaicb53c622007-08-10 17:21:45 +020014437#ifdef CONFIG_SND_HDA_POWER_SAVE
14438static struct hda_amp_list alc861_loopbacks[] = {
14439 { 0x15, HDA_INPUT, 0 },
14440 { 0x15, HDA_INPUT, 1 },
14441 { 0x15, HDA_INPUT, 2 },
14442 { 0x15, HDA_INPUT, 3 },
14443 { } /* end */
14444};
14445#endif
14446
Kailang Yangdf694da2005-12-05 19:42:22 +010014447
14448/*
14449 * configuration and preset
14450 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014451static const char *alc861_models[ALC861_MODEL_LAST] = {
14452 [ALC861_3ST] = "3stack",
14453 [ALC660_3ST] = "3stack-660",
14454 [ALC861_3ST_DIG] = "3stack-dig",
14455 [ALC861_6ST_DIG] = "6stack-dig",
14456 [ALC861_UNIWILL_M31] = "uniwill-m31",
14457 [ALC861_TOSHIBA] = "toshiba",
14458 [ALC861_ASUS] = "asus",
14459 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14460 [ALC861_AUTO] = "auto",
14461};
14462
14463static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014464 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014465 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14466 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14467 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014468 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014469 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014470 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014471 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14472 * Any other models that need this preset?
14473 */
14474 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014475 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14476 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014477 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14478 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14479 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14480 /* FIXME: the below seems conflict */
14481 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14482 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14483 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014484 {}
14485};
14486
14487static struct alc_config_preset alc861_presets[] = {
14488 [ALC861_3ST] = {
14489 .mixers = { alc861_3ST_mixer },
14490 .init_verbs = { alc861_threestack_init_verbs },
14491 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14492 .dac_nids = alc861_dac_nids,
14493 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14494 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014495 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014496 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14497 .adc_nids = alc861_adc_nids,
14498 .input_mux = &alc861_capture_source,
14499 },
14500 [ALC861_3ST_DIG] = {
14501 .mixers = { alc861_base_mixer },
14502 .init_verbs = { alc861_threestack_init_verbs },
14503 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14504 .dac_nids = alc861_dac_nids,
14505 .dig_out_nid = ALC861_DIGOUT_NID,
14506 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14507 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014508 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014509 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14510 .adc_nids = alc861_adc_nids,
14511 .input_mux = &alc861_capture_source,
14512 },
14513 [ALC861_6ST_DIG] = {
14514 .mixers = { alc861_base_mixer },
14515 .init_verbs = { alc861_base_init_verbs },
14516 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14517 .dac_nids = alc861_dac_nids,
14518 .dig_out_nid = ALC861_DIGOUT_NID,
14519 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14520 .channel_mode = alc861_8ch_modes,
14521 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14522 .adc_nids = alc861_adc_nids,
14523 .input_mux = &alc861_capture_source,
14524 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014525 [ALC660_3ST] = {
14526 .mixers = { alc861_3ST_mixer },
14527 .init_verbs = { alc861_threestack_init_verbs },
14528 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14529 .dac_nids = alc660_dac_nids,
14530 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14531 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014532 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014533 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14534 .adc_nids = alc861_adc_nids,
14535 .input_mux = &alc861_capture_source,
14536 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014537 [ALC861_UNIWILL_M31] = {
14538 .mixers = { alc861_uniwill_m31_mixer },
14539 .init_verbs = { alc861_uniwill_m31_init_verbs },
14540 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14541 .dac_nids = alc861_dac_nids,
14542 .dig_out_nid = ALC861_DIGOUT_NID,
14543 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14544 .channel_mode = alc861_uniwill_m31_modes,
14545 .need_dac_fix = 1,
14546 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14547 .adc_nids = alc861_adc_nids,
14548 .input_mux = &alc861_capture_source,
14549 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014550 [ALC861_TOSHIBA] = {
14551 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014552 .init_verbs = { alc861_base_init_verbs,
14553 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014554 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14555 .dac_nids = alc861_dac_nids,
14556 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14557 .channel_mode = alc883_3ST_2ch_modes,
14558 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14559 .adc_nids = alc861_adc_nids,
14560 .input_mux = &alc861_capture_source,
14561 .unsol_event = alc861_toshiba_unsol_event,
14562 .init_hook = alc861_toshiba_automute,
14563 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014564 [ALC861_ASUS] = {
14565 .mixers = { alc861_asus_mixer },
14566 .init_verbs = { alc861_asus_init_verbs },
14567 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14568 .dac_nids = alc861_dac_nids,
14569 .dig_out_nid = ALC861_DIGOUT_NID,
14570 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14571 .channel_mode = alc861_asus_modes,
14572 .need_dac_fix = 1,
14573 .hp_nid = 0x06,
14574 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14575 .adc_nids = alc861_adc_nids,
14576 .input_mux = &alc861_capture_source,
14577 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014578 [ALC861_ASUS_LAPTOP] = {
14579 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14580 .init_verbs = { alc861_asus_init_verbs,
14581 alc861_asus_laptop_init_verbs },
14582 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14583 .dac_nids = alc861_dac_nids,
14584 .dig_out_nid = ALC861_DIGOUT_NID,
14585 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14586 .channel_mode = alc883_3ST_2ch_modes,
14587 .need_dac_fix = 1,
14588 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14589 .adc_nids = alc861_adc_nids,
14590 .input_mux = &alc861_capture_source,
14591 },
14592};
Kailang Yangdf694da2005-12-05 19:42:22 +010014593
14594
14595static int patch_alc861(struct hda_codec *codec)
14596{
14597 struct alc_spec *spec;
14598 int board_config;
14599 int err;
14600
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014601 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014602 if (spec == NULL)
14603 return -ENOMEM;
14604
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014605 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014606
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014607 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14608 alc861_models,
14609 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014610
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014611 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020014612 printk(KERN_INFO "hda_codec: Unknown model for %s, "
14613 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014614 board_config = ALC861_AUTO;
14615 }
14616
14617 if (board_config == ALC861_AUTO) {
14618 /* automatic parse from the BIOS config */
14619 err = alc861_parse_auto_config(codec);
14620 if (err < 0) {
14621 alc_free(codec);
14622 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014623 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014624 printk(KERN_INFO
14625 "hda_codec: Cannot set up configuration "
14626 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014627 board_config = ALC861_3ST_DIG;
14628 }
14629 }
14630
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014631 err = snd_hda_attach_beep_device(codec, 0x23);
14632 if (err < 0) {
14633 alc_free(codec);
14634 return err;
14635 }
14636
Kailang Yangdf694da2005-12-05 19:42:22 +010014637 if (board_config != ALC861_AUTO)
14638 setup_preset(spec, &alc861_presets[board_config]);
14639
Kailang Yangdf694da2005-12-05 19:42:22 +010014640 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14641 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14642
Kailang Yangdf694da2005-12-05 19:42:22 +010014643 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14644 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14645
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014646 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14647
Takashi Iwai2134ea42008-01-10 16:53:55 +010014648 spec->vmaster_nid = 0x03;
14649
Kailang Yangdf694da2005-12-05 19:42:22 +010014650 codec->patch_ops = alc_patch_ops;
14651 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014652 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014653#ifdef CONFIG_SND_HDA_POWER_SAVE
14654 if (!spec->loopback.amplist)
14655 spec->loopback.amplist = alc861_loopbacks;
14656#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014657 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014658
Kailang Yangdf694da2005-12-05 19:42:22 +010014659 return 0;
14660}
14661
14662/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014663 * ALC861-VD support
14664 *
14665 * Based on ALC882
14666 *
14667 * In addition, an independent DAC
14668 */
14669#define ALC861VD_DIGOUT_NID 0x06
14670
14671static hda_nid_t alc861vd_dac_nids[4] = {
14672 /* front, surr, clfe, side surr */
14673 0x02, 0x03, 0x04, 0x05
14674};
14675
14676/* dac_nids for ALC660vd are in a different order - according to
14677 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014678 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014679 * of ALC660vd codecs, but for now there is only 3stack mixer
14680 * - and it is the same as in 861vd.
14681 * adc_nids in ALC660vd are (is) the same as in 861vd
14682 */
14683static hda_nid_t alc660vd_dac_nids[3] = {
14684 /* front, rear, clfe, rear_surr */
14685 0x02, 0x04, 0x03
14686};
14687
14688static hda_nid_t alc861vd_adc_nids[1] = {
14689 /* ADC0 */
14690 0x09,
14691};
14692
Takashi Iwaie1406342008-02-11 18:32:32 +010014693static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14694
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014695/* input MUX */
14696/* FIXME: should be a matrix-type input source selection */
14697static struct hda_input_mux alc861vd_capture_source = {
14698 .num_items = 4,
14699 .items = {
14700 { "Mic", 0x0 },
14701 { "Front Mic", 0x1 },
14702 { "Line", 0x2 },
14703 { "CD", 0x4 },
14704 },
14705};
14706
Kailang Yang272a5272007-05-14 11:00:38 +020014707static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014708 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014709 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014710 { "Ext Mic", 0x0 },
14711 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014712 },
14713};
14714
Kailang Yangd1a991a2007-08-15 16:21:59 +020014715static struct hda_input_mux alc861vd_hp_capture_source = {
14716 .num_items = 2,
14717 .items = {
14718 { "Front Mic", 0x0 },
14719 { "ATAPI Mic", 0x1 },
14720 },
14721};
14722
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014723/*
14724 * 2ch mode
14725 */
14726static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14727 { 2, NULL }
14728};
14729
14730/*
14731 * 6ch mode
14732 */
14733static struct hda_verb alc861vd_6stack_ch6_init[] = {
14734 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14735 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14736 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14737 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14738 { } /* end */
14739};
14740
14741/*
14742 * 8ch mode
14743 */
14744static struct hda_verb alc861vd_6stack_ch8_init[] = {
14745 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14746 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14747 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14748 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14749 { } /* end */
14750};
14751
14752static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14753 { 6, alc861vd_6stack_ch6_init },
14754 { 8, alc861vd_6stack_ch8_init },
14755};
14756
14757static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14758 {
14759 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14760 .name = "Channel Mode",
14761 .info = alc_ch_mode_info,
14762 .get = alc_ch_mode_get,
14763 .put = alc_ch_mode_put,
14764 },
14765 { } /* end */
14766};
14767
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014768/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14769 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14770 */
14771static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14772 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14773 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14774
14775 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14776 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14777
14778 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14779 HDA_OUTPUT),
14780 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14781 HDA_OUTPUT),
14782 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14783 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14784
14785 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14786 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14787
14788 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14789
14790 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14791 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14792 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14793
14794 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14795 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14796 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14797
14798 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14799 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14800
14801 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14802 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14803
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014804 { } /* end */
14805};
14806
14807static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14808 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14809 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14810
14811 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14812
14813 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14814 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14815 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14816
14817 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14818 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14819 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14820
14821 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14822 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14823
14824 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14825 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14826
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014827 { } /* end */
14828};
14829
Kailang Yangbdd148a2007-05-08 15:19:08 +020014830static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14831 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14832 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14833 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14834
14835 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14836
14837 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14840
14841 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14842 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14843 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14844
14845 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14846 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14847
14848 { } /* end */
14849};
14850
Tobin Davisb419f342008-03-07 11:57:51 +010014851/* Pin assignment: Speaker=0x14, HP = 0x15,
14852 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014853 */
14854static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014855 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14856 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014857 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14858 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014859 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14860 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14861 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14862 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14863 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14864 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014865 { } /* end */
14866};
14867
Kailang Yangd1a991a2007-08-15 16:21:59 +020014868/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14869 * Front Mic=0x18, ATAPI Mic = 0x19,
14870 */
14871static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14872 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14873 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14874 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14875 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14876 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14877 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14878 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14879 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014880
Kailang Yangd1a991a2007-08-15 16:21:59 +020014881 { } /* end */
14882};
14883
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014884/*
14885 * generic initialization of ADC, input mixers and output mixers
14886 */
14887static struct hda_verb alc861vd_volume_init_verbs[] = {
14888 /*
14889 * Unmute ADC0 and set the default input to mic-in
14890 */
14891 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14892 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14893
14894 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14895 * the analog-loopback mixer widget
14896 */
14897 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14902 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014903
14904 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14906 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014909
14910 /*
14911 * Set up output mixers (0x02 - 0x05)
14912 */
14913 /* set vol=0 to output mixers */
14914 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14915 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14916 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14917 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14918
14919 /* set up input amps for analog loopback */
14920 /* Amp Indices: DAC = 0, mixer = 1 */
14921 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14922 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14923 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14924 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14925 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14926 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14927 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14928 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14929
14930 { }
14931};
14932
14933/*
14934 * 3-stack pin configuration:
14935 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14936 */
14937static struct hda_verb alc861vd_3stack_init_verbs[] = {
14938 /*
14939 * Set pin mode and muting
14940 */
14941 /* set front pin widgets 0x14 for output */
14942 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14943 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14944 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14945
14946 /* Mic (rear) pin: input vref at 80% */
14947 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14948 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14949 /* Front Mic pin: input vref at 80% */
14950 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14951 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14952 /* Line In pin: input */
14953 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14954 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14955 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14956 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14957 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14958 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14959 /* CD pin widget for input */
14960 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14961
14962 { }
14963};
14964
14965/*
14966 * 6-stack pin configuration:
14967 */
14968static struct hda_verb alc861vd_6stack_init_verbs[] = {
14969 /*
14970 * Set pin mode and muting
14971 */
14972 /* set front pin widgets 0x14 for output */
14973 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14974 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14975 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14976
14977 /* Rear Pin: output 1 (0x0d) */
14978 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14979 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14980 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14981 /* CLFE Pin: output 2 (0x0e) */
14982 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14983 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14984 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14985 /* Side Pin: output 3 (0x0f) */
14986 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14987 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14988 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14989
14990 /* Mic (rear) pin: input vref at 80% */
14991 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14992 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14993 /* Front Mic pin: input vref at 80% */
14994 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14995 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14996 /* Line In pin: input */
14997 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14998 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14999 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15000 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15001 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15002 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15003 /* CD pin widget for input */
15004 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15005
15006 { }
15007};
15008
Kailang Yangbdd148a2007-05-08 15:19:08 +020015009static struct hda_verb alc861vd_eapd_verbs[] = {
15010 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15011 { }
15012};
15013
Kailang Yangf9423e72008-05-27 12:32:25 +020015014static struct hda_verb alc660vd_eapd_verbs[] = {
15015 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15016 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15017 { }
15018};
15019
Kailang Yangbdd148a2007-05-08 15:19:08 +020015020static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15021 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15022 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15023 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15024 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015025 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015026 {}
15027};
15028
Kailang Yangbdd148a2007-05-08 15:19:08 +020015029static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15030{
15031 unsigned int present;
15032 unsigned char bits;
15033
15034 present = snd_hda_codec_read(codec, 0x18, 0,
15035 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015036 bits = present ? HDA_AMP_MUTE : 0;
15037 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15038 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015039}
15040
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015041static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015042{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015043 struct alc_spec *spec = codec->spec;
15044
15045 spec->autocfg.hp_pins[0] = 0x1b;
15046 spec->autocfg.speaker_pins[0] = 0x14;
15047 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015048 alc861vd_lenovo_mic_automute(codec);
15049}
15050
15051static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15052 unsigned int res)
15053{
15054 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015055 case ALC880_MIC_EVENT:
15056 alc861vd_lenovo_mic_automute(codec);
15057 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015058 default:
15059 alc_automute_amp_unsol_event(codec, res);
15060 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015061 }
15062}
15063
Kailang Yang272a5272007-05-14 11:00:38 +020015064static struct hda_verb alc861vd_dallas_verbs[] = {
15065 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15066 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15067 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15068 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15069
15070 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15072 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15076 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015078
Kailang Yang272a5272007-05-14 11:00:38 +020015079 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15080 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15081 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15082 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15083 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15084 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15085 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15086 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15087
15088 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15089 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15090 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15091 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15092 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15093 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15094 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15095 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15096
15097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15101
15102 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015103 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015104 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15105
15106 { } /* end */
15107};
15108
15109/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015110static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015111{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015112 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015113
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015114 spec->autocfg.hp_pins[0] = 0x15;
15115 spec->autocfg.speaker_pins[0] = 0x14;
15116 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020015117}
15118
Takashi Iwaicb53c622007-08-10 17:21:45 +020015119#ifdef CONFIG_SND_HDA_POWER_SAVE
15120#define alc861vd_loopbacks alc880_loopbacks
15121#endif
15122
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015123/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015124#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15125#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15126#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15127#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15128
15129/*
15130 * configuration and preset
15131 */
15132static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15133 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015134 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015135 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015136 [ALC861VD_3ST] = "3stack",
15137 [ALC861VD_3ST_DIG] = "3stack-digout",
15138 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015139 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015140 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015141 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015142 [ALC861VD_AUTO] = "auto",
15143};
15144
15145static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015146 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15147 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015148 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015149 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010015150 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015151 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015152 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015153 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015154 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020015155 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015156 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015157 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015158 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015159 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015160 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015161 {}
15162};
15163
15164static struct alc_config_preset alc861vd_presets[] = {
15165 [ALC660VD_3ST] = {
15166 .mixers = { alc861vd_3st_mixer },
15167 .init_verbs = { alc861vd_volume_init_verbs,
15168 alc861vd_3stack_init_verbs },
15169 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15170 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015171 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15172 .channel_mode = alc861vd_3stack_2ch_modes,
15173 .input_mux = &alc861vd_capture_source,
15174 },
Mike Crash6963f842007-06-25 12:12:51 +020015175 [ALC660VD_3ST_DIG] = {
15176 .mixers = { alc861vd_3st_mixer },
15177 .init_verbs = { alc861vd_volume_init_verbs,
15178 alc861vd_3stack_init_verbs },
15179 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15180 .dac_nids = alc660vd_dac_nids,
15181 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015182 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15183 .channel_mode = alc861vd_3stack_2ch_modes,
15184 .input_mux = &alc861vd_capture_source,
15185 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015186 [ALC861VD_3ST] = {
15187 .mixers = { alc861vd_3st_mixer },
15188 .init_verbs = { alc861vd_volume_init_verbs,
15189 alc861vd_3stack_init_verbs },
15190 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15191 .dac_nids = alc861vd_dac_nids,
15192 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15193 .channel_mode = alc861vd_3stack_2ch_modes,
15194 .input_mux = &alc861vd_capture_source,
15195 },
15196 [ALC861VD_3ST_DIG] = {
15197 .mixers = { alc861vd_3st_mixer },
15198 .init_verbs = { alc861vd_volume_init_verbs,
15199 alc861vd_3stack_init_verbs },
15200 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15201 .dac_nids = alc861vd_dac_nids,
15202 .dig_out_nid = ALC861VD_DIGOUT_NID,
15203 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15204 .channel_mode = alc861vd_3stack_2ch_modes,
15205 .input_mux = &alc861vd_capture_source,
15206 },
15207 [ALC861VD_6ST_DIG] = {
15208 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15209 .init_verbs = { alc861vd_volume_init_verbs,
15210 alc861vd_6stack_init_verbs },
15211 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15212 .dac_nids = alc861vd_dac_nids,
15213 .dig_out_nid = ALC861VD_DIGOUT_NID,
15214 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15215 .channel_mode = alc861vd_6stack_modes,
15216 .input_mux = &alc861vd_capture_source,
15217 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015218 [ALC861VD_LENOVO] = {
15219 .mixers = { alc861vd_lenovo_mixer },
15220 .init_verbs = { alc861vd_volume_init_verbs,
15221 alc861vd_3stack_init_verbs,
15222 alc861vd_eapd_verbs,
15223 alc861vd_lenovo_unsol_verbs },
15224 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15225 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015226 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15227 .channel_mode = alc861vd_3stack_2ch_modes,
15228 .input_mux = &alc861vd_capture_source,
15229 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015230 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015231 },
Kailang Yang272a5272007-05-14 11:00:38 +020015232 [ALC861VD_DALLAS] = {
15233 .mixers = { alc861vd_dallas_mixer },
15234 .init_verbs = { alc861vd_dallas_verbs },
15235 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15236 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015237 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15238 .channel_mode = alc861vd_3stack_2ch_modes,
15239 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015240 .unsol_event = alc_automute_amp_unsol_event,
15241 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015242 },
15243 [ALC861VD_HP] = {
15244 .mixers = { alc861vd_hp_mixer },
15245 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15246 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15247 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015248 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015249 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15250 .channel_mode = alc861vd_3stack_2ch_modes,
15251 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015252 .unsol_event = alc_automute_amp_unsol_event,
15253 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020015254 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015255 [ALC660VD_ASUS_V1S] = {
15256 .mixers = { alc861vd_lenovo_mixer },
15257 .init_verbs = { alc861vd_volume_init_verbs,
15258 alc861vd_3stack_init_verbs,
15259 alc861vd_eapd_verbs,
15260 alc861vd_lenovo_unsol_verbs },
15261 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15262 .dac_nids = alc660vd_dac_nids,
15263 .dig_out_nid = ALC861VD_DIGOUT_NID,
15264 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15265 .channel_mode = alc861vd_3stack_2ch_modes,
15266 .input_mux = &alc861vd_capture_source,
15267 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015268 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015270};
15271
15272/*
15273 * BIOS auto configuration
15274 */
15275static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15276 hda_nid_t nid, int pin_type, int dac_idx)
15277{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015278 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015279}
15280
15281static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15282{
15283 struct alc_spec *spec = codec->spec;
15284 int i;
15285
15286 for (i = 0; i <= HDA_SIDE; i++) {
15287 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015288 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015289 if (nid)
15290 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015291 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015292 }
15293}
15294
15295
15296static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15297{
15298 struct alc_spec *spec = codec->spec;
15299 hda_nid_t pin;
15300
15301 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015302 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015303 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015304 pin = spec->autocfg.speaker_pins[0];
15305 if (pin)
15306 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015307}
15308
15309#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15310#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15311
15312static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15313{
15314 struct alc_spec *spec = codec->spec;
15315 int i;
15316
15317 for (i = 0; i < AUTO_PIN_LAST; i++) {
15318 hda_nid_t nid = spec->autocfg.input_pins[i];
15319 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015320 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015321 if (nid != ALC861VD_PIN_CD_NID &&
15322 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015323 snd_hda_codec_write(codec, nid, 0,
15324 AC_VERB_SET_AMP_GAIN_MUTE,
15325 AMP_OUT_MUTE);
15326 }
15327 }
15328}
15329
Takashi Iwaif511b012008-08-15 16:46:42 +020015330#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15331
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015332#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15333#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15334
15335/* add playback controls from the parsed DAC table */
15336/* Based on ALC880 version. But ALC861VD has separate,
15337 * different NIDs for mute/unmute switch and volume control */
15338static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15339 const struct auto_pin_cfg *cfg)
15340{
15341 char name[32];
15342 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15343 hda_nid_t nid_v, nid_s;
15344 int i, err;
15345
15346 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015347 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015348 continue;
15349 nid_v = alc861vd_idx_to_mixer_vol(
15350 alc880_dac_to_idx(
15351 spec->multiout.dac_nids[i]));
15352 nid_s = alc861vd_idx_to_mixer_switch(
15353 alc880_dac_to_idx(
15354 spec->multiout.dac_nids[i]));
15355
15356 if (i == 2) {
15357 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015358 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15359 "Center Playback Volume",
15360 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15361 HDA_OUTPUT));
15362 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015363 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015364 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15365 "LFE Playback Volume",
15366 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15367 HDA_OUTPUT));
15368 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015369 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015370 err = add_control(spec, ALC_CTL_BIND_MUTE,
15371 "Center Playback Switch",
15372 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15373 HDA_INPUT));
15374 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015375 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015376 err = add_control(spec, ALC_CTL_BIND_MUTE,
15377 "LFE Playback Switch",
15378 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15379 HDA_INPUT));
15380 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015381 return err;
15382 } else {
15383 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015384 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15385 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15386 HDA_OUTPUT));
15387 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015388 return err;
15389 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015390 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015391 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015392 HDA_INPUT));
15393 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015394 return err;
15395 }
15396 }
15397 return 0;
15398}
15399
15400/* add playback controls for speaker and HP outputs */
15401/* Based on ALC880 version. But ALC861VD has separate,
15402 * different NIDs for mute/unmute switch and volume control */
15403static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15404 hda_nid_t pin, const char *pfx)
15405{
15406 hda_nid_t nid_v, nid_s;
15407 int err;
15408 char name[32];
15409
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015410 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015411 return 0;
15412
15413 if (alc880_is_fixed_pin(pin)) {
15414 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15415 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015416 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015417 spec->multiout.hp_nid = nid_v;
15418 else
15419 spec->multiout.extra_out_nid[0] = nid_v;
15420 /* control HP volume/switch on the output mixer amp */
15421 nid_v = alc861vd_idx_to_mixer_vol(
15422 alc880_fixed_pin_idx(pin));
15423 nid_s = alc861vd_idx_to_mixer_switch(
15424 alc880_fixed_pin_idx(pin));
15425
15426 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015427 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15428 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15429 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015430 return err;
15431 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015432 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15433 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15434 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015435 return err;
15436 } else if (alc880_is_multi_pin(pin)) {
15437 /* set manual connection */
15438 /* we have only a switch on HP-out PIN */
15439 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015440 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15441 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15442 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015443 return err;
15444 }
15445 return 0;
15446}
15447
15448/* parse the BIOS configuration and set up the alc_spec
15449 * return 1 if successful, 0 if the proper config is not found,
15450 * or a negative error code
15451 * Based on ALC880 version - had to change it to override
15452 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15453static int alc861vd_parse_auto_config(struct hda_codec *codec)
15454{
15455 struct alc_spec *spec = codec->spec;
15456 int err;
15457 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15458
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015459 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15460 alc861vd_ignore);
15461 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015462 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015463 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015464 return 0; /* can't find valid BIOS pin config */
15465
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015466 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15467 if (err < 0)
15468 return err;
15469 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15470 if (err < 0)
15471 return err;
15472 err = alc861vd_auto_create_extra_out(spec,
15473 spec->autocfg.speaker_pins[0],
15474 "Speaker");
15475 if (err < 0)
15476 return err;
15477 err = alc861vd_auto_create_extra_out(spec,
15478 spec->autocfg.hp_pins[0],
15479 "Headphone");
15480 if (err < 0)
15481 return err;
15482 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15483 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015484 return err;
15485
15486 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15487
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015488 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015489 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15490
Takashi Iwai603c4012008-07-30 15:01:44 +020015491 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015492 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015493
Takashi Iwaid88897e2008-10-31 15:01:37 +010015494 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015495
15496 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015497 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015498
Takashi Iwai776e1842007-08-29 15:07:11 +020015499 err = alc_auto_add_mic_boost(codec);
15500 if (err < 0)
15501 return err;
15502
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015503 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15504
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015505 return 1;
15506}
15507
15508/* additional initialization for auto-configuration model */
15509static void alc861vd_auto_init(struct hda_codec *codec)
15510{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015511 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015512 alc861vd_auto_init_multi_out(codec);
15513 alc861vd_auto_init_hp_out(codec);
15514 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015515 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015516 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015517 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015518}
15519
15520static int patch_alc861vd(struct hda_codec *codec)
15521{
15522 struct alc_spec *spec;
15523 int err, board_config;
15524
15525 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15526 if (spec == NULL)
15527 return -ENOMEM;
15528
15529 codec->spec = spec;
15530
15531 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15532 alc861vd_models,
15533 alc861vd_cfg_tbl);
15534
15535 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020015536 printk(KERN_INFO "hda_codec: Unknown model for %s, "
15537 "trying auto-probe from BIOS...\n", codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015538 board_config = ALC861VD_AUTO;
15539 }
15540
15541 if (board_config == ALC861VD_AUTO) {
15542 /* automatic parse from the BIOS config */
15543 err = alc861vd_parse_auto_config(codec);
15544 if (err < 0) {
15545 alc_free(codec);
15546 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015547 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015548 printk(KERN_INFO
15549 "hda_codec: Cannot set up configuration "
15550 "from BIOS. Using base mode...\n");
15551 board_config = ALC861VD_3ST;
15552 }
15553 }
15554
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015555 err = snd_hda_attach_beep_device(codec, 0x23);
15556 if (err < 0) {
15557 alc_free(codec);
15558 return err;
15559 }
15560
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015561 if (board_config != ALC861VD_AUTO)
15562 setup_preset(spec, &alc861vd_presets[board_config]);
15563
Kailang Yang2f893282008-05-27 12:14:47 +020015564 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015565 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015566 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015567 }
15568
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015569 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15570 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15571
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015572 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15573 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15574
15575 spec->adc_nids = alc861vd_adc_nids;
15576 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015577 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015578
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015579 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015580 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015581
Takashi Iwai2134ea42008-01-10 16:53:55 +010015582 spec->vmaster_nid = 0x02;
15583
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015584 codec->patch_ops = alc_patch_ops;
15585
15586 if (board_config == ALC861VD_AUTO)
15587 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015588#ifdef CONFIG_SND_HDA_POWER_SAVE
15589 if (!spec->loopback.amplist)
15590 spec->loopback.amplist = alc861vd_loopbacks;
15591#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015592 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015593
15594 return 0;
15595}
15596
15597/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015598 * ALC662 support
15599 *
15600 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15601 * configuration. Each pin widget can choose any input DACs and a mixer.
15602 * Each ADC is connected from a mixer of all inputs. This makes possible
15603 * 6-channel independent captures.
15604 *
15605 * In addition, an independent DAC for the multi-playback (not used in this
15606 * driver yet).
15607 */
15608#define ALC662_DIGOUT_NID 0x06
15609#define ALC662_DIGIN_NID 0x0a
15610
15611static hda_nid_t alc662_dac_nids[4] = {
15612 /* front, rear, clfe, rear_surr */
15613 0x02, 0x03, 0x04
15614};
15615
Kailang Yang622e84c2009-04-21 07:39:04 +020015616static hda_nid_t alc272_dac_nids[2] = {
15617 0x02, 0x03
15618};
15619
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015620static hda_nid_t alc662_adc_nids[1] = {
15621 /* ADC1-2 */
15622 0x09,
15623};
Takashi Iwaie1406342008-02-11 18:32:32 +010015624
Kailang Yang622e84c2009-04-21 07:39:04 +020015625static hda_nid_t alc272_adc_nids[1] = {
15626 /* ADC1-2 */
15627 0x08,
15628};
15629
Kailang Yang77a261b2008-02-19 11:38:05 +010015630static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015631static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15632
Takashi Iwaie1406342008-02-11 18:32:32 +010015633
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015634/* input MUX */
15635/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015636static struct hda_input_mux alc662_capture_source = {
15637 .num_items = 4,
15638 .items = {
15639 { "Mic", 0x0 },
15640 { "Front Mic", 0x1 },
15641 { "Line", 0x2 },
15642 { "CD", 0x4 },
15643 },
15644};
15645
15646static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15647 .num_items = 2,
15648 .items = {
15649 { "Mic", 0x1 },
15650 { "Line", 0x2 },
15651 },
15652};
Kailang Yang291702f2007-10-16 14:28:03 +020015653
15654static struct hda_input_mux alc662_eeepc_capture_source = {
15655 .num_items = 2,
15656 .items = {
15657 { "i-Mic", 0x1 },
15658 { "e-Mic", 0x0 },
15659 },
15660};
15661
Kailang Yang6dda9f42008-05-27 12:05:31 +020015662static struct hda_input_mux alc663_capture_source = {
15663 .num_items = 3,
15664 .items = {
15665 { "Mic", 0x0 },
15666 { "Front Mic", 0x1 },
15667 { "Line", 0x2 },
15668 },
15669};
15670
15671static struct hda_input_mux alc663_m51va_capture_source = {
15672 .num_items = 2,
15673 .items = {
15674 { "Ext-Mic", 0x0 },
15675 { "D-Mic", 0x9 },
15676 },
15677};
15678
Chris Pockelé9541ba12009-05-12 08:08:53 +020015679#if 1 /* set to 0 for testing other input sources below */
15680static struct hda_input_mux alc272_nc10_capture_source = {
15681 .num_items = 2,
15682 .items = {
15683 { "Autoselect Mic", 0x0 },
15684 { "Internal Mic", 0x1 },
15685 },
15686};
15687#else
15688static struct hda_input_mux alc272_nc10_capture_source = {
15689 .num_items = 16,
15690 .items = {
15691 { "Autoselect Mic", 0x0 },
15692 { "Internal Mic", 0x1 },
15693 { "In-0x02", 0x2 },
15694 { "In-0x03", 0x3 },
15695 { "In-0x04", 0x4 },
15696 { "In-0x05", 0x5 },
15697 { "In-0x06", 0x6 },
15698 { "In-0x07", 0x7 },
15699 { "In-0x08", 0x8 },
15700 { "In-0x09", 0x9 },
15701 { "In-0x0a", 0x0a },
15702 { "In-0x0b", 0x0b },
15703 { "In-0x0c", 0x0c },
15704 { "In-0x0d", 0x0d },
15705 { "In-0x0e", 0x0e },
15706 { "In-0x0f", 0x0f },
15707 },
15708};
15709#endif
15710
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015711/*
15712 * 2ch mode
15713 */
15714static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15715 { 2, NULL }
15716};
15717
15718/*
15719 * 2ch mode
15720 */
15721static struct hda_verb alc662_3ST_ch2_init[] = {
15722 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15723 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15724 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15725 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15726 { } /* end */
15727};
15728
15729/*
15730 * 6ch mode
15731 */
15732static struct hda_verb alc662_3ST_ch6_init[] = {
15733 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15734 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15735 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15736 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15737 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15738 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15739 { } /* end */
15740};
15741
15742static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15743 { 2, alc662_3ST_ch2_init },
15744 { 6, alc662_3ST_ch6_init },
15745};
15746
15747/*
15748 * 2ch mode
15749 */
15750static struct hda_verb alc662_sixstack_ch6_init[] = {
15751 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15752 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15753 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15754 { } /* end */
15755};
15756
15757/*
15758 * 6ch mode
15759 */
15760static struct hda_verb alc662_sixstack_ch8_init[] = {
15761 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15762 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15763 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15764 { } /* end */
15765};
15766
15767static struct hda_channel_mode alc662_5stack_modes[2] = {
15768 { 2, alc662_sixstack_ch6_init },
15769 { 6, alc662_sixstack_ch8_init },
15770};
15771
15772/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15773 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15774 */
15775
15776static struct snd_kcontrol_new alc662_base_mixer[] = {
15777 /* output mixer control */
15778 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015779 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015780 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015781 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015782 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15783 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015784 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15785 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015786 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15787
15788 /*Input mixer control */
15789 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15790 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15791 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15792 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15793 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15794 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15795 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15796 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015797 { } /* end */
15798};
15799
15800static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15801 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015802 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015803 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15804 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15805 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15806 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15807 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15810 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15811 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015812 { } /* end */
15813};
15814
15815static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15816 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015817 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015818 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015819 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015820 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15821 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015822 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15823 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015824 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15825 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15826 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15827 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15828 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15829 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15830 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15831 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15832 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015833 { } /* end */
15834};
15835
15836static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15837 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15838 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015839 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15840 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015841 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15842 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15843 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15844 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15845 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015846 { } /* end */
15847};
15848
Kailang Yang291702f2007-10-16 14:28:03 +020015849static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015850 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15851 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015852
15853 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15854 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15855 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15856
15857 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15858 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15859 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15860 { } /* end */
15861};
15862
Kailang Yang8c427222008-01-10 13:03:59 +010015863static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015864 ALC262_HIPPO_MASTER_SWITCH,
15865 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015866 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015867 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15868 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015869 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15870 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15871 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15872 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15873 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15874 { } /* end */
15875};
15876
Kailang Yangf1d4e282008-08-26 14:03:29 +020015877static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15878 .ops = &snd_hda_bind_vol,
15879 .values = {
15880 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15881 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15882 0
15883 },
15884};
15885
15886static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15887 .ops = &snd_hda_bind_sw,
15888 .values = {
15889 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15890 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15891 0
15892 },
15893};
15894
Kailang Yang6dda9f42008-05-27 12:05:31 +020015895static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015896 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15897 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15900 { } /* end */
15901};
15902
15903static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15904 .ops = &snd_hda_bind_sw,
15905 .values = {
15906 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15907 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15908 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15909 0
15910 },
15911};
15912
15913static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15914 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15915 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15916 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15917 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15918 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15919 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15920
15921 { } /* end */
15922};
15923
15924static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15925 .ops = &snd_hda_bind_sw,
15926 .values = {
15927 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15928 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15929 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15930 0
15931 },
15932};
15933
15934static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15935 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15936 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15939 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15940 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15941 { } /* end */
15942};
15943
15944static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015945 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15946 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015947 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15950 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15951 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15952 { } /* end */
15953};
15954
15955static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15956 .ops = &snd_hda_bind_vol,
15957 .values = {
15958 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15959 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15960 0
15961 },
15962};
15963
15964static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15965 .ops = &snd_hda_bind_sw,
15966 .values = {
15967 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15968 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15969 0
15970 },
15971};
15972
15973static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15974 HDA_BIND_VOL("Master Playback Volume",
15975 &alc663_asus_two_bind_master_vol),
15976 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15977 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015978 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15979 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015981 { } /* end */
15982};
15983
15984static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15985 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15986 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15987 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15988 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15990 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015991 { } /* end */
15992};
15993
15994static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15995 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15996 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15997 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15998 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15999 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16000
16001 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16002 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16003 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16004 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16005 { } /* end */
16006};
16007
16008static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16009 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16010 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16011 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16012
16013 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16015 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16016 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16017 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16018 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16019 { } /* end */
16020};
16021
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016022static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16023 {
16024 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16025 .name = "Channel Mode",
16026 .info = alc_ch_mode_info,
16027 .get = alc_ch_mode_get,
16028 .put = alc_ch_mode_put,
16029 },
16030 { } /* end */
16031};
16032
16033static struct hda_verb alc662_init_verbs[] = {
16034 /* ADC: mute amp left and right */
16035 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16036 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16037 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16038
Takashi Iwaicb53c622007-08-10 17:21:45 +020016039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016044
Kailang Yangb60dd392007-09-20 12:50:29 +020016045 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16047 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16049 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16050 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016051
16052 /* Front Pin: output 0 (0x0c) */
16053 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16054 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16055
16056 /* Rear Pin: output 1 (0x0d) */
16057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16058 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16059
16060 /* CLFE Pin: output 2 (0x0e) */
16061 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16062 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16063
16064 /* Mic (rear) pin: input vref at 80% */
16065 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16066 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16067 /* Front Mic pin: input vref at 80% */
16068 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16069 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16070 /* Line In pin: input */
16071 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16072 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16073 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16074 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16075 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16076 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16077 /* CD pin widget for input */
16078 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16079
16080 /* FIXME: use matrix-type input source selection */
16081 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16082 /* Input mixer */
16083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016084 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016085
16086 /* always trun on EAPD */
16087 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16088 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16089
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016090 { }
16091};
16092
16093static struct hda_verb alc662_sue_init_verbs[] = {
16094 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16095 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016096 {}
16097};
16098
16099static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16100 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16101 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16102 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016103};
16104
Kailang Yang8c427222008-01-10 13:03:59 +010016105/* Set Unsolicited Event*/
16106static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16107 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16108 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16109 {}
16110};
16111
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016112/*
16113 * generic initialization of ADC, input mixers and output mixers
16114 */
16115static struct hda_verb alc662_auto_init_verbs[] = {
16116 /*
16117 * Unmute ADC and set the default input to mic-in
16118 */
16119 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16120 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16121
16122 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16123 * mixer widget
16124 * Note: PASD motherboards uses the Line In 2 as the input for front
16125 * panel mic (mic 2)
16126 */
16127 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016133
16134 /*
16135 * Set up output mixers (0x0c - 0x0f)
16136 */
16137 /* set vol=0 to output mixers */
16138 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16139 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16140 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16141
16142 /* set up input amps for analog loopback */
16143 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016144 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16146 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16147 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16148 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16149 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016150
16151
16152 /* FIXME: use matrix-type input source selection */
16153 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16154 /* Input mixer */
16155 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016156 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016157 { }
16158};
16159
Takashi Iwai24fb9172008-09-02 14:48:20 +020016160/* additional verbs for ALC663 */
16161static struct hda_verb alc663_auto_init_verbs[] = {
16162 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16163 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16164 { }
16165};
16166
Kailang Yang6dda9f42008-05-27 12:05:31 +020016167static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016168 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16169 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016170 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16171 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016172 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16173 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16174 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016175 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16176 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16177 {}
16178};
16179
Kailang Yangf1d4e282008-08-26 14:03:29 +020016180static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16181 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16182 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16183 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16185 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16186 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16187 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16188 {}
16189};
16190
16191static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16192 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16195 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16197 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16198 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16199 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16200 {}
16201};
16202
16203static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16204 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16205 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16206 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16207 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16208 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16209 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_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_m1_init_verbs[] = {
16215 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16216 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16217 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16218 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* 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, 0x0}, /* 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 {0x21, 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
16230static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16231 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16232 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16233 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16234 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16237 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16238 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16239 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16240 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16241 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16242 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16243 {}
16244};
16245
Kailang Yang6dda9f42008-05-27 12:05:31 +020016246static struct hda_verb alc663_g71v_init_verbs[] = {
16247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16248 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16249 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16250
16251 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16252 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16253 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16254
16255 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16256 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16257 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16258 {}
16259};
16260
16261static struct hda_verb alc663_g50v_init_verbs[] = {
16262 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16263 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16264 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16265
16266 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16267 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16268 {}
16269};
16270
Kailang Yangf1d4e282008-08-26 14:03:29 +020016271static struct hda_verb alc662_ecs_init_verbs[] = {
16272 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16273 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16274 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16275 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16276 {}
16277};
16278
Kailang Yang622e84c2009-04-21 07:39:04 +020016279static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16280 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16281 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16283 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16284 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16285 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16286 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16289 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16290 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16291 {}
16292};
16293
16294static struct hda_verb alc272_dell_init_verbs[] = {
16295 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16296 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16297 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16298 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16299 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16300 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16301 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16302 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16303 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16304 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16305 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16306 {}
16307};
16308
Kailang Yangf1d4e282008-08-26 14:03:29 +020016309static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16310 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16311 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16312 { } /* end */
16313};
16314
Kailang Yang622e84c2009-04-21 07:39:04 +020016315static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16316 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16317 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16318 { } /* end */
16319};
16320
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016321static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16322{
16323 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016324 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016325
16326 present = snd_hda_codec_read(codec, 0x14, 0,
16327 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016328 bits = present ? HDA_AMP_MUTE : 0;
16329 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16330 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016331}
16332
16333static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16334{
16335 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016336 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016337
16338 present = snd_hda_codec_read(codec, 0x1b, 0,
16339 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016340 bits = present ? HDA_AMP_MUTE : 0;
16341 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16342 HDA_AMP_MUTE, bits);
16343 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16344 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016345}
16346
16347static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16348 unsigned int res)
16349{
16350 if ((res >> 26) == ALC880_HP_EVENT)
16351 alc662_lenovo_101e_all_automute(codec);
16352 if ((res >> 26) == ALC880_FRONT_EVENT)
16353 alc662_lenovo_101e_ispeaker_automute(codec);
16354}
16355
Kailang Yang291702f2007-10-16 14:28:03 +020016356static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16357{
16358 unsigned int present;
16359
16360 present = snd_hda_codec_read(codec, 0x18, 0,
16361 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16362 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16363 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16364 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16365 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16366 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16367 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16368 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16369 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16370}
16371
16372/* unsolicited event for HP jack sensing */
16373static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16374 unsigned int res)
16375{
Kailang Yang291702f2007-10-16 14:28:03 +020016376 if ((res >> 26) == ALC880_MIC_EVENT)
16377 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016378 else
16379 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016380}
16381
16382static void alc662_eeepc_inithook(struct hda_codec *codec)
16383{
Takashi Iwai42171c12009-05-08 14:11:43 +020016384 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020016385 alc662_eeepc_mic_automute(codec);
16386}
16387
Kailang Yang8c427222008-01-10 13:03:59 +010016388static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16389{
Takashi Iwai42171c12009-05-08 14:11:43 +020016390 struct alc_spec *spec = codec->spec;
16391
16392 spec->autocfg.hp_pins[0] = 0x14;
16393 spec->autocfg.speaker_pins[0] = 0x1b;
16394 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010016395}
16396
Kailang Yang6dda9f42008-05-27 12:05:31 +020016397static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16398{
16399 unsigned int present;
16400 unsigned char bits;
16401
16402 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016403 AC_VERB_GET_PIN_SENSE, 0)
16404 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016405 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016406 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16407 AMP_IN_MUTE(0), bits);
16408 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16409 AMP_IN_MUTE(0), bits);
16410}
16411
16412static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16413{
16414 unsigned int present;
16415 unsigned char bits;
16416
16417 present = snd_hda_codec_read(codec, 0x21, 0,
16418 AC_VERB_GET_PIN_SENSE, 0)
16419 & AC_PINSENSE_PRESENCE;
16420 bits = present ? HDA_AMP_MUTE : 0;
16421 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16422 AMP_IN_MUTE(0), bits);
16423 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16424 AMP_IN_MUTE(0), bits);
16425 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16426 AMP_IN_MUTE(0), bits);
16427 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16428 AMP_IN_MUTE(0), bits);
16429}
16430
16431static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16432{
16433 unsigned int present;
16434 unsigned char bits;
16435
16436 present = snd_hda_codec_read(codec, 0x15, 0,
16437 AC_VERB_GET_PIN_SENSE, 0)
16438 & AC_PINSENSE_PRESENCE;
16439 bits = present ? HDA_AMP_MUTE : 0;
16440 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16441 AMP_IN_MUTE(0), bits);
16442 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16443 AMP_IN_MUTE(0), bits);
16444 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16445 AMP_IN_MUTE(0), bits);
16446 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16447 AMP_IN_MUTE(0), bits);
16448}
16449
16450static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16451{
16452 unsigned int present;
16453 unsigned char bits;
16454
16455 present = snd_hda_codec_read(codec, 0x1b, 0,
16456 AC_VERB_GET_PIN_SENSE, 0)
16457 & AC_PINSENSE_PRESENCE;
16458 bits = present ? 0 : PIN_OUT;
16459 snd_hda_codec_write(codec, 0x14, 0,
16460 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16461}
16462
16463static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16464{
16465 unsigned int present1, present2;
16466
16467 present1 = snd_hda_codec_read(codec, 0x21, 0,
16468 AC_VERB_GET_PIN_SENSE, 0)
16469 & AC_PINSENSE_PRESENCE;
16470 present2 = snd_hda_codec_read(codec, 0x15, 0,
16471 AC_VERB_GET_PIN_SENSE, 0)
16472 & AC_PINSENSE_PRESENCE;
16473
16474 if (present1 || present2) {
16475 snd_hda_codec_write_cache(codec, 0x14, 0,
16476 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16477 } else {
16478 snd_hda_codec_write_cache(codec, 0x14, 0,
16479 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16480 }
16481}
16482
16483static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16484{
16485 unsigned int present1, present2;
16486
16487 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16488 AC_VERB_GET_PIN_SENSE, 0)
16489 & AC_PINSENSE_PRESENCE;
16490 present2 = snd_hda_codec_read(codec, 0x15, 0,
16491 AC_VERB_GET_PIN_SENSE, 0)
16492 & AC_PINSENSE_PRESENCE;
16493
16494 if (present1 || present2) {
16495 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16496 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16497 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16498 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16499 } else {
16500 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16501 AMP_IN_MUTE(0), 0);
16502 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16503 AMP_IN_MUTE(0), 0);
16504 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016505}
16506
16507static void alc663_m51va_mic_automute(struct hda_codec *codec)
16508{
16509 unsigned int present;
16510
16511 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016512 AC_VERB_GET_PIN_SENSE, 0)
16513 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016514 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016515 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016516 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016517 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016518 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016519 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016520 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016521 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016522}
16523
16524static void alc663_m51va_unsol_event(struct hda_codec *codec,
16525 unsigned int res)
16526{
16527 switch (res >> 26) {
16528 case ALC880_HP_EVENT:
16529 alc663_m51va_speaker_automute(codec);
16530 break;
16531 case ALC880_MIC_EVENT:
16532 alc663_m51va_mic_automute(codec);
16533 break;
16534 }
16535}
16536
16537static void alc663_m51va_inithook(struct hda_codec *codec)
16538{
16539 alc663_m51va_speaker_automute(codec);
16540 alc663_m51va_mic_automute(codec);
16541}
16542
Kailang Yangf1d4e282008-08-26 14:03:29 +020016543/* ***************** Mode1 ******************************/
16544static void alc663_mode1_unsol_event(struct hda_codec *codec,
16545 unsigned int res)
16546{
16547 switch (res >> 26) {
16548 case ALC880_HP_EVENT:
16549 alc663_m51va_speaker_automute(codec);
16550 break;
16551 case ALC880_MIC_EVENT:
16552 alc662_eeepc_mic_automute(codec);
16553 break;
16554 }
16555}
16556
16557static void alc663_mode1_inithook(struct hda_codec *codec)
16558{
16559 alc663_m51va_speaker_automute(codec);
16560 alc662_eeepc_mic_automute(codec);
16561}
16562/* ***************** Mode2 ******************************/
16563static void alc662_mode2_unsol_event(struct hda_codec *codec,
16564 unsigned int res)
16565{
16566 switch (res >> 26) {
16567 case ALC880_HP_EVENT:
16568 alc662_f5z_speaker_automute(codec);
16569 break;
16570 case ALC880_MIC_EVENT:
16571 alc662_eeepc_mic_automute(codec);
16572 break;
16573 }
16574}
16575
16576static void alc662_mode2_inithook(struct hda_codec *codec)
16577{
16578 alc662_f5z_speaker_automute(codec);
16579 alc662_eeepc_mic_automute(codec);
16580}
16581/* ***************** Mode3 ******************************/
16582static void alc663_mode3_unsol_event(struct hda_codec *codec,
16583 unsigned int res)
16584{
16585 switch (res >> 26) {
16586 case ALC880_HP_EVENT:
16587 alc663_two_hp_m1_speaker_automute(codec);
16588 break;
16589 case ALC880_MIC_EVENT:
16590 alc662_eeepc_mic_automute(codec);
16591 break;
16592 }
16593}
16594
16595static void alc663_mode3_inithook(struct hda_codec *codec)
16596{
16597 alc663_two_hp_m1_speaker_automute(codec);
16598 alc662_eeepc_mic_automute(codec);
16599}
16600/* ***************** Mode4 ******************************/
16601static void alc663_mode4_unsol_event(struct hda_codec *codec,
16602 unsigned int res)
16603{
16604 switch (res >> 26) {
16605 case ALC880_HP_EVENT:
16606 alc663_21jd_two_speaker_automute(codec);
16607 break;
16608 case ALC880_MIC_EVENT:
16609 alc662_eeepc_mic_automute(codec);
16610 break;
16611 }
16612}
16613
16614static void alc663_mode4_inithook(struct hda_codec *codec)
16615{
16616 alc663_21jd_two_speaker_automute(codec);
16617 alc662_eeepc_mic_automute(codec);
16618}
16619/* ***************** Mode5 ******************************/
16620static void alc663_mode5_unsol_event(struct hda_codec *codec,
16621 unsigned int res)
16622{
16623 switch (res >> 26) {
16624 case ALC880_HP_EVENT:
16625 alc663_15jd_two_speaker_automute(codec);
16626 break;
16627 case ALC880_MIC_EVENT:
16628 alc662_eeepc_mic_automute(codec);
16629 break;
16630 }
16631}
16632
16633static void alc663_mode5_inithook(struct hda_codec *codec)
16634{
16635 alc663_15jd_two_speaker_automute(codec);
16636 alc662_eeepc_mic_automute(codec);
16637}
16638/* ***************** Mode6 ******************************/
16639static void alc663_mode6_unsol_event(struct hda_codec *codec,
16640 unsigned int res)
16641{
16642 switch (res >> 26) {
16643 case ALC880_HP_EVENT:
16644 alc663_two_hp_m2_speaker_automute(codec);
16645 break;
16646 case ALC880_MIC_EVENT:
16647 alc662_eeepc_mic_automute(codec);
16648 break;
16649 }
16650}
16651
16652static void alc663_mode6_inithook(struct hda_codec *codec)
16653{
16654 alc663_two_hp_m2_speaker_automute(codec);
16655 alc662_eeepc_mic_automute(codec);
16656}
16657
Kailang Yang6dda9f42008-05-27 12:05:31 +020016658static void alc663_g71v_hp_automute(struct hda_codec *codec)
16659{
16660 unsigned int present;
16661 unsigned char bits;
16662
16663 present = snd_hda_codec_read(codec, 0x21, 0,
16664 AC_VERB_GET_PIN_SENSE, 0)
16665 & AC_PINSENSE_PRESENCE;
16666 bits = present ? HDA_AMP_MUTE : 0;
16667 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16668 HDA_AMP_MUTE, bits);
16669 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16670 HDA_AMP_MUTE, bits);
16671}
16672
16673static void alc663_g71v_front_automute(struct hda_codec *codec)
16674{
16675 unsigned int present;
16676 unsigned char bits;
16677
16678 present = snd_hda_codec_read(codec, 0x15, 0,
16679 AC_VERB_GET_PIN_SENSE, 0)
16680 & AC_PINSENSE_PRESENCE;
16681 bits = present ? HDA_AMP_MUTE : 0;
16682 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16683 HDA_AMP_MUTE, bits);
16684}
16685
16686static void alc663_g71v_unsol_event(struct hda_codec *codec,
16687 unsigned int res)
16688{
16689 switch (res >> 26) {
16690 case ALC880_HP_EVENT:
16691 alc663_g71v_hp_automute(codec);
16692 break;
16693 case ALC880_FRONT_EVENT:
16694 alc663_g71v_front_automute(codec);
16695 break;
16696 case ALC880_MIC_EVENT:
16697 alc662_eeepc_mic_automute(codec);
16698 break;
16699 }
16700}
16701
16702static void alc663_g71v_inithook(struct hda_codec *codec)
16703{
16704 alc663_g71v_front_automute(codec);
16705 alc663_g71v_hp_automute(codec);
16706 alc662_eeepc_mic_automute(codec);
16707}
16708
16709static void alc663_g50v_unsol_event(struct hda_codec *codec,
16710 unsigned int res)
16711{
16712 switch (res >> 26) {
16713 case ALC880_HP_EVENT:
16714 alc663_m51va_speaker_automute(codec);
16715 break;
16716 case ALC880_MIC_EVENT:
16717 alc662_eeepc_mic_automute(codec);
16718 break;
16719 }
16720}
16721
16722static void alc663_g50v_inithook(struct hda_codec *codec)
16723{
16724 alc663_m51va_speaker_automute(codec);
16725 alc662_eeepc_mic_automute(codec);
16726}
16727
Kailang Yangf1d4e282008-08-26 14:03:29 +020016728static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16729 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016730 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016731
16732 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16733 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16734 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16735
16736 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16737 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16738 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16739 { } /* end */
16740};
16741
Chris Pockelé9541ba12009-05-12 08:08:53 +020016742static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16743 /* Master Playback automatically created from Speaker and Headphone */
16744 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16745 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16746 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16747 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16748
16749 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16750 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16751 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16752
16753 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16754 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16755 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16756 { } /* end */
16757};
16758
Takashi Iwaicb53c622007-08-10 17:21:45 +020016759#ifdef CONFIG_SND_HDA_POWER_SAVE
16760#define alc662_loopbacks alc880_loopbacks
16761#endif
16762
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016763
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016764/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016765#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16766#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16767#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16768#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16769
16770/*
16771 * configuration and preset
16772 */
16773static const char *alc662_models[ALC662_MODEL_LAST] = {
16774 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16775 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16776 [ALC662_3ST_6ch] = "3stack-6ch",
16777 [ALC662_5ST_DIG] = "6stack-dig",
16778 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016779 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016780 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016781 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016782 [ALC663_ASUS_M51VA] = "m51va",
16783 [ALC663_ASUS_G71V] = "g71v",
16784 [ALC663_ASUS_H13] = "h13",
16785 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016786 [ALC663_ASUS_MODE1] = "asus-mode1",
16787 [ALC662_ASUS_MODE2] = "asus-mode2",
16788 [ALC663_ASUS_MODE3] = "asus-mode3",
16789 [ALC663_ASUS_MODE4] = "asus-mode4",
16790 [ALC663_ASUS_MODE5] = "asus-mode5",
16791 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016792 [ALC272_DELL] = "dell",
16793 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016794 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016795 [ALC662_AUTO] = "auto",
16796};
16797
16798static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016799 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016800 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16801 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016802 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16803 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16804 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16805 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16806 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16807 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16808 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16809 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16810 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16811 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16812 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16813 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016814 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16815 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16816 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016817 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16818 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16819 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16820 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016821 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016822 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16823 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016824 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016825 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16826 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16827 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016828 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16829 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16830 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016831 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16832 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16833 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016834 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016835 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16836 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016837 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016838 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016839 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016840 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16841 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16842 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016843 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016844 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16845 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016846 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016847 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016848 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016849 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016850 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16851 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016852 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016853 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16854 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016855 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016856 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016857 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016858 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016859 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016860 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16861 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016862 {}
16863};
16864
16865static struct alc_config_preset alc662_presets[] = {
16866 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016867 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016868 .init_verbs = { alc662_init_verbs },
16869 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16870 .dac_nids = alc662_dac_nids,
16871 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016872 .dig_in_nid = ALC662_DIGIN_NID,
16873 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16874 .channel_mode = alc662_3ST_2ch_modes,
16875 .input_mux = &alc662_capture_source,
16876 },
16877 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016878 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016879 .init_verbs = { alc662_init_verbs },
16880 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16881 .dac_nids = alc662_dac_nids,
16882 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016883 .dig_in_nid = ALC662_DIGIN_NID,
16884 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16885 .channel_mode = alc662_3ST_6ch_modes,
16886 .need_dac_fix = 1,
16887 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016888 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016889 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016890 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016891 .init_verbs = { alc662_init_verbs },
16892 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16893 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016894 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16895 .channel_mode = alc662_3ST_6ch_modes,
16896 .need_dac_fix = 1,
16897 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016898 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016899 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016900 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016901 .init_verbs = { alc662_init_verbs },
16902 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16903 .dac_nids = alc662_dac_nids,
16904 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016905 .dig_in_nid = ALC662_DIGIN_NID,
16906 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16907 .channel_mode = alc662_5stack_modes,
16908 .input_mux = &alc662_capture_source,
16909 },
16910 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016911 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016912 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16913 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16914 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016915 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16916 .channel_mode = alc662_3ST_2ch_modes,
16917 .input_mux = &alc662_lenovo_101e_capture_source,
16918 .unsol_event = alc662_lenovo_101e_unsol_event,
16919 .init_hook = alc662_lenovo_101e_all_automute,
16920 },
Kailang Yang291702f2007-10-16 14:28:03 +020016921 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016922 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016923 .init_verbs = { alc662_init_verbs,
16924 alc662_eeepc_sue_init_verbs },
16925 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16926 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016927 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16928 .channel_mode = alc662_3ST_2ch_modes,
16929 .input_mux = &alc662_eeepc_capture_source,
16930 .unsol_event = alc662_eeepc_unsol_event,
16931 .init_hook = alc662_eeepc_inithook,
16932 },
Kailang Yang8c427222008-01-10 13:03:59 +010016933 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016934 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016935 alc662_chmode_mixer },
16936 .init_verbs = { alc662_init_verbs,
16937 alc662_eeepc_ep20_sue_init_verbs },
16938 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16939 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016940 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16941 .channel_mode = alc662_3ST_6ch_modes,
16942 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016943 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016944 .init_hook = alc662_eeepc_ep20_inithook,
16945 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016946 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016947 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016948 .init_verbs = { alc662_init_verbs,
16949 alc662_ecs_init_verbs },
16950 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16951 .dac_nids = alc662_dac_nids,
16952 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16953 .channel_mode = alc662_3ST_2ch_modes,
16954 .input_mux = &alc662_eeepc_capture_source,
16955 .unsol_event = alc662_eeepc_unsol_event,
16956 .init_hook = alc662_eeepc_inithook,
16957 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016958 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016959 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016960 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16961 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16962 .dac_nids = alc662_dac_nids,
16963 .dig_out_nid = ALC662_DIGOUT_NID,
16964 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16965 .channel_mode = alc662_3ST_2ch_modes,
16966 .input_mux = &alc663_m51va_capture_source,
16967 .unsol_event = alc663_m51va_unsol_event,
16968 .init_hook = alc663_m51va_inithook,
16969 },
16970 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016971 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016972 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16973 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16974 .dac_nids = alc662_dac_nids,
16975 .dig_out_nid = ALC662_DIGOUT_NID,
16976 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16977 .channel_mode = alc662_3ST_2ch_modes,
16978 .input_mux = &alc662_eeepc_capture_source,
16979 .unsol_event = alc663_g71v_unsol_event,
16980 .init_hook = alc663_g71v_inithook,
16981 },
16982 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016983 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016984 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16985 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16986 .dac_nids = alc662_dac_nids,
16987 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16988 .channel_mode = alc662_3ST_2ch_modes,
16989 .input_mux = &alc663_m51va_capture_source,
16990 .unsol_event = alc663_m51va_unsol_event,
16991 .init_hook = alc663_m51va_inithook,
16992 },
16993 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016994 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016995 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16996 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16997 .dac_nids = alc662_dac_nids,
16998 .dig_out_nid = ALC662_DIGOUT_NID,
16999 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17000 .channel_mode = alc662_3ST_6ch_modes,
17001 .input_mux = &alc663_capture_source,
17002 .unsol_event = alc663_g50v_unsol_event,
17003 .init_hook = alc663_g50v_inithook,
17004 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017005 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017006 .mixers = { alc663_m51va_mixer },
17007 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017008 .init_verbs = { alc662_init_verbs,
17009 alc663_21jd_amic_init_verbs },
17010 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17011 .hp_nid = 0x03,
17012 .dac_nids = alc662_dac_nids,
17013 .dig_out_nid = ALC662_DIGOUT_NID,
17014 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17015 .channel_mode = alc662_3ST_2ch_modes,
17016 .input_mux = &alc662_eeepc_capture_source,
17017 .unsol_event = alc663_mode1_unsol_event,
17018 .init_hook = alc663_mode1_inithook,
17019 },
17020 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017021 .mixers = { alc662_1bjd_mixer },
17022 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017023 .init_verbs = { alc662_init_verbs,
17024 alc662_1bjd_amic_init_verbs },
17025 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17026 .dac_nids = alc662_dac_nids,
17027 .dig_out_nid = ALC662_DIGOUT_NID,
17028 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17029 .channel_mode = alc662_3ST_2ch_modes,
17030 .input_mux = &alc662_eeepc_capture_source,
17031 .unsol_event = alc662_mode2_unsol_event,
17032 .init_hook = alc662_mode2_inithook,
17033 },
17034 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017035 .mixers = { alc663_two_hp_m1_mixer },
17036 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017037 .init_verbs = { alc662_init_verbs,
17038 alc663_two_hp_amic_m1_init_verbs },
17039 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17040 .hp_nid = 0x03,
17041 .dac_nids = alc662_dac_nids,
17042 .dig_out_nid = ALC662_DIGOUT_NID,
17043 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17044 .channel_mode = alc662_3ST_2ch_modes,
17045 .input_mux = &alc662_eeepc_capture_source,
17046 .unsol_event = alc663_mode3_unsol_event,
17047 .init_hook = alc663_mode3_inithook,
17048 },
17049 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017050 .mixers = { alc663_asus_21jd_clfe_mixer },
17051 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017052 .init_verbs = { alc662_init_verbs,
17053 alc663_21jd_amic_init_verbs},
17054 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17055 .hp_nid = 0x03,
17056 .dac_nids = alc662_dac_nids,
17057 .dig_out_nid = ALC662_DIGOUT_NID,
17058 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17059 .channel_mode = alc662_3ST_2ch_modes,
17060 .input_mux = &alc662_eeepc_capture_source,
17061 .unsol_event = alc663_mode4_unsol_event,
17062 .init_hook = alc663_mode4_inithook,
17063 },
17064 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017065 .mixers = { alc663_asus_15jd_clfe_mixer },
17066 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017067 .init_verbs = { alc662_init_verbs,
17068 alc663_15jd_amic_init_verbs },
17069 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17070 .hp_nid = 0x03,
17071 .dac_nids = alc662_dac_nids,
17072 .dig_out_nid = ALC662_DIGOUT_NID,
17073 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17074 .channel_mode = alc662_3ST_2ch_modes,
17075 .input_mux = &alc662_eeepc_capture_source,
17076 .unsol_event = alc663_mode5_unsol_event,
17077 .init_hook = alc663_mode5_inithook,
17078 },
17079 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017080 .mixers = { alc663_two_hp_m2_mixer },
17081 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017082 .init_verbs = { alc662_init_verbs,
17083 alc663_two_hp_amic_m2_init_verbs },
17084 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17085 .hp_nid = 0x03,
17086 .dac_nids = alc662_dac_nids,
17087 .dig_out_nid = ALC662_DIGOUT_NID,
17088 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17089 .channel_mode = alc662_3ST_2ch_modes,
17090 .input_mux = &alc662_eeepc_capture_source,
17091 .unsol_event = alc663_mode6_unsol_event,
17092 .init_hook = alc663_mode6_inithook,
17093 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017094 [ALC272_DELL] = {
17095 .mixers = { alc663_m51va_mixer },
17096 .cap_mixer = alc272_auto_capture_mixer,
17097 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17098 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17099 .dac_nids = alc662_dac_nids,
17100 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17101 .adc_nids = alc272_adc_nids,
17102 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17103 .capsrc_nids = alc272_capsrc_nids,
17104 .channel_mode = alc662_3ST_2ch_modes,
17105 .input_mux = &alc663_m51va_capture_source,
17106 .unsol_event = alc663_m51va_unsol_event,
17107 .init_hook = alc663_m51va_inithook,
17108 },
17109 [ALC272_DELL_ZM1] = {
17110 .mixers = { alc663_m51va_mixer },
17111 .cap_mixer = alc662_auto_capture_mixer,
17112 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17113 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17114 .dac_nids = alc662_dac_nids,
17115 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17116 .adc_nids = alc662_adc_nids,
17117 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
17118 .capsrc_nids = alc662_capsrc_nids,
17119 .channel_mode = alc662_3ST_2ch_modes,
17120 .input_mux = &alc663_m51va_capture_source,
17121 .unsol_event = alc663_m51va_unsol_event,
17122 .init_hook = alc663_m51va_inithook,
17123 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017124 [ALC272_SAMSUNG_NC10] = {
17125 .mixers = { alc272_nc10_mixer },
17126 .init_verbs = { alc662_init_verbs,
17127 alc663_21jd_amic_init_verbs },
17128 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17129 .dac_nids = alc272_dac_nids,
17130 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17131 .channel_mode = alc662_3ST_2ch_modes,
17132 .input_mux = &alc272_nc10_capture_source,
17133 .unsol_event = alc663_mode4_unsol_event,
17134 .init_hook = alc663_mode4_inithook,
17135 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017136};
17137
17138
17139/*
17140 * BIOS auto configuration
17141 */
17142
17143/* add playback controls from the parsed DAC table */
17144static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17145 const struct auto_pin_cfg *cfg)
17146{
17147 char name[32];
17148 static const char *chname[4] = {
17149 "Front", "Surround", NULL /*CLFE*/, "Side"
17150 };
17151 hda_nid_t nid;
17152 int i, err;
17153
17154 for (i = 0; i < cfg->line_outs; i++) {
17155 if (!spec->multiout.dac_nids[i])
17156 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020017157 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017158 if (i == 2) {
17159 /* Center/LFE */
17160 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17161 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017162 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17163 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017164 if (err < 0)
17165 return err;
17166 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17167 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017168 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17169 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017170 if (err < 0)
17171 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017172 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017173 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017174 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017175 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017176 if (err < 0)
17177 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017178 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017179 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017180 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017181 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017182 if (err < 0)
17183 return err;
17184 } else {
17185 sprintf(name, "%s Playback Volume", chname[i]);
17186 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017187 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17188 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017189 if (err < 0)
17190 return err;
17191 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017192 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17193 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17194 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017195 if (err < 0)
17196 return err;
17197 }
17198 }
17199 return 0;
17200}
17201
17202/* add playback controls for speaker and HP outputs */
17203static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17204 const char *pfx)
17205{
17206 hda_nid_t nid;
17207 int err;
17208 char name[32];
17209
17210 if (!pin)
17211 return 0;
17212
Takashi Iwai24fb9172008-09-02 14:48:20 +020017213 if (pin == 0x17) {
17214 /* ALC663 has a mono output pin on 0x17 */
17215 sprintf(name, "%s Playback Switch", pfx);
17216 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17217 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17218 return err;
17219 }
17220
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017221 if (alc880_is_fixed_pin(pin)) {
17222 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017223 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017224 /* specify the DAC as the extra output */
17225 if (!spec->multiout.hp_nid)
17226 spec->multiout.hp_nid = nid;
17227 else
17228 spec->multiout.extra_out_nid[0] = nid;
17229 /* control HP volume/switch on the output mixer amp */
17230 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17231 sprintf(name, "%s Playback Volume", pfx);
17232 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17233 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17234 if (err < 0)
17235 return err;
17236 sprintf(name, "%s Playback Switch", pfx);
17237 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17238 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17239 if (err < 0)
17240 return err;
17241 } else if (alc880_is_multi_pin(pin)) {
17242 /* set manual connection */
17243 /* we have only a switch on HP-out PIN */
17244 sprintf(name, "%s Playback Switch", pfx);
17245 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17246 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17247 if (err < 0)
17248 return err;
17249 }
17250 return 0;
17251}
17252
Takashi Iwai2d864c42009-03-20 12:52:47 +010017253/* return the index of the src widget from the connection list of the nid.
17254 * return -1 if not found
17255 */
17256static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
17257 hda_nid_t src)
17258{
17259 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
17260 int i, conns;
17261
17262 conns = snd_hda_get_connections(codec, nid, conn_list,
17263 ARRAY_SIZE(conn_list));
17264 if (conns < 0)
17265 return -1;
17266 for (i = 0; i < conns; i++)
17267 if (conn_list[i] == src)
17268 return i;
17269 return -1;
17270}
17271
17272static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17273{
Takashi Iwai1327a322009-03-23 13:07:47 +010017274 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010017275 return (pincap & AC_PINCAP_IN) != 0;
17276}
17277
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017278/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010017279static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017280 const struct auto_pin_cfg *cfg)
17281{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017282 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017283 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017284 int i, err, idx;
17285
17286 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017287 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
17288 idx = alc662_input_pin_idx(codec, 0x0b,
17289 cfg->input_pins[i]);
17290 if (idx >= 0) {
17291 err = new_analog_input(spec, cfg->input_pins[i],
17292 auto_pin_cfg_labels[i],
17293 idx, 0x0b);
17294 if (err < 0)
17295 return err;
17296 }
17297 idx = alc662_input_pin_idx(codec, 0x22,
17298 cfg->input_pins[i]);
17299 if (idx >= 0) {
17300 imux->items[imux->num_items].label =
17301 auto_pin_cfg_labels[i];
17302 imux->items[imux->num_items].index = idx;
17303 imux->num_items++;
17304 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017305 }
17306 }
17307 return 0;
17308}
17309
17310static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17311 hda_nid_t nid, int pin_type,
17312 int dac_idx)
17313{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017314 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017315 /* need the manual connection? */
17316 if (alc880_is_multi_pin(nid)) {
17317 struct alc_spec *spec = codec->spec;
17318 int idx = alc880_multi_pin_idx(nid);
17319 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17320 AC_VERB_SET_CONNECT_SEL,
17321 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17322 }
17323}
17324
17325static void alc662_auto_init_multi_out(struct hda_codec *codec)
17326{
17327 struct alc_spec *spec = codec->spec;
17328 int i;
17329
17330 for (i = 0; i <= HDA_SIDE; i++) {
17331 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017332 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017333 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017334 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017335 i);
17336 }
17337}
17338
17339static void alc662_auto_init_hp_out(struct hda_codec *codec)
17340{
17341 struct alc_spec *spec = codec->spec;
17342 hda_nid_t pin;
17343
17344 pin = spec->autocfg.hp_pins[0];
17345 if (pin) /* connect to front */
17346 /* use dac 0 */
17347 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017348 pin = spec->autocfg.speaker_pins[0];
17349 if (pin)
17350 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017351}
17352
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017353#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17354
17355static void alc662_auto_init_analog_input(struct hda_codec *codec)
17356{
17357 struct alc_spec *spec = codec->spec;
17358 int i;
17359
17360 for (i = 0; i < AUTO_PIN_LAST; i++) {
17361 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017362 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017363 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017364 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017365 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017366 snd_hda_codec_write(codec, nid, 0,
17367 AC_VERB_SET_AMP_GAIN_MUTE,
17368 AMP_OUT_MUTE);
17369 }
17370 }
17371}
17372
Takashi Iwaif511b012008-08-15 16:46:42 +020017373#define alc662_auto_init_input_src alc882_auto_init_input_src
17374
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017375static int alc662_parse_auto_config(struct hda_codec *codec)
17376{
17377 struct alc_spec *spec = codec->spec;
17378 int err;
17379 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17380
17381 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17382 alc662_ignore);
17383 if (err < 0)
17384 return err;
17385 if (!spec->autocfg.line_outs)
17386 return 0; /* can't find valid BIOS pin config */
17387
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017388 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17389 if (err < 0)
17390 return err;
17391 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17392 if (err < 0)
17393 return err;
17394 err = alc662_auto_create_extra_out(spec,
17395 spec->autocfg.speaker_pins[0],
17396 "Speaker");
17397 if (err < 0)
17398 return err;
17399 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17400 "Headphone");
17401 if (err < 0)
17402 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017403 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017404 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017405 return err;
17406
17407 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17408
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017409 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017410 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17411
Takashi Iwai603c4012008-07-30 15:01:44 +020017412 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017413 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017414
17415 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017416 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017417
Takashi Iwaid88897e2008-10-31 15:01:37 +010017418 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017419 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017420 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017421
17422 err = alc_auto_add_mic_boost(codec);
17423 if (err < 0)
17424 return err;
17425
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017426 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17427
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017428 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017429}
17430
17431/* additional initialization for auto-configuration model */
17432static void alc662_auto_init(struct hda_codec *codec)
17433{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017434 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017435 alc662_auto_init_multi_out(codec);
17436 alc662_auto_init_hp_out(codec);
17437 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017438 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017439 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017440 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017441}
17442
17443static int patch_alc662(struct hda_codec *codec)
17444{
17445 struct alc_spec *spec;
17446 int err, board_config;
17447
17448 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17449 if (!spec)
17450 return -ENOMEM;
17451
17452 codec->spec = spec;
17453
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017454 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17455
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017456 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17457 alc662_models,
17458 alc662_cfg_tbl);
17459 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020017460 printk(KERN_INFO "hda_codec: Unknown model for %s, "
17461 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017462 board_config = ALC662_AUTO;
17463 }
17464
17465 if (board_config == ALC662_AUTO) {
17466 /* automatic parse from the BIOS config */
17467 err = alc662_parse_auto_config(codec);
17468 if (err < 0) {
17469 alc_free(codec);
17470 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017471 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017472 printk(KERN_INFO
17473 "hda_codec: Cannot set up configuration "
17474 "from BIOS. Using base mode...\n");
17475 board_config = ALC662_3ST_2ch_DIG;
17476 }
17477 }
17478
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017479 err = snd_hda_attach_beep_device(codec, 0x1);
17480 if (err < 0) {
17481 alc_free(codec);
17482 return err;
17483 }
17484
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017485 if (board_config != ALC662_AUTO)
17486 setup_preset(spec, &alc662_presets[board_config]);
17487
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017488 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17489 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17490
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017491 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17492 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17493
Takashi Iwaie1406342008-02-11 18:32:32 +010017494 spec->adc_nids = alc662_adc_nids;
17495 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17496 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017497
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017498 if (!spec->cap_mixer)
17499 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017500 if (codec->vendor_id == 0x10ec0662)
17501 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17502 else
17503 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017504
Takashi Iwai2134ea42008-01-10 16:53:55 +010017505 spec->vmaster_nid = 0x02;
17506
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017507 codec->patch_ops = alc_patch_ops;
17508 if (board_config == ALC662_AUTO)
17509 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017510#ifdef CONFIG_SND_HDA_POWER_SAVE
17511 if (!spec->loopback.amplist)
17512 spec->loopback.amplist = alc662_loopbacks;
17513#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017514 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017515
17516 return 0;
17517}
17518
17519/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017520 * patch entries
17521 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017522static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017523 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017524 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017525 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017526 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017527 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017528 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017529 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017530 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017531 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17532 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17533 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017534 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17535 .patch = patch_alc883 },
17536 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17537 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017538 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017539 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017540 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017541 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017542 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17543 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017544 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017545 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017546 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017547 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017548 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17549 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017550 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017551 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017552 {} /* terminator */
17553};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017554
17555MODULE_ALIAS("snd-hda-codec-id:10ec*");
17556
17557MODULE_LICENSE("GPL");
17558MODULE_DESCRIPTION("Realtek HD-audio codec");
17559
17560static struct hda_codec_preset_list realtek_list = {
17561 .preset = snd_hda_preset_realtek,
17562 .owner = THIS_MODULE,
17563};
17564
17565static int __init patch_realtek_init(void)
17566{
17567 return snd_hda_add_codec_preset(&realtek_list);
17568}
17569
17570static void __exit patch_realtek_exit(void)
17571{
17572 snd_hda_delete_codec_preset(&realtek_list);
17573}
17574
17575module_init(patch_realtek_init)
17576module_exit(patch_realtek_exit)