blob: 30eeb304351c875af1c17fd9568a9b5e29dcabdf [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ünther3e1647c2009-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 Iwaiaa563af2009-07-31 10:05:11 +0200278 char stream_name_analog[32]; /* 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 Iwaiaa563af2009-07-31 10:05:11 +0200284 char stream_name_digital[32]; /* 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);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200562 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
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;
Jaroslav Kysela9d309372009-07-10 12:27:31 +02004508 if (dig_nid > 0x7f) {
4509 printk(KERN_ERR "alc880_auto: invalid dig_nid "
4510 "connection 0x%x for NID 0x%x\n", dig_nid,
4511 spec->autocfg.dig_out_pins[i]);
4512 continue;
4513 }
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004514 if (!i)
4515 spec->multiout.dig_out_nid = dig_nid;
4516 else {
4517 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4518 spec->slave_dig_outs[i - 1] = dig_nid;
4519 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4520 break;
4521 }
4522 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004523 if (spec->autocfg.dig_in_pin)
4524 spec->dig_in_nid = ALC880_DIGIN_NID;
4525
Takashi Iwai603c4012008-07-30 15:01:44 +02004526 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004527 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004528
Takashi Iwaid88897e2008-10-31 15:01:37 +01004529 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004530
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004531 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004532 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004533
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004534 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4535
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004536 return 1;
4537}
4538
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004539/* additional initialization for auto-configuration model */
4540static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004541{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004542 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004543 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004544 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004545 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004546 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004547 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004548}
4549
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004550static void set_capture_mixer(struct alc_spec *spec)
4551{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004552 static struct snd_kcontrol_new *caps[2][3] = {
4553 { alc_capture_mixer_nosrc1,
4554 alc_capture_mixer_nosrc2,
4555 alc_capture_mixer_nosrc3 },
4556 { alc_capture_mixer1,
4557 alc_capture_mixer2,
4558 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004559 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004560 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4561 int mux;
4562 if (spec->input_mux && spec->input_mux->num_items > 1)
4563 mux = 1;
4564 else
4565 mux = 0;
4566 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4567 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004568}
4569
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004570#define set_beep_amp(spec, nid, idx, dir) \
4571 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4572
4573/*
4574 * OK, here we have finally the patch for ALC880
4575 */
4576
Linus Torvalds1da177e2005-04-16 15:20:36 -07004577static int patch_alc880(struct hda_codec *codec)
4578{
4579 struct alc_spec *spec;
4580 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004581 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004582
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004583 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004584 if (spec == NULL)
4585 return -ENOMEM;
4586
4587 codec->spec = spec;
4588
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004589 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4590 alc880_models,
4591 alc880_cfg_tbl);
4592 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02004593 printk(KERN_INFO "hda_codec: Unknown model for %s, "
4594 "trying auto-probe from BIOS...\n", codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004595 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004596 }
4597
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004598 if (board_config == ALC880_AUTO) {
4599 /* automatic parse from the BIOS config */
4600 err = alc880_parse_auto_config(codec);
4601 if (err < 0) {
4602 alc_free(codec);
4603 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004604 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004605 printk(KERN_INFO
4606 "hda_codec: Cannot set up configuration "
4607 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004608 board_config = ALC880_3ST;
4609 }
4610 }
4611
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004612 err = snd_hda_attach_beep_device(codec, 0x1);
4613 if (err < 0) {
4614 alc_free(codec);
4615 return err;
4616 }
4617
Kailang Yangdf694da2005-12-05 19:42:22 +01004618 if (board_config != ALC880_AUTO)
4619 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004620
Linus Torvalds1da177e2005-04-16 15:20:36 -07004621 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4622 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004623 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004624
Linus Torvalds1da177e2005-04-16 15:20:36 -07004625 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4626 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4627
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004628 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004629 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004630 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004631 /* get type */
4632 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004633 if (wcap != AC_WID_AUD_IN) {
4634 spec->adc_nids = alc880_adc_nids_alt;
4635 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004636 } else {
4637 spec->adc_nids = alc880_adc_nids;
4638 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004639 }
4640 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004641 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004642 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004643
Takashi Iwai2134ea42008-01-10 16:53:55 +01004644 spec->vmaster_nid = 0x0c;
4645
Linus Torvalds1da177e2005-04-16 15:20:36 -07004646 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004647 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004648 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004649#ifdef CONFIG_SND_HDA_POWER_SAVE
4650 if (!spec->loopback.amplist)
4651 spec->loopback.amplist = alc880_loopbacks;
4652#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004653 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004654
4655 return 0;
4656}
4657
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004658
Linus Torvalds1da177e2005-04-16 15:20:36 -07004659/*
4660 * ALC260 support
4661 */
4662
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004663static hda_nid_t alc260_dac_nids[1] = {
4664 /* front */
4665 0x02,
4666};
4667
4668static hda_nid_t alc260_adc_nids[1] = {
4669 /* ADC0 */
4670 0x04,
4671};
4672
Kailang Yangdf694da2005-12-05 19:42:22 +01004673static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004674 /* ADC1 */
4675 0x05,
4676};
4677
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004678/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4679 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4680 */
4681static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004682 /* ADC0, ADC1 */
4683 0x04, 0x05
4684};
4685
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004686#define ALC260_DIGOUT_NID 0x03
4687#define ALC260_DIGIN_NID 0x06
4688
4689static struct hda_input_mux alc260_capture_source = {
4690 .num_items = 4,
4691 .items = {
4692 { "Mic", 0x0 },
4693 { "Front Mic", 0x1 },
4694 { "Line", 0x2 },
4695 { "CD", 0x4 },
4696 },
4697};
4698
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004699/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004700 * headphone jack and the internal CD lines since these are the only pins at
4701 * which audio can appear. For flexibility, also allow the option of
4702 * recording the mixer output on the second ADC (ADC0 doesn't have a
4703 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004704 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004705static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4706 {
4707 .num_items = 3,
4708 .items = {
4709 { "Mic/Line", 0x0 },
4710 { "CD", 0x4 },
4711 { "Headphone", 0x2 },
4712 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004713 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004714 {
4715 .num_items = 4,
4716 .items = {
4717 { "Mic/Line", 0x0 },
4718 { "CD", 0x4 },
4719 { "Headphone", 0x2 },
4720 { "Mixer", 0x5 },
4721 },
4722 },
4723
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004724};
4725
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004726/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4727 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004728 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004729static struct hda_input_mux alc260_acer_capture_sources[2] = {
4730 {
4731 .num_items = 4,
4732 .items = {
4733 { "Mic", 0x0 },
4734 { "Line", 0x2 },
4735 { "CD", 0x4 },
4736 { "Headphone", 0x5 },
4737 },
4738 },
4739 {
4740 .num_items = 5,
4741 .items = {
4742 { "Mic", 0x0 },
4743 { "Line", 0x2 },
4744 { "CD", 0x4 },
4745 { "Headphone", 0x6 },
4746 { "Mixer", 0x5 },
4747 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004748 },
4749};
Michael Schwingencc959482009-02-22 18:58:45 +01004750
4751/* Maxdata Favorit 100XS */
4752static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4753 {
4754 .num_items = 2,
4755 .items = {
4756 { "Line/Mic", 0x0 },
4757 { "CD", 0x4 },
4758 },
4759 },
4760 {
4761 .num_items = 3,
4762 .items = {
4763 { "Line/Mic", 0x0 },
4764 { "CD", 0x4 },
4765 { "Mixer", 0x5 },
4766 },
4767 },
4768};
4769
Linus Torvalds1da177e2005-04-16 15:20:36 -07004770/*
4771 * This is just place-holder, so there's something for alc_build_pcms to look
4772 * at when it calculates the maximum number of channels. ALC260 has no mixer
4773 * element which allows changing the channel mode, so the verb list is
4774 * never used.
4775 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004776static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004777 { 2, NULL },
4778};
4779
Kailang Yangdf694da2005-12-05 19:42:22 +01004780
4781/* Mixer combinations
4782 *
4783 * basic: base_output + input + pc_beep + capture
4784 * HP: base_output + input + capture_alt
4785 * HP_3013: hp_3013 + input + capture
4786 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004787 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004788 */
4789
4790static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004791 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004792 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004793 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4794 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4795 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4796 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4797 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004798};
Kailang Yangdf694da2005-12-05 19:42:22 +01004799
4800static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004801 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4802 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4803 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4804 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4805 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4806 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4807 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4808 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004809 { } /* end */
4810};
4811
Takashi Iwaibec15c32008-01-28 18:16:30 +01004812/* update HP, line and mono out pins according to the master switch */
4813static void alc260_hp_master_update(struct hda_codec *codec,
4814 hda_nid_t hp, hda_nid_t line,
4815 hda_nid_t mono)
4816{
4817 struct alc_spec *spec = codec->spec;
4818 unsigned int val = spec->master_sw ? PIN_HP : 0;
4819 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004820 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004821 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004822 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004823 val);
4824 /* mono (speaker) depending on the HP jack sense */
4825 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004826 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004827 val);
4828}
4829
4830static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4831 struct snd_ctl_elem_value *ucontrol)
4832{
4833 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4834 struct alc_spec *spec = codec->spec;
4835 *ucontrol->value.integer.value = spec->master_sw;
4836 return 0;
4837}
4838
4839static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4840 struct snd_ctl_elem_value *ucontrol)
4841{
4842 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4843 struct alc_spec *spec = codec->spec;
4844 int val = !!*ucontrol->value.integer.value;
4845 hda_nid_t hp, line, mono;
4846
4847 if (val == spec->master_sw)
4848 return 0;
4849 spec->master_sw = val;
4850 hp = (kcontrol->private_value >> 16) & 0xff;
4851 line = (kcontrol->private_value >> 8) & 0xff;
4852 mono = kcontrol->private_value & 0xff;
4853 alc260_hp_master_update(codec, hp, line, mono);
4854 return 1;
4855}
4856
4857static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4858 {
4859 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4860 .name = "Master Playback Switch",
4861 .info = snd_ctl_boolean_mono_info,
4862 .get = alc260_hp_master_sw_get,
4863 .put = alc260_hp_master_sw_put,
4864 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4865 },
4866 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4867 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4868 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4869 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4870 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4871 HDA_OUTPUT),
4872 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4873 { } /* end */
4874};
4875
4876static struct hda_verb alc260_hp_unsol_verbs[] = {
4877 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4878 {},
4879};
4880
4881static void alc260_hp_automute(struct hda_codec *codec)
4882{
4883 struct alc_spec *spec = codec->spec;
4884 unsigned int present;
4885
4886 present = snd_hda_codec_read(codec, 0x10, 0,
4887 AC_VERB_GET_PIN_SENSE, 0);
4888 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4889 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4890}
4891
4892static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4893{
4894 if ((res >> 26) == ALC880_HP_EVENT)
4895 alc260_hp_automute(codec);
4896}
4897
Kailang Yangdf694da2005-12-05 19:42:22 +01004898static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004899 {
4900 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4901 .name = "Master Playback Switch",
4902 .info = snd_ctl_boolean_mono_info,
4903 .get = alc260_hp_master_sw_get,
4904 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004905 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004906 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004907 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4908 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4909 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4910 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4911 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4912 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004913 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4914 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004915 { } /* end */
4916};
4917
Kailang Yang3f878302008-08-26 13:02:23 +02004918static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4919 .ops = &snd_hda_bind_vol,
4920 .values = {
4921 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4922 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4923 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4924 0
4925 },
4926};
4927
4928static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4929 .ops = &snd_hda_bind_sw,
4930 .values = {
4931 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4932 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4933 0
4934 },
4935};
4936
4937static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4938 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4939 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4940 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4941 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4942 { } /* end */
4943};
4944
Takashi Iwaibec15c32008-01-28 18:16:30 +01004945static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4946 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4947 {},
4948};
4949
4950static void alc260_hp_3013_automute(struct hda_codec *codec)
4951{
4952 struct alc_spec *spec = codec->spec;
4953 unsigned int present;
4954
4955 present = snd_hda_codec_read(codec, 0x15, 0,
4956 AC_VERB_GET_PIN_SENSE, 0);
4957 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004958 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004959}
4960
4961static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4962 unsigned int res)
4963{
4964 if ((res >> 26) == ALC880_HP_EVENT)
4965 alc260_hp_3013_automute(codec);
4966}
4967
Kailang Yang3f878302008-08-26 13:02:23 +02004968static void alc260_hp_3012_automute(struct hda_codec *codec)
4969{
4970 unsigned int present, bits;
4971
4972 present = snd_hda_codec_read(codec, 0x10, 0,
4973 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4974
4975 bits = present ? 0 : PIN_OUT;
4976 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4977 bits);
4978 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4979 bits);
4980 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4981 bits);
4982}
4983
4984static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4985 unsigned int res)
4986{
4987 if ((res >> 26) == ALC880_HP_EVENT)
4988 alc260_hp_3012_automute(codec);
4989}
4990
4991/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004992 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4993 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004994static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004995 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004996 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004997 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004998 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4999 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5000 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5001 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005002 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005003 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5004 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005005 { } /* end */
5006};
5007
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005008/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5009 * versions of the ALC260 don't act on requests to enable mic bias from NID
5010 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5011 * datasheet doesn't mention this restriction. At this stage it's not clear
5012 * whether this behaviour is intentional or is a hardware bug in chip
5013 * revisions available in early 2006. Therefore for now allow the
5014 * "Headphone Jack Mode" control to span all choices, but if it turns out
5015 * that the lack of mic bias for this NID is intentional we could change the
5016 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5017 *
5018 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5019 * don't appear to make the mic bias available from the "line" jack, even
5020 * though the NID used for this jack (0x14) can supply it. The theory is
5021 * that perhaps Acer have included blocking capacitors between the ALC260
5022 * and the output jack. If this turns out to be the case for all such
5023 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5024 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005025 *
5026 * The C20x Tablet series have a mono internal speaker which is controlled
5027 * via the chip's Mono sum widget and pin complex, so include the necessary
5028 * controls for such models. On models without a "mono speaker" the control
5029 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005030 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005031static struct snd_kcontrol_new alc260_acer_mixer[] = {
5032 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5033 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005034 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005035 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005036 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005037 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005038 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005039 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5040 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5041 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5042 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5043 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5044 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5045 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5046 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005047 { } /* end */
5048};
5049
Michael Schwingencc959482009-02-22 18:58:45 +01005050/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5051 */
5052static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5053 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5054 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5055 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5056 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5057 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5058 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5059 { } /* end */
5060};
5061
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005062/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5063 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5064 */
5065static struct snd_kcontrol_new alc260_will_mixer[] = {
5066 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5067 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5068 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5069 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5070 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5071 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5072 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5073 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5074 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5075 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005076 { } /* end */
5077};
5078
5079/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5080 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5081 */
5082static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5083 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5084 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5085 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5086 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5087 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5088 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5089 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5090 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5091 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5092 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5093 { } /* end */
5094};
5095
Kailang Yangdf694da2005-12-05 19:42:22 +01005096/*
5097 * initialization verbs
5098 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005099static struct hda_verb alc260_init_verbs[] = {
5100 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005101 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005102 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005103 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005104 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005105 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005106 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005107 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005108 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005109 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005110 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005111 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005112 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005113 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005114 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005115 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005116 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005117 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5118 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005119 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005120 /* set connection select to line in (default select for this ADC) */
5121 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005122 /* mute capture amp left and right */
5123 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5124 /* set connection select to line in (default select for this ADC) */
5125 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005126 /* set vol=0 Line-Out mixer amp left and right */
5127 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5128 /* unmute pin widget amp left and right (no gain on this amp) */
5129 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5130 /* set vol=0 HP mixer amp left and right */
5131 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5132 /* unmute pin widget amp left and right (no gain on this amp) */
5133 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5134 /* set vol=0 Mono mixer amp left and right */
5135 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5136 /* unmute pin widget amp left and right (no gain on this amp) */
5137 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5138 /* unmute LINE-2 out pin */
5139 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005140 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5141 * Line In 2 = 0x03
5142 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005143 /* mute analog inputs */
5144 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5145 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5146 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005149 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005150 /* mute Front out path */
5151 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5152 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5153 /* mute Headphone out path */
5154 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5155 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5156 /* mute Mono out path */
5157 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5158 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005159 { }
5160};
5161
Takashi Iwai474167d2006-05-17 17:17:43 +02005162#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005163static struct hda_verb alc260_hp_init_verbs[] = {
5164 /* Headphone and output */
5165 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5166 /* mono output */
5167 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5168 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5169 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5170 /* Mic2 (front panel) pin widget for input and vref at 80% */
5171 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5172 /* Line In pin widget for input */
5173 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5174 /* Line-2 pin widget for output */
5175 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5176 /* CD pin widget for input */
5177 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5178 /* unmute amp left and right */
5179 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5180 /* set connection select to line in (default select for this ADC) */
5181 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5182 /* unmute Line-Out mixer amp left and right (volume = 0) */
5183 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5184 /* mute pin widget amp left and right (no gain on this amp) */
5185 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5186 /* unmute HP mixer amp left and right (volume = 0) */
5187 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5188 /* mute pin widget amp left and right (no gain on this amp) */
5189 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005190 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5191 * Line In 2 = 0x03
5192 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005193 /* mute analog inputs */
5194 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5196 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5197 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005199 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5200 /* Unmute Front out path */
5201 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5202 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5203 /* Unmute Headphone out path */
5204 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5205 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5206 /* Unmute Mono out path */
5207 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5208 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5209 { }
5210};
Takashi Iwai474167d2006-05-17 17:17:43 +02005211#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005212
5213static struct hda_verb alc260_hp_3013_init_verbs[] = {
5214 /* Line out and output */
5215 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5216 /* mono output */
5217 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5218 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5219 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5220 /* Mic2 (front panel) pin widget for input and vref at 80% */
5221 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5222 /* Line In pin widget for input */
5223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5224 /* Headphone pin widget for output */
5225 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5226 /* CD pin widget for input */
5227 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5228 /* unmute amp left and right */
5229 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5230 /* set connection select to line in (default select for this ADC) */
5231 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5232 /* unmute Line-Out mixer amp left and right (volume = 0) */
5233 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5234 /* mute pin widget amp left and right (no gain on this amp) */
5235 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5236 /* unmute HP mixer amp left and right (volume = 0) */
5237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5238 /* mute pin widget amp left and right (no gain on this amp) */
5239 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005240 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5241 * Line In 2 = 0x03
5242 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005243 /* mute analog inputs */
5244 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005249 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5250 /* Unmute Front out path */
5251 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5252 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5253 /* Unmute Headphone out path */
5254 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5255 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5256 /* Unmute Mono out path */
5257 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5258 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5259 { }
5260};
5261
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005262/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005263 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5264 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005265 */
5266static struct hda_verb alc260_fujitsu_init_verbs[] = {
5267 /* Disable all GPIOs */
5268 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5269 /* Internal speaker is connected to headphone pin */
5270 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5271 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5272 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005273 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5274 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5275 /* Ensure all other unused pins are disabled and muted. */
5276 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5277 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005278 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005279 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005280 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005281 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005284
Jonathan Woithef7ace402006-02-28 11:46:14 +01005285 /* Disable digital (SPDIF) pins */
5286 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5287 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005288
Kailang Yangea1fb292008-08-26 12:58:38 +02005289 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005290 * when acting as an output.
5291 */
5292 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5293
5294 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005295 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5296 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5297 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5298 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5299 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5300 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5301 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5302 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5303 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005304
Jonathan Woithef7ace402006-02-28 11:46:14 +01005305 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5306 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5307 /* Unmute Line1 pin widget output buffer since it starts as an output.
5308 * If the pin mode is changed by the user the pin mode control will
5309 * take care of enabling the pin's input/output buffers as needed.
5310 * Therefore there's no need to enable the input buffer at this
5311 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005312 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005313 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005314 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005315 * mixer ctrl)
5316 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005317 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005318
Jonathan Woithef7ace402006-02-28 11:46:14 +01005319 /* Mute capture amp left and right */
5320 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005321 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005322 * in (on mic1 pin)
5323 */
5324 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005325
Jonathan Woithef7ace402006-02-28 11:46:14 +01005326 /* Do the same for the second ADC: mute capture input amp and
5327 * set ADC connection to line in (on mic1 pin)
5328 */
5329 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5330 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005331
Jonathan Woithef7ace402006-02-28 11:46:14 +01005332 /* Mute all inputs to mixer widget (even unconnected ones) */
5333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5336 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5338 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005341
5342 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005343};
5344
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005345/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5346 * similar laptops (adapted from Fujitsu init verbs).
5347 */
5348static struct hda_verb alc260_acer_init_verbs[] = {
5349 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5350 * the headphone jack. Turn this on and rely on the standard mute
5351 * methods whenever the user wants to turn these outputs off.
5352 */
5353 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5354 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5355 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5356 /* Internal speaker/Headphone jack is connected to Line-out pin */
5357 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5358 /* Internal microphone/Mic jack is connected to Mic1 pin */
5359 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5360 /* Line In jack is connected to Line1 pin */
5361 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005362 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5363 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005364 /* Ensure all other unused pins are disabled and muted. */
5365 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5366 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005367 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5368 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5369 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5370 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5371 /* Disable digital (SPDIF) pins */
5372 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5373 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5374
Kailang Yangea1fb292008-08-26 12:58:38 +02005375 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005376 * bus when acting as outputs.
5377 */
5378 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5379 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5380
5381 /* Start with output sum widgets muted and their output gains at min */
5382 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5383 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5384 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5385 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5386 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5387 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5388 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5389 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5390 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5391
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005392 /* Unmute Line-out pin widget amp left and right
5393 * (no equiv mixer ctrl)
5394 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005395 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005396 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5397 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005398 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5399 * inputs. If the pin mode is changed by the user the pin mode control
5400 * will take care of enabling the pin's input/output buffers as needed.
5401 * Therefore there's no need to enable the input buffer at this
5402 * stage.
5403 */
5404 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5405 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5406
5407 /* Mute capture amp left and right */
5408 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5409 /* Set ADC connection select to match default mixer setting - mic
5410 * (on mic1 pin)
5411 */
5412 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5413
5414 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005415 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005416 */
5417 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005418 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005419
5420 /* Mute all inputs to mixer widget (even unconnected ones) */
5421 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5422 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5423 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5424 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5425 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5426 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5427 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5428 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5429
5430 { }
5431};
5432
Michael Schwingencc959482009-02-22 18:58:45 +01005433/* Initialisation sequence for Maxdata Favorit 100XS
5434 * (adapted from Acer init verbs).
5435 */
5436static struct hda_verb alc260_favorit100_init_verbs[] = {
5437 /* GPIO 0 enables the output jack.
5438 * Turn this on and rely on the standard mute
5439 * methods whenever the user wants to turn these outputs off.
5440 */
5441 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5442 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5443 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5444 /* Line/Mic input jack is connected to Mic1 pin */
5445 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5446 /* Ensure all other unused pins are disabled and muted. */
5447 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5448 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5449 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5450 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5451 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5452 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5453 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5454 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5455 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5456 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5457 /* Disable digital (SPDIF) pins */
5458 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5459 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5460
5461 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5462 * bus when acting as outputs.
5463 */
5464 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5465 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5466
5467 /* Start with output sum widgets muted and their output gains at min */
5468 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5469 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5470 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5471 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5472 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5473 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5474 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5475 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5476 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5477
5478 /* Unmute Line-out pin widget amp left and right
5479 * (no equiv mixer ctrl)
5480 */
5481 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5482 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5483 * inputs. If the pin mode is changed by the user the pin mode control
5484 * will take care of enabling the pin's input/output buffers as needed.
5485 * Therefore there's no need to enable the input buffer at this
5486 * stage.
5487 */
5488 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5489
5490 /* Mute capture amp left and right */
5491 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5492 /* Set ADC connection select to match default mixer setting - mic
5493 * (on mic1 pin)
5494 */
5495 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5496
5497 /* Do similar with the second ADC: mute capture input amp and
5498 * set ADC connection to mic to match ALSA's default state.
5499 */
5500 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5501 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5502
5503 /* Mute all inputs to mixer widget (even unconnected ones) */
5504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5505 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5506 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5507 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5508 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5509 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5510 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5511 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5512
5513 { }
5514};
5515
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005516static struct hda_verb alc260_will_verbs[] = {
5517 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5518 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5519 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5520 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5521 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5522 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5523 {}
5524};
5525
5526static struct hda_verb alc260_replacer_672v_verbs[] = {
5527 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5528 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5529 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5530
5531 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5532 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5533 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5534
5535 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5536 {}
5537};
5538
5539/* toggle speaker-output according to the hp-jack state */
5540static void alc260_replacer_672v_automute(struct hda_codec *codec)
5541{
5542 unsigned int present;
5543
5544 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5545 present = snd_hda_codec_read(codec, 0x0f, 0,
5546 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5547 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005548 snd_hda_codec_write_cache(codec, 0x01, 0,
5549 AC_VERB_SET_GPIO_DATA, 1);
5550 snd_hda_codec_write_cache(codec, 0x0f, 0,
5551 AC_VERB_SET_PIN_WIDGET_CONTROL,
5552 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005553 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005554 snd_hda_codec_write_cache(codec, 0x01, 0,
5555 AC_VERB_SET_GPIO_DATA, 0);
5556 snd_hda_codec_write_cache(codec, 0x0f, 0,
5557 AC_VERB_SET_PIN_WIDGET_CONTROL,
5558 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005559 }
5560}
5561
5562static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5563 unsigned int res)
5564{
5565 if ((res >> 26) == ALC880_HP_EVENT)
5566 alc260_replacer_672v_automute(codec);
5567}
5568
Kailang Yang3f878302008-08-26 13:02:23 +02005569static struct hda_verb alc260_hp_dc7600_verbs[] = {
5570 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5571 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5572 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5573 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5574 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5576 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5577 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5578 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5579 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5580 {}
5581};
5582
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005583/* Test configuration for debugging, modelled after the ALC880 test
5584 * configuration.
5585 */
5586#ifdef CONFIG_SND_DEBUG
5587static hda_nid_t alc260_test_dac_nids[1] = {
5588 0x02,
5589};
5590static hda_nid_t alc260_test_adc_nids[2] = {
5591 0x04, 0x05,
5592};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005593/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005594 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005595 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005596 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005597static struct hda_input_mux alc260_test_capture_sources[2] = {
5598 {
5599 .num_items = 7,
5600 .items = {
5601 { "MIC1 pin", 0x0 },
5602 { "MIC2 pin", 0x1 },
5603 { "LINE1 pin", 0x2 },
5604 { "LINE2 pin", 0x3 },
5605 { "CD pin", 0x4 },
5606 { "LINE-OUT pin", 0x5 },
5607 { "HP-OUT pin", 0x6 },
5608 },
5609 },
5610 {
5611 .num_items = 8,
5612 .items = {
5613 { "MIC1 pin", 0x0 },
5614 { "MIC2 pin", 0x1 },
5615 { "LINE1 pin", 0x2 },
5616 { "LINE2 pin", 0x3 },
5617 { "CD pin", 0x4 },
5618 { "Mixer", 0x5 },
5619 { "LINE-OUT pin", 0x6 },
5620 { "HP-OUT pin", 0x7 },
5621 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005622 },
5623};
5624static struct snd_kcontrol_new alc260_test_mixer[] = {
5625 /* Output driver widgets */
5626 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5627 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5628 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5629 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5630 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5631 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5632
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005633 /* Modes for retasking pin widgets
5634 * Note: the ALC260 doesn't seem to act on requests to enable mic
5635 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5636 * mention this restriction. At this stage it's not clear whether
5637 * this behaviour is intentional or is a hardware bug in chip
5638 * revisions available at least up until early 2006. Therefore for
5639 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5640 * choices, but if it turns out that the lack of mic bias for these
5641 * NIDs is intentional we could change their modes from
5642 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5643 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005644 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5645 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5646 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5647 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5648 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5649 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5650
5651 /* Loopback mixer controls */
5652 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5653 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5654 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5655 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5656 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5657 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5658 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5659 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5660 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5661 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005662 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5663 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5664 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5665 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005666
5667 /* Controls for GPIO pins, assuming they are configured as outputs */
5668 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5669 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5670 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5671 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5672
Jonathan Woithe92621f12006-02-28 11:47:47 +01005673 /* Switches to allow the digital IO pins to be enabled. The datasheet
5674 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005675 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005676 */
5677 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5678 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5679
Jonathan Woithef8225f62008-01-08 12:16:54 +01005680 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5681 * this output to turn on an external amplifier.
5682 */
5683 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5684 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5685
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005686 { } /* end */
5687};
5688static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005689 /* Enable all GPIOs as outputs with an initial value of 0 */
5690 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5691 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5692 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5693
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005694 /* Enable retasking pins as output, initially without power amp */
5695 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5696 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5697 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5698 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5699 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5700 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5701
Jonathan Woithe92621f12006-02-28 11:47:47 +01005702 /* Disable digital (SPDIF) pins initially, but users can enable
5703 * them via a mixer switch. In the case of SPDIF-out, this initverb
5704 * payload also sets the generation to 0, output to be in "consumer"
5705 * PCM format, copyright asserted, no pre-emphasis and no validity
5706 * control.
5707 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005708 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5709 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5710
Kailang Yangea1fb292008-08-26 12:58:38 +02005711 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005712 * OUT1 sum bus when acting as an output.
5713 */
5714 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5715 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5716 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5717 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5718
5719 /* Start with output sum widgets muted and their output gains at min */
5720 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5721 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5722 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5723 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5724 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5725 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5726 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5727 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5728 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5729
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005730 /* Unmute retasking pin widget output buffers since the default
5731 * state appears to be output. As the pin mode is changed by the
5732 * user the pin mode control will take care of enabling the pin's
5733 * input/output buffers as needed.
5734 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005735 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5736 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5737 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5738 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5739 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5740 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5741 /* Also unmute the mono-out pin widget */
5742 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5743
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005744 /* Mute capture amp left and right */
5745 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005746 /* Set ADC connection select to match default mixer setting (mic1
5747 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005748 */
5749 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5750
5751 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005752 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005753 */
5754 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5755 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5756
5757 /* Mute all inputs to mixer widget (even unconnected ones) */
5758 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5759 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5760 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5761 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5762 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5763 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5764 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5765 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5766
5767 { }
5768};
5769#endif
5770
Takashi Iwai63300792008-01-24 15:31:36 +01005771#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5772#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005773
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005774#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5775#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5776
Kailang Yangdf694da2005-12-05 19:42:22 +01005777/*
5778 * for BIOS auto-configuration
5779 */
5780
5781static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005782 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005783{
5784 hda_nid_t nid_vol;
5785 unsigned long vol_val, sw_val;
5786 char name[32];
5787 int err;
5788
5789 if (nid >= 0x0f && nid < 0x11) {
5790 nid_vol = nid - 0x7;
5791 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5792 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5793 } else if (nid == 0x11) {
5794 nid_vol = nid - 0x7;
5795 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5796 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5797 } else if (nid >= 0x12 && nid <= 0x15) {
5798 nid_vol = 0x08;
5799 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5800 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5801 } else
5802 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005803
Takashi Iwai863b4512008-10-21 17:01:47 +02005804 if (!(*vol_bits & (1 << nid_vol))) {
5805 /* first control for the volume widget */
5806 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5807 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5808 if (err < 0)
5809 return err;
5810 *vol_bits |= (1 << nid_vol);
5811 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005812 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005813 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5814 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005815 return err;
5816 return 1;
5817}
5818
5819/* add playback controls from the parsed DAC table */
5820static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5821 const struct auto_pin_cfg *cfg)
5822{
5823 hda_nid_t nid;
5824 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005825 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005826
5827 spec->multiout.num_dacs = 1;
5828 spec->multiout.dac_nids = spec->private_dac_nids;
5829 spec->multiout.dac_nids[0] = 0x02;
5830
5831 nid = cfg->line_out_pins[0];
5832 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005833 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005834 if (err < 0)
5835 return err;
5836 }
5837
Takashi Iwai82bc9552006-03-21 11:24:42 +01005838 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005839 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005840 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005841 if (err < 0)
5842 return err;
5843 }
5844
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005845 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005846 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005847 err = alc260_add_playback_controls(spec, nid, "Headphone",
5848 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005849 if (err < 0)
5850 return err;
5851 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005852 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005853}
5854
5855/* create playback/capture controls for input pins */
5856static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5857 const struct auto_pin_cfg *cfg)
5858{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005859 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005860 int i, err, idx;
5861
5862 for (i = 0; i < AUTO_PIN_LAST; i++) {
5863 if (cfg->input_pins[i] >= 0x12) {
5864 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005865 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005866 auto_pin_cfg_labels[i], idx,
5867 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005868 if (err < 0)
5869 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005870 imux->items[imux->num_items].label =
5871 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005872 imux->items[imux->num_items].index = idx;
5873 imux->num_items++;
5874 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005875 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005876 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005877 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005878 auto_pin_cfg_labels[i], idx,
5879 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005880 if (err < 0)
5881 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005882 imux->items[imux->num_items].label =
5883 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005884 imux->items[imux->num_items].index = idx;
5885 imux->num_items++;
5886 }
5887 }
5888 return 0;
5889}
5890
5891static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5892 hda_nid_t nid, int pin_type,
5893 int sel_idx)
5894{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005895 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005896 /* need the manual connection? */
5897 if (nid >= 0x12) {
5898 int idx = nid - 0x12;
5899 snd_hda_codec_write(codec, idx + 0x0b, 0,
5900 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005901 }
5902}
5903
5904static void alc260_auto_init_multi_out(struct hda_codec *codec)
5905{
5906 struct alc_spec *spec = codec->spec;
5907 hda_nid_t nid;
5908
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005909 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005910 if (nid) {
5911 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5912 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5913 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005914
Takashi Iwai82bc9552006-03-21 11:24:42 +01005915 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005916 if (nid)
5917 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5918
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005919 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005920 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005921 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005922}
Kailang Yangdf694da2005-12-05 19:42:22 +01005923
5924#define ALC260_PIN_CD_NID 0x16
5925static void alc260_auto_init_analog_input(struct hda_codec *codec)
5926{
5927 struct alc_spec *spec = codec->spec;
5928 int i;
5929
5930 for (i = 0; i < AUTO_PIN_LAST; i++) {
5931 hda_nid_t nid = spec->autocfg.input_pins[i];
5932 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005933 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005934 if (nid != ALC260_PIN_CD_NID &&
5935 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005936 snd_hda_codec_write(codec, nid, 0,
5937 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005938 AMP_OUT_MUTE);
5939 }
5940 }
5941}
5942
5943/*
5944 * generic initialization of ADC, input mixers and output mixers
5945 */
5946static struct hda_verb alc260_volume_init_verbs[] = {
5947 /*
5948 * Unmute ADC0-1 and set the default input to mic-in
5949 */
5950 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5951 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5952 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5953 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005954
Kailang Yangdf694da2005-12-05 19:42:22 +01005955 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5956 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005957 * Note: PASD motherboards uses the Line In 2 as the input for
5958 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005959 */
5960 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005961 /* mute analog inputs */
5962 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5963 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5964 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5965 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005967
5968 /*
5969 * Set up output mixers (0x08 - 0x0a)
5970 */
5971 /* set vol=0 to output mixers */
5972 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5973 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5974 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5975 /* set up input amps for analog loopback */
5976 /* Amp Indices: DAC = 0, mixer = 1 */
5977 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5978 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5979 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5980 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5981 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5982 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005983
Kailang Yangdf694da2005-12-05 19:42:22 +01005984 { }
5985};
5986
5987static int alc260_parse_auto_config(struct hda_codec *codec)
5988{
5989 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005990 int err;
5991 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5992
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005993 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5994 alc260_ignore);
5995 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005996 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005997 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5998 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005999 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006000 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006001 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006002 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
6003 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006004 return err;
6005
6006 spec->multiout.max_channels = 2;
6007
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006008 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006009 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006010 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006011 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006012
Takashi Iwaid88897e2008-10-31 15:01:37 +01006013 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006014
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006015 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006016 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006017
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006018 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6019
Kailang Yangdf694da2005-12-05 19:42:22 +01006020 return 1;
6021}
6022
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006023/* additional initialization for auto-configuration model */
6024static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006025{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006026 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006027 alc260_auto_init_multi_out(codec);
6028 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006029 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006030 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006031}
6032
Takashi Iwaicb53c622007-08-10 17:21:45 +02006033#ifdef CONFIG_SND_HDA_POWER_SAVE
6034static struct hda_amp_list alc260_loopbacks[] = {
6035 { 0x07, HDA_INPUT, 0 },
6036 { 0x07, HDA_INPUT, 1 },
6037 { 0x07, HDA_INPUT, 2 },
6038 { 0x07, HDA_INPUT, 3 },
6039 { 0x07, HDA_INPUT, 4 },
6040 { } /* end */
6041};
6042#endif
6043
Kailang Yangdf694da2005-12-05 19:42:22 +01006044/*
6045 * ALC260 configurations
6046 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006047static const char *alc260_models[ALC260_MODEL_LAST] = {
6048 [ALC260_BASIC] = "basic",
6049 [ALC260_HP] = "hp",
6050 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006051 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006052 [ALC260_FUJITSU_S702X] = "fujitsu",
6053 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006054 [ALC260_WILL] = "will",
6055 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006056 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006057#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006058 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006059#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006060 [ALC260_AUTO] = "auto",
6061};
6062
6063static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006064 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006065 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006066 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006067 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006068 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006069 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006070 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006071 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006072 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6073 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6074 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6075 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6076 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6077 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6078 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6079 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6080 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006081 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006082 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006083 {}
6084};
6085
Kailang Yangdf694da2005-12-05 19:42:22 +01006086static struct alc_config_preset alc260_presets[] = {
6087 [ALC260_BASIC] = {
6088 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006089 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006090 .init_verbs = { alc260_init_verbs },
6091 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6092 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006093 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006094 .adc_nids = alc260_adc_nids,
6095 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6096 .channel_mode = alc260_modes,
6097 .input_mux = &alc260_capture_source,
6098 },
6099 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006100 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006101 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006102 .init_verbs = { alc260_init_verbs,
6103 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006104 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6105 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006106 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6107 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006108 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6109 .channel_mode = alc260_modes,
6110 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006111 .unsol_event = alc260_hp_unsol_event,
6112 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006113 },
Kailang Yang3f878302008-08-26 13:02:23 +02006114 [ALC260_HP_DC7600] = {
6115 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006116 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006117 .init_verbs = { alc260_init_verbs,
6118 alc260_hp_dc7600_verbs },
6119 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6120 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006121 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6122 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006123 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6124 .channel_mode = alc260_modes,
6125 .input_mux = &alc260_capture_source,
6126 .unsol_event = alc260_hp_3012_unsol_event,
6127 .init_hook = alc260_hp_3012_automute,
6128 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006129 [ALC260_HP_3013] = {
6130 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006131 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006132 .init_verbs = { alc260_hp_3013_init_verbs,
6133 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006134 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6135 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006136 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6137 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006138 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6139 .channel_mode = alc260_modes,
6140 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006141 .unsol_event = alc260_hp_3013_unsol_event,
6142 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006143 },
6144 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006145 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006146 .init_verbs = { alc260_fujitsu_init_verbs },
6147 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6148 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006149 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6150 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006151 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6152 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006153 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6154 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006155 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006156 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006157 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006158 .init_verbs = { alc260_acer_init_verbs },
6159 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6160 .dac_nids = alc260_dac_nids,
6161 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6162 .adc_nids = alc260_dual_adc_nids,
6163 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6164 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006165 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6166 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006167 },
Michael Schwingencc959482009-02-22 18:58:45 +01006168 [ALC260_FAVORIT100] = {
6169 .mixers = { alc260_favorit100_mixer },
6170 .init_verbs = { alc260_favorit100_init_verbs },
6171 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6172 .dac_nids = alc260_dac_nids,
6173 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6174 .adc_nids = alc260_dual_adc_nids,
6175 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6176 .channel_mode = alc260_modes,
6177 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6178 .input_mux = alc260_favorit100_capture_sources,
6179 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006180 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006181 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006182 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6183 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6184 .dac_nids = alc260_dac_nids,
6185 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6186 .adc_nids = alc260_adc_nids,
6187 .dig_out_nid = ALC260_DIGOUT_NID,
6188 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6189 .channel_mode = alc260_modes,
6190 .input_mux = &alc260_capture_source,
6191 },
6192 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006193 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006194 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6195 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6196 .dac_nids = alc260_dac_nids,
6197 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6198 .adc_nids = alc260_adc_nids,
6199 .dig_out_nid = ALC260_DIGOUT_NID,
6200 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6201 .channel_mode = alc260_modes,
6202 .input_mux = &alc260_capture_source,
6203 .unsol_event = alc260_replacer_672v_unsol_event,
6204 .init_hook = alc260_replacer_672v_automute,
6205 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006206#ifdef CONFIG_SND_DEBUG
6207 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006208 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006209 .init_verbs = { alc260_test_init_verbs },
6210 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6211 .dac_nids = alc260_test_dac_nids,
6212 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6213 .adc_nids = alc260_test_adc_nids,
6214 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6215 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006216 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6217 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006218 },
6219#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006220};
6221
Linus Torvalds1da177e2005-04-16 15:20:36 -07006222static int patch_alc260(struct hda_codec *codec)
6223{
6224 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006225 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006226
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006227 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006228 if (spec == NULL)
6229 return -ENOMEM;
6230
6231 codec->spec = spec;
6232
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006233 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6234 alc260_models,
6235 alc260_cfg_tbl);
6236 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +02006237 snd_printd(KERN_INFO "hda_codec: Unknown model for %s, "
6238 "trying auto-probe from BIOS...\n",
6239 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006240 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006241 }
6242
Kailang Yangdf694da2005-12-05 19:42:22 +01006243 if (board_config == ALC260_AUTO) {
6244 /* automatic parse from the BIOS config */
6245 err = alc260_parse_auto_config(codec);
6246 if (err < 0) {
6247 alc_free(codec);
6248 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006249 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006250 printk(KERN_INFO
6251 "hda_codec: Cannot set up configuration "
6252 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006253 board_config = ALC260_BASIC;
6254 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006255 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006256
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006257 err = snd_hda_attach_beep_device(codec, 0x1);
6258 if (err < 0) {
6259 alc_free(codec);
6260 return err;
6261 }
6262
Kailang Yangdf694da2005-12-05 19:42:22 +01006263 if (board_config != ALC260_AUTO)
6264 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006265
Linus Torvalds1da177e2005-04-16 15:20:36 -07006266 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6267 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6268
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006269 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6270 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6271
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006272 if (!spec->adc_nids && spec->input_mux) {
6273 /* check whether NID 0x04 is valid */
6274 unsigned int wcap = get_wcaps(codec, 0x04);
6275 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6276 /* get type */
6277 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6278 spec->adc_nids = alc260_adc_nids_alt;
6279 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6280 } else {
6281 spec->adc_nids = alc260_adc_nids;
6282 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6283 }
6284 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006285 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006286 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006287
Takashi Iwai2134ea42008-01-10 16:53:55 +01006288 spec->vmaster_nid = 0x08;
6289
Linus Torvalds1da177e2005-04-16 15:20:36 -07006290 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006291 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006292 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006293#ifdef CONFIG_SND_HDA_POWER_SAVE
6294 if (!spec->loopback.amplist)
6295 spec->loopback.amplist = alc260_loopbacks;
6296#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006297 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006298
6299 return 0;
6300}
6301
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006302
Linus Torvalds1da177e2005-04-16 15:20:36 -07006303/*
6304 * ALC882 support
6305 *
6306 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6307 * configuration. Each pin widget can choose any input DACs and a mixer.
6308 * Each ADC is connected from a mixer of all inputs. This makes possible
6309 * 6-channel independent captures.
6310 *
6311 * In addition, an independent DAC for the multi-playback (not used in this
6312 * driver yet).
6313 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006314#define ALC882_DIGOUT_NID 0x06
6315#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07006316
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006317static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006318 { 8, NULL }
6319};
6320
6321static hda_nid_t alc882_dac_nids[4] = {
6322 /* front, rear, clfe, rear_surr */
6323 0x02, 0x03, 0x04, 0x05
6324};
6325
Kailang Yangdf694da2005-12-05 19:42:22 +01006326/* identical with ALC880 */
6327#define alc882_adc_nids alc880_adc_nids
6328#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07006329
Takashi Iwaie1406342008-02-11 18:32:32 +01006330static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6331static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6332
Linus Torvalds1da177e2005-04-16 15:20:36 -07006333/* input MUX */
6334/* FIXME: should be a matrix-type input source selection */
6335
6336static struct hda_input_mux alc882_capture_source = {
6337 .num_items = 4,
6338 .items = {
6339 { "Mic", 0x0 },
6340 { "Front Mic", 0x1 },
6341 { "Line", 0x2 },
6342 { "CD", 0x4 },
6343 },
6344};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006345
6346static struct hda_input_mux mb5_capture_source = {
6347 .num_items = 3,
6348 .items = {
6349 { "Mic", 0x1 },
6350 { "Line", 0x2 },
6351 { "CD", 0x4 },
6352 },
6353};
6354
Kailang Yangdf694da2005-12-05 19:42:22 +01006355/*
Kailang Yang272a5272007-05-14 11:00:38 +02006356 * 2ch mode
6357 */
6358static struct hda_verb alc882_3ST_ch2_init[] = {
6359 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6360 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6361 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6362 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6363 { } /* end */
6364};
6365
6366/*
6367 * 6ch mode
6368 */
6369static struct hda_verb alc882_3ST_ch6_init[] = {
6370 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6371 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6372 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6373 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6374 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6375 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6376 { } /* end */
6377};
6378
6379static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6380 { 2, alc882_3ST_ch2_init },
6381 { 6, alc882_3ST_ch6_init },
6382};
6383
6384/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006385 * 6ch mode
6386 */
6387static struct hda_verb alc882_sixstack_ch6_init[] = {
6388 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6389 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6390 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6391 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6392 { } /* end */
6393};
6394
6395/*
6396 * 8ch mode
6397 */
6398static struct hda_verb alc882_sixstack_ch8_init[] = {
6399 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6400 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6401 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6402 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6403 { } /* end */
6404};
6405
6406static struct hda_channel_mode alc882_sixstack_modes[2] = {
6407 { 6, alc882_sixstack_ch6_init },
6408 { 8, alc882_sixstack_ch8_init },
6409};
6410
Takashi Iwai87350ad2007-08-16 18:19:38 +02006411/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006412 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006413 */
6414
6415/*
6416 * 2ch mode
6417 */
6418static struct hda_verb alc885_mbp_ch2_init[] = {
6419 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6420 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6421 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6422 { } /* end */
6423};
6424
6425/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006426 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006427 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006428static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006429 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6430 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6431 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6432 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6433 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6434 { } /* end */
6435};
6436
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006437static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006438 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006439 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006440};
6441
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006442/*
6443 * 2ch
6444 * Speakers/Woofer/HP = Front
6445 * LineIn = Input
6446 */
6447static struct hda_verb alc885_mb5_ch2_init[] = {
6448 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6449 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6450 { } /* end */
6451};
6452
6453/*
6454 * 6ch mode
6455 * Speakers/HP = Front
6456 * Woofer = LFE
6457 * LineIn = Surround
6458 */
6459static struct hda_verb alc885_mb5_ch6_init[] = {
6460 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6461 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6462 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6463 { } /* end */
6464};
6465
6466static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6467 { 2, alc885_mb5_ch2_init },
6468 { 6, alc885_mb5_ch6_init },
6469};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006470
Linus Torvalds1da177e2005-04-16 15:20:36 -07006471/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6472 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6473 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006474static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006475 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006476 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006477 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006478 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006479 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6480 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006481 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6482 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006483 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006484 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006485 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6486 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6487 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6488 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6489 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6490 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006491 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006492 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6493 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006494 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006495 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006496 { } /* end */
6497};
6498
Takashi Iwai87350ad2007-08-16 18:19:38 +02006499static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006500 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6501 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
6502 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6503 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
6504 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006505 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6506 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006507 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6508 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006509 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006510 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6511 { } /* end */
6512};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006513
6514static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006515 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6516 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6517 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6518 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6519 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6520 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6521 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6522 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006523 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6524 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6525 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6526 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6527 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6528 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6529 { } /* end */
6530};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006531
Kailang Yangbdd148a2007-05-08 15:19:08 +02006532static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6533 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6534 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6535 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6536 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6537 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6538 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6539 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6540 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6541 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006542 { } /* end */
6543};
6544
Kailang Yang272a5272007-05-14 11:00:38 +02006545static struct snd_kcontrol_new alc882_targa_mixer[] = {
6546 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6547 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6548 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6549 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6550 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6551 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6552 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6553 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6554 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006555 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006556 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6557 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006558 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006559 { } /* end */
6560};
6561
6562/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6563 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6564 */
6565static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6566 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6567 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6568 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6569 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6570 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6571 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6572 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6573 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6574 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6575 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6576 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6577 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006578 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006579 { } /* end */
6580};
6581
Takashi Iwai914759b2007-09-06 14:52:04 +02006582static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6583 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6584 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6585 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6586 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6587 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6588 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6589 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6590 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6591 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6592 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006593 { } /* end */
6594};
6595
Kailang Yangdf694da2005-12-05 19:42:22 +01006596static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6597 {
6598 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6599 .name = "Channel Mode",
6600 .info = alc_ch_mode_info,
6601 .get = alc_ch_mode_get,
6602 .put = alc_ch_mode_put,
6603 },
6604 { } /* end */
6605};
6606
Linus Torvalds1da177e2005-04-16 15:20:36 -07006607static struct hda_verb alc882_init_verbs[] = {
6608 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006609 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6610 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6611 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006612 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006613 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6614 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6615 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006616 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006617 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6618 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6619 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006620 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006621 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6622 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6623 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006624
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006625 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006626 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006627 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006628 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006629 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006630 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006631 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006632 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006633 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006634 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006635 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006636 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006637 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006638 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006639 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006640 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006641 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006643 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6644 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006645 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006646 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6647 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006648 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006649 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6650 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6651 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6652 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6653 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006654 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006655 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006656
6657 /* FIXME: use matrix-type input source selection */
6658 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6659 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006660 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6661 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6663 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006664 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6668 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006669 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6673 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6674 /* ADC1: mute amp left and right */
6675 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006676 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006677 /* ADC2: mute amp left and right */
6678 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006679 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006680 /* ADC3: mute amp left and right */
6681 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006682 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006683
6684 { }
6685};
6686
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006687static struct hda_verb alc882_eapd_verbs[] = {
6688 /* change to EAPD mode */
6689 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006690 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006691 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006692};
6693
Tobin Davis9102cd12006-12-15 10:02:12 +01006694/* Mac Pro test */
6695static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6696 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6697 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6698 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6699 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6700 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006701 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006702 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6703 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006704 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006705 { } /* end */
6706};
6707
6708static struct hda_verb alc882_macpro_init_verbs[] = {
6709 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6710 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6712 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6713 /* Front Pin: output 0 (0x0c) */
6714 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6715 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6716 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6717 /* Front Mic pin: input vref at 80% */
6718 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6719 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6720 /* Speaker: output */
6721 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6722 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6723 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6724 /* Headphone output (output 0 - 0x0c) */
6725 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6726 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6727 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6728
6729 /* FIXME: use matrix-type input source selection */
6730 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6731 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6732 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6733 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6734 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6735 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6736 /* Input mixer2 */
6737 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6738 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6739 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6740 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6741 /* Input mixer3 */
6742 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6743 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6744 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6745 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6746 /* ADC1: mute amp left and right */
6747 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6748 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6749 /* ADC2: mute amp left and right */
6750 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6751 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6752 /* ADC3: mute amp left and right */
6753 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6754 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6755
6756 { }
6757};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006758
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006759/* Macbook 5,1 */
6760static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006761 /* DACs */
6762 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6763 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6764 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6765 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006766 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006767 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6768 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6769 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006770 /* Surround mixer */
6771 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6772 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6773 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6774 /* LFE mixer */
6775 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6776 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6777 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6778 /* HP mixer */
6779 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6780 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6781 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6782 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006783 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6784 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006785 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6786 /* LFE Pin (0x0e) */
6787 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6788 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6789 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
6790 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006791 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6792 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006793 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006794 /* Front Mic pin: input vref at 80% */
6795 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6796 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6797 /* Line In pin */
6798 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6800
6801 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6802 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6803 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6804 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6805 { }
6806};
6807
Takashi Iwai87350ad2007-08-16 18:19:38 +02006808/* Macbook Pro rev3 */
6809static struct hda_verb alc885_mbp3_init_verbs[] = {
6810 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6812 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6814 /* Rear mixer */
6815 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6816 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6817 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006818 /* HP mixer */
6819 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6820 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6821 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02006822 /* Front Pin: output 0 (0x0c) */
6823 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6824 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6825 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006826 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006828 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6829 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02006830 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6831 /* Mic (rear) pin: input vref at 80% */
6832 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6833 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6834 /* Front Mic pin: input vref at 80% */
6835 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6836 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6837 /* Line In pin: use output 1 when in LineOut mode */
6838 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6839 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6840 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6841
6842 /* FIXME: use matrix-type input source selection */
6843 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6844 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6845 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6846 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6847 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6848 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6849 /* Input mixer2 */
6850 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6851 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6852 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6853 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6854 /* Input mixer3 */
6855 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6856 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6857 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6858 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6859 /* ADC1: mute amp left and right */
6860 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6861 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6862 /* ADC2: mute amp left and right */
6863 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6864 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6865 /* ADC3: mute amp left and right */
6866 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6867 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6868
6869 { }
6870};
6871
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006872/* iMac 24 mixer. */
6873static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6874 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6875 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6876 { } /* end */
6877};
6878
6879/* iMac 24 init verbs. */
6880static struct hda_verb alc885_imac24_init_verbs[] = {
6881 /* Internal speakers: output 0 (0x0c) */
6882 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6883 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6884 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6885 /* Internal speakers: output 0 (0x0c) */
6886 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6887 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6888 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6889 /* Headphone: output 0 (0x0c) */
6890 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6891 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6892 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6893 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6894 /* Front Mic: input vref at 80% */
6895 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6896 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6897 { }
6898};
6899
6900/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006901static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006902{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006903 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006904
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006905 spec->autocfg.hp_pins[0] = 0x14;
6906 spec->autocfg.speaker_pins[0] = 0x18;
6907 spec->autocfg.speaker_pins[1] = 0x1a;
6908 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006909}
6910
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006911static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006912{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006913 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006914
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006915 spec->autocfg.hp_pins[0] = 0x15;
6916 spec->autocfg.speaker_pins[0] = 0x14;
6917 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02006918}
6919
6920
Kailang Yang272a5272007-05-14 11:00:38 +02006921static struct hda_verb alc882_targa_verbs[] = {
6922 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6923 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6924
6925 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6926 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006927
Kailang Yang272a5272007-05-14 11:00:38 +02006928 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6929 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6930 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6931
6932 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02006933 { } /* end */
6934};
6935
6936/* toggle speaker-output according to the hp-jack state */
6937static void alc882_targa_automute(struct hda_codec *codec)
6938{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006939 struct alc_spec *spec = codec->spec;
6940 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006941 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006942 spec->jack_present ? 1 : 3);
6943}
6944
6945static void alc882_targa_init_hook(struct hda_codec *codec)
6946{
6947 struct alc_spec *spec = codec->spec;
6948
6949 spec->autocfg.hp_pins[0] = 0x14;
6950 spec->autocfg.speaker_pins[0] = 0x1b;
6951 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006952}
6953
6954static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6955{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006956 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02006957 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006958}
6959
6960static struct hda_verb alc882_asus_a7j_verbs[] = {
6961 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6962 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6963
6964 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6965 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6966 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006967
Kailang Yang272a5272007-05-14 11:00:38 +02006968 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6969 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6970 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6971
6972 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6973 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6974 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6975 { } /* end */
6976};
6977
Takashi Iwai914759b2007-09-06 14:52:04 +02006978static struct hda_verb alc882_asus_a7m_verbs[] = {
6979 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6980 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6981
6982 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6983 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6984 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006985
Takashi Iwai914759b2007-09-06 14:52:04 +02006986 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6987 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6988 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6989
6990 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6991 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6992 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6993 { } /* end */
6994};
6995
Tobin Davis9102cd12006-12-15 10:02:12 +01006996static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6997{
6998 unsigned int gpiostate, gpiomask, gpiodir;
6999
7000 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7001 AC_VERB_GET_GPIO_DATA, 0);
7002
7003 if (!muted)
7004 gpiostate |= (1 << pin);
7005 else
7006 gpiostate &= ~(1 << pin);
7007
7008 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7009 AC_VERB_GET_GPIO_MASK, 0);
7010 gpiomask |= (1 << pin);
7011
7012 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7013 AC_VERB_GET_GPIO_DIRECTION, 0);
7014 gpiodir |= (1 << pin);
7015
7016
7017 snd_hda_codec_write(codec, codec->afg, 0,
7018 AC_VERB_SET_GPIO_MASK, gpiomask);
7019 snd_hda_codec_write(codec, codec->afg, 0,
7020 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7021
7022 msleep(1);
7023
7024 snd_hda_codec_write(codec, codec->afg, 0,
7025 AC_VERB_SET_GPIO_DATA, gpiostate);
7026}
7027
Takashi Iwai7debbe52007-08-16 15:01:03 +02007028/* set up GPIO at initialization */
7029static void alc885_macpro_init_hook(struct hda_codec *codec)
7030{
7031 alc882_gpio_mute(codec, 0, 0);
7032 alc882_gpio_mute(codec, 1, 0);
7033}
7034
7035/* set up GPIO and update auto-muting at initialization */
7036static void alc885_imac24_init_hook(struct hda_codec *codec)
7037{
7038 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007039 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007040}
7041
Kailang Yangdf694da2005-12-05 19:42:22 +01007042/*
7043 * generic initialization of ADC, input mixers and output mixers
7044 */
7045static struct hda_verb alc882_auto_init_verbs[] = {
7046 /*
7047 * Unmute ADC0-2 and set the default input to mic-in
7048 */
7049 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7051 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7052 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7053 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7054 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7055
Takashi Iwaicb53c622007-08-10 17:21:45 +02007056 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007057 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007058 * Note: PASD motherboards uses the Line In 2 as the input for
7059 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007060 */
7061 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007067
7068 /*
7069 * Set up output mixers (0x0c - 0x0f)
7070 */
7071 /* set vol=0 to output mixers */
7072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7075 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7076 /* set up input amps for analog loopback */
7077 /* Amp Indices: DAC = 0, mixer = 1 */
7078 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7079 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7080 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7081 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7083 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7085 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7086 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7087 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7088
7089 /* FIXME: use matrix-type input source selection */
7090 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7091 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7092 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7093 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7094 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7095 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7096 /* Input mixer2 */
7097 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7098 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7099 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7101 /* Input mixer3 */
7102 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7103 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7106
7107 { }
7108};
7109
Takashi Iwaicb53c622007-08-10 17:21:45 +02007110#ifdef CONFIG_SND_HDA_POWER_SAVE
7111#define alc882_loopbacks alc880_loopbacks
7112#endif
7113
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007114/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007115#define alc882_pcm_analog_playback alc880_pcm_analog_playback
7116#define alc882_pcm_analog_capture alc880_pcm_analog_capture
7117#define alc882_pcm_digital_playback alc880_pcm_digital_playback
7118#define alc882_pcm_digital_capture alc880_pcm_digital_capture
7119
7120/*
7121 * configuration and preset
7122 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007123static const char *alc882_models[ALC882_MODEL_LAST] = {
7124 [ALC882_3ST_DIG] = "3stack-dig",
7125 [ALC882_6ST_DIG] = "6stack-dig",
7126 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02007127 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02007128 [ALC882_TARGA] = "targa",
7129 [ALC882_ASUS_A7J] = "asus-a7j",
7130 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01007131 [ALC885_MACPRO] = "macpro",
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007132 [ALC885_MB5] = "mb5",
Takashi Iwai87350ad2007-08-16 18:19:38 +02007133 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007134 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007135 [ALC882_AUTO] = "auto",
7136};
7137
7138static struct snd_pci_quirk alc882_cfg_tbl[] = {
7139 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02007140 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02007141 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02007142 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007143 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02007144 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01007145 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007146 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01007147 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007148 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
7149 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
7150 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01007151 {}
7152};
7153
7154static struct alc_config_preset alc882_presets[] = {
7155 [ALC882_3ST_DIG] = {
7156 .mixers = { alc882_base_mixer },
7157 .init_verbs = { alc882_init_verbs },
7158 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7159 .dac_nids = alc882_dac_nids,
7160 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007161 .dig_in_nid = ALC882_DIGIN_NID,
7162 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7163 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007164 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007165 .input_mux = &alc882_capture_source,
7166 },
7167 [ALC882_6ST_DIG] = {
7168 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7169 .init_verbs = { alc882_init_verbs },
7170 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7171 .dac_nids = alc882_dac_nids,
7172 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007173 .dig_in_nid = ALC882_DIGIN_NID,
7174 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7175 .channel_mode = alc882_sixstack_modes,
7176 .input_mux = &alc882_capture_source,
7177 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007178 [ALC882_ARIMA] = {
7179 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7180 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
7181 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7182 .dac_nids = alc882_dac_nids,
7183 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7184 .channel_mode = alc882_sixstack_modes,
7185 .input_mux = &alc882_capture_source,
7186 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02007187 [ALC882_W2JC] = {
7188 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
7189 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7190 alc880_gpio1_init_verbs },
7191 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7192 .dac_nids = alc882_dac_nids,
7193 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7194 .channel_mode = alc880_threestack_modes,
7195 .need_dac_fix = 1,
7196 .input_mux = &alc882_capture_source,
7197 .dig_out_nid = ALC882_DIGOUT_NID,
7198 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007199 [ALC885_MBP3] = {
7200 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
7201 .init_verbs = { alc885_mbp3_init_verbs,
7202 alc880_gpio1_init_verbs },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007203 .num_dacs = 2,
Takashi Iwai87350ad2007-08-16 18:19:38 +02007204 .dac_nids = alc882_dac_nids,
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007205 .hp_nid = 0x04,
7206 .channel_mode = alc885_mbp_4ch_modes,
7207 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007208 .input_mux = &alc882_capture_source,
7209 .dig_out_nid = ALC882_DIGOUT_NID,
7210 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007211 .unsol_event = alc_automute_amp_unsol_event,
7212 .init_hook = alc885_mbp3_init_hook,
Takashi Iwai87350ad2007-08-16 18:19:38 +02007213 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007214 [ALC885_MB5] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007215 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007216 .init_verbs = { alc885_mb5_init_verbs,
7217 alc880_gpio1_init_verbs },
7218 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7219 .dac_nids = alc882_dac_nids,
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007220 .channel_mode = alc885_mb5_6ch_modes,
7221 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007222 .input_mux = &mb5_capture_source,
7223 .dig_out_nid = ALC882_DIGOUT_NID,
7224 .dig_in_nid = ALC882_DIGIN_NID,
7225 },
Tobin Davis9102cd12006-12-15 10:02:12 +01007226 [ALC885_MACPRO] = {
7227 .mixers = { alc882_macpro_mixer },
7228 .init_verbs = { alc882_macpro_init_verbs },
7229 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7230 .dac_nids = alc882_dac_nids,
7231 .dig_out_nid = ALC882_DIGOUT_NID,
7232 .dig_in_nid = ALC882_DIGIN_NID,
7233 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7234 .channel_mode = alc882_ch_modes,
7235 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007236 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01007237 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007238 [ALC885_IMAC24] = {
7239 .mixers = { alc885_imac24_mixer },
7240 .init_verbs = { alc885_imac24_init_verbs },
7241 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7242 .dac_nids = alc882_dac_nids,
7243 .dig_out_nid = ALC882_DIGOUT_NID,
7244 .dig_in_nid = ALC882_DIGIN_NID,
7245 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7246 .channel_mode = alc882_ch_modes,
7247 .input_mux = &alc882_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007248 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007249 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007250 },
Kailang Yang272a5272007-05-14 11:00:38 +02007251 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007252 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02007253 .init_verbs = { alc882_init_verbs, alc880_gpio3_init_verbs,
7254 alc882_targa_verbs},
Kailang Yang272a5272007-05-14 11:00:38 +02007255 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7256 .dac_nids = alc882_dac_nids,
7257 .dig_out_nid = ALC882_DIGOUT_NID,
7258 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7259 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007260 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007261 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7262 .channel_mode = alc882_3ST_6ch_modes,
7263 .need_dac_fix = 1,
7264 .input_mux = &alc882_capture_source,
7265 .unsol_event = alc882_targa_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007266 .init_hook = alc882_targa_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02007267 },
7268 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007269 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007270 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7271 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7272 .dac_nids = alc882_dac_nids,
7273 .dig_out_nid = ALC882_DIGOUT_NID,
7274 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7275 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007276 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007277 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7278 .channel_mode = alc882_3ST_6ch_modes,
7279 .need_dac_fix = 1,
7280 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007281 },
Takashi Iwai914759b2007-09-06 14:52:04 +02007282 [ALC882_ASUS_A7M] = {
7283 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7284 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7285 alc880_gpio1_init_verbs,
7286 alc882_asus_a7m_verbs },
7287 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7288 .dac_nids = alc882_dac_nids,
7289 .dig_out_nid = ALC882_DIGOUT_NID,
7290 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7291 .channel_mode = alc880_threestack_modes,
7292 .need_dac_fix = 1,
7293 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007294 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007295};
7296
7297
7298/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007299 * Pin config fixes
7300 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007301enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007302 PINFIX_ABIT_AW9D_MAX
7303};
7304
7305static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7306 { 0x15, 0x01080104 }, /* side */
7307 { 0x16, 0x01011012 }, /* rear */
7308 { 0x17, 0x01016011 }, /* clfe */
7309 { }
7310};
7311
7312static const struct alc_pincfg *alc882_pin_fixes[] = {
7313 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7314};
7315
7316static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7317 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7318 {}
7319};
7320
7321/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007322 * BIOS auto configuration
7323 */
7324static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7325 hda_nid_t nid, int pin_type,
7326 int dac_idx)
7327{
7328 /* set as output */
7329 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007330 int idx;
7331
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007332 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007333 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7334 idx = 4;
7335 else
7336 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007337 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7338
7339}
7340
7341static void alc882_auto_init_multi_out(struct hda_codec *codec)
7342{
7343 struct alc_spec *spec = codec->spec;
7344 int i;
7345
7346 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007347 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007348 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007349 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007350 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007351 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007352 }
7353}
7354
7355static void alc882_auto_init_hp_out(struct hda_codec *codec)
7356{
7357 struct alc_spec *spec = codec->spec;
7358 hda_nid_t pin;
7359
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007360 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007361 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007362 /* use dac 0 */
7363 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007364 pin = spec->autocfg.speaker_pins[0];
7365 if (pin)
7366 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007367}
7368
7369#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7370#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7371
7372static void alc882_auto_init_analog_input(struct hda_codec *codec)
7373{
7374 struct alc_spec *spec = codec->spec;
7375 int i;
7376
7377 for (i = 0; i < AUTO_PIN_LAST; i++) {
7378 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007379 if (!nid)
7380 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007381 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007382 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7383 snd_hda_codec_write(codec, nid, 0,
7384 AC_VERB_SET_AMP_GAIN_MUTE,
7385 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007386 }
7387}
7388
Takashi Iwaif511b012008-08-15 16:46:42 +02007389static void alc882_auto_init_input_src(struct hda_codec *codec)
7390{
7391 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007392 int c;
7393
7394 for (c = 0; c < spec->num_adc_nids; c++) {
7395 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7396 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007397 unsigned int mux_idx;
7398 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007399 int conns, mute, idx, item;
7400
7401 conns = snd_hda_get_connections(codec, nid, conn_list,
7402 ARRAY_SIZE(conn_list));
7403 if (conns < 0)
7404 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007405 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7406 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007407 for (idx = 0; idx < conns; idx++) {
7408 /* if the current connection is the selected one,
7409 * unmute it as default - otherwise mute it
7410 */
7411 mute = AMP_IN_MUTE(idx);
7412 for (item = 0; item < imux->num_items; item++) {
7413 if (imux->items[item].index == idx) {
7414 if (spec->cur_mux[c] == item)
7415 mute = AMP_IN_UNMUTE(idx);
7416 break;
7417 }
7418 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007419 /* check if we have a selector or mixer
7420 * we could check for the widget type instead, but
7421 * just check for Amp-In presence (in case of mixer
7422 * without amp-in there is something wrong, this
7423 * function shouldn't be used or capsrc nid is wrong)
7424 */
7425 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7426 snd_hda_codec_write(codec, nid, 0,
7427 AC_VERB_SET_AMP_GAIN_MUTE,
7428 mute);
7429 else if (mute != AMP_IN_MUTE(idx))
7430 snd_hda_codec_write(codec, nid, 0,
7431 AC_VERB_SET_CONNECT_SEL,
7432 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007433 }
7434 }
7435}
7436
Takashi Iwai776e1842007-08-29 15:07:11 +02007437/* add mic boosts if needed */
7438static int alc_auto_add_mic_boost(struct hda_codec *codec)
7439{
7440 struct alc_spec *spec = codec->spec;
7441 int err;
7442 hda_nid_t nid;
7443
7444 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007445 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007446 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7447 "Mic Boost",
7448 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7449 if (err < 0)
7450 return err;
7451 }
7452 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007453 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007454 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7455 "Front Mic Boost",
7456 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7457 if (err < 0)
7458 return err;
7459 }
7460 return 0;
7461}
7462
Kailang Yangdf694da2005-12-05 19:42:22 +01007463/* almost identical with ALC880 parser... */
7464static int alc882_parse_auto_config(struct hda_codec *codec)
7465{
7466 struct alc_spec *spec = codec->spec;
7467 int err = alc880_parse_auto_config(codec);
7468
7469 if (err < 0)
7470 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007471 else if (!err)
7472 return 0; /* no config found */
7473
7474 err = alc_auto_add_mic_boost(codec);
7475 if (err < 0)
7476 return err;
7477
7478 /* hack - override the init verbs */
7479 spec->init_verbs[0] = alc882_auto_init_verbs;
7480
7481 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007482}
7483
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007484/* additional initialization for auto-configuration model */
7485static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007486{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007487 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007488 alc882_auto_init_multi_out(codec);
7489 alc882_auto_init_hp_out(codec);
7490 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007491 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007492 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007493 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007494}
7495
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007496static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7497
Linus Torvalds1da177e2005-04-16 15:20:36 -07007498static int patch_alc882(struct hda_codec *codec)
7499{
7500 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007501 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007502
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007503 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007504 if (spec == NULL)
7505 return -ENOMEM;
7506
Linus Torvalds1da177e2005-04-16 15:20:36 -07007507 codec->spec = spec;
7508
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007509 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7510 alc882_models,
7511 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007512
Kailang Yangdf694da2005-12-05 19:42:22 +01007513 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007514 /* Pick up systems that don't supply PCI SSID */
7515 switch (codec->subsystem_id) {
7516 case 0x106b0c00: /* Mac Pro */
7517 board_config = ALC885_MACPRO;
7518 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007519 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007520 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007521 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007522 board_config = ALC885_IMAC24;
7523 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007524 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007525 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007526 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007527 case 0x106b2c00: /* Macbook Pro rev3 */
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007528 /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */
Luke Yelavich2a884642009-01-28 15:58:38 +11007529 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007530 board_config = ALC885_MBP3;
7531 break;
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007532 case 0x106b3f00: /* Macbook 5,1 */
Takashi Iwai7442f9d2009-05-14 18:20:33 +02007533 case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense
7534 * seems not working, so apparently
7535 * no perfect solution yet
7536 */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007537 board_config = ALC885_MB5;
7538 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007539 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007540 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007541 if (codec->revision_id == 0x100101 ||
7542 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007543 alc_free(codec);
7544 return patch_alc883(codec);
7545 }
Takashi Iwai6c627f32009-05-18 12:33:36 +02007546 printk(KERN_INFO "hda_codec: Unknown model for %s, "
7547 "trying auto-probe from BIOS...\n",
7548 codec->chip_name);
Tobin Davis081d17c2007-02-15 17:46:18 +01007549 board_config = ALC882_AUTO;
7550 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007551 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007552
Takashi Iwaif95474e2007-07-10 00:47:43 +02007553 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7554
Kailang Yangdf694da2005-12-05 19:42:22 +01007555 if (board_config == ALC882_AUTO) {
7556 /* automatic parse from the BIOS config */
7557 err = alc882_parse_auto_config(codec);
7558 if (err < 0) {
7559 alc_free(codec);
7560 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007561 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007562 printk(KERN_INFO
7563 "hda_codec: Cannot set up configuration "
7564 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007565 board_config = ALC882_3ST_DIG;
7566 }
7567 }
7568
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007569 err = snd_hda_attach_beep_device(codec, 0x1);
7570 if (err < 0) {
7571 alc_free(codec);
7572 return err;
7573 }
7574
Kailang Yangdf694da2005-12-05 19:42:22 +01007575 if (board_config != ALC882_AUTO)
7576 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007577
Kailang Yangdf694da2005-12-05 19:42:22 +01007578 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7579 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007580 /* FIXME: setup DAC5 */
7581 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7582 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007583
Kailang Yangdf694da2005-12-05 19:42:22 +01007584 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7585 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007586
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007587 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007588 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007589 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007590 /* get type */
7591 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007592 if (wcap != AC_WID_AUD_IN) {
7593 spec->adc_nids = alc882_adc_nids_alt;
7594 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007595 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007596 } else {
7597 spec->adc_nids = alc882_adc_nids;
7598 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007599 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007600 }
7601 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007602 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007603 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007604
Takashi Iwai2134ea42008-01-10 16:53:55 +01007605 spec->vmaster_nid = 0x0c;
7606
Linus Torvalds1da177e2005-04-16 15:20:36 -07007607 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007608 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007609 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007610#ifdef CONFIG_SND_HDA_POWER_SAVE
7611 if (!spec->loopback.amplist)
7612 spec->loopback.amplist = alc882_loopbacks;
7613#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007614 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007615
7616 return 0;
7617}
7618
7619/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007620 * ALC883 support
7621 *
7622 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7623 * configuration. Each pin widget can choose any input DACs and a mixer.
7624 * Each ADC is connected from a mixer of all inputs. This makes possible
7625 * 6-channel independent captures.
7626 *
7627 * In addition, an independent DAC for the multi-playback (not used in this
7628 * driver yet).
7629 */
7630#define ALC883_DIGOUT_NID 0x06
7631#define ALC883_DIGIN_NID 0x0a
7632
Wu Fengguang3ab90932008-11-17 09:51:09 +01007633#define ALC1200_DIGOUT_NID 0x10
7634
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007635static hda_nid_t alc883_dac_nids[4] = {
7636 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007637 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007638};
7639
7640static hda_nid_t alc883_adc_nids[2] = {
7641 /* ADC1-2 */
7642 0x08, 0x09,
7643};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007644
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007645static hda_nid_t alc883_adc_nids_alt[1] = {
7646 /* ADC1 */
7647 0x08,
7648};
7649
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007650static hda_nid_t alc883_adc_nids_rev[2] = {
7651 /* ADC2-1 */
7652 0x09, 0x08
7653};
7654
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007655#define alc889_adc_nids alc880_adc_nids
7656
Takashi Iwaie1406342008-02-11 18:32:32 +01007657static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7658
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007659static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7660
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007661#define alc889_capsrc_nids alc882_capsrc_nids
7662
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007663/* input MUX */
7664/* FIXME: should be a matrix-type input source selection */
7665
7666static struct hda_input_mux alc883_capture_source = {
7667 .num_items = 4,
7668 .items = {
7669 { "Mic", 0x0 },
7670 { "Front Mic", 0x1 },
7671 { "Line", 0x2 },
7672 { "CD", 0x4 },
7673 },
7674};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007675
Jiang zhe17bba1b2008-06-04 12:11:07 +02007676static struct hda_input_mux alc883_3stack_6ch_intel = {
7677 .num_items = 4,
7678 .items = {
7679 { "Mic", 0x1 },
7680 { "Front Mic", 0x0 },
7681 { "Line", 0x2 },
7682 { "CD", 0x4 },
7683 },
7684};
7685
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007686static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7687 .num_items = 2,
7688 .items = {
7689 { "Mic", 0x1 },
7690 { "Line", 0x2 },
7691 },
7692};
7693
Kailang Yang272a5272007-05-14 11:00:38 +02007694static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7695 .num_items = 4,
7696 .items = {
7697 { "Mic", 0x0 },
7698 { "iMic", 0x1 },
7699 { "Line", 0x2 },
7700 { "CD", 0x4 },
7701 },
7702};
7703
Jiang zhefb97dc62008-03-06 11:07:11 +01007704static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7705 .num_items = 2,
7706 .items = {
7707 { "Mic", 0x0 },
7708 { "Int Mic", 0x1 },
7709 },
7710};
7711
Kailang Yange2757d52008-08-26 13:17:46 +02007712static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7713 .num_items = 3,
7714 .items = {
7715 { "Mic", 0x0 },
7716 { "Front Mic", 0x1 },
7717 { "Line", 0x4 },
7718 },
7719};
7720
7721static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7722 .num_items = 2,
7723 .items = {
7724 { "Mic", 0x0 },
7725 { "Line", 0x2 },
7726 },
7727};
7728
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007729static struct hda_input_mux alc889A_mb31_capture_source = {
7730 .num_items = 2,
7731 .items = {
7732 { "Mic", 0x0 },
7733 /* Front Mic (0x01) unused */
7734 { "Line", 0x2 },
7735 /* Line 2 (0x03) unused */
7736 /* CD (0x04) unsused? */
7737 },
7738};
7739
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007740/*
7741 * 2ch mode
7742 */
7743static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7744 { 2, NULL }
7745};
7746
7747/*
7748 * 2ch mode
7749 */
7750static struct hda_verb alc883_3ST_ch2_init[] = {
7751 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7752 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7753 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7754 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7755 { } /* end */
7756};
7757
7758/*
Tobin Davisb2011312007-09-17 12:45:11 +02007759 * 4ch mode
7760 */
7761static struct hda_verb alc883_3ST_ch4_init[] = {
7762 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7763 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7764 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7765 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7766 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7767 { } /* end */
7768};
7769
7770/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007771 * 6ch mode
7772 */
7773static struct hda_verb alc883_3ST_ch6_init[] = {
7774 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7775 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7776 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7777 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7778 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7779 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7780 { } /* end */
7781};
7782
Tobin Davisb2011312007-09-17 12:45:11 +02007783static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007784 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007785 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007786 { 6, alc883_3ST_ch6_init },
7787};
7788
David Heidelberger64a8be72009-06-08 16:15:18 +02007789
7790/*
7791 * 2ch mode
7792 */
7793static struct hda_verb alc883_4ST_ch2_init[] = {
Takashi Iwaif03ecf52009-06-08 16:38:17 +02007794 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
David Heidelberger64a8be72009-06-08 16:15:18 +02007795 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7796 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7797 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7798 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7799 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7800 { } /* end */
7801};
7802
7803/*
7804 * 4ch mode
7805 */
7806static struct hda_verb alc883_4ST_ch4_init[] = {
7807 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7808 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7809 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7810 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7811 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7812 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7813 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7814 { } /* end */
7815};
7816
7817/*
7818 * 6ch mode
7819 */
7820static struct hda_verb alc883_4ST_ch6_init[] = {
7821 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7822 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7823 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7824 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7825 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7826 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7827 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7828 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7829 { } /* end */
7830};
7831
7832/*
7833 * 8ch mode
7834 */
7835static struct hda_verb alc883_4ST_ch8_init[] = {
7836 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7837 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7838 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7839 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7840 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7841 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7842 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7843 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7844 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7845 { } /* end */
7846};
7847
7848static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7849 { 2, alc883_4ST_ch2_init },
7850 { 4, alc883_4ST_ch4_init },
7851 { 6, alc883_4ST_ch6_init },
7852 { 8, alc883_4ST_ch8_init },
7853};
7854
7855
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007856/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007857 * 2ch mode
7858 */
7859static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7860 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7861 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7862 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7863 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7864 { } /* end */
7865};
7866
7867/*
7868 * 4ch mode
7869 */
7870static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7871 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7872 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7873 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7874 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7875 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7876 { } /* end */
7877};
7878
7879/*
7880 * 6ch mode
7881 */
7882static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7883 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7884 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7885 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7886 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7887 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7888 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7889 { } /* end */
7890};
7891
7892static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7893 { 2, alc883_3ST_ch2_intel_init },
7894 { 4, alc883_3ST_ch4_intel_init },
7895 { 6, alc883_3ST_ch6_intel_init },
7896};
7897
7898/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007899 * 6ch mode
7900 */
7901static struct hda_verb alc883_sixstack_ch6_init[] = {
7902 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7903 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7904 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7905 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7906 { } /* end */
7907};
7908
7909/*
7910 * 8ch mode
7911 */
7912static struct hda_verb alc883_sixstack_ch8_init[] = {
7913 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7914 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7915 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7916 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7917 { } /* end */
7918};
7919
7920static struct hda_channel_mode alc883_sixstack_modes[2] = {
7921 { 6, alc883_sixstack_ch6_init },
7922 { 8, alc883_sixstack_ch8_init },
7923};
7924
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007925/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7926static struct hda_verb alc889A_mb31_ch2_init[] = {
7927 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7928 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7929 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7930 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7931 { } /* end */
7932};
7933
7934/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7935static struct hda_verb alc889A_mb31_ch4_init[] = {
7936 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7937 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7938 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7939 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7940 { } /* end */
7941};
7942
7943/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7944static struct hda_verb alc889A_mb31_ch5_init[] = {
7945 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7946 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7947 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7948 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7949 { } /* end */
7950};
7951
7952/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7953static struct hda_verb alc889A_mb31_ch6_init[] = {
7954 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7955 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7956 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7957 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7958 { } /* end */
7959};
7960
7961static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7962 { 2, alc889A_mb31_ch2_init },
7963 { 4, alc889A_mb31_ch4_init },
7964 { 5, alc889A_mb31_ch5_init },
7965 { 6, alc889A_mb31_ch6_init },
7966};
7967
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007968static struct hda_verb alc883_medion_eapd_verbs[] = {
7969 /* eanable EAPD on medion laptop */
7970 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7971 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7972 { }
7973};
7974
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007975/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7976 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7977 */
7978
7979static struct snd_kcontrol_new alc883_base_mixer[] = {
7980 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7981 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7982 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7983 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7984 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7985 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7986 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7987 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7988 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7989 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7990 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7991 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7992 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7993 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7994 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007996 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7998 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007999 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008000 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008001 { } /* end */
8002};
8003
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008004static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8005 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8006 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8007 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8008 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8009 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8010 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8011 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8012 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8013 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8015 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8016 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8017 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008018 { } /* end */
8019};
8020
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008021static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008022 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8023 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8024 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8025 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8026 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8027 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8028 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8029 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8030 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8031 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008032 { } /* end */
8033};
8034
Jiang zhefb97dc62008-03-06 11:07:11 +01008035static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8036 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8037 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8038 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8039 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8040 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8041 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8042 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8043 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8044 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8045 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008046 { } /* end */
8047};
8048
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008049static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8050 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8051 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8052 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8053 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8054 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8055 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8056 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8057 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008058 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008059 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8060 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008061 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008062 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008063 { } /* end */
8064};
8065
8066static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8067 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8068 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8069 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8070 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8071 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8072 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8073 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8074 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8075 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8076 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8077 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8078 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8079 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8080 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008081 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008082 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8083 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008084 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008085 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008086 { } /* end */
8087};
8088
Jiang zhe17bba1b2008-06-04 12:11:07 +02008089static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8090 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8091 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8092 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8093 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8094 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8095 HDA_OUTPUT),
8096 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8097 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8098 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8099 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8100 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8101 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8102 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8103 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8104 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8105 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8106 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8107 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8108 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8109 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008110 { } /* end */
8111};
8112
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008113static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008114 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008115 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008116 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008117 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008118 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8119 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008120 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8121 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008122 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8123 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8124 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8125 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8126 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8127 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008128 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008129 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8130 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008131 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008132 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008133 { } /* end */
8134};
8135
Sasha Alexandrc2592492009-06-16 14:52:54 -04008136static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008137 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8138 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8139 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8140 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8141 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8142 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8143 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8144 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8145 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8146 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8147 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8148 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8149 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8150 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008151 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008152 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008153 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008154};
Kailang Yangccc656c2006-10-17 12:32:26 +02008155
Sasha Alexandrc2592492009-06-16 14:52:54 -04008156static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008157 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8158 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8159 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8160 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8161 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008163 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008165 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8166 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8167 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008168 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008169};
Kailang Yangccc656c2006-10-17 12:32:26 +02008170
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008171static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8172 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8173 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008174 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8175 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8178 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008180 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008181};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008182
Kailang Yang272a5272007-05-14 11:00:38 +02008183static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8184 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8185 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8186 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8187 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8188 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8189 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8190 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8191 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8192 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008193 { } /* end */
8194};
8195
8196static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8197 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8198 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8199 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8200 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8201 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8202 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8203 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8204 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8205 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008206 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008207};
Kailang Yang272a5272007-05-14 11:00:38 +02008208
Tobin Davis2880a862007-08-07 11:50:26 +02008209static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008210 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8211 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008212 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008213 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8214 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8216 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8217 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008218 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008219};
Tobin Davis2880a862007-08-07 11:50:26 +02008220
Tony Vroond2fd4b02009-06-21 00:40:10 +01008221static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8222 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8223 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8224 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8225 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008226 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8227 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008228 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8229 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8231 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8232 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8233 { } /* end */
8234};
8235
Kailang Yange2757d52008-08-26 13:17:46 +02008236static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8237 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8238 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8239 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8240 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8241 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8242 0x0d, 1, 0x0, HDA_OUTPUT),
8243 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8244 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8245 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8246 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8247 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008248 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8249 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8250 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8251 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8252 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8253 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8255 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8256 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8257 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008258 { } /* end */
8259};
8260
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008261static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8262 /* Output mixers */
8263 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8264 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8265 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8266 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8267 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8268 HDA_OUTPUT),
8269 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8270 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8271 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8272 /* Output switches */
8273 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8274 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8275 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8276 /* Boost mixers */
8277 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8278 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8279 /* Input mixers */
8280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8281 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8282 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8283 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8284 { } /* end */
8285};
8286
Guido Günther3e1647c2009-06-05 00:47:26 +02008287static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8288 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8289 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8290 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8291 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8292 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8293 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8294 { } /* end */
8295};
8296
Kailang Yange2757d52008-08-26 13:17:46 +02008297static struct hda_bind_ctls alc883_bind_cap_vol = {
8298 .ops = &snd_hda_bind_vol,
8299 .values = {
8300 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8301 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8302 0
8303 },
8304};
8305
8306static struct hda_bind_ctls alc883_bind_cap_switch = {
8307 .ops = &snd_hda_bind_sw,
8308 .values = {
8309 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8310 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8311 0
8312 },
8313};
8314
8315static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8316 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8317 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8318 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8319 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8320 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8321 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8322 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8323 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008324 { } /* end */
8325};
8326
8327static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008328 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8329 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8330 {
8331 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8332 /* .name = "Capture Source", */
8333 .name = "Input Source",
8334 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008335 .info = alc_mux_enum_info,
8336 .get = alc_mux_enum_get,
8337 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008338 },
8339 { } /* end */
8340};
8341
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008342static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8343 {
8344 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8345 .name = "Channel Mode",
8346 .info = alc_ch_mode_info,
8347 .get = alc_ch_mode_get,
8348 .put = alc_ch_mode_put,
8349 },
8350 { } /* end */
8351};
8352
8353static struct hda_verb alc883_init_verbs[] = {
8354 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02008355 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008356 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8357 /* ADC2: mute amp left and right */
8358 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8359 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8360 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8361 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8362 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8364 /* Rear mixer */
8365 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8366 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8367 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8368 /* CLFE mixer */
8369 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8370 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8371 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8372 /* Side mixer */
8373 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8374 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8375 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8376
Takashi Iwaicb53c622007-08-10 17:21:45 +02008377 /* mute analog input loopbacks */
8378 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8379 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8380 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8381 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8382 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008383
8384 /* Front Pin: output 0 (0x0c) */
8385 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8386 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8387 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8388 /* Rear Pin: output 1 (0x0d) */
8389 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8390 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8391 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8392 /* CLFE Pin: output 2 (0x0e) */
8393 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8394 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8395 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8396 /* Side Pin: output 3 (0x0f) */
8397 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8398 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8399 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8400 /* Mic (rear) pin: input vref at 80% */
8401 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8402 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8403 /* Front Mic pin: input vref at 80% */
8404 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8405 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8406 /* Line In pin: input */
8407 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8408 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8409 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8410 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8411 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8412 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8413 /* CD pin widget for input */
8414 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8415
8416 /* FIXME: use matrix-type input source selection */
8417 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8418 /* Input mixer2 */
8419 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008420 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8421 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8422 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008423 /* Input mixer3 */
8424 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008425 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8426 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8427 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008428 { }
8429};
8430
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008431/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008432static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008433{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008434 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008435
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008436 spec->autocfg.hp_pins[0] = 0x15;
8437 spec->autocfg.speaker_pins[0] = 0x14;
8438 spec->autocfg.speaker_pins[1] = 0x17;
8439 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008440}
8441
8442/* auto-toggle front mic */
8443/*
8444static void alc883_mitac_mic_automute(struct hda_codec *codec)
8445{
8446 unsigned int present;
8447 unsigned char bits;
8448
8449 present = snd_hda_codec_read(codec, 0x18, 0,
8450 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8451 bits = present ? HDA_AMP_MUTE : 0;
8452 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8453}
8454*/
8455
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008456static struct hda_verb alc883_mitac_verbs[] = {
8457 /* HP */
8458 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8459 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8460 /* Subwoofer */
8461 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8462 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8463
8464 /* enable unsolicited event */
8465 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8466 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8467
8468 { } /* end */
8469};
8470
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008471static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008472 /* HP */
8473 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8475 /* Int speaker */
8476 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8477 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8478
8479 /* enable unsolicited event */
8480 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008481 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008482
8483 { } /* end */
8484};
8485
Jiang zhefb97dc62008-03-06 11:07:11 +01008486static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8487 /* HP */
8488 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8489 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8490 /* Subwoofer */
8491 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8492 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8493
8494 /* enable unsolicited event */
8495 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8496
8497 { } /* end */
8498};
8499
Sasha Alexandrc2592492009-06-16 14:52:54 -04008500static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8503
8504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8505 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008506
David Heidelberger64a8be72009-06-08 16:15:18 +02008507/* Connect Line-Out side jack (SPDIF) to Side */
8508 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8509 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8510 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8511/* Connect Mic jack to CLFE */
8512 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8513 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8514 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8515/* Connect Line-in jack to Surround */
8516 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8517 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8518 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8519/* Connect HP out jack to Front */
8520 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8521 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8522 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008523
8524 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008525
8526 { } /* end */
8527};
8528
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008529static struct hda_verb alc883_lenovo_101e_verbs[] = {
8530 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8531 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8532 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8533 { } /* end */
8534};
8535
Kailang Yang272a5272007-05-14 11:00:38 +02008536static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8537 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8538 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8539 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8540 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8541 { } /* end */
8542};
8543
8544static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8545 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8547 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8548 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8549 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8550 { } /* end */
8551};
8552
Kailang Yang189609a2007-08-20 11:31:23 +02008553static struct hda_verb alc883_haier_w66_verbs[] = {
8554 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8556
8557 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8558
8559 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8560 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8561 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8562 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8563 { } /* end */
8564};
8565
Kailang Yange2757d52008-08-26 13:17:46 +02008566static struct hda_verb alc888_lenovo_sky_verbs[] = {
8567 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8568 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8569 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8570 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8571 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8572 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8573 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8574 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8575 { } /* end */
8576};
8577
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008578static struct hda_verb alc888_6st_dell_verbs[] = {
8579 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8580 { }
8581};
8582
Guido Günther3e1647c2009-06-05 00:47:26 +02008583static struct hda_verb alc883_vaiott_verbs[] = {
8584 /* HP */
8585 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8587
8588 /* enable unsolicited event */
8589 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8590
8591 { } /* end */
8592};
8593
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008594static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008595{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008596 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008597
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008598 spec->autocfg.hp_pins[0] = 0x1b;
8599 spec->autocfg.speaker_pins[0] = 0x14;
8600 spec->autocfg.speaker_pins[1] = 0x16;
8601 spec->autocfg.speaker_pins[2] = 0x18;
8602 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008603}
8604
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008605static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008606 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008607 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8608 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008609 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008610 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008611};
8612
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008613/*
8614 * 2ch mode
8615 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008616static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008617 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8618 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8619 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8620 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008621 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008622};
8623
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008624/*
8625 * 4ch mode
8626 */
8627static struct hda_verb alc888_3st_hp_4ch_init[] = {
8628 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8629 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8630 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8631 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8632 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8633 { } /* end */
8634};
8635
8636/*
8637 * 6ch mode
8638 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008639static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008640 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8641 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008642 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008643 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8644 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008645 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8646 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008647};
8648
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008649static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008650 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008651 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008652 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008653};
8654
Kailang Yang272a5272007-05-14 11:00:38 +02008655/* toggle front-jack and RCA according to the hp-jack state */
8656static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8657{
8658 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008659
Kailang Yang272a5272007-05-14 11:00:38 +02008660 present = snd_hda_codec_read(codec, 0x1b, 0,
8661 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008662 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8663 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8664 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8665 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008666}
8667
8668/* toggle RCA according to the front-jack state */
8669static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8670{
8671 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008672
Kailang Yang272a5272007-05-14 11:00:38 +02008673 present = snd_hda_codec_read(codec, 0x14, 0,
8674 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008675 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8676 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008677}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008678
Kailang Yang272a5272007-05-14 11:00:38 +02008679static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8680 unsigned int res)
8681{
8682 if ((res >> 26) == ALC880_HP_EVENT)
8683 alc888_lenovo_ms7195_front_automute(codec);
8684 if ((res >> 26) == ALC880_FRONT_EVENT)
8685 alc888_lenovo_ms7195_rca_automute(codec);
8686}
8687
8688static struct hda_verb alc883_medion_md2_verbs[] = {
8689 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8690 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8691
8692 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8693
8694 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8695 { } /* end */
8696};
8697
8698/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008699static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008700{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008701 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008702
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008703 spec->autocfg.hp_pins[0] = 0x14;
8704 spec->autocfg.speaker_pins[0] = 0x15;
8705 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008706}
8707
Kailang Yangccc656c2006-10-17 12:32:26 +02008708/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008709#define alc883_targa_init_hook alc882_targa_init_hook
8710#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008711
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008712static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8713{
8714 unsigned int present;
8715
8716 present = snd_hda_codec_read(codec, 0x18, 0,
8717 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8718 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8719 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8720}
8721
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008722static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008723{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008724 struct alc_spec *spec = codec->spec;
8725
8726 spec->autocfg.hp_pins[0] = 0x15;
8727 spec->autocfg.speaker_pins[0] = 0x14;
8728 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008729 alc883_clevo_m720_mic_automute(codec);
8730}
8731
8732static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008733 unsigned int res)
8734{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008735 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008736 case ALC880_MIC_EVENT:
8737 alc883_clevo_m720_mic_automute(codec);
8738 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008739 default:
8740 alc_automute_amp_unsol_event(codec, res);
8741 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008742 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008743}
8744
Jiang zhefb97dc62008-03-06 11:07:11 +01008745/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008746static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008747{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008748 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008749
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008750 spec->autocfg.hp_pins[0] = 0x14;
8751 spec->autocfg.speaker_pins[0] = 0x15;
8752 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008753}
8754
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008755static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008756{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008757 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008758
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008759 spec->autocfg.hp_pins[0] = 0x1b;
8760 spec->autocfg.speaker_pins[0] = 0x14;
8761 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008762}
8763
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008764static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8765{
8766 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008767 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008768
David Heidelberger64a8be72009-06-08 16:15:18 +02008769 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8770 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008771 bits = present ? HDA_AMP_MUTE : 0;
8772 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8773 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008774}
8775
8776static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8777{
8778 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008779 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008780
8781 present = snd_hda_codec_read(codec, 0x1b, 0,
8782 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008783 bits = present ? HDA_AMP_MUTE : 0;
8784 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8785 HDA_AMP_MUTE, bits);
8786 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8787 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008788}
8789
8790static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8791 unsigned int res)
8792{
8793 if ((res >> 26) == ALC880_HP_EVENT)
8794 alc883_lenovo_101e_all_automute(codec);
8795 if ((res >> 26) == ALC880_FRONT_EVENT)
8796 alc883_lenovo_101e_ispeaker_automute(codec);
8797}
8798
Takashi Iwai676a9b52007-08-16 15:23:35 +02008799/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008800static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008801{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008802 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008803
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008804 spec->autocfg.hp_pins[0] = 0x14;
8805 spec->autocfg.speaker_pins[0] = 0x15;
8806 spec->autocfg.speaker_pins[1] = 0x16;
8807 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008808}
8809
Kailang Yangd1a991a2007-08-15 16:21:59 +02008810static struct hda_verb alc883_acer_eapd_verbs[] = {
8811 /* HP Pin: output 0 (0x0c) */
8812 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8813 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8814 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8815 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008816 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8817 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008818 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008819 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8820 /* eanable EAPD on medion laptop */
8821 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8822 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008823 /* enable unsolicited event */
8824 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008825 { }
8826};
8827
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008828static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008829{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008830 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008831
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008832 spec->autocfg.hp_pins[0] = 0x1b;
8833 spec->autocfg.speaker_pins[0] = 0x14;
8834 spec->autocfg.speaker_pins[1] = 0x15;
8835 spec->autocfg.speaker_pins[2] = 0x16;
8836 spec->autocfg.speaker_pins[3] = 0x17;
8837 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008838}
8839
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008840static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008841{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008842 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008843
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008844 spec->autocfg.hp_pins[0] = 0x1b;
8845 spec->autocfg.speaker_pins[0] = 0x14;
8846 spec->autocfg.speaker_pins[1] = 0x15;
8847 spec->autocfg.speaker_pins[2] = 0x16;
8848 spec->autocfg.speaker_pins[3] = 0x17;
8849 spec->autocfg.speaker_pins[4] = 0x1a;
8850 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008851}
8852
Guido Günther3e1647c2009-06-05 00:47:26 +02008853static void alc883_vaiott_init_hook(struct hda_codec *codec)
8854{
8855 struct alc_spec *spec = codec->spec;
8856
8857 spec->autocfg.hp_pins[0] = 0x15;
8858 spec->autocfg.speaker_pins[0] = 0x14;
8859 spec->autocfg.speaker_pins[1] = 0x17;
8860 alc_automute_amp(codec);
8861}
8862
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008863/*
8864 * generic initialization of ADC, input mixers and output mixers
8865 */
8866static struct hda_verb alc883_auto_init_verbs[] = {
8867 /*
8868 * Unmute ADC0-2 and set the default input to mic-in
8869 */
8870 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8871 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8872 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8873 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8874
Takashi Iwaicb53c622007-08-10 17:21:45 +02008875 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008876 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008877 * Note: PASD motherboards uses the Line In 2 as the input for
8878 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008879 */
8880 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008881 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8882 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8883 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8884 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8885 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008886
8887 /*
8888 * Set up output mixers (0x0c - 0x0f)
8889 */
8890 /* set vol=0 to output mixers */
8891 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8892 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8893 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8894 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8895 /* set up input amps for analog loopback */
8896 /* Amp Indices: DAC = 0, mixer = 1 */
8897 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8898 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8899 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8900 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8901 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8902 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8903 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8904 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8905 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8906 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8907
8908 /* FIXME: use matrix-type input source selection */
8909 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8910 /* Input mixer1 */
8911 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8912 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8913 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008914 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008915 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8916 /* Input mixer2 */
8917 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8918 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8919 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008920 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008921 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008922
8923 { }
8924};
8925
Kailang Yange2757d52008-08-26 13:17:46 +02008926static struct hda_verb alc888_asus_m90v_verbs[] = {
8927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8928 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8929 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8930 /* enable unsolicited event */
8931 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8932 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8933 { } /* end */
8934};
8935
8936static void alc883_nb_mic_automute(struct hda_codec *codec)
8937{
8938 unsigned int present;
8939
8940 present = snd_hda_codec_read(codec, 0x18, 0,
8941 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8942 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8943 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8944 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8945 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8946}
8947
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008948static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008949{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008950 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008951
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008952 spec->autocfg.hp_pins[0] = 0x1b;
8953 spec->autocfg.speaker_pins[0] = 0x14;
8954 spec->autocfg.speaker_pins[1] = 0x15;
8955 spec->autocfg.speaker_pins[2] = 0x16;
8956 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008957}
8958
8959static void alc883_mode2_unsol_event(struct hda_codec *codec,
8960 unsigned int res)
8961{
8962 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008963 case ALC880_MIC_EVENT:
8964 alc883_nb_mic_automute(codec);
8965 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008966 default:
8967 alc_sku_unsol_event(codec, res);
8968 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008969 }
8970}
8971
8972static void alc883_mode2_inithook(struct hda_codec *codec)
8973{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008974 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008975 alc883_nb_mic_automute(codec);
8976}
8977
8978static struct hda_verb alc888_asus_eee1601_verbs[] = {
8979 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8980 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8982 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8983 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8984 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8985 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8986 /* enable unsolicited event */
8987 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8988 { } /* end */
8989};
8990
Kailang Yange2757d52008-08-26 13:17:46 +02008991static void alc883_eee1601_inithook(struct hda_codec *codec)
8992{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008993 struct alc_spec *spec = codec->spec;
8994
8995 spec->autocfg.hp_pins[0] = 0x14;
8996 spec->autocfg.speaker_pins[0] = 0x1b;
8997 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008998}
8999
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009000static struct hda_verb alc889A_mb31_verbs[] = {
9001 /* Init rear pin (used as headphone output) */
9002 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9003 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9004 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9005 /* Init line pin (used as output in 4ch and 6ch mode) */
9006 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9007 /* Init line 2 pin (used as headphone out by default) */
9008 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9009 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9010 { } /* end */
9011};
9012
9013/* Mute speakers according to the headphone jack state */
9014static void alc889A_mb31_automute(struct hda_codec *codec)
9015{
9016 unsigned int present;
9017
9018 /* Mute only in 2ch or 4ch mode */
9019 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9020 == 0x00) {
9021 present = snd_hda_codec_read(codec, 0x15, 0,
9022 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
9023 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9024 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9025 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9026 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9027 }
9028}
9029
9030static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9031{
9032 if ((res >> 26) == ALC880_HP_EVENT)
9033 alc889A_mb31_automute(codec);
9034}
9035
Takashi Iwaicb53c622007-08-10 17:21:45 +02009036#ifdef CONFIG_SND_HDA_POWER_SAVE
9037#define alc883_loopbacks alc880_loopbacks
9038#endif
9039
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009040/* pcm configuration: identical with ALC880 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009041#define alc883_pcm_analog_playback alc880_pcm_analog_playback
9042#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01009043#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009044#define alc883_pcm_digital_playback alc880_pcm_digital_playback
9045#define alc883_pcm_digital_capture alc880_pcm_digital_capture
9046
9047/*
9048 * configuration and preset
9049 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009050static const char *alc883_models[ALC883_MODEL_LAST] = {
9051 [ALC883_3ST_2ch_DIG] = "3stack-dig",
9052 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9053 [ALC883_3ST_6ch] = "3stack-6ch",
9054 [ALC883_6ST_DIG] = "6stack-dig",
9055 [ALC883_TARGA_DIG] = "targa-dig",
9056 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009057 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009058 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009059 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009060 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009061 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009062 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009063 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009064 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009065 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009066 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009067 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9068 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009069 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009070 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009071 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009072 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009073 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009074 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009075 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009076 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009077 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009078 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009079 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009080 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009081 [ALC883_AUTO] = "auto",
9082};
9083
9084static struct snd_pci_quirk alc883_cfg_tbl[] = {
9085 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009086 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009087 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009088 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009089 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9090 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009091 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009092 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9093 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009094 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
9095 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009096 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9097 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009098 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9099 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01009100 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01009101 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009102 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009103 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009104 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009105 ALC888_ACER_ASPIRE_6530G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009106 /* default Acer -- disabled as it causes more problems.
9107 * model=auto should work fine now
9108 */
9109 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009110 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02009111 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009112 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9113 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009114 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009115 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009116 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009117 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009118 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009119 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009120 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009121 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02009122 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009123 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009124 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009125 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9126 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009127 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009128 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02009129 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009130 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9131 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9132 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02009133 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009134 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009135 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009136 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9137 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9138 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9139 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9140 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9141 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
9142 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9143 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9144 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009145 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009146 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9147 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009148 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009149 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009150 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009151 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009152 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009153 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009154 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009155 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009156 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9157 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009158 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009159 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009160 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009161 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009162 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009163 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009164 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009165 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009166 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009167 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9168 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009169 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009170 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009171 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009172 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009173 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009174 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9175 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009176 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08009177 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009178 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Guido Günther3e1647c2009-06-05 00:47:26 +02009179 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009180 {}
9181};
9182
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009183static hda_nid_t alc883_slave_dig_outs[] = {
9184 ALC1200_DIGOUT_NID, 0,
9185};
9186
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009187static hda_nid_t alc1200_slave_dig_outs[] = {
9188 ALC883_DIGOUT_NID, 0,
9189};
9190
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009191static struct alc_config_preset alc883_presets[] = {
9192 [ALC883_3ST_2ch_DIG] = {
9193 .mixers = { alc883_3ST_2ch_mixer },
9194 .init_verbs = { alc883_init_verbs },
9195 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9196 .dac_nids = alc883_dac_nids,
9197 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009198 .dig_in_nid = ALC883_DIGIN_NID,
9199 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9200 .channel_mode = alc883_3ST_2ch_modes,
9201 .input_mux = &alc883_capture_source,
9202 },
9203 [ALC883_3ST_6ch_DIG] = {
9204 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9205 .init_verbs = { alc883_init_verbs },
9206 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9207 .dac_nids = alc883_dac_nids,
9208 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009209 .dig_in_nid = ALC883_DIGIN_NID,
9210 .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 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009215 [ALC883_3ST_6ch] = {
9216 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9217 .init_verbs = { alc883_init_verbs },
9218 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9219 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009220 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9221 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009222 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009223 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009224 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009225 [ALC883_3ST_6ch_INTEL] = {
9226 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9227 .init_verbs = { alc883_init_verbs },
9228 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9229 .dac_nids = alc883_dac_nids,
9230 .dig_out_nid = ALC883_DIGOUT_NID,
9231 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009232 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009233 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9234 .channel_mode = alc883_3ST_6ch_intel_modes,
9235 .need_dac_fix = 1,
9236 .input_mux = &alc883_3stack_6ch_intel,
9237 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009238 [ALC883_6ST_DIG] = {
9239 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9240 .init_verbs = { alc883_init_verbs },
9241 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9242 .dac_nids = alc883_dac_nids,
9243 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009244 .dig_in_nid = ALC883_DIGIN_NID,
9245 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9246 .channel_mode = alc883_sixstack_modes,
9247 .input_mux = &alc883_capture_source,
9248 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009249 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009250 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009251 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9252 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009253 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9254 .dac_nids = alc883_dac_nids,
9255 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009256 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9257 .channel_mode = alc883_3ST_6ch_modes,
9258 .need_dac_fix = 1,
9259 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009260 .unsol_event = alc883_targa_unsol_event,
9261 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009262 },
9263 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009264 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009265 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9266 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009267 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9268 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009269 .adc_nids = alc883_adc_nids_alt,
9270 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009271 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009272 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9273 .channel_mode = alc883_3ST_2ch_modes,
9274 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009275 .unsol_event = alc883_targa_unsol_event,
9276 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009277 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009278 [ALC883_TARGA_8ch_DIG] = {
9279 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9280 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009281 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009282 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9283 .dac_nids = alc883_dac_nids,
9284 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9285 .adc_nids = alc883_adc_nids_rev,
9286 .capsrc_nids = alc883_capsrc_nids_rev,
9287 .dig_out_nid = ALC883_DIGOUT_NID,
9288 .dig_in_nid = ALC883_DIGIN_NID,
9289 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9290 .channel_mode = alc883_4ST_8ch_modes,
9291 .need_dac_fix = 1,
9292 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009293 .unsol_event = alc883_targa_unsol_event,
9294 .init_hook = alc883_targa_init_hook,
David Heidelberger64a8be72009-06-08 16:15:18 +02009295 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009296 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009297 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009298 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9299 * and the headphone jack. Turn this on and rely on the
9300 * standard mute methods whenever the user wants to turn
9301 * these outputs off.
9302 */
9303 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9304 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9305 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009306 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9307 .channel_mode = alc883_3ST_2ch_modes,
9308 .input_mux = &alc883_capture_source,
9309 },
Tobin Davis2880a862007-08-07 11:50:26 +02009310 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009311 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009312 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009313 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9314 .dac_nids = alc883_dac_nids,
9315 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009316 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9317 .channel_mode = alc883_3ST_2ch_modes,
9318 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009319 .unsol_event = alc_automute_amp_unsol_event,
9320 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009321 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009322 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009323 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009324 alc883_chmode_mixer },
9325 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9326 alc888_acer_aspire_4930g_verbs },
9327 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9328 .dac_nids = alc883_dac_nids,
9329 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9330 .adc_nids = alc883_adc_nids_rev,
9331 .capsrc_nids = alc883_capsrc_nids_rev,
9332 .dig_out_nid = ALC883_DIGOUT_NID,
9333 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9334 .channel_mode = alc883_3ST_6ch_modes,
9335 .need_dac_fix = 1,
9336 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009337 ARRAY_SIZE(alc888_2_capture_sources),
9338 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009339 .unsol_event = alc_automute_amp_unsol_event,
9340 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009341 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009342 [ALC888_ACER_ASPIRE_6530G] = {
9343 .mixers = { alc888_acer_aspire_6530_mixer },
9344 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9345 alc888_acer_aspire_6530g_verbs },
9346 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9347 .dac_nids = alc883_dac_nids,
9348 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9349 .adc_nids = alc883_adc_nids_rev,
9350 .capsrc_nids = alc883_capsrc_nids_rev,
9351 .dig_out_nid = ALC883_DIGOUT_NID,
9352 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9353 .channel_mode = alc883_3ST_2ch_modes,
9354 .num_mux_defs =
9355 ARRAY_SIZE(alc888_2_capture_sources),
9356 .input_mux = alc888_acer_aspire_6530_sources,
9357 .unsol_event = alc_automute_amp_unsol_event,
Emilio López320d5922009-06-25 08:18:44 +02009358 .init_hook = alc888_acer_aspire_6530g_init_hook,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009359 },
Hector Martin3b315d72009-06-02 10:54:19 +02009360 [ALC888_ACER_ASPIRE_8930G] = {
9361 .mixers = { alc888_base_mixer,
9362 alc883_chmode_mixer },
9363 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009364 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009365 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9366 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009367 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9368 .adc_nids = alc889_adc_nids,
9369 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009370 .dig_out_nid = ALC883_DIGOUT_NID,
9371 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9372 .channel_mode = alc883_3ST_6ch_modes,
9373 .need_dac_fix = 1,
9374 .const_channel_count = 6,
9375 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009376 ARRAY_SIZE(alc889_capture_sources),
9377 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009378 .unsol_event = alc_automute_amp_unsol_event,
Hector Martin018df412009-06-04 00:13:40 +02009379 .init_hook = alc889_acer_aspire_8930g_init_hook,
Hector Martin3b315d72009-06-02 10:54:19 +02009380 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009381 [ALC883_MEDION] = {
9382 .mixers = { alc883_fivestack_mixer,
9383 alc883_chmode_mixer },
9384 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009385 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009386 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9387 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009388 .adc_nids = alc883_adc_nids_alt,
9389 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009390 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9391 .channel_mode = alc883_sixstack_modes,
9392 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009393 },
Kailang Yang272a5272007-05-14 11:00:38 +02009394 [ALC883_MEDION_MD2] = {
9395 .mixers = { alc883_medion_md2_mixer},
9396 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9397 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9398 .dac_nids = alc883_dac_nids,
9399 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009400 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9401 .channel_mode = alc883_3ST_2ch_modes,
9402 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009403 .unsol_event = alc_automute_amp_unsol_event,
9404 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02009405 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009406 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009407 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009408 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9409 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9410 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009411 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9412 .channel_mode = alc883_3ST_2ch_modes,
9413 .input_mux = &alc883_capture_source,
9414 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009415 [ALC883_CLEVO_M720] = {
9416 .mixers = { alc883_clevo_m720_mixer },
9417 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009418 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9419 .dac_nids = alc883_dac_nids,
9420 .dig_out_nid = ALC883_DIGOUT_NID,
9421 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9422 .channel_mode = alc883_3ST_2ch_modes,
9423 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009424 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009425 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009426 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009427 [ALC883_LENOVO_101E_2ch] = {
9428 .mixers = { alc883_lenovo_101e_2ch_mixer},
9429 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9430 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9431 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009432 .adc_nids = alc883_adc_nids_alt,
9433 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009434 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9435 .channel_mode = alc883_3ST_2ch_modes,
9436 .input_mux = &alc883_lenovo_101e_capture_source,
9437 .unsol_event = alc883_lenovo_101e_unsol_event,
9438 .init_hook = alc883_lenovo_101e_all_automute,
9439 },
Kailang Yang272a5272007-05-14 11:00:38 +02009440 [ALC883_LENOVO_NB0763] = {
9441 .mixers = { alc883_lenovo_nb0763_mixer },
9442 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9443 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9444 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009445 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9446 .channel_mode = alc883_3ST_2ch_modes,
9447 .need_dac_fix = 1,
9448 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009449 .unsol_event = alc_automute_amp_unsol_event,
9450 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02009451 },
9452 [ALC888_LENOVO_MS7195_DIG] = {
9453 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9454 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9455 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9456 .dac_nids = alc883_dac_nids,
9457 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009458 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9459 .channel_mode = alc883_3ST_6ch_modes,
9460 .need_dac_fix = 1,
9461 .input_mux = &alc883_capture_source,
9462 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9463 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009464 },
9465 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009466 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009467 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9468 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9469 .dac_nids = alc883_dac_nids,
9470 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009471 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9472 .channel_mode = alc883_3ST_2ch_modes,
9473 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009474 .unsol_event = alc_automute_amp_unsol_event,
9475 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009476 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009477 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009478 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009479 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009480 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9481 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009482 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9483 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009484 .need_dac_fix = 1,
9485 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009486 .unsol_event = alc_automute_amp_unsol_event,
9487 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009488 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009489 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009490 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009491 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9492 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9493 .dac_nids = alc883_dac_nids,
9494 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009495 .dig_in_nid = ALC883_DIGIN_NID,
9496 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9497 .channel_mode = alc883_sixstack_modes,
9498 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009499 .unsol_event = alc_automute_amp_unsol_event,
9500 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009501 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009502 [ALC883_MITAC] = {
9503 .mixers = { alc883_mitac_mixer },
9504 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9505 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9506 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009507 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9508 .channel_mode = alc883_3ST_2ch_modes,
9509 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009510 .unsol_event = alc_automute_amp_unsol_event,
9511 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009512 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009513 [ALC883_FUJITSU_PI2515] = {
9514 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9515 .init_verbs = { alc883_init_verbs,
9516 alc883_2ch_fujitsu_pi2515_verbs},
9517 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9518 .dac_nids = alc883_dac_nids,
9519 .dig_out_nid = ALC883_DIGOUT_NID,
9520 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9521 .channel_mode = alc883_3ST_2ch_modes,
9522 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009523 .unsol_event = alc_automute_amp_unsol_event,
9524 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01009525 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009526 [ALC888_FUJITSU_XA3530] = {
9527 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9528 .init_verbs = { alc883_init_verbs,
9529 alc888_fujitsu_xa3530_verbs },
9530 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9531 .dac_nids = alc883_dac_nids,
9532 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9533 .adc_nids = alc883_adc_nids_rev,
9534 .capsrc_nids = alc883_capsrc_nids_rev,
9535 .dig_out_nid = ALC883_DIGOUT_NID,
9536 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9537 .channel_mode = alc888_4ST_8ch_intel_modes,
9538 .num_mux_defs =
9539 ARRAY_SIZE(alc888_2_capture_sources),
9540 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009541 .unsol_event = alc_automute_amp_unsol_event,
9542 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009543 },
Kailang Yange2757d52008-08-26 13:17:46 +02009544 [ALC888_LENOVO_SKY] = {
9545 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9546 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9547 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9548 .dac_nids = alc883_dac_nids,
9549 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009550 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9551 .channel_mode = alc883_sixstack_modes,
9552 .need_dac_fix = 1,
9553 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009554 .unsol_event = alc_automute_amp_unsol_event,
9555 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009556 },
9557 [ALC888_ASUS_M90V] = {
9558 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9559 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9560 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9561 .dac_nids = alc883_dac_nids,
9562 .dig_out_nid = ALC883_DIGOUT_NID,
9563 .dig_in_nid = ALC883_DIGIN_NID,
9564 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9565 .channel_mode = alc883_3ST_6ch_modes,
9566 .need_dac_fix = 1,
9567 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9568 .unsol_event = alc883_mode2_unsol_event,
9569 .init_hook = alc883_mode2_inithook,
9570 },
9571 [ALC888_ASUS_EEE1601] = {
9572 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009573 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009574 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9575 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9576 .dac_nids = alc883_dac_nids,
9577 .dig_out_nid = ALC883_DIGOUT_NID,
9578 .dig_in_nid = ALC883_DIGIN_NID,
9579 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9580 .channel_mode = alc883_3ST_2ch_modes,
9581 .need_dac_fix = 1,
9582 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009583 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009584 .init_hook = alc883_eee1601_inithook,
9585 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009586 [ALC1200_ASUS_P5Q] = {
9587 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9588 .init_verbs = { alc883_init_verbs },
9589 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9590 .dac_nids = alc883_dac_nids,
9591 .dig_out_nid = ALC1200_DIGOUT_NID,
9592 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009593 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009594 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9595 .channel_mode = alc883_sixstack_modes,
9596 .input_mux = &alc883_capture_source,
9597 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009598 [ALC889A_MB31] = {
9599 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9600 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9601 alc880_gpio1_init_verbs },
9602 .adc_nids = alc883_adc_nids,
9603 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9604 .dac_nids = alc883_dac_nids,
9605 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9606 .channel_mode = alc889A_mb31_6ch_modes,
9607 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9608 .input_mux = &alc889A_mb31_capture_source,
9609 .dig_out_nid = ALC883_DIGOUT_NID,
9610 .unsol_event = alc889A_mb31_unsol_event,
9611 .init_hook = alc889A_mb31_automute,
9612 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009613 [ALC883_SONY_VAIO_TT] = {
9614 .mixers = { alc883_vaiott_mixer },
9615 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9616 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9617 .dac_nids = alc883_dac_nids,
9618 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9619 .channel_mode = alc883_3ST_2ch_modes,
9620 .input_mux = &alc883_capture_source,
9621 .unsol_event = alc_automute_amp_unsol_event,
9622 .init_hook = alc883_vaiott_init_hook,
9623 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009624};
9625
9626
9627/*
9628 * BIOS auto configuration
9629 */
9630static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9631 hda_nid_t nid, int pin_type,
9632 int dac_idx)
9633{
9634 /* set as output */
9635 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009636 int idx;
9637
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009638 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009639 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9640 idx = 4;
9641 else
9642 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009643 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9644
9645}
9646
9647static void alc883_auto_init_multi_out(struct hda_codec *codec)
9648{
9649 struct alc_spec *spec = codec->spec;
9650 int i;
9651
9652 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009653 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009654 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009655 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009656 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009657 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009658 }
9659}
9660
9661static void alc883_auto_init_hp_out(struct hda_codec *codec)
9662{
9663 struct alc_spec *spec = codec->spec;
9664 hda_nid_t pin;
9665
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009666 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009667 if (pin) /* connect to front */
9668 /* use dac 0 */
9669 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009670 pin = spec->autocfg.speaker_pins[0];
9671 if (pin)
9672 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009673}
9674
9675#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9676#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9677
9678static void alc883_auto_init_analog_input(struct hda_codec *codec)
9679{
9680 struct alc_spec *spec = codec->spec;
9681 int i;
9682
9683 for (i = 0; i < AUTO_PIN_LAST; i++) {
9684 hda_nid_t nid = spec->autocfg.input_pins[i];
9685 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009686 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009687 if (nid != ALC883_PIN_CD_NID &&
9688 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009689 snd_hda_codec_write(codec, nid, 0,
9690 AC_VERB_SET_AMP_GAIN_MUTE,
9691 AMP_OUT_MUTE);
9692 }
9693 }
9694}
9695
Takashi Iwaif511b012008-08-15 16:46:42 +02009696#define alc883_auto_init_input_src alc882_auto_init_input_src
9697
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009698/* almost identical with ALC880 parser... */
9699static int alc883_parse_auto_config(struct hda_codec *codec)
9700{
9701 struct alc_spec *spec = codec->spec;
9702 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009703 struct auto_pin_cfg *cfg = &spec->autocfg;
9704 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009705
9706 if (err < 0)
9707 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009708 else if (!err)
9709 return 0; /* no config found */
9710
9711 err = alc_auto_add_mic_boost(codec);
9712 if (err < 0)
9713 return err;
9714
9715 /* hack - override the init verbs */
9716 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009717
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009718 /* setup input_mux for ALC889 */
9719 if (codec->vendor_id == 0x10ec0889) {
9720 /* digital-mic input pin is excluded in alc880_auto_create..()
9721 * because it's under 0x18
9722 */
9723 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9724 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9725 struct hda_input_mux *imux = &spec->private_imux[0];
9726 for (i = 1; i < 3; i++)
9727 memcpy(&spec->private_imux[i],
9728 &spec->private_imux[0],
9729 sizeof(spec->private_imux[0]));
9730 imux->items[imux->num_items].label = "Int DMic";
9731 imux->items[imux->num_items].index = 0x0b;
9732 imux->num_items++;
9733 spec->num_mux_defs = 3;
9734 spec->input_mux = spec->private_imux;
9735 }
9736 }
9737
Takashi Iwai776e1842007-08-29 15:07:11 +02009738 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009739}
9740
9741/* additional initialization for auto-configuration model */
9742static void alc883_auto_init(struct hda_codec *codec)
9743{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009744 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009745 alc883_auto_init_multi_out(codec);
9746 alc883_auto_init_hp_out(codec);
9747 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009748 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009749 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009750 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009751}
9752
9753static int patch_alc883(struct hda_codec *codec)
9754{
9755 struct alc_spec *spec;
9756 int err, board_config;
9757
9758 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9759 if (spec == NULL)
9760 return -ENOMEM;
9761
9762 codec->spec = spec;
9763
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009764 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9765
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009766 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9767 alc883_models,
9768 alc883_cfg_tbl);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009769 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
9770 /* Pick up systems that don't supply PCI SSID */
9771 switch (codec->subsystem_id) {
9772 case 0x106b3600: /* Macbook 3.1 */
9773 board_config = ALC889A_MB31;
9774 break;
9775 default:
9776 printk(KERN_INFO
9777 "hda_codec: Unknown model for %s, trying "
9778 "auto-probe from BIOS...\n", codec->chip_name);
9779 board_config = ALC883_AUTO;
9780 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009781 }
9782
9783 if (board_config == ALC883_AUTO) {
9784 /* automatic parse from the BIOS config */
9785 err = alc883_parse_auto_config(codec);
9786 if (err < 0) {
9787 alc_free(codec);
9788 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009789 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009790 printk(KERN_INFO
9791 "hda_codec: Cannot set up configuration "
9792 "from BIOS. Using base mode...\n");
9793 board_config = ALC883_3ST_2ch_DIG;
9794 }
9795 }
9796
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009797 err = snd_hda_attach_beep_device(codec, 0x1);
9798 if (err < 0) {
9799 alc_free(codec);
9800 return err;
9801 }
9802
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009803 if (board_config != ALC883_AUTO)
9804 setup_preset(spec, &alc883_presets[board_config]);
9805
Kailang Yang2f893282008-05-27 12:14:47 +02009806 switch (codec->vendor_id) {
9807 case 0x10ec0888:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009808 if (!spec->num_adc_nids) {
9809 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9810 spec->adc_nids = alc883_adc_nids;
9811 }
9812 if (!spec->capsrc_nids)
9813 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009814 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009815 break;
9816 case 0x10ec0889:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009817 if (!spec->num_adc_nids) {
9818 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9819 spec->adc_nids = alc889_adc_nids;
9820 }
9821 if (!spec->capsrc_nids)
9822 spec->capsrc_nids = alc889_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009823 break;
9824 default:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009825 if (!spec->num_adc_nids) {
9826 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9827 spec->adc_nids = alc883_adc_nids;
9828 }
9829 if (!spec->capsrc_nids)
9830 spec->capsrc_nids = alc883_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009831 break;
9832 }
9833
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009834 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9835 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009836 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009837
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009838 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9839 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9840
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009841 if (!spec->cap_mixer)
9842 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009843 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009844
Takashi Iwai2134ea42008-01-10 16:53:55 +01009845 spec->vmaster_nid = 0x0c;
9846
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009847 codec->patch_ops = alc_patch_ops;
9848 if (board_config == ALC883_AUTO)
9849 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009850
Takashi Iwaicb53c622007-08-10 17:21:45 +02009851#ifdef CONFIG_SND_HDA_POWER_SAVE
9852 if (!spec->loopback.amplist)
9853 spec->loopback.amplist = alc883_loopbacks;
9854#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009855 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009856
9857 return 0;
9858}
9859
9860/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009861 * ALC262 support
9862 */
9863
9864#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9865#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9866
9867#define alc262_dac_nids alc260_dac_nids
9868#define alc262_adc_nids alc882_adc_nids
9869#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009870#define alc262_capsrc_nids alc882_capsrc_nids
9871#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009872
9873#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009874#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009875
Kailang Yang4e555fe2008-08-26 13:05:55 +02009876static hda_nid_t alc262_dmic_adc_nids[1] = {
9877 /* ADC0 */
9878 0x09
9879};
9880
9881static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9882
Kailang Yangdf694da2005-12-05 19:42:22 +01009883static struct snd_kcontrol_new alc262_base_mixer[] = {
9884 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9885 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9886 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9887 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9888 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9889 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009892 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009893 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9894 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009895 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009896 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9898 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9899 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009900 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009901};
9902
Takashi Iwaice875f02008-01-28 18:17:43 +01009903/* update HP, line and mono-out pins according to the master switch */
9904static void alc262_hp_master_update(struct hda_codec *codec)
9905{
9906 struct alc_spec *spec = codec->spec;
9907 int val = spec->master_sw;
9908
9909 /* HP & line-out */
9910 snd_hda_codec_write_cache(codec, 0x1b, 0,
9911 AC_VERB_SET_PIN_WIDGET_CONTROL,
9912 val ? PIN_HP : 0);
9913 snd_hda_codec_write_cache(codec, 0x15, 0,
9914 AC_VERB_SET_PIN_WIDGET_CONTROL,
9915 val ? PIN_HP : 0);
9916 /* mono (speaker) depending on the HP jack sense */
9917 val = val && !spec->jack_present;
9918 snd_hda_codec_write_cache(codec, 0x16, 0,
9919 AC_VERB_SET_PIN_WIDGET_CONTROL,
9920 val ? PIN_OUT : 0);
9921}
9922
9923static void alc262_hp_bpc_automute(struct hda_codec *codec)
9924{
9925 struct alc_spec *spec = codec->spec;
9926 unsigned int presence;
9927 presence = snd_hda_codec_read(codec, 0x1b, 0,
9928 AC_VERB_GET_PIN_SENSE, 0);
9929 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9930 alc262_hp_master_update(codec);
9931}
9932
9933static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9934{
9935 if ((res >> 26) != ALC880_HP_EVENT)
9936 return;
9937 alc262_hp_bpc_automute(codec);
9938}
9939
9940static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9941{
9942 struct alc_spec *spec = codec->spec;
9943 unsigned int presence;
9944 presence = snd_hda_codec_read(codec, 0x15, 0,
9945 AC_VERB_GET_PIN_SENSE, 0);
9946 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9947 alc262_hp_master_update(codec);
9948}
9949
9950static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9951 unsigned int res)
9952{
9953 if ((res >> 26) != ALC880_HP_EVENT)
9954 return;
9955 alc262_hp_wildwest_automute(codec);
9956}
9957
Takashi Iwaib72519b2009-05-08 14:31:55 +02009958#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009959
9960static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9961 struct snd_ctl_elem_value *ucontrol)
9962{
9963 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9964 struct alc_spec *spec = codec->spec;
9965 int val = !!*ucontrol->value.integer.value;
9966
9967 if (val == spec->master_sw)
9968 return 0;
9969 spec->master_sw = val;
9970 alc262_hp_master_update(codec);
9971 return 1;
9972}
9973
Takashi Iwaib72519b2009-05-08 14:31:55 +02009974#define ALC262_HP_MASTER_SWITCH \
9975 { \
9976 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9977 .name = "Master Playback Switch", \
9978 .info = snd_ctl_boolean_mono_info, \
9979 .get = alc262_hp_master_sw_get, \
9980 .put = alc262_hp_master_sw_put, \
9981 }
9982
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009983static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009984 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009985 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9986 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009988 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9989 HDA_OUTPUT),
9990 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9991 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9993 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009994 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9996 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009997 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009998 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9999 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10000 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10001 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010002 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10003 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10004 { } /* end */
10005};
10006
Kailang Yangcd7509a2007-01-26 18:33:17 +010010007static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010008 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010009 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10010 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10011 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10012 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010013 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10014 HDA_OUTPUT),
10015 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10016 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010017 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10018 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010019 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010020 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10021 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10022 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10023 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010024 { } /* end */
10025};
10026
10027static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10028 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10029 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010030 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010031 { } /* end */
10032};
10033
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010034/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010035static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010036{
10037 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010038
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010039 spec->autocfg.hp_pins[0] = 0x15;
10040 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
10041 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010042}
10043
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010044static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010045 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10046 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010047 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10048 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10049 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10050 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10051 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10052 { } /* end */
10053};
10054
10055static struct hda_verb alc262_hp_t5735_verbs[] = {
10056 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10058
10059 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10060 { }
10061};
10062
Kailang Yang8c427222008-01-10 13:03:59 +010010063static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010064 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10065 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010066 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10067 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010068 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10069 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10070 { } /* end */
10071};
10072
10073static struct hda_verb alc262_hp_rp5700_verbs[] = {
10074 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10075 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10076 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10077 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10078 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10079 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10080 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10081 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10082 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10083 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10084 {}
10085};
10086
10087static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10088 .num_items = 1,
10089 .items = {
10090 { "Line", 0x1 },
10091 },
10092};
10093
Takashi Iwai42171c12009-05-08 14:11:43 +020010094/* bind hp and internal speaker mute (with plug check) as master switch */
10095static void alc262_hippo_master_update(struct hda_codec *codec)
10096{
10097 struct alc_spec *spec = codec->spec;
10098 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10099 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10100 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10101 unsigned int mute;
10102
10103 /* HP */
10104 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10105 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10106 HDA_AMP_MUTE, mute);
10107 /* mute internal speaker per jack sense */
10108 if (spec->jack_present)
10109 mute = HDA_AMP_MUTE;
10110 if (line_nid)
10111 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10112 HDA_AMP_MUTE, mute);
10113 if (speaker_nid && speaker_nid != line_nid)
10114 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10115 HDA_AMP_MUTE, mute);
10116}
10117
10118#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10119
10120static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10121 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010122{
10123 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010124 struct alc_spec *spec = codec->spec;
10125 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010126
Takashi Iwai42171c12009-05-08 14:11:43 +020010127 if (val == spec->master_sw)
10128 return 0;
10129 spec->master_sw = val;
10130 alc262_hippo_master_update(codec);
10131 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010132}
Takashi Iwai5b319542007-07-26 11:49:22 +020010133
Takashi Iwai42171c12009-05-08 14:11:43 +020010134#define ALC262_HIPPO_MASTER_SWITCH \
10135 { \
10136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10137 .name = "Master Playback Switch", \
10138 .info = snd_ctl_boolean_mono_info, \
10139 .get = alc262_hippo_master_sw_get, \
10140 .put = alc262_hippo_master_sw_put, \
10141 }
10142
10143static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10144 ALC262_HIPPO_MASTER_SWITCH,
10145 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10146 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10147 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10148 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10149 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10150 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10151 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10152 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10153 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10154 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10155 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10156 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10157 { } /* end */
10158};
10159
10160static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10161 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10162 ALC262_HIPPO_MASTER_SWITCH,
10163 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10164 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10165 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10166 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10167 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10168 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10169 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10170 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10171 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10172 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10173 { } /* end */
10174};
10175
10176/* mute/unmute internal speaker according to the hp jack and mute state */
10177static void alc262_hippo_automute(struct hda_codec *codec)
10178{
10179 struct alc_spec *spec = codec->spec;
10180 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10181 unsigned int present;
10182
10183 /* need to execute and sync at first */
10184 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10185 present = snd_hda_codec_read(codec, hp_nid, 0,
10186 AC_VERB_GET_PIN_SENSE, 0);
10187 spec->jack_present = (present & 0x80000000) != 0;
10188 alc262_hippo_master_update(codec);
10189}
10190
10191static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10192{
10193 if ((res >> 26) != ALC880_HP_EVENT)
10194 return;
10195 alc262_hippo_automute(codec);
10196}
10197
10198static void alc262_hippo_init_hook(struct hda_codec *codec)
10199{
10200 struct alc_spec *spec = codec->spec;
10201
10202 spec->autocfg.hp_pins[0] = 0x15;
10203 spec->autocfg.speaker_pins[0] = 0x14;
10204 alc262_hippo_automute(codec);
10205}
10206
10207static void alc262_hippo1_init_hook(struct hda_codec *codec)
10208{
10209 struct alc_spec *spec = codec->spec;
10210
10211 spec->autocfg.hp_pins[0] = 0x1b;
10212 spec->autocfg.speaker_pins[0] = 0x14;
10213 alc262_hippo_automute(codec);
10214}
10215
10216
Kailang Yang272a5272007-05-14 11:00:38 +020010217static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010218 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010219 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010220 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10221 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10222 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10223 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10224 { } /* end */
10225};
10226
Kailang Yang83c34212007-07-05 11:43:05 +020010227static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010228 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10229 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010230 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10231 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10232 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10233 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10234 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10235 { } /* end */
10236};
Kailang Yang272a5272007-05-14 11:00:38 +020010237
Tony Vroonba340e82009-02-02 19:01:30 +000010238static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10239 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10240 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10241 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10242 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10243 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10244 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10245 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10246 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10247 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10248 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10249 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10250 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10251 { } /* end */
10252};
10253
10254static struct hda_verb alc262_tyan_verbs[] = {
10255 /* Headphone automute */
10256 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10257 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10258 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10259
10260 /* P11 AUX_IN, white 4-pin connector */
10261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10262 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10263 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10264 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10265
10266 {}
10267};
10268
10269/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010270static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010271{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010272 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010273
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010274 spec->autocfg.hp_pins[0] = 0x1b;
10275 spec->autocfg.speaker_pins[0] = 0x15;
10276 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +000010277}
10278
Tony Vroonba340e82009-02-02 19:01:30 +000010279
Kailang Yangdf694da2005-12-05 19:42:22 +010010280#define alc262_capture_mixer alc882_capture_mixer
10281#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10282
10283/*
10284 * generic initialization of ADC, input mixers and output mixers
10285 */
10286static struct hda_verb alc262_init_verbs[] = {
10287 /*
10288 * Unmute ADC0-2 and set the default input to mic-in
10289 */
10290 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10292 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10293 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10294 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10295 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10296
Takashi Iwaicb53c622007-08-10 17:21:45 +020010297 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010298 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010299 * Note: PASD motherboards uses the Line In 2 as the input for
10300 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010301 */
10302 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010303 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10304 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10305 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010308
10309 /*
10310 * Set up output mixers (0x0c - 0x0e)
10311 */
10312 /* set vol=0 to output mixers */
10313 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10314 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10315 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10316 /* set up input amps for analog loopback */
10317 /* Amp Indices: DAC = 0, mixer = 1 */
10318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10319 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10320 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10321 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10322 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10323 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10324
10325 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10326 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10327 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10328 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10329 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10330 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10331
10332 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10333 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10334 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10335 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10336 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010337
Kailang Yangdf694da2005-12-05 19:42:22 +010010338 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10339 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010340
Kailang Yangdf694da2005-12-05 19:42:22 +010010341 /* FIXME: use matrix-type input source selection */
10342 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10343 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10345 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10347 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10348 /* Input mixer2 */
10349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10350 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10351 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10352 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10353 /* Input mixer3 */
10354 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10355 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10356 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010357 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010358
10359 { }
10360};
10361
Kailang Yang4e555fe2008-08-26 13:05:55 +020010362static struct hda_verb alc262_eapd_verbs[] = {
10363 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10364 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10365 { }
10366};
10367
Kailang Yangccc656c2006-10-17 12:32:26 +020010368static struct hda_verb alc262_hippo_unsol_verbs[] = {
10369 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10370 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10371 {}
10372};
10373
10374static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10375 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10376 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10377 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10378
10379 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10380 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10381 {}
10382};
10383
Kailang Yang272a5272007-05-14 11:00:38 +020010384static struct hda_verb alc262_sony_unsol_verbs[] = {
10385 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10386 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10387 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10388
10389 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10390 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010391 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010392};
10393
Kailang Yang4e555fe2008-08-26 13:05:55 +020010394static struct hda_input_mux alc262_dmic_capture_source = {
10395 .num_items = 2,
10396 .items = {
10397 { "Int DMic", 0x9 },
10398 { "Mic", 0x0 },
10399 },
10400};
10401
10402static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10403 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10404 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10405 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10406 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10407 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010408 { } /* end */
10409};
10410
10411static struct hda_verb alc262_toshiba_s06_verbs[] = {
10412 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10413 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10414 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10415 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10416 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10417 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10418 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10419 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10420 {}
10421};
10422
10423static void alc262_dmic_automute(struct hda_codec *codec)
10424{
10425 unsigned int present;
10426
10427 present = snd_hda_codec_read(codec, 0x18, 0,
10428 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10429 snd_hda_codec_write(codec, 0x22, 0,
10430 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10431}
10432
Kailang Yang4e555fe2008-08-26 13:05:55 +020010433
10434/* unsolicited event for HP jack sensing */
10435static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10436 unsigned int res)
10437{
Kailang Yang4e555fe2008-08-26 13:05:55 +020010438 if ((res >> 26) == ALC880_MIC_EVENT)
10439 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010440 else
10441 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010442}
10443
10444static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10445{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010446 struct alc_spec *spec = codec->spec;
10447
10448 spec->autocfg.hp_pins[0] = 0x15;
10449 spec->autocfg.speaker_pins[0] = 0x14;
10450 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010451 alc262_dmic_automute(codec);
10452}
10453
Takashi Iwai834be882006-03-01 14:16:17 +010010454/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010455 * nec model
10456 * 0x15 = headphone
10457 * 0x16 = internal speaker
10458 * 0x18 = external mic
10459 */
10460
10461static struct snd_kcontrol_new alc262_nec_mixer[] = {
10462 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10463 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10464
10465 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10467 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10468
10469 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10470 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10471 { } /* end */
10472};
10473
10474static struct hda_verb alc262_nec_verbs[] = {
10475 /* Unmute Speaker */
10476 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10477
10478 /* Headphone */
10479 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10480 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10481
10482 /* External mic to headphone */
10483 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10484 /* External mic to speaker */
10485 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10486 {}
10487};
10488
10489/*
Takashi Iwai834be882006-03-01 14:16:17 +010010490 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010491 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10492 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010493 */
10494
10495#define ALC_HP_EVENT 0x37
10496
10497static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10498 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10499 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010500 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10501 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010502 {}
10503};
10504
Jiang zhe0e31daf2008-03-20 12:12:39 +010010505static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10506 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10507 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10508 {}
10509};
10510
Takashi Iwai834be882006-03-01 14:16:17 +010010511static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010512 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010513 .items = {
10514 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010515 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010516 { "CD", 0x4 },
10517 },
10518};
10519
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010520static struct hda_input_mux alc262_HP_capture_source = {
10521 .num_items = 5,
10522 .items = {
10523 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010524 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010525 { "Line", 0x2 },
10526 { "CD", 0x4 },
10527 { "AUX IN", 0x6 },
10528 },
10529};
10530
zhejiangaccbe492007-08-31 12:36:05 +020010531static struct hda_input_mux alc262_HP_D7000_capture_source = {
10532 .num_items = 4,
10533 .items = {
10534 { "Mic", 0x0 },
10535 { "Front Mic", 0x2 },
10536 { "Line", 0x1 },
10537 { "CD", 0x4 },
10538 },
10539};
10540
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010541/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010542static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10543{
10544 struct alc_spec *spec = codec->spec;
10545 unsigned int mute;
10546
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010547 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010548 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010549 /* need to execute and sync at first */
10550 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010551 /* check laptop HP jack */
10552 present = snd_hda_codec_read(codec, 0x14, 0,
10553 AC_VERB_GET_PIN_SENSE, 0);
10554 /* need to execute and sync at first */
10555 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10556 /* check docking HP jack */
10557 present |= snd_hda_codec_read(codec, 0x1b, 0,
10558 AC_VERB_GET_PIN_SENSE, 0);
10559 if (present & AC_PINSENSE_PRESENCE)
10560 spec->jack_present = 1;
10561 else
10562 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010563 spec->sense_updated = 1;
10564 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010565 /* unmute internal speaker only if both HPs are unplugged and
10566 * master switch is on
10567 */
10568 if (spec->jack_present)
10569 mute = HDA_AMP_MUTE;
10570 else
Takashi Iwai834be882006-03-01 14:16:17 +010010571 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010572 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10573 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010574}
10575
10576/* unsolicited event for HP jack sensing */
10577static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10578 unsigned int res)
10579{
10580 if ((res >> 26) != ALC_HP_EVENT)
10581 return;
10582 alc262_fujitsu_automute(codec, 1);
10583}
10584
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010585static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10586{
10587 alc262_fujitsu_automute(codec, 1);
10588}
10589
Takashi Iwai834be882006-03-01 14:16:17 +010010590/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010591static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10592 .ops = &snd_hda_bind_vol,
10593 .values = {
10594 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10595 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10596 0
10597 },
10598};
Takashi Iwai834be882006-03-01 14:16:17 +010010599
Jiang zhe0e31daf2008-03-20 12:12:39 +010010600/* mute/unmute internal speaker according to the hp jack and mute state */
10601static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10602{
10603 struct alc_spec *spec = codec->spec;
10604 unsigned int mute;
10605
10606 if (force || !spec->sense_updated) {
10607 unsigned int present_int_hp;
10608 /* need to execute and sync at first */
10609 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10610 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10611 AC_VERB_GET_PIN_SENSE, 0);
10612 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10613 spec->sense_updated = 1;
10614 }
10615 if (spec->jack_present) {
10616 /* mute internal speaker */
10617 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10618 HDA_AMP_MUTE, HDA_AMP_MUTE);
10619 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10620 HDA_AMP_MUTE, HDA_AMP_MUTE);
10621 } else {
10622 /* unmute internal speaker if necessary */
10623 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10624 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10625 HDA_AMP_MUTE, mute);
10626 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10627 HDA_AMP_MUTE, mute);
10628 }
10629}
10630
10631/* unsolicited event for HP jack sensing */
10632static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10633 unsigned int res)
10634{
10635 if ((res >> 26) != ALC_HP_EVENT)
10636 return;
10637 alc262_lenovo_3000_automute(codec, 1);
10638}
10639
Takashi Iwai8de56b72009-07-24 16:51:47 +020010640static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10641 int dir, int idx, long *valp)
10642{
10643 int i, change = 0;
10644
10645 for (i = 0; i < 2; i++, valp++)
10646 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10647 HDA_AMP_MUTE,
10648 *valp ? 0 : HDA_AMP_MUTE);
10649 return change;
10650}
10651
Takashi Iwai834be882006-03-01 14:16:17 +010010652/* bind hp and internal speaker mute (with plug check) */
10653static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10654 struct snd_ctl_elem_value *ucontrol)
10655{
10656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10657 long *valp = ucontrol->value.integer.value;
10658 int change;
10659
Takashi Iwai8de56b72009-07-24 16:51:47 +020010660 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10661 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010662 if (change)
10663 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010664 return change;
10665}
10666
10667static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010668 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010669 {
10670 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10671 .name = "Master Playback Switch",
10672 .info = snd_hda_mixer_amp_switch_info,
10673 .get = snd_hda_mixer_amp_switch_get,
10674 .put = alc262_fujitsu_master_sw_put,
10675 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10676 },
10677 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10678 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10679 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010682 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10683 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10684 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010685 { } /* end */
10686};
10687
Jiang zhe0e31daf2008-03-20 12:12:39 +010010688/* bind hp and internal speaker mute (with plug check) */
10689static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10690 struct snd_ctl_elem_value *ucontrol)
10691{
10692 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10693 long *valp = ucontrol->value.integer.value;
10694 int change;
10695
Takashi Iwai8de56b72009-07-24 16:51:47 +020010696 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010697 if (change)
10698 alc262_lenovo_3000_automute(codec, 0);
10699 return change;
10700}
10701
10702static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10703 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10704 {
10705 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10706 .name = "Master Playback Switch",
10707 .info = snd_hda_mixer_amp_switch_info,
10708 .get = snd_hda_mixer_amp_switch_get,
10709 .put = alc262_lenovo_3000_master_sw_put,
10710 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10711 },
10712 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10713 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10714 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10715 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10716 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10717 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10718 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10719 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10720 { } /* end */
10721};
10722
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010723static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10724 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010725 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010726 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10727 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10728 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10729 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10730 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10731 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10732 { } /* end */
10733};
10734
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010735/* additional init verbs for Benq laptops */
10736static struct hda_verb alc262_EAPD_verbs[] = {
10737 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10738 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10739 {}
10740};
10741
Kailang Yang83c34212007-07-05 11:43:05 +020010742static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10743 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10744 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10745
10746 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10747 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10748 {}
10749};
10750
Tobin Davisf651b502007-10-26 12:40:47 +020010751/* Samsung Q1 Ultra Vista model setup */
10752static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010753 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10754 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10756 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10757 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010758 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010759 { } /* end */
10760};
10761
10762static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010763 /* output mixer */
10764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10767 /* speaker */
10768 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10769 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10770 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10771 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10772 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010773 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010774 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10775 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10776 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10777 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10778 /* internal mic */
10779 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10780 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10781 /* ADC, choose mic */
10782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10783 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10784 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10785 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10786 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10787 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10788 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10789 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10790 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10791 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010792 {}
10793};
10794
Tobin Davisf651b502007-10-26 12:40:47 +020010795/* mute/unmute internal speaker according to the hp jack and mute state */
10796static void alc262_ultra_automute(struct hda_codec *codec)
10797{
10798 struct alc_spec *spec = codec->spec;
10799 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010800
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010801 mute = 0;
10802 /* auto-mute only when HP is used as HP */
10803 if (!spec->cur_mux[0]) {
10804 unsigned int present;
10805 /* need to execute and sync at first */
10806 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10807 present = snd_hda_codec_read(codec, 0x15, 0,
10808 AC_VERB_GET_PIN_SENSE, 0);
10809 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10810 if (spec->jack_present)
10811 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010812 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010813 /* mute/unmute internal speaker */
10814 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10815 HDA_AMP_MUTE, mute);
10816 /* mute/unmute HP */
10817 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10818 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010819}
10820
10821/* unsolicited event for HP jack sensing */
10822static void alc262_ultra_unsol_event(struct hda_codec *codec,
10823 unsigned int res)
10824{
10825 if ((res >> 26) != ALC880_HP_EVENT)
10826 return;
10827 alc262_ultra_automute(codec);
10828}
10829
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010830static struct hda_input_mux alc262_ultra_capture_source = {
10831 .num_items = 2,
10832 .items = {
10833 { "Mic", 0x1 },
10834 { "Headphone", 0x7 },
10835 },
10836};
10837
10838static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10839 struct snd_ctl_elem_value *ucontrol)
10840{
10841 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10842 struct alc_spec *spec = codec->spec;
10843 int ret;
10844
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010845 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010846 if (!ret)
10847 return 0;
10848 /* reprogram the HP pin as mic or HP according to the input source */
10849 snd_hda_codec_write_cache(codec, 0x15, 0,
10850 AC_VERB_SET_PIN_WIDGET_CONTROL,
10851 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10852 alc262_ultra_automute(codec); /* mute/unmute HP */
10853 return ret;
10854}
10855
10856static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10857 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10858 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10859 {
10860 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10861 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010862 .info = alc_mux_enum_info,
10863 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010864 .put = alc262_ultra_mux_enum_put,
10865 },
10866 { } /* end */
10867};
10868
Kailang Yangdf694da2005-12-05 19:42:22 +010010869/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010870static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10871 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010872{
10873 hda_nid_t nid;
10874 int err;
10875
10876 spec->multiout.num_dacs = 1; /* only use one dac */
10877 spec->multiout.dac_nids = spec->private_dac_nids;
10878 spec->multiout.dac_nids[0] = 2;
10879
10880 nid = cfg->line_out_pins[0];
10881 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010882 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10883 "Front Playback Volume",
10884 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, 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 "Front Playback Switch",
10889 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10890 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010891 return err;
10892 }
10893
Takashi Iwai82bc9552006-03-21 11:24:42 +010010894 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010895 if (nid) {
10896 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010897 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10898 "Speaker Playback Volume",
10899 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10900 HDA_OUTPUT));
10901 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010902 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010903 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10904 "Speaker Playback Switch",
10905 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10906 HDA_OUTPUT));
10907 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010908 return err;
10909 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010910 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10911 "Speaker Playback Switch",
10912 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10913 HDA_OUTPUT));
10914 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010915 return err;
10916 }
10917 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010918 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010919 if (nid) {
10920 /* spec->multiout.hp_nid = 2; */
10921 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010922 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10923 "Headphone Playback Volume",
10924 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10925 HDA_OUTPUT));
10926 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010927 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010928 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10929 "Headphone Playback Switch",
10930 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10931 HDA_OUTPUT));
10932 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010933 return err;
10934 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010935 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10936 "Headphone Playback Switch",
10937 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10938 HDA_OUTPUT));
10939 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010940 return err;
10941 }
10942 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010943 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010944}
10945
Takashi Iwai8c927b42009-06-22 10:56:54 +020010946static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec,
10947 const struct auto_pin_cfg *cfg)
10948{
10949 int err;
10950
10951 err = alc880_auto_create_analog_input_ctls(spec, cfg);
10952 if (err < 0)
10953 return err;
10954 /* digital-mic input pin is excluded in alc880_auto_create..()
10955 * because it's under 0x18
10956 */
10957 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
10958 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
10959 struct hda_input_mux *imux = &spec->private_imux[0];
10960 imux->items[imux->num_items].label = "Int Mic";
10961 imux->items[imux->num_items].index = 0x09;
10962 imux->num_items++;
10963 }
10964 return 0;
10965}
10966
Kailang Yangdf694da2005-12-05 19:42:22 +010010967
10968/*
10969 * generic initialization of ADC, input mixers and output mixers
10970 */
10971static struct hda_verb alc262_volume_init_verbs[] = {
10972 /*
10973 * Unmute ADC0-2 and set the default input to mic-in
10974 */
10975 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10976 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10977 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10978 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10979 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10980 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10981
Takashi Iwaicb53c622007-08-10 17:21:45 +020010982 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010983 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010984 * Note: PASD motherboards uses the Line In 2 as the input for
10985 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010986 */
10987 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010988 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10989 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10990 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10991 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10992 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010993
10994 /*
10995 * Set up output mixers (0x0c - 0x0f)
10996 */
10997 /* set vol=0 to output mixers */
10998 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10999 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11000 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011001
Kailang Yangdf694da2005-12-05 19:42:22 +010011002 /* set up input amps for analog loopback */
11003 /* Amp Indices: DAC = 0, mixer = 1 */
11004 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11005 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11006 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11007 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11008 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11009 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11010
11011 /* FIXME: use matrix-type input source selection */
11012 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11013 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11014 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11015 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11016 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11017 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11018 /* Input mixer2 */
11019 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11020 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11021 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11022 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11023 /* Input mixer3 */
11024 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11025 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11026 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11027 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11028
11029 { }
11030};
11031
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011032static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11033 /*
11034 * Unmute ADC0-2 and set the default input to mic-in
11035 */
11036 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11037 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11038 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11040 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11041 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11042
Takashi Iwaicb53c622007-08-10 17:21:45 +020011043 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011044 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011045 * Note: PASD motherboards uses the Line In 2 as the input for
11046 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011047 */
11048 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011049 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11050 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11051 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11052 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11053 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11054 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11055 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011056
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011057 /*
11058 * Set up output mixers (0x0c - 0x0e)
11059 */
11060 /* set vol=0 to output mixers */
11061 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11062 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11063 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11064
11065 /* set up input amps for analog loopback */
11066 /* Amp Indices: DAC = 0, mixer = 1 */
11067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11069 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11070 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11071 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11072 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11073
Takashi Iwaice875f02008-01-28 18:17:43 +010011074 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011075 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11076 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11077
11078 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11079 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11080
11081 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11082 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11083
11084 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11085 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11086 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11087 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11088 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11089
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011090 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011091 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11092 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011093 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011094 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11095 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11096
11097
11098 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011099 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11100 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011101 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011102 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11103 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11104 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11105 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11106 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11107 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11108 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11109 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011110 /* Input mixer2 */
11111 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011112 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11113 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11114 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11115 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11116 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11117 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11118 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11119 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011120 /* Input mixer3 */
11121 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11123 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11124 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11125 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11126 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11127 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11128 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11129 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011130
Takashi Iwaice875f02008-01-28 18:17:43 +010011131 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11132
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011133 { }
11134};
11135
Kailang Yangcd7509a2007-01-26 18:33:17 +010011136static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11137 /*
11138 * Unmute ADC0-2 and set the default input to mic-in
11139 */
11140 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11141 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11142 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11143 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11144 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11145 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11146
Takashi Iwaicb53c622007-08-10 17:21:45 +020011147 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011148 * mixer widget
11149 * Note: PASD motherboards uses the Line In 2 as the input for front
11150 * panel mic (mic 2)
11151 */
11152 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011153 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11154 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11155 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11156 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11157 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11158 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11159 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11160 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011161 /*
11162 * Set up output mixers (0x0c - 0x0e)
11163 */
11164 /* set vol=0 to output mixers */
11165 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11166 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11167 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11168
11169 /* set up input amps for analog loopback */
11170 /* Amp Indices: DAC = 0, mixer = 1 */
11171 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11172 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11173 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11174 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11175 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11176 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11177
11178
11179 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11180 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11181 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11182 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11183 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11184 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11185 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11186
11187 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11189
11190 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11191 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11192
11193 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11194 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11195 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11196 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11197 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11198 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11199
11200 /* FIXME: use matrix-type input source selection */
11201 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11202 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11203 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11204 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11205 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11206 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11207 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11208 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11210 /* Input mixer2 */
11211 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11212 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11213 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11214 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11215 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11216 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11217 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11218 /* Input mixer3 */
11219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11220 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11221 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11222 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11223 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11224 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11225 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11226
Takashi Iwaice875f02008-01-28 18:17:43 +010011227 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11228
Kailang Yangcd7509a2007-01-26 18:33:17 +010011229 { }
11230};
11231
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011232static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11233
11234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11235 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11236 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11237
11238 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11239 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11240 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11241 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11242
11243 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11244 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11245 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11246 {}
11247};
11248
11249
Takashi Iwaicb53c622007-08-10 17:21:45 +020011250#ifdef CONFIG_SND_HDA_POWER_SAVE
11251#define alc262_loopbacks alc880_loopbacks
11252#endif
11253
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011254/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011255#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11256#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11257#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11258#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11259
11260/*
11261 * BIOS auto configuration
11262 */
11263static int alc262_parse_auto_config(struct hda_codec *codec)
11264{
11265 struct alc_spec *spec = codec->spec;
11266 int err;
11267 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11268
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011269 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11270 alc262_ignore);
11271 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011272 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011273 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011274 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011275 spec->multiout.max_channels = 2;
11276 spec->no_analog = 1;
11277 goto dig_only;
11278 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011279 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011280 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011281 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11282 if (err < 0)
11283 return err;
11284 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
11285 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011286 return err;
11287
11288 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11289
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011290 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011291 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011292 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011293 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011294 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011295 if (spec->autocfg.dig_in_pin)
11296 spec->dig_in_nid = ALC262_DIGIN_NID;
11297
Takashi Iwai603c4012008-07-30 15:01:44 +020011298 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011299 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011300
Takashi Iwaid88897e2008-10-31 15:01:37 +010011301 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011302 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011303 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011304
Takashi Iwai776e1842007-08-29 15:07:11 +020011305 err = alc_auto_add_mic_boost(codec);
11306 if (err < 0)
11307 return err;
11308
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011309 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11310
Kailang Yangdf694da2005-12-05 19:42:22 +010011311 return 1;
11312}
11313
11314#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11315#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11316#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011317#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011318
11319
11320/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011321static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011322{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011323 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011324 alc262_auto_init_multi_out(codec);
11325 alc262_auto_init_hp_out(codec);
11326 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011327 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011328 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011329 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011330}
11331
11332/*
11333 * configuration and preset
11334 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011335static const char *alc262_models[ALC262_MODEL_LAST] = {
11336 [ALC262_BASIC] = "basic",
11337 [ALC262_HIPPO] = "hippo",
11338 [ALC262_HIPPO_1] = "hippo_1",
11339 [ALC262_FUJITSU] = "fujitsu",
11340 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011341 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011342 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011343 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011344 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011345 [ALC262_BENQ_T31] = "benq-t31",
11346 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011347 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011348 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011349 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011350 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011351 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011352 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011353 [ALC262_AUTO] = "auto",
11354};
11355
11356static struct snd_pci_quirk alc262_cfg_tbl[] = {
11357 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011358 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011359 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11360 ALC262_HP_BPC),
11361 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11362 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011363 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11364 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011365 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011366 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011367 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011368 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011369 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011370 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011371 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011372 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011373 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11374 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11375 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011376 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11377 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011378 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011379 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011380 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011381 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011382 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011383 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011384 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11385 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011386 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011387 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011388 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011389 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011390 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011391 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011392 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11393 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011394 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011395 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011396 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011397 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011398 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011399 {}
11400};
11401
11402static struct alc_config_preset alc262_presets[] = {
11403 [ALC262_BASIC] = {
11404 .mixers = { alc262_base_mixer },
11405 .init_verbs = { alc262_init_verbs },
11406 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11407 .dac_nids = alc262_dac_nids,
11408 .hp_nid = 0x03,
11409 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11410 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011411 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011412 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011413 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011414 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020011415 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
11416 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11417 .dac_nids = alc262_dac_nids,
11418 .hp_nid = 0x03,
11419 .dig_out_nid = ALC262_DIGOUT_NID,
11420 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11421 .channel_mode = alc262_modes,
11422 .input_mux = &alc262_capture_source,
11423 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011424 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011425 },
11426 [ALC262_HIPPO_1] = {
11427 .mixers = { alc262_hippo1_mixer },
11428 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11429 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11430 .dac_nids = alc262_dac_nids,
11431 .hp_nid = 0x02,
11432 .dig_out_nid = ALC262_DIGOUT_NID,
11433 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11434 .channel_mode = alc262_modes,
11435 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011436 .unsol_event = alc262_hippo_unsol_event,
11437 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011438 },
Takashi Iwai834be882006-03-01 14:16:17 +010011439 [ALC262_FUJITSU] = {
11440 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011441 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11442 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011443 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11444 .dac_nids = alc262_dac_nids,
11445 .hp_nid = 0x03,
11446 .dig_out_nid = ALC262_DIGOUT_NID,
11447 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11448 .channel_mode = alc262_modes,
11449 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011450 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011451 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011452 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011453 [ALC262_HP_BPC] = {
11454 .mixers = { alc262_HP_BPC_mixer },
11455 .init_verbs = { alc262_HP_BPC_init_verbs },
11456 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11457 .dac_nids = alc262_dac_nids,
11458 .hp_nid = 0x03,
11459 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11460 .channel_mode = alc262_modes,
11461 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011462 .unsol_event = alc262_hp_bpc_unsol_event,
11463 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011464 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011465 [ALC262_HP_BPC_D7000_WF] = {
11466 .mixers = { alc262_HP_BPC_WildWest_mixer },
11467 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11468 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11469 .dac_nids = alc262_dac_nids,
11470 .hp_nid = 0x03,
11471 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11472 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011473 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011474 .unsol_event = alc262_hp_wildwest_unsol_event,
11475 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011476 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011477 [ALC262_HP_BPC_D7000_WL] = {
11478 .mixers = { alc262_HP_BPC_WildWest_mixer,
11479 alc262_HP_BPC_WildWest_option_mixer },
11480 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11481 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11482 .dac_nids = alc262_dac_nids,
11483 .hp_nid = 0x03,
11484 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11485 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011486 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011487 .unsol_event = alc262_hp_wildwest_unsol_event,
11488 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011489 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011490 [ALC262_HP_TC_T5735] = {
11491 .mixers = { alc262_hp_t5735_mixer },
11492 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11493 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11494 .dac_nids = alc262_dac_nids,
11495 .hp_nid = 0x03,
11496 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11497 .channel_mode = alc262_modes,
11498 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011499 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011500 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011501 },
11502 [ALC262_HP_RP5700] = {
11503 .mixers = { alc262_hp_rp5700_mixer },
11504 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11505 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11506 .dac_nids = alc262_dac_nids,
11507 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11508 .channel_mode = alc262_modes,
11509 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011510 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011511 [ALC262_BENQ_ED8] = {
11512 .mixers = { alc262_base_mixer },
11513 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11514 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11515 .dac_nids = alc262_dac_nids,
11516 .hp_nid = 0x03,
11517 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11518 .channel_mode = alc262_modes,
11519 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011520 },
Kailang Yang272a5272007-05-14 11:00:38 +020011521 [ALC262_SONY_ASSAMD] = {
11522 .mixers = { alc262_sony_mixer },
11523 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11524 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11525 .dac_nids = alc262_dac_nids,
11526 .hp_nid = 0x02,
11527 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11528 .channel_mode = alc262_modes,
11529 .input_mux = &alc262_capture_source,
11530 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011531 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011532 },
11533 [ALC262_BENQ_T31] = {
11534 .mixers = { alc262_benq_t31_mixer },
11535 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11536 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11537 .dac_nids = alc262_dac_nids,
11538 .hp_nid = 0x03,
11539 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11540 .channel_mode = alc262_modes,
11541 .input_mux = &alc262_capture_source,
11542 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011543 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011544 },
Tobin Davisf651b502007-10-26 12:40:47 +020011545 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011546 .mixers = { alc262_ultra_mixer },
11547 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011548 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011549 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11550 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011551 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11552 .channel_mode = alc262_modes,
11553 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011554 .adc_nids = alc262_adc_nids, /* ADC0 */
11555 .capsrc_nids = alc262_capsrc_nids,
11556 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011557 .unsol_event = alc262_ultra_unsol_event,
11558 .init_hook = alc262_ultra_automute,
11559 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011560 [ALC262_LENOVO_3000] = {
11561 .mixers = { alc262_lenovo_3000_mixer },
11562 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11563 alc262_lenovo_3000_unsol_verbs },
11564 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11565 .dac_nids = alc262_dac_nids,
11566 .hp_nid = 0x03,
11567 .dig_out_nid = ALC262_DIGOUT_NID,
11568 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11569 .channel_mode = alc262_modes,
11570 .input_mux = &alc262_fujitsu_capture_source,
11571 .unsol_event = alc262_lenovo_3000_unsol_event,
11572 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011573 [ALC262_NEC] = {
11574 .mixers = { alc262_nec_mixer },
11575 .init_verbs = { alc262_nec_verbs },
11576 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11577 .dac_nids = alc262_dac_nids,
11578 .hp_nid = 0x03,
11579 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11580 .channel_mode = alc262_modes,
11581 .input_mux = &alc262_capture_source,
11582 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011583 [ALC262_TOSHIBA_S06] = {
11584 .mixers = { alc262_toshiba_s06_mixer },
11585 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11586 alc262_eapd_verbs },
11587 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11588 .capsrc_nids = alc262_dmic_capsrc_nids,
11589 .dac_nids = alc262_dac_nids,
11590 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011591 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011592 .dig_out_nid = ALC262_DIGOUT_NID,
11593 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11594 .channel_mode = alc262_modes,
11595 .input_mux = &alc262_dmic_capture_source,
11596 .unsol_event = alc262_toshiba_s06_unsol_event,
11597 .init_hook = alc262_toshiba_s06_init_hook,
11598 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011599 [ALC262_TOSHIBA_RX1] = {
11600 .mixers = { alc262_toshiba_rx1_mixer },
11601 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11602 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11603 .dac_nids = alc262_dac_nids,
11604 .hp_nid = 0x03,
11605 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11606 .channel_mode = alc262_modes,
11607 .input_mux = &alc262_capture_source,
11608 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011609 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011610 },
Tony Vroonba340e82009-02-02 19:01:30 +000011611 [ALC262_TYAN] = {
11612 .mixers = { alc262_tyan_mixer },
11613 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11614 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11615 .dac_nids = alc262_dac_nids,
11616 .hp_nid = 0x02,
11617 .dig_out_nid = ALC262_DIGOUT_NID,
11618 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11619 .channel_mode = alc262_modes,
11620 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011621 .unsol_event = alc_automute_amp_unsol_event,
11622 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011623 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011624};
11625
11626static int patch_alc262(struct hda_codec *codec)
11627{
11628 struct alc_spec *spec;
11629 int board_config;
11630 int err;
11631
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011632 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011633 if (spec == NULL)
11634 return -ENOMEM;
11635
11636 codec->spec = spec;
11637#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011638 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11639 * under-run
11640 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011641 {
11642 int tmp;
11643 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11644 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11645 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11646 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11647 }
11648#endif
11649
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011650 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11651
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011652 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11653 alc262_models,
11654 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011655
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011656 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020011657 printk(KERN_INFO "hda_codec: Unknown model for %s, "
11658 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011659 board_config = ALC262_AUTO;
11660 }
11661
11662 if (board_config == ALC262_AUTO) {
11663 /* automatic parse from the BIOS config */
11664 err = alc262_parse_auto_config(codec);
11665 if (err < 0) {
11666 alc_free(codec);
11667 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011668 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011669 printk(KERN_INFO
11670 "hda_codec: Cannot set up configuration "
11671 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011672 board_config = ALC262_BASIC;
11673 }
11674 }
11675
Takashi Iwai07eba612009-02-19 08:06:35 +010011676 if (!spec->no_analog) {
11677 err = snd_hda_attach_beep_device(codec, 0x1);
11678 if (err < 0) {
11679 alc_free(codec);
11680 return err;
11681 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011682 }
11683
Kailang Yangdf694da2005-12-05 19:42:22 +010011684 if (board_config != ALC262_AUTO)
11685 setup_preset(spec, &alc262_presets[board_config]);
11686
Kailang Yangdf694da2005-12-05 19:42:22 +010011687 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11688 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011689
Kailang Yangdf694da2005-12-05 19:42:22 +010011690 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11691 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11692
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011693 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011694 int i;
11695 /* check whether the digital-mic has to be supported */
11696 for (i = 0; i < spec->input_mux->num_items; i++) {
11697 if (spec->input_mux->items[i].index >= 9)
11698 break;
11699 }
11700 if (i < spec->input_mux->num_items) {
11701 /* use only ADC0 */
11702 spec->adc_nids = alc262_dmic_adc_nids;
11703 spec->num_adc_nids = 1;
11704 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011705 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011706 /* all analog inputs */
11707 /* check whether NID 0x07 is valid */
11708 unsigned int wcap = get_wcaps(codec, 0x07);
11709
11710 /* get type */
11711 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
11712 if (wcap != AC_WID_AUD_IN) {
11713 spec->adc_nids = alc262_adc_nids_alt;
11714 spec->num_adc_nids =
11715 ARRAY_SIZE(alc262_adc_nids_alt);
11716 spec->capsrc_nids = alc262_capsrc_nids_alt;
11717 } else {
11718 spec->adc_nids = alc262_adc_nids;
11719 spec->num_adc_nids =
11720 ARRAY_SIZE(alc262_adc_nids);
11721 spec->capsrc_nids = alc262_capsrc_nids;
11722 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011723 }
11724 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011725 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011726 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011727 if (!spec->no_analog)
11728 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011729
Takashi Iwai2134ea42008-01-10 16:53:55 +010011730 spec->vmaster_nid = 0x0c;
11731
Kailang Yangdf694da2005-12-05 19:42:22 +010011732 codec->patch_ops = alc_patch_ops;
11733 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011734 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011735#ifdef CONFIG_SND_HDA_POWER_SAVE
11736 if (!spec->loopback.amplist)
11737 spec->loopback.amplist = alc262_loopbacks;
11738#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011739 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011740
Kailang Yangdf694da2005-12-05 19:42:22 +010011741 return 0;
11742}
11743
Kailang Yangdf694da2005-12-05 19:42:22 +010011744/*
Kailang Yanga361d842007-06-05 12:30:55 +020011745 * ALC268 channel source setting (2 channel)
11746 */
11747#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11748#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011749
Kailang Yanga361d842007-06-05 12:30:55 +020011750static hda_nid_t alc268_dac_nids[2] = {
11751 /* front, hp */
11752 0x02, 0x03
11753};
11754
11755static hda_nid_t alc268_adc_nids[2] = {
11756 /* ADC0-1 */
11757 0x08, 0x07
11758};
11759
11760static hda_nid_t alc268_adc_nids_alt[1] = {
11761 /* ADC0 */
11762 0x08
11763};
11764
Takashi Iwaie1406342008-02-11 18:32:32 +010011765static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11766
Kailang Yanga361d842007-06-05 12:30:55 +020011767static struct snd_kcontrol_new alc268_base_mixer[] = {
11768 /* output mixer control */
11769 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11770 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11771 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11772 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011773 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11774 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11775 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011776 { }
11777};
11778
Takashi Iwai42171c12009-05-08 14:11:43 +020011779static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11780 /* output mixer control */
11781 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11782 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11783 ALC262_HIPPO_MASTER_SWITCH,
11784 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11785 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11786 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11787 { }
11788};
11789
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011790/* bind Beep switches of both NID 0x0f and 0x10 */
11791static struct hda_bind_ctls alc268_bind_beep_sw = {
11792 .ops = &snd_hda_bind_sw,
11793 .values = {
11794 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11795 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11796 0
11797 },
11798};
11799
11800static struct snd_kcontrol_new alc268_beep_mixer[] = {
11801 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11802 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11803 { }
11804};
11805
Kailang Yangd1a991a2007-08-15 16:21:59 +020011806static struct hda_verb alc268_eapd_verbs[] = {
11807 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11808 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11809 { }
11810};
11811
Takashi Iwaid2738092007-08-16 14:59:45 +020011812/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011813static struct hda_verb alc268_toshiba_verbs[] = {
11814 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11815 { } /* end */
11816};
11817
Kailang Yang8ef355d2008-08-26 13:10:22 +020011818static struct hda_input_mux alc268_acer_lc_capture_source = {
11819 .num_items = 2,
11820 .items = {
11821 { "i-Mic", 0x6 },
11822 { "E-Mic", 0x0 },
11823 },
11824};
11825
Takashi Iwaid2738092007-08-16 14:59:45 +020011826/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011827/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011828static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11829 .ops = &snd_hda_bind_vol,
11830 .values = {
11831 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11832 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11833 0
11834 },
11835};
11836
Takashi Iwai889c4392007-08-23 18:56:52 +020011837/* mute/unmute internal speaker according to the hp jack and mute state */
11838static void alc268_acer_automute(struct hda_codec *codec, int force)
11839{
11840 struct alc_spec *spec = codec->spec;
11841 unsigned int mute;
11842
11843 if (force || !spec->sense_updated) {
11844 unsigned int present;
11845 present = snd_hda_codec_read(codec, 0x14, 0,
11846 AC_VERB_GET_PIN_SENSE, 0);
11847 spec->jack_present = (present & 0x80000000) != 0;
11848 spec->sense_updated = 1;
11849 }
11850 if (spec->jack_present)
11851 mute = HDA_AMP_MUTE; /* mute internal speaker */
11852 else /* unmute internal speaker if necessary */
11853 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11854 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11855 HDA_AMP_MUTE, mute);
11856}
11857
11858
11859/* bind hp and internal speaker mute (with plug check) */
11860static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11861 struct snd_ctl_elem_value *ucontrol)
11862{
11863 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11864 long *valp = ucontrol->value.integer.value;
11865 int change;
11866
Takashi Iwai8de56b72009-07-24 16:51:47 +020011867 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020011868 if (change)
11869 alc268_acer_automute(codec, 0);
11870 return change;
11871}
Takashi Iwaid2738092007-08-16 14:59:45 +020011872
Kailang Yang8ef355d2008-08-26 13:10:22 +020011873static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11874 /* output mixer control */
11875 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11876 {
11877 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11878 .name = "Master Playback Switch",
11879 .info = snd_hda_mixer_amp_switch_info,
11880 .get = snd_hda_mixer_amp_switch_get,
11881 .put = alc268_acer_master_sw_put,
11882 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11883 },
11884 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11885 { }
11886};
11887
Takashi Iwaid2738092007-08-16 14:59:45 +020011888static struct snd_kcontrol_new alc268_acer_mixer[] = {
11889 /* output mixer control */
11890 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11891 {
11892 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11893 .name = "Master Playback Switch",
11894 .info = snd_hda_mixer_amp_switch_info,
11895 .get = snd_hda_mixer_amp_switch_get,
11896 .put = alc268_acer_master_sw_put,
11897 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11898 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011899 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11900 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11901 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011902 { }
11903};
11904
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011905static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11906 /* output mixer control */
11907 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11908 {
11909 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11910 .name = "Master Playback Switch",
11911 .info = snd_hda_mixer_amp_switch_info,
11912 .get = snd_hda_mixer_amp_switch_get,
11913 .put = alc268_acer_master_sw_put,
11914 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11915 },
11916 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11917 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11918 { }
11919};
11920
Kailang Yang8ef355d2008-08-26 13:10:22 +020011921static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11922 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11923 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11924 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11925 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11926 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11927 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11928 { }
11929};
11930
Takashi Iwaid2738092007-08-16 14:59:45 +020011931static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011932 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11933 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011934 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11935 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011936 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11937 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011938 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11939 { }
11940};
11941
11942/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011943#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11944#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011945
11946static void alc268_acer_unsol_event(struct hda_codec *codec,
11947 unsigned int res)
11948{
Takashi Iwai889c4392007-08-23 18:56:52 +020011949 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011950 return;
11951 alc268_acer_automute(codec, 1);
11952}
11953
Takashi Iwai889c4392007-08-23 18:56:52 +020011954static void alc268_acer_init_hook(struct hda_codec *codec)
11955{
11956 alc268_acer_automute(codec, 1);
11957}
11958
Kailang Yang8ef355d2008-08-26 13:10:22 +020011959/* toggle speaker-output according to the hp-jack state */
11960static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11961{
11962 unsigned int present;
11963 unsigned char bits;
11964
11965 present = snd_hda_codec_read(codec, 0x15, 0,
11966 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11967 bits = present ? AMP_IN_MUTE(0) : 0;
11968 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11969 AMP_IN_MUTE(0), bits);
11970 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11971 AMP_IN_MUTE(0), bits);
11972}
11973
11974
11975static void alc268_acer_mic_automute(struct hda_codec *codec)
11976{
11977 unsigned int present;
11978
11979 present = snd_hda_codec_read(codec, 0x18, 0,
11980 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11981 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11982 present ? 0x0 : 0x6);
11983}
11984
11985static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11986 unsigned int res)
11987{
11988 if ((res >> 26) == ALC880_HP_EVENT)
11989 alc268_aspire_one_speaker_automute(codec);
11990 if ((res >> 26) == ALC880_MIC_EVENT)
11991 alc268_acer_mic_automute(codec);
11992}
11993
11994static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11995{
11996 alc268_aspire_one_speaker_automute(codec);
11997 alc268_acer_mic_automute(codec);
11998}
11999
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012000static struct snd_kcontrol_new alc268_dell_mixer[] = {
12001 /* output mixer control */
12002 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12003 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12004 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12006 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12007 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12008 { }
12009};
12010
12011static struct hda_verb alc268_dell_verbs[] = {
12012 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12013 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12014 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12015 { }
12016};
12017
12018/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012019static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012020{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012021 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012022
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012023 spec->autocfg.hp_pins[0] = 0x15;
12024 spec->autocfg.speaker_pins[0] = 0x14;
12025 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012026}
12027
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012028static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12029 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12030 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12031 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12032 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12033 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12034 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12035 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12036 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12037 { }
12038};
12039
12040static struct hda_verb alc267_quanta_il1_verbs[] = {
12041 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12042 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12043 { }
12044};
12045
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012046static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
12047{
12048 unsigned int present;
12049
12050 present = snd_hda_codec_read(codec, 0x18, 0,
12051 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12052 snd_hda_codec_write(codec, 0x23, 0,
12053 AC_VERB_SET_CONNECT_SEL,
12054 present ? 0x00 : 0x01);
12055}
12056
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012057static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012058{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012059 struct alc_spec *spec = codec->spec;
12060
12061 spec->autocfg.hp_pins[0] = 0x15;
12062 spec->autocfg.speaker_pins[0] = 0x14;
12063 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012064 alc267_quanta_il1_mic_automute(codec);
12065}
12066
12067static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
12068 unsigned int res)
12069{
12070 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012071 case ALC880_MIC_EVENT:
12072 alc267_quanta_il1_mic_automute(codec);
12073 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012074 default:
12075 alc_sku_unsol_event(codec, res);
12076 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012077 }
12078}
12079
Kailang Yanga361d842007-06-05 12:30:55 +020012080/*
12081 * generic initialization of ADC, input mixers and output mixers
12082 */
12083static struct hda_verb alc268_base_init_verbs[] = {
12084 /* Unmute DAC0-1 and set vol = 0 */
12085 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012086 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012087
12088 /*
12089 * Set up output mixers (0x0c - 0x0e)
12090 */
12091 /* set vol=0 to output mixers */
12092 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012093 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12094
12095 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12096 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12097
12098 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12099 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12100 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12101 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12102 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12103 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12104 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12105 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12106
12107 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12108 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12109 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12110 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012111 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012112
12113 /* set PCBEEP vol = 0, mute connections */
12114 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12115 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12116 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012117
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012118 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012119
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012120 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12121 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12122 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12123 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012124
Kailang Yanga361d842007-06-05 12:30:55 +020012125 { }
12126};
12127
12128/*
12129 * generic initialization of ADC, input mixers and output mixers
12130 */
12131static struct hda_verb alc268_volume_init_verbs[] = {
12132 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012133 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12134 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012135
12136 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12137 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12138 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12139 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12140 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12141
Kailang Yanga361d842007-06-05 12:30:55 +020012142 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012143 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12144 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12145
12146 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012147 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012148
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012149 /* set PCBEEP vol = 0, mute connections */
12150 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12151 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12152 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012153
12154 { }
12155};
12156
Kailang Yanga361d842007-06-05 12:30:55 +020012157static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12158 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12159 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12160 {
12161 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12162 /* The multiple "Capture Source" controls confuse alsamixer
12163 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012164 */
12165 /* .name = "Capture Source", */
12166 .name = "Input Source",
12167 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012168 .info = alc_mux_enum_info,
12169 .get = alc_mux_enum_get,
12170 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012171 },
12172 { } /* end */
12173};
12174
12175static struct snd_kcontrol_new alc268_capture_mixer[] = {
12176 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12177 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12178 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12179 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12180 {
12181 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12182 /* The multiple "Capture Source" controls confuse alsamixer
12183 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012184 */
12185 /* .name = "Capture Source", */
12186 .name = "Input Source",
12187 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012188 .info = alc_mux_enum_info,
12189 .get = alc_mux_enum_get,
12190 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012191 },
12192 { } /* end */
12193};
12194
12195static struct hda_input_mux alc268_capture_source = {
12196 .num_items = 4,
12197 .items = {
12198 { "Mic", 0x0 },
12199 { "Front Mic", 0x1 },
12200 { "Line", 0x2 },
12201 { "CD", 0x3 },
12202 },
12203};
12204
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012205static struct hda_input_mux alc268_acer_capture_source = {
12206 .num_items = 3,
12207 .items = {
12208 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012209 { "Internal Mic", 0x1 },
12210 { "Line", 0x2 },
12211 },
12212};
12213
12214static struct hda_input_mux alc268_acer_dmic_capture_source = {
12215 .num_items = 3,
12216 .items = {
12217 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012218 { "Internal Mic", 0x6 },
12219 { "Line", 0x2 },
12220 },
12221};
12222
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012223#ifdef CONFIG_SND_DEBUG
12224static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012225 /* Volume widgets */
12226 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12227 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12228 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12229 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12230 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12231 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12232 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12233 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12234 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12235 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12236 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12237 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12238 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012239 /* The below appears problematic on some hardwares */
12240 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012241 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12242 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12243 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12244 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12245
12246 /* Modes for retasking pin widgets */
12247 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12248 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12249 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12250 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12251
12252 /* Controls for GPIO pins, assuming they are configured as outputs */
12253 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12254 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12255 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12256 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12257
12258 /* Switches to allow the digital SPDIF output pin to be enabled.
12259 * The ALC268 does not have an SPDIF input.
12260 */
12261 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12262
12263 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12264 * this output to turn on an external amplifier.
12265 */
12266 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12267 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12268
12269 { } /* end */
12270};
12271#endif
12272
Kailang Yanga361d842007-06-05 12:30:55 +020012273/* create input playback/capture controls for the given pin */
12274static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12275 const char *ctlname, int idx)
12276{
12277 char name[32];
12278 int err;
12279
12280 sprintf(name, "%s Playback Volume", ctlname);
12281 if (nid == 0x14) {
12282 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12283 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
12284 HDA_OUTPUT));
12285 if (err < 0)
12286 return err;
12287 } else if (nid == 0x15) {
12288 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12289 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
12290 HDA_OUTPUT));
12291 if (err < 0)
12292 return err;
12293 } else
12294 return -1;
12295 sprintf(name, "%s Playback Switch", ctlname);
12296 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12297 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
12298 if (err < 0)
12299 return err;
12300 return 0;
12301}
12302
12303/* add playback controls from the parsed DAC table */
12304static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12305 const struct auto_pin_cfg *cfg)
12306{
12307 hda_nid_t nid;
12308 int err;
12309
12310 spec->multiout.num_dacs = 2; /* only use one dac */
12311 spec->multiout.dac_nids = spec->private_dac_nids;
12312 spec->multiout.dac_nids[0] = 2;
12313 spec->multiout.dac_nids[1] = 3;
12314
12315 nid = cfg->line_out_pins[0];
12316 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020012317 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020012318
12319 nid = cfg->speaker_pins[0];
12320 if (nid == 0x1d) {
12321 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12322 "Speaker Playback Volume",
12323 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12324 if (err < 0)
12325 return err;
12326 }
12327 nid = cfg->hp_pins[0];
12328 if (nid)
12329 alc268_new_analog_output(spec, nid, "Headphone", 0);
12330
12331 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12332 if (nid == 0x16) {
12333 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12334 "Mono Playback Switch",
12335 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
12336 if (err < 0)
12337 return err;
12338 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012339 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012340}
12341
12342/* create playback/capture controls for input pins */
12343static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12344 const struct auto_pin_cfg *cfg)
12345{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012346 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012347 int i, idx1;
12348
12349 for (i = 0; i < AUTO_PIN_LAST; i++) {
12350 switch(cfg->input_pins[i]) {
12351 case 0x18:
12352 idx1 = 0; /* Mic 1 */
12353 break;
12354 case 0x19:
12355 idx1 = 1; /* Mic 2 */
12356 break;
12357 case 0x1a:
12358 idx1 = 2; /* Line In */
12359 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012360 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012361 idx1 = 3; /* CD */
12362 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012363 case 0x12:
12364 case 0x13:
12365 idx1 = 6; /* digital mics */
12366 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012367 default:
12368 continue;
12369 }
12370 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12371 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012372 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012373 }
12374 return 0;
12375}
12376
12377static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12378{
12379 struct alc_spec *spec = codec->spec;
12380 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12381 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12382 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12383 unsigned int dac_vol1, dac_vol2;
12384
12385 if (speaker_nid) {
12386 snd_hda_codec_write(codec, speaker_nid, 0,
12387 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12388 snd_hda_codec_write(codec, 0x0f, 0,
12389 AC_VERB_SET_AMP_GAIN_MUTE,
12390 AMP_IN_UNMUTE(1));
12391 snd_hda_codec_write(codec, 0x10, 0,
12392 AC_VERB_SET_AMP_GAIN_MUTE,
12393 AMP_IN_UNMUTE(1));
12394 } else {
12395 snd_hda_codec_write(codec, 0x0f, 0,
12396 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12397 snd_hda_codec_write(codec, 0x10, 0,
12398 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12399 }
12400
12401 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012402 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012403 dac_vol2 = AMP_OUT_ZERO;
12404 else if (line_nid == 0x15)
12405 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012406 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012407 dac_vol2 = AMP_OUT_ZERO;
12408 else if (hp_nid == 0x15)
12409 dac_vol1 = AMP_OUT_ZERO;
12410 if (line_nid != 0x16 || hp_nid != 0x16 ||
12411 spec->autocfg.line_out_pins[1] != 0x16 ||
12412 spec->autocfg.line_out_pins[2] != 0x16)
12413 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12414
12415 snd_hda_codec_write(codec, 0x02, 0,
12416 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12417 snd_hda_codec_write(codec, 0x03, 0,
12418 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12419}
12420
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012421/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012422#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12423#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012424#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012425#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12426
12427/*
12428 * BIOS auto configuration
12429 */
12430static int alc268_parse_auto_config(struct hda_codec *codec)
12431{
12432 struct alc_spec *spec = codec->spec;
12433 int err;
12434 static hda_nid_t alc268_ignore[] = { 0 };
12435
12436 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12437 alc268_ignore);
12438 if (err < 0)
12439 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012440 if (!spec->autocfg.line_outs) {
12441 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12442 spec->multiout.max_channels = 2;
12443 spec->no_analog = 1;
12444 goto dig_only;
12445 }
Kailang Yanga361d842007-06-05 12:30:55 +020012446 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012447 }
Kailang Yanga361d842007-06-05 12:30:55 +020012448 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12449 if (err < 0)
12450 return err;
12451 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12452 if (err < 0)
12453 return err;
12454
12455 spec->multiout.max_channels = 2;
12456
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012457 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012458 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012459 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012460 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012461 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12462 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012463 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012464 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012465
Takashi Iwai892981f2009-03-02 08:04:35 +010012466 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012467 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012468
Takashi Iwaid88897e2008-10-31 15:01:37 +010012469 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012470 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012471 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012472
Takashi Iwai776e1842007-08-29 15:07:11 +020012473 err = alc_auto_add_mic_boost(codec);
12474 if (err < 0)
12475 return err;
12476
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012477 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12478
Kailang Yanga361d842007-06-05 12:30:55 +020012479 return 1;
12480}
12481
12482#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12483#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12484#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12485
12486/* init callback for auto-configuration model -- overriding the default init */
12487static void alc268_auto_init(struct hda_codec *codec)
12488{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012489 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012490 alc268_auto_init_multi_out(codec);
12491 alc268_auto_init_hp_out(codec);
12492 alc268_auto_init_mono_speaker_out(codec);
12493 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012494 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012495 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012496}
12497
12498/*
12499 * configuration and preset
12500 */
12501static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012502 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012503 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012504 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012505 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012506 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012507 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012508 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012509 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012510#ifdef CONFIG_SND_DEBUG
12511 [ALC268_TEST] = "test",
12512#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012513 [ALC268_AUTO] = "auto",
12514};
12515
12516static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012517 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012518 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012519 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012520 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012521 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012522 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12523 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012524 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012525 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012526 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12527 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012528 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012529 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012530 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012531 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012532 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012533 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012534 {}
12535};
12536
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012537/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12538static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12539 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12540 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12541 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12542 ALC268_TOSHIBA),
12543 {}
12544};
12545
Kailang Yanga361d842007-06-05 12:30:55 +020012546static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012547 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012548 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012549 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12550 alc267_quanta_il1_verbs },
12551 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12552 .dac_nids = alc268_dac_nids,
12553 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12554 .adc_nids = alc268_adc_nids_alt,
12555 .hp_nid = 0x03,
12556 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12557 .channel_mode = alc268_modes,
12558 .input_mux = &alc268_capture_source,
12559 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012560 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012561 },
Kailang Yanga361d842007-06-05 12:30:55 +020012562 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012563 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12564 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012565 .init_verbs = { alc268_base_init_verbs },
12566 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12567 .dac_nids = alc268_dac_nids,
12568 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12569 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012570 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012571 .hp_nid = 0x03,
12572 .dig_out_nid = ALC268_DIGOUT_NID,
12573 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12574 .channel_mode = alc268_modes,
12575 .input_mux = &alc268_capture_source,
12576 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012577 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012578 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012579 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012580 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12581 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012582 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12583 .dac_nids = alc268_dac_nids,
12584 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12585 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012586 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012587 .hp_nid = 0x03,
12588 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12589 .channel_mode = alc268_modes,
12590 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012591 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012592 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012593 },
12594 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012595 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12596 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012597 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12598 alc268_acer_verbs },
12599 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12600 .dac_nids = alc268_dac_nids,
12601 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12602 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012603 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012604 .hp_nid = 0x02,
12605 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12606 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012607 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012608 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012609 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012610 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012611 [ALC268_ACER_DMIC] = {
12612 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12613 alc268_beep_mixer },
12614 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12615 alc268_acer_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 = 0x02,
12622 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12623 .channel_mode = alc268_modes,
12624 .input_mux = &alc268_acer_dmic_capture_source,
12625 .unsol_event = alc268_acer_unsol_event,
12626 .init_hook = alc268_acer_init_hook,
12627 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012628 [ALC268_ACER_ASPIRE_ONE] = {
12629 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012630 alc268_beep_mixer,
12631 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012632 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12633 alc268_acer_aspire_one_verbs },
12634 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12635 .dac_nids = alc268_dac_nids,
12636 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12637 .adc_nids = alc268_adc_nids_alt,
12638 .capsrc_nids = alc268_capsrc_nids,
12639 .hp_nid = 0x03,
12640 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12641 .channel_mode = alc268_modes,
12642 .input_mux = &alc268_acer_lc_capture_source,
12643 .unsol_event = alc268_acer_lc_unsol_event,
12644 .init_hook = alc268_acer_lc_init_hook,
12645 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012646 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012647 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012648 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12649 alc268_dell_verbs },
12650 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12651 .dac_nids = alc268_dac_nids,
12652 .hp_nid = 0x02,
12653 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12654 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012655 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012656 .init_hook = alc268_dell_init_hook,
12657 .input_mux = &alc268_capture_source,
12658 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012659 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012660 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12661 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012662 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12663 alc268_toshiba_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,
Mirco Tischlerf12462c2008-02-04 12:33:59 +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 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012675 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012676 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012677#ifdef CONFIG_SND_DEBUG
12678 [ALC268_TEST] = {
12679 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12680 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12681 alc268_volume_init_verbs },
12682 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12683 .dac_nids = alc268_dac_nids,
12684 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12685 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012686 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012687 .hp_nid = 0x03,
12688 .dig_out_nid = ALC268_DIGOUT_NID,
12689 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12690 .channel_mode = alc268_modes,
12691 .input_mux = &alc268_capture_source,
12692 },
12693#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012694};
12695
12696static int patch_alc268(struct hda_codec *codec)
12697{
12698 struct alc_spec *spec;
12699 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012700 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012701
12702 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12703 if (spec == NULL)
12704 return -ENOMEM;
12705
12706 codec->spec = spec;
12707
12708 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12709 alc268_models,
12710 alc268_cfg_tbl);
12711
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012712 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12713 board_config = snd_hda_check_board_codec_sid_config(codec,
12714 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12715
Kailang Yanga361d842007-06-05 12:30:55 +020012716 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020012717 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12718 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012719 board_config = ALC268_AUTO;
12720 }
12721
12722 if (board_config == ALC268_AUTO) {
12723 /* automatic parse from the BIOS config */
12724 err = alc268_parse_auto_config(codec);
12725 if (err < 0) {
12726 alc_free(codec);
12727 return err;
12728 } else if (!err) {
12729 printk(KERN_INFO
12730 "hda_codec: Cannot set up configuration "
12731 "from BIOS. Using base mode...\n");
12732 board_config = ALC268_3ST;
12733 }
12734 }
12735
12736 if (board_config != ALC268_AUTO)
12737 setup_preset(spec, &alc268_presets[board_config]);
12738
Kailang Yanga361d842007-06-05 12:30:55 +020012739 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12740 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012741 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012742
Kailang Yanga361d842007-06-05 12:30:55 +020012743 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12744
Takashi Iwai22971e32009-02-10 11:56:44 +010012745 has_beep = 0;
12746 for (i = 0; i < spec->num_mixers; i++) {
12747 if (spec->mixers[i] == alc268_beep_mixer) {
12748 has_beep = 1;
12749 break;
12750 }
12751 }
12752
12753 if (has_beep) {
12754 err = snd_hda_attach_beep_device(codec, 0x1);
12755 if (err < 0) {
12756 alc_free(codec);
12757 return err;
12758 }
12759 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12760 /* override the amp caps for beep generator */
12761 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012762 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12763 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12764 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12765 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012766 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012767
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012768 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012769 /* check whether NID 0x07 is valid */
12770 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012771 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012772
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012773 /* get type */
12774 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012775 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012776 spec->adc_nids = alc268_adc_nids_alt;
12777 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012778 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012779 } else {
12780 spec->adc_nids = alc268_adc_nids;
12781 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012782 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012783 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012784 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012785 /* set default input source */
12786 for (i = 0; i < spec->num_adc_nids; i++)
12787 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12788 0, AC_VERB_SET_CONNECT_SEL,
12789 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012790 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012791
12792 spec->vmaster_nid = 0x02;
12793
Kailang Yanga361d842007-06-05 12:30:55 +020012794 codec->patch_ops = alc_patch_ops;
12795 if (board_config == ALC268_AUTO)
12796 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012797
Takashi Iwaidaead532008-11-28 12:55:36 +010012798 codec->proc_widget_hook = print_realtek_coef;
12799
Kailang Yanga361d842007-06-05 12:30:55 +020012800 return 0;
12801}
12802
12803/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012804 * ALC269 channel source setting (2 channel)
12805 */
12806#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12807
12808#define alc269_dac_nids alc260_dac_nids
12809
12810static hda_nid_t alc269_adc_nids[1] = {
12811 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012812 0x08,
12813};
12814
Takashi Iwaie01bf502008-08-21 16:25:07 +020012815static hda_nid_t alc269_capsrc_nids[1] = {
12816 0x23,
12817};
12818
12819/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12820 * not a mux!
12821 */
12822
Kailang Yangf53281e2008-07-18 12:36:43 +020012823static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12824 .num_items = 2,
12825 .items = {
12826 { "i-Mic", 0x5 },
12827 { "e-Mic", 0x0 },
12828 },
12829};
12830
12831static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12832 .num_items = 2,
12833 .items = {
12834 { "i-Mic", 0x1 },
12835 { "e-Mic", 0x0 },
12836 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012837};
12838
12839#define alc269_modes alc260_modes
12840#define alc269_capture_source alc880_lg_lw_capture_source
12841
12842static struct snd_kcontrol_new alc269_base_mixer[] = {
12843 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12844 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12845 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12846 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
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("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12851 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12852 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12853 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12854 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12855 { } /* end */
12856};
12857
Kailang Yang60db6b52008-08-26 13:13:00 +020012858static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12859 /* output mixer control */
12860 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12861 {
12862 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12863 .name = "Master Playback Switch",
12864 .info = snd_hda_mixer_amp_switch_info,
12865 .get = snd_hda_mixer_amp_switch_get,
12866 .put = alc268_acer_master_sw_put,
12867 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12868 },
12869 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12870 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12871 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12872 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12873 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12874 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012875 { }
12876};
12877
Tony Vroon64154832008-11-06 15:08:49 +000012878static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12879 /* output mixer control */
12880 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12881 {
12882 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12883 .name = "Master Playback Switch",
12884 .info = snd_hda_mixer_amp_switch_info,
12885 .get = snd_hda_mixer_amp_switch_get,
12886 .put = alc268_acer_master_sw_put,
12887 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12888 },
12889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12890 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12891 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12892 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12893 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12894 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12895 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12896 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12897 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012898 { }
12899};
12900
Kailang Yangf53281e2008-07-18 12:36:43 +020012901static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012902 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012903 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012904 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012905 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012906 { } /* end */
12907};
12908
Kailang Yangf6a92242007-12-13 16:52:54 +010012909/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012910static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12911 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12912 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012913 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12914 { } /* end */
12915};
12916
12917/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012918#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012919
Kailang Yang60db6b52008-08-26 13:13:00 +020012920static struct hda_verb alc269_quanta_fl1_verbs[] = {
12921 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12922 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12923 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12924 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12925 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12926 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12927 { }
12928};
12929
Tony Vroon64154832008-11-06 15:08:49 +000012930static struct hda_verb alc269_lifebook_verbs[] = {
12931 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12932 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12933 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12934 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12935 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12936 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12937 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12938 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12939 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12940 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12941 { }
12942};
12943
Kailang Yang60db6b52008-08-26 13:13:00 +020012944/* toggle speaker-output according to the hp-jack state */
12945static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12946{
12947 unsigned int present;
12948 unsigned char bits;
12949
12950 present = snd_hda_codec_read(codec, 0x15, 0,
12951 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12952 bits = present ? AMP_IN_MUTE(0) : 0;
12953 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12954 AMP_IN_MUTE(0), bits);
12955 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12956 AMP_IN_MUTE(0), bits);
12957
12958 snd_hda_codec_write(codec, 0x20, 0,
12959 AC_VERB_SET_COEF_INDEX, 0x0c);
12960 snd_hda_codec_write(codec, 0x20, 0,
12961 AC_VERB_SET_PROC_COEF, 0x680);
12962
12963 snd_hda_codec_write(codec, 0x20, 0,
12964 AC_VERB_SET_COEF_INDEX, 0x0c);
12965 snd_hda_codec_write(codec, 0x20, 0,
12966 AC_VERB_SET_PROC_COEF, 0x480);
12967}
12968
Tony Vroon64154832008-11-06 15:08:49 +000012969/* toggle speaker-output according to the hp-jacks state */
12970static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12971{
12972 unsigned int present;
12973 unsigned char bits;
12974
12975 /* Check laptop headphone socket */
12976 present = snd_hda_codec_read(codec, 0x15, 0,
12977 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12978
12979 /* Check port replicator headphone socket */
12980 present |= snd_hda_codec_read(codec, 0x1a, 0,
12981 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12982
12983 bits = present ? AMP_IN_MUTE(0) : 0;
12984 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12985 AMP_IN_MUTE(0), bits);
12986 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12987 AMP_IN_MUTE(0), bits);
12988
12989 snd_hda_codec_write(codec, 0x20, 0,
12990 AC_VERB_SET_COEF_INDEX, 0x0c);
12991 snd_hda_codec_write(codec, 0x20, 0,
12992 AC_VERB_SET_PROC_COEF, 0x680);
12993
12994 snd_hda_codec_write(codec, 0x20, 0,
12995 AC_VERB_SET_COEF_INDEX, 0x0c);
12996 snd_hda_codec_write(codec, 0x20, 0,
12997 AC_VERB_SET_PROC_COEF, 0x480);
12998}
12999
Kailang Yang60db6b52008-08-26 13:13:00 +020013000static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
13001{
13002 unsigned int present;
13003
13004 present = snd_hda_codec_read(codec, 0x18, 0,
13005 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13006 snd_hda_codec_write(codec, 0x23, 0,
13007 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
13008}
13009
Tony Vroon64154832008-11-06 15:08:49 +000013010static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13011{
13012 unsigned int present_laptop;
13013 unsigned int present_dock;
13014
13015 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
13016 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13017
13018 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
13019 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13020
13021 /* Laptop mic port overrides dock mic port, design decision */
13022 if (present_dock)
13023 snd_hda_codec_write(codec, 0x23, 0,
13024 AC_VERB_SET_CONNECT_SEL, 0x3);
13025 if (present_laptop)
13026 snd_hda_codec_write(codec, 0x23, 0,
13027 AC_VERB_SET_CONNECT_SEL, 0x0);
13028 if (!present_dock && !present_laptop)
13029 snd_hda_codec_write(codec, 0x23, 0,
13030 AC_VERB_SET_CONNECT_SEL, 0x1);
13031}
13032
Kailang Yang60db6b52008-08-26 13:13:00 +020013033static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13034 unsigned int res)
13035{
13036 if ((res >> 26) == ALC880_HP_EVENT)
13037 alc269_quanta_fl1_speaker_automute(codec);
13038 if ((res >> 26) == ALC880_MIC_EVENT)
13039 alc269_quanta_fl1_mic_automute(codec);
13040}
13041
Tony Vroon64154832008-11-06 15:08:49 +000013042static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13043 unsigned int res)
13044{
13045 if ((res >> 26) == ALC880_HP_EVENT)
13046 alc269_lifebook_speaker_automute(codec);
13047 if ((res >> 26) == ALC880_MIC_EVENT)
13048 alc269_lifebook_mic_autoswitch(codec);
13049}
13050
Kailang Yang60db6b52008-08-26 13:13:00 +020013051static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13052{
13053 alc269_quanta_fl1_speaker_automute(codec);
13054 alc269_quanta_fl1_mic_automute(codec);
13055}
13056
Tony Vroon64154832008-11-06 15:08:49 +000013057static void alc269_lifebook_init_hook(struct hda_codec *codec)
13058{
13059 alc269_lifebook_speaker_automute(codec);
13060 alc269_lifebook_mic_autoswitch(codec);
13061}
13062
Kailang Yang60db6b52008-08-26 13:13:00 +020013063static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13064 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13065 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13066 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13067 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13068 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13069 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13070 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13071 {}
13072};
13073
13074static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13075 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13076 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13077 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13078 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13079 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13080 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13081 {}
13082};
13083
13084/* toggle speaker-output according to the hp-jack state */
13085static void alc269_speaker_automute(struct hda_codec *codec)
13086{
13087 unsigned int present;
13088 unsigned char bits;
13089
13090 present = snd_hda_codec_read(codec, 0x15, 0,
13091 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13092 bits = present ? AMP_IN_MUTE(0) : 0;
13093 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13094 AMP_IN_MUTE(0), bits);
13095 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13096 AMP_IN_MUTE(0), bits);
13097}
13098
13099static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
13100{
13101 unsigned int present;
13102
13103 present = snd_hda_codec_read(codec, 0x18, 0,
13104 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13105 snd_hda_codec_write(codec, 0x23, 0,
13106 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
13107}
13108
13109static void alc269_eeepc_amic_automute(struct hda_codec *codec)
13110{
13111 unsigned int present;
13112
13113 present = snd_hda_codec_read(codec, 0x18, 0,
13114 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13115 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13116 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13117 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13118 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13119}
13120
13121/* unsolicited event for HP jack sensing */
13122static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
13123 unsigned int res)
13124{
13125 if ((res >> 26) == ALC880_HP_EVENT)
13126 alc269_speaker_automute(codec);
13127
13128 if ((res >> 26) == ALC880_MIC_EVENT)
13129 alc269_eeepc_dmic_automute(codec);
13130}
13131
13132static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
13133{
13134 alc269_speaker_automute(codec);
13135 alc269_eeepc_dmic_automute(codec);
13136}
13137
13138/* unsolicited event for HP jack sensing */
13139static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
13140 unsigned int res)
13141{
13142 if ((res >> 26) == ALC880_HP_EVENT)
13143 alc269_speaker_automute(codec);
13144
13145 if ((res >> 26) == ALC880_MIC_EVENT)
13146 alc269_eeepc_amic_automute(codec);
13147}
13148
13149static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
13150{
13151 alc269_speaker_automute(codec);
13152 alc269_eeepc_amic_automute(codec);
13153}
13154
Kailang Yangf6a92242007-12-13 16:52:54 +010013155/*
13156 * generic initialization of ADC, input mixers and output mixers
13157 */
13158static struct hda_verb alc269_init_verbs[] = {
13159 /*
13160 * Unmute ADC0 and set the default input to mic-in
13161 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013162 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013163
13164 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13165 * analog-loopback mixer widget
13166 * Note: PASD motherboards uses the Line In 2 as the input for
13167 * front panel mic (mic 2)
13168 */
13169 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13170 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13171 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13172 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13173 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13174 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13175
13176 /*
13177 * Set up output mixers (0x0c - 0x0e)
13178 */
13179 /* set vol=0 to output mixers */
13180 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13181 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13182
13183 /* set up input amps for analog loopback */
13184 /* Amp Indices: DAC = 0, mixer = 1 */
13185 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13186 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13187 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13188 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13189 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13190 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13191
13192 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13193 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13194 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13195 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13196 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13197 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13198 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13199
13200 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13201 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13202 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13203 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13204 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13205 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13206 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13207
13208 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13209 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13210
13211 /* FIXME: use matrix-type input source selection */
13212 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13213 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013214 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13215 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013216 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13217 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13218
13219 /* set EAPD */
13220 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13221 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13222 { }
13223};
13224
13225/* add playback controls from the parsed DAC table */
13226static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
13227 const struct auto_pin_cfg *cfg)
13228{
13229 hda_nid_t nid;
13230 int err;
13231
13232 spec->multiout.num_dacs = 1; /* only use one dac */
13233 spec->multiout.dac_nids = spec->private_dac_nids;
13234 spec->multiout.dac_nids[0] = 2;
13235
13236 nid = cfg->line_out_pins[0];
13237 if (nid) {
13238 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13239 "Front Playback Volume",
13240 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
13241 if (err < 0)
13242 return err;
13243 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13244 "Front Playback Switch",
13245 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13246 if (err < 0)
13247 return err;
13248 }
13249
13250 nid = cfg->speaker_pins[0];
13251 if (nid) {
13252 if (!cfg->line_out_pins[0]) {
13253 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13254 "Speaker Playback Volume",
13255 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13256 HDA_OUTPUT));
13257 if (err < 0)
13258 return err;
13259 }
13260 if (nid == 0x16) {
13261 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13262 "Speaker Playback Switch",
13263 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13264 HDA_OUTPUT));
13265 if (err < 0)
13266 return err;
13267 } else {
13268 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13269 "Speaker Playback Switch",
13270 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13271 HDA_OUTPUT));
13272 if (err < 0)
13273 return err;
13274 }
13275 }
13276 nid = cfg->hp_pins[0];
13277 if (nid) {
13278 /* spec->multiout.hp_nid = 2; */
13279 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
13280 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13281 "Headphone Playback Volume",
13282 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13283 HDA_OUTPUT));
13284 if (err < 0)
13285 return err;
13286 }
13287 if (nid == 0x16) {
13288 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13289 "Headphone Playback Switch",
13290 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13291 HDA_OUTPUT));
13292 if (err < 0)
13293 return err;
13294 } else {
13295 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13296 "Headphone Playback Switch",
13297 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13298 HDA_OUTPUT));
13299 if (err < 0)
13300 return err;
13301 }
13302 }
13303 return 0;
13304}
13305
Takashi Iwai8c927b42009-06-22 10:56:54 +020013306#define alc269_auto_create_analog_input_ctls \
13307 alc262_auto_create_analog_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013308
13309#ifdef CONFIG_SND_HDA_POWER_SAVE
13310#define alc269_loopbacks alc880_loopbacks
13311#endif
13312
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013313/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013314#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13315#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13316#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13317#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13318
Takashi Iwaif03d3112009-03-05 14:18:16 +010013319static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13320 .substreams = 1,
13321 .channels_min = 2,
13322 .channels_max = 8,
13323 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13324 /* NID is set in alc_build_pcms */
13325 .ops = {
13326 .open = alc880_playback_pcm_open,
13327 .prepare = alc880_playback_pcm_prepare,
13328 .cleanup = alc880_playback_pcm_cleanup
13329 },
13330};
13331
13332static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13333 .substreams = 1,
13334 .channels_min = 2,
13335 .channels_max = 2,
13336 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13337 /* NID is set in alc_build_pcms */
13338};
13339
Kailang Yangf6a92242007-12-13 16:52:54 +010013340/*
13341 * BIOS auto configuration
13342 */
13343static int alc269_parse_auto_config(struct hda_codec *codec)
13344{
13345 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013346 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013347 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13348
13349 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13350 alc269_ignore);
13351 if (err < 0)
13352 return err;
13353
13354 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13355 if (err < 0)
13356 return err;
13357 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13358 if (err < 0)
13359 return err;
13360
13361 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13362
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013363 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013364 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13365
Takashi Iwai603c4012008-07-30 15:01:44 +020013366 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013367 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013368
Takashi Iwaid88897e2008-10-31 15:01:37 +010013369 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013370 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013371 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013372 /* set default input source */
13373 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13374 0, AC_VERB_SET_CONNECT_SEL,
13375 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013376
13377 err = alc_auto_add_mic_boost(codec);
13378 if (err < 0)
13379 return err;
13380
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013381 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013382 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013383
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013384 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13385
Kailang Yangf6a92242007-12-13 16:52:54 +010013386 return 1;
13387}
13388
13389#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13390#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13391#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13392
13393
13394/* init callback for auto-configuration model -- overriding the default init */
13395static void alc269_auto_init(struct hda_codec *codec)
13396{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013397 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013398 alc269_auto_init_multi_out(codec);
13399 alc269_auto_init_hp_out(codec);
13400 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013401 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013402 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013403}
13404
13405/*
13406 * configuration and preset
13407 */
13408static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013409 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013410 [ALC269_QUANTA_FL1] = "quanta",
13411 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013412 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013413 [ALC269_FUJITSU] = "fujitsu",
13414 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013415};
13416
13417static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013418 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013419 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13420 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013421 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13422 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13423 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13424 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13425 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13426 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013427 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13428 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013429 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13430 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013431 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013432 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013433 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013434 {}
13435};
13436
13437static struct alc_config_preset alc269_presets[] = {
13438 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013439 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013440 .init_verbs = { alc269_init_verbs },
13441 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13442 .dac_nids = alc269_dac_nids,
13443 .hp_nid = 0x03,
13444 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13445 .channel_mode = alc269_modes,
13446 .input_mux = &alc269_capture_source,
13447 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013448 [ALC269_QUANTA_FL1] = {
13449 .mixers = { alc269_quanta_fl1_mixer },
13450 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13451 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13452 .dac_nids = alc269_dac_nids,
13453 .hp_nid = 0x03,
13454 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13455 .channel_mode = alc269_modes,
13456 .input_mux = &alc269_capture_source,
13457 .unsol_event = alc269_quanta_fl1_unsol_event,
13458 .init_hook = alc269_quanta_fl1_init_hook,
13459 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013460 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013461 .mixers = { alc269_eeepc_mixer },
13462 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013463 .init_verbs = { alc269_init_verbs,
13464 alc269_eeepc_amic_init_verbs },
13465 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13466 .dac_nids = alc269_dac_nids,
13467 .hp_nid = 0x03,
13468 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13469 .channel_mode = alc269_modes,
13470 .input_mux = &alc269_eeepc_amic_capture_source,
13471 .unsol_event = alc269_eeepc_amic_unsol_event,
13472 .init_hook = alc269_eeepc_amic_inithook,
13473 },
13474 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013475 .mixers = { alc269_eeepc_mixer },
13476 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013477 .init_verbs = { alc269_init_verbs,
13478 alc269_eeepc_dmic_init_verbs },
13479 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13480 .dac_nids = alc269_dac_nids,
13481 .hp_nid = 0x03,
13482 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13483 .channel_mode = alc269_modes,
13484 .input_mux = &alc269_eeepc_dmic_capture_source,
13485 .unsol_event = alc269_eeepc_dmic_unsol_event,
13486 .init_hook = alc269_eeepc_dmic_inithook,
13487 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013488 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013489 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013490 .cap_mixer = alc269_epc_capture_mixer,
13491 .init_verbs = { alc269_init_verbs,
13492 alc269_eeepc_dmic_init_verbs },
13493 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13494 .dac_nids = alc269_dac_nids,
13495 .hp_nid = 0x03,
13496 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13497 .channel_mode = alc269_modes,
13498 .input_mux = &alc269_eeepc_dmic_capture_source,
13499 .unsol_event = alc269_eeepc_dmic_unsol_event,
13500 .init_hook = alc269_eeepc_dmic_inithook,
13501 },
Tony Vroon64154832008-11-06 15:08:49 +000013502 [ALC269_LIFEBOOK] = {
13503 .mixers = { alc269_lifebook_mixer },
13504 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13505 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13506 .dac_nids = alc269_dac_nids,
13507 .hp_nid = 0x03,
13508 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13509 .channel_mode = alc269_modes,
13510 .input_mux = &alc269_capture_source,
13511 .unsol_event = alc269_lifebook_unsol_event,
13512 .init_hook = alc269_lifebook_init_hook,
13513 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013514};
13515
13516static int patch_alc269(struct hda_codec *codec)
13517{
13518 struct alc_spec *spec;
13519 int board_config;
13520 int err;
13521
13522 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13523 if (spec == NULL)
13524 return -ENOMEM;
13525
13526 codec->spec = spec;
13527
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013528 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13529
Kailang Yangf6a92242007-12-13 16:52:54 +010013530 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13531 alc269_models,
13532 alc269_cfg_tbl);
13533
13534 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020013535 printk(KERN_INFO "hda_codec: Unknown model for %s, "
13536 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013537 board_config = ALC269_AUTO;
13538 }
13539
13540 if (board_config == ALC269_AUTO) {
13541 /* automatic parse from the BIOS config */
13542 err = alc269_parse_auto_config(codec);
13543 if (err < 0) {
13544 alc_free(codec);
13545 return err;
13546 } else if (!err) {
13547 printk(KERN_INFO
13548 "hda_codec: Cannot set up configuration "
13549 "from BIOS. Using base mode...\n");
13550 board_config = ALC269_BASIC;
13551 }
13552 }
13553
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013554 err = snd_hda_attach_beep_device(codec, 0x1);
13555 if (err < 0) {
13556 alc_free(codec);
13557 return err;
13558 }
13559
Kailang Yangf6a92242007-12-13 16:52:54 +010013560 if (board_config != ALC269_AUTO)
13561 setup_preset(spec, &alc269_presets[board_config]);
13562
Takashi Iwaif03d3112009-03-05 14:18:16 +010013563 if (codec->subsystem_id == 0x17aa3bf8) {
13564 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13565 * fix the sample rate of analog I/O to 44.1kHz
13566 */
13567 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13568 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13569 } else {
13570 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13571 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13572 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013573 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13574 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13575
13576 spec->adc_nids = alc269_adc_nids;
13577 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013578 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013579 if (!spec->cap_mixer)
13580 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013581 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013582
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013583 spec->vmaster_nid = 0x02;
13584
Kailang Yangf6a92242007-12-13 16:52:54 +010013585 codec->patch_ops = alc_patch_ops;
13586 if (board_config == ALC269_AUTO)
13587 spec->init_hook = alc269_auto_init;
13588#ifdef CONFIG_SND_HDA_POWER_SAVE
13589 if (!spec->loopback.amplist)
13590 spec->loopback.amplist = alc269_loopbacks;
13591#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013592 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013593
13594 return 0;
13595}
13596
13597/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013598 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13599 */
13600
13601/*
13602 * set the path ways for 2 channel output
13603 * need to set the codec line out and mic 1 pin widgets to inputs
13604 */
13605static struct hda_verb alc861_threestack_ch2_init[] = {
13606 /* set pin widget 1Ah (line in) for input */
13607 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013608 /* set pin widget 18h (mic1/2) for input, for mic also enable
13609 * the vref
13610 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013611 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13612
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013613 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13614#if 0
13615 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13616 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13617#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013618 { } /* end */
13619};
13620/*
13621 * 6ch mode
13622 * need to set the codec line out and mic 1 pin widgets to outputs
13623 */
13624static struct hda_verb alc861_threestack_ch6_init[] = {
13625 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13626 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13627 /* set pin widget 18h (mic1) for output (CLFE)*/
13628 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13629
13630 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013631 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013632
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013633 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13634#if 0
13635 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13636 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13637#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013638 { } /* end */
13639};
13640
13641static struct hda_channel_mode alc861_threestack_modes[2] = {
13642 { 2, alc861_threestack_ch2_init },
13643 { 6, alc861_threestack_ch6_init },
13644};
Takashi Iwai22309c32006-08-09 16:57:28 +020013645/* Set mic1 as input and unmute the mixer */
13646static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13647 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13648 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13649 { } /* end */
13650};
13651/* Set mic1 as output and mute mixer */
13652static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13653 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13654 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13655 { } /* end */
13656};
13657
13658static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13659 { 2, alc861_uniwill_m31_ch2_init },
13660 { 4, alc861_uniwill_m31_ch4_init },
13661};
Kailang Yangdf694da2005-12-05 19:42:22 +010013662
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013663/* Set mic1 and line-in as input and unmute the mixer */
13664static struct hda_verb alc861_asus_ch2_init[] = {
13665 /* set pin widget 1Ah (line in) for input */
13666 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013667 /* set pin widget 18h (mic1/2) for input, for mic also enable
13668 * the vref
13669 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013670 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13671
13672 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13673#if 0
13674 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13675 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13676#endif
13677 { } /* end */
13678};
13679/* Set mic1 nad line-in as output and mute mixer */
13680static struct hda_verb alc861_asus_ch6_init[] = {
13681 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13682 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13683 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13684 /* set pin widget 18h (mic1) for output (CLFE)*/
13685 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13686 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13687 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13688 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13689
13690 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13691#if 0
13692 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13693 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13694#endif
13695 { } /* end */
13696};
13697
13698static struct hda_channel_mode alc861_asus_modes[2] = {
13699 { 2, alc861_asus_ch2_init },
13700 { 6, alc861_asus_ch6_init },
13701};
13702
Kailang Yangdf694da2005-12-05 19:42:22 +010013703/* patch-ALC861 */
13704
13705static struct snd_kcontrol_new alc861_base_mixer[] = {
13706 /* output mixer control */
13707 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13708 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13709 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13710 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13711 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13712
13713 /*Input mixer control */
13714 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13715 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13716 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13717 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13718 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13719 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13720 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13721 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13722 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13723 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013724
Kailang Yangdf694da2005-12-05 19:42:22 +010013725 { } /* end */
13726};
13727
13728static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13729 /* output mixer control */
13730 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13731 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13732 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13733 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13734 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13735
13736 /* Input mixer control */
13737 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13738 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13739 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13740 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13741 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13742 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13744 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13745 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13746 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013747
Kailang Yangdf694da2005-12-05 19:42:22 +010013748 {
13749 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13750 .name = "Channel Mode",
13751 .info = alc_ch_mode_info,
13752 .get = alc_ch_mode_get,
13753 .put = alc_ch_mode_put,
13754 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13755 },
13756 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013757};
13758
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013759static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013760 /* output mixer control */
13761 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13763 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013764
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013765 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013766};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013767
Takashi Iwai22309c32006-08-09 16:57:28 +020013768static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13769 /* output mixer control */
13770 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13771 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13772 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13773 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13774 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13775
13776 /* Input mixer control */
13777 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13778 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13779 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13780 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13781 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13782 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13783 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13784 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13785 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13786 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013787
Takashi Iwai22309c32006-08-09 16:57:28 +020013788 {
13789 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13790 .name = "Channel Mode",
13791 .info = alc_ch_mode_info,
13792 .get = alc_ch_mode_get,
13793 .put = alc_ch_mode_put,
13794 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13795 },
13796 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013797};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013798
13799static struct snd_kcontrol_new alc861_asus_mixer[] = {
13800 /* output mixer control */
13801 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13802 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13803 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13804 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13805 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13806
13807 /* Input mixer control */
13808 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13809 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13810 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13811 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13812 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13813 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13814 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13815 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13816 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013817 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13818
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013819 {
13820 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13821 .name = "Channel Mode",
13822 .info = alc_ch_mode_info,
13823 .get = alc_ch_mode_get,
13824 .put = alc_ch_mode_put,
13825 .private_value = ARRAY_SIZE(alc861_asus_modes),
13826 },
13827 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013828};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013829
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013830/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013831static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013832 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13833 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013834 { }
13835};
13836
Kailang Yangdf694da2005-12-05 19:42:22 +010013837/*
13838 * generic initialization of ADC, input mixers and output mixers
13839 */
13840static struct hda_verb alc861_base_init_verbs[] = {
13841 /*
13842 * Unmute ADC0 and set the default input to mic-in
13843 */
13844 /* port-A for surround (rear panel) */
13845 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13846 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13847 /* port-B for mic-in (rear panel) with vref */
13848 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13849 /* port-C for line-in (rear panel) */
13850 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13851 /* port-D for Front */
13852 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13853 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13854 /* port-E for HP out (front panel) */
13855 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13856 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013857 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013858 /* port-F for mic-in (front panel) with vref */
13859 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13860 /* port-G for CLFE (rear panel) */
13861 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13862 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13863 /* port-H for side (rear panel) */
13864 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13865 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13866 /* CD-in */
13867 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13868 /* route front mic to ADC1*/
13869 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13870 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013871
Kailang Yangdf694da2005-12-05 19:42:22 +010013872 /* Unmute DAC0~3 & spdif out*/
13873 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13874 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13875 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13876 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13877 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013878
Kailang Yangdf694da2005-12-05 19:42:22 +010013879 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13880 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13881 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13882 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13883 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013884
Kailang Yangdf694da2005-12-05 19:42:22 +010013885 /* Unmute Stereo Mixer 15 */
13886 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13887 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13888 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013889 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013890
13891 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13892 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13893 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13894 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13895 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13896 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13897 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13898 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013899 /* hp used DAC 3 (Front) */
13900 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013901 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13902
13903 { }
13904};
13905
13906static struct hda_verb alc861_threestack_init_verbs[] = {
13907 /*
13908 * Unmute ADC0 and set the default input to mic-in
13909 */
13910 /* port-A for surround (rear panel) */
13911 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13912 /* port-B for mic-in (rear panel) with vref */
13913 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13914 /* port-C for line-in (rear panel) */
13915 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13916 /* port-D for Front */
13917 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13918 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13919 /* port-E for HP out (front panel) */
13920 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13921 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013922 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013923 /* port-F for mic-in (front panel) with vref */
13924 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13925 /* port-G for CLFE (rear panel) */
13926 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13927 /* port-H for side (rear panel) */
13928 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13929 /* CD-in */
13930 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13931 /* route front mic to ADC1*/
13932 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13933 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13934 /* Unmute DAC0~3 & spdif out*/
13935 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13936 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13937 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13938 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013940
Kailang Yangdf694da2005-12-05 19:42:22 +010013941 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13942 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13943 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13944 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13945 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013946
Kailang Yangdf694da2005-12-05 19:42:22 +010013947 /* Unmute Stereo Mixer 15 */
13948 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13949 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13950 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013951 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013952
13953 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13954 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13955 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13956 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13957 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13958 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13959 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13960 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013961 /* hp used DAC 3 (Front) */
13962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013963 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13964 { }
13965};
Takashi Iwai22309c32006-08-09 16:57:28 +020013966
13967static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13968 /*
13969 * Unmute ADC0 and set the default input to mic-in
13970 */
13971 /* port-A for surround (rear panel) */
13972 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13973 /* port-B for mic-in (rear panel) with vref */
13974 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13975 /* port-C for line-in (rear panel) */
13976 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13977 /* port-D for Front */
13978 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13979 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13980 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013981 /* this has to be set to VREF80 */
13982 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013983 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013984 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013985 /* port-F for mic-in (front panel) with vref */
13986 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13987 /* port-G for CLFE (rear panel) */
13988 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13989 /* port-H for side (rear panel) */
13990 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13991 /* CD-in */
13992 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13993 /* route front mic to ADC1*/
13994 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13995 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13996 /* Unmute DAC0~3 & spdif out*/
13997 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13998 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13999 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14000 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14001 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014002
Takashi Iwai22309c32006-08-09 16:57:28 +020014003 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14004 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14005 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14006 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14007 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014008
Takashi Iwai22309c32006-08-09 16:57:28 +020014009 /* Unmute Stereo Mixer 15 */
14010 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14011 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014013 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014014
14015 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14016 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14017 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14018 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14019 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14020 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14021 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14022 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014023 /* hp used DAC 3 (Front) */
14024 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014025 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14026 { }
14027};
14028
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014029static struct hda_verb alc861_asus_init_verbs[] = {
14030 /*
14031 * Unmute ADC0 and set the default input to mic-in
14032 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014033 /* port-A for surround (rear panel)
14034 * according to codec#0 this is the HP jack
14035 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014036 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14037 /* route front PCM to HP */
14038 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14039 /* port-B for mic-in (rear panel) with vref */
14040 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14041 /* port-C for line-in (rear panel) */
14042 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14043 /* port-D for Front */
14044 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14045 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14046 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014047 /* this has to be set to VREF80 */
14048 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014049 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014050 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014051 /* port-F for mic-in (front panel) with vref */
14052 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14053 /* port-G for CLFE (rear panel) */
14054 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14055 /* port-H for side (rear panel) */
14056 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14057 /* CD-in */
14058 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14059 /* route front mic to ADC1*/
14060 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14061 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14062 /* Unmute DAC0~3 & spdif out*/
14063 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14064 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14065 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14066 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14067 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14068 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14069 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14070 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14071 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14072 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014073
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014074 /* Unmute Stereo Mixer 15 */
14075 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14076 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14077 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014078 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014079
14080 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14081 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14082 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14083 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14084 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14085 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14086 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14087 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014088 /* hp used DAC 3 (Front) */
14089 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014090 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14091 { }
14092};
14093
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014094/* additional init verbs for ASUS laptops */
14095static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14096 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14097 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14098 { }
14099};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014100
Kailang Yangdf694da2005-12-05 19:42:22 +010014101/*
14102 * generic initialization of ADC, input mixers and output mixers
14103 */
14104static struct hda_verb alc861_auto_init_verbs[] = {
14105 /*
14106 * Unmute ADC0 and set the default input to mic-in
14107 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014108 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014109 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014110
Kailang Yangdf694da2005-12-05 19:42:22 +010014111 /* Unmute DAC0~3 & spdif out*/
14112 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14113 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14114 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14115 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014117
Kailang Yangdf694da2005-12-05 19:42:22 +010014118 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14119 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14120 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14121 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14122 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014123
Kailang Yangdf694da2005-12-05 19:42:22 +010014124 /* Unmute Stereo Mixer 15 */
14125 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14129
14130 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14131 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14132 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14133 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14134 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14135 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14136 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14137 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14138
14139 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14140 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014141 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14142 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014143 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14144 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014145 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14146 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014147
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014148 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014149
14150 { }
14151};
14152
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014153static struct hda_verb alc861_toshiba_init_verbs[] = {
14154 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014155
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014156 { }
14157};
14158
14159/* toggle speaker-output according to the hp-jack state */
14160static void alc861_toshiba_automute(struct hda_codec *codec)
14161{
14162 unsigned int present;
14163
14164 present = snd_hda_codec_read(codec, 0x0f, 0,
14165 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014166 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14167 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14168 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14169 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014170}
14171
14172static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14173 unsigned int res)
14174{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014175 if ((res >> 26) == ALC880_HP_EVENT)
14176 alc861_toshiba_automute(codec);
14177}
14178
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014179/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014180#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14181#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14182#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14183#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14184
14185
14186#define ALC861_DIGOUT_NID 0x07
14187
14188static struct hda_channel_mode alc861_8ch_modes[1] = {
14189 { 8, NULL }
14190};
14191
14192static hda_nid_t alc861_dac_nids[4] = {
14193 /* front, surround, clfe, side */
14194 0x03, 0x06, 0x05, 0x04
14195};
14196
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014197static hda_nid_t alc660_dac_nids[3] = {
14198 /* front, clfe, surround */
14199 0x03, 0x05, 0x06
14200};
14201
Kailang Yangdf694da2005-12-05 19:42:22 +010014202static hda_nid_t alc861_adc_nids[1] = {
14203 /* ADC0-2 */
14204 0x08,
14205};
14206
14207static struct hda_input_mux alc861_capture_source = {
14208 .num_items = 5,
14209 .items = {
14210 { "Mic", 0x0 },
14211 { "Front Mic", 0x3 },
14212 { "Line", 0x1 },
14213 { "CD", 0x4 },
14214 { "Mixer", 0x5 },
14215 },
14216};
14217
14218/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014219static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
14220 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014221{
14222 int i;
14223 hda_nid_t nid;
14224
14225 spec->multiout.dac_nids = spec->private_dac_nids;
14226 for (i = 0; i < cfg->line_outs; i++) {
14227 nid = cfg->line_out_pins[i];
14228 if (nid) {
14229 if (i >= ARRAY_SIZE(alc861_dac_nids))
14230 continue;
14231 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
14232 }
14233 }
14234 spec->multiout.num_dacs = cfg->line_outs;
14235 return 0;
14236}
14237
14238/* add playback controls from the parsed DAC table */
14239static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
14240 const struct auto_pin_cfg *cfg)
14241{
14242 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014243 static const char *chname[4] = {
14244 "Front", "Surround", NULL /*CLFE*/, "Side"
14245 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014246 hda_nid_t nid;
14247 int i, idx, err;
14248
14249 for (i = 0; i < cfg->line_outs; i++) {
14250 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014251 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014252 continue;
14253 if (nid == 0x05) {
14254 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014255 err = add_control(spec, ALC_CTL_BIND_MUTE,
14256 "Center Playback Switch",
14257 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14258 HDA_OUTPUT));
14259 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014260 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014261 err = add_control(spec, ALC_CTL_BIND_MUTE,
14262 "LFE Playback Switch",
14263 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14264 HDA_OUTPUT));
14265 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014266 return err;
14267 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014268 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
14269 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010014270 if (nid == alc861_dac_nids[idx])
14271 break;
14272 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014273 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14274 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14275 HDA_OUTPUT));
14276 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014277 return err;
14278 }
14279 }
14280 return 0;
14281}
14282
14283static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
14284{
14285 int err;
14286 hda_nid_t nid;
14287
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014288 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014289 return 0;
14290
14291 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
14292 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014293 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
14294 "Headphone Playback Switch",
14295 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14296 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014297 return err;
14298 spec->multiout.hp_nid = nid;
14299 }
14300 return 0;
14301}
14302
14303/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014304static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
14305 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014306{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014307 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014308 int i, err, idx, idx1;
14309
14310 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014311 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014312 case 0x0c:
14313 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014314 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014315 break;
14316 case 0x0f:
14317 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014318 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014319 break;
14320 case 0x0d:
14321 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014322 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014323 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014324 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014325 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014326 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014327 break;
14328 case 0x11:
14329 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014330 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014331 break;
14332 default:
14333 continue;
14334 }
14335
Takashi Iwai4a471b72005-12-07 13:56:29 +010014336 err = new_analog_input(spec, cfg->input_pins[i],
14337 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014338 if (err < 0)
14339 return err;
14340
Takashi Iwai4a471b72005-12-07 13:56:29 +010014341 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014342 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014343 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014344 }
14345 return 0;
14346}
14347
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014348static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14349 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010014350 int pin_type, int dac_idx)
14351{
Jacek Luczak564c5be2008-05-03 18:41:23 +020014352 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14353 pin_type);
14354 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14355 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010014356}
14357
14358static void alc861_auto_init_multi_out(struct hda_codec *codec)
14359{
14360 struct alc_spec *spec = codec->spec;
14361 int i;
14362
14363 for (i = 0; i < spec->autocfg.line_outs; i++) {
14364 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014365 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014366 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014367 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014368 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014369 }
14370}
14371
14372static void alc861_auto_init_hp_out(struct hda_codec *codec)
14373{
14374 struct alc_spec *spec = codec->spec;
14375 hda_nid_t pin;
14376
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014377 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014378 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014379 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
14380 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014381 pin = spec->autocfg.speaker_pins[0];
14382 if (pin)
14383 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014384}
14385
14386static void alc861_auto_init_analog_input(struct hda_codec *codec)
14387{
14388 struct alc_spec *spec = codec->spec;
14389 int i;
14390
14391 for (i = 0; i < AUTO_PIN_LAST; i++) {
14392 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014393 if (nid >= 0x0c && nid <= 0x11)
14394 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014395 }
14396}
14397
14398/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014399/* return 1 if successful, 0 if the proper config is not found,
14400 * or a negative error code
14401 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014402static int alc861_parse_auto_config(struct hda_codec *codec)
14403{
14404 struct alc_spec *spec = codec->spec;
14405 int err;
14406 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14407
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014408 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14409 alc861_ignore);
14410 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014411 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014412 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014413 return 0; /* can't find valid BIOS pin config */
14414
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014415 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
14416 if (err < 0)
14417 return err;
14418 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
14419 if (err < 0)
14420 return err;
14421 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
14422 if (err < 0)
14423 return err;
14424 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
14425 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014426 return err;
14427
14428 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14429
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014430 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014431 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14432
Takashi Iwai603c4012008-07-30 15:01:44 +020014433 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014434 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014435
Takashi Iwaid88897e2008-10-31 15:01:37 +010014436 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014437
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014438 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014439 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014440
14441 spec->adc_nids = alc861_adc_nids;
14442 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014443 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014444
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014445 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14446
Kailang Yangdf694da2005-12-05 19:42:22 +010014447 return 1;
14448}
14449
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014450/* additional initialization for auto-configuration model */
14451static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014452{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014453 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014454 alc861_auto_init_multi_out(codec);
14455 alc861_auto_init_hp_out(codec);
14456 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014457 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014458 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014459}
14460
Takashi Iwaicb53c622007-08-10 17:21:45 +020014461#ifdef CONFIG_SND_HDA_POWER_SAVE
14462static struct hda_amp_list alc861_loopbacks[] = {
14463 { 0x15, HDA_INPUT, 0 },
14464 { 0x15, HDA_INPUT, 1 },
14465 { 0x15, HDA_INPUT, 2 },
14466 { 0x15, HDA_INPUT, 3 },
14467 { } /* end */
14468};
14469#endif
14470
Kailang Yangdf694da2005-12-05 19:42:22 +010014471
14472/*
14473 * configuration and preset
14474 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014475static const char *alc861_models[ALC861_MODEL_LAST] = {
14476 [ALC861_3ST] = "3stack",
14477 [ALC660_3ST] = "3stack-660",
14478 [ALC861_3ST_DIG] = "3stack-dig",
14479 [ALC861_6ST_DIG] = "6stack-dig",
14480 [ALC861_UNIWILL_M31] = "uniwill-m31",
14481 [ALC861_TOSHIBA] = "toshiba",
14482 [ALC861_ASUS] = "asus",
14483 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14484 [ALC861_AUTO] = "auto",
14485};
14486
14487static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014488 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014489 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14490 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14491 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014492 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014493 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014494 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014495 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14496 * Any other models that need this preset?
14497 */
14498 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014499 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14500 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014501 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14502 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14503 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14504 /* FIXME: the below seems conflict */
14505 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14506 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14507 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014508 {}
14509};
14510
14511static struct alc_config_preset alc861_presets[] = {
14512 [ALC861_3ST] = {
14513 .mixers = { alc861_3ST_mixer },
14514 .init_verbs = { alc861_threestack_init_verbs },
14515 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14516 .dac_nids = alc861_dac_nids,
14517 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14518 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014519 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014520 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14521 .adc_nids = alc861_adc_nids,
14522 .input_mux = &alc861_capture_source,
14523 },
14524 [ALC861_3ST_DIG] = {
14525 .mixers = { alc861_base_mixer },
14526 .init_verbs = { alc861_threestack_init_verbs },
14527 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14528 .dac_nids = alc861_dac_nids,
14529 .dig_out_nid = ALC861_DIGOUT_NID,
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,
Kailang Yangdf694da2005-12-05 19:42:22 +010014533 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14534 .adc_nids = alc861_adc_nids,
14535 .input_mux = &alc861_capture_source,
14536 },
14537 [ALC861_6ST_DIG] = {
14538 .mixers = { alc861_base_mixer },
14539 .init_verbs = { alc861_base_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_8ch_modes),
14544 .channel_mode = alc861_8ch_modes,
14545 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14546 .adc_nids = alc861_adc_nids,
14547 .input_mux = &alc861_capture_source,
14548 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014549 [ALC660_3ST] = {
14550 .mixers = { alc861_3ST_mixer },
14551 .init_verbs = { alc861_threestack_init_verbs },
14552 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14553 .dac_nids = alc660_dac_nids,
14554 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14555 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014556 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014557 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14558 .adc_nids = alc861_adc_nids,
14559 .input_mux = &alc861_capture_source,
14560 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014561 [ALC861_UNIWILL_M31] = {
14562 .mixers = { alc861_uniwill_m31_mixer },
14563 .init_verbs = { alc861_uniwill_m31_init_verbs },
14564 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14565 .dac_nids = alc861_dac_nids,
14566 .dig_out_nid = ALC861_DIGOUT_NID,
14567 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14568 .channel_mode = alc861_uniwill_m31_modes,
14569 .need_dac_fix = 1,
14570 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14571 .adc_nids = alc861_adc_nids,
14572 .input_mux = &alc861_capture_source,
14573 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014574 [ALC861_TOSHIBA] = {
14575 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014576 .init_verbs = { alc861_base_init_verbs,
14577 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014578 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14579 .dac_nids = alc861_dac_nids,
14580 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14581 .channel_mode = alc883_3ST_2ch_modes,
14582 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14583 .adc_nids = alc861_adc_nids,
14584 .input_mux = &alc861_capture_source,
14585 .unsol_event = alc861_toshiba_unsol_event,
14586 .init_hook = alc861_toshiba_automute,
14587 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014588 [ALC861_ASUS] = {
14589 .mixers = { alc861_asus_mixer },
14590 .init_verbs = { alc861_asus_init_verbs },
14591 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14592 .dac_nids = alc861_dac_nids,
14593 .dig_out_nid = ALC861_DIGOUT_NID,
14594 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14595 .channel_mode = alc861_asus_modes,
14596 .need_dac_fix = 1,
14597 .hp_nid = 0x06,
14598 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14599 .adc_nids = alc861_adc_nids,
14600 .input_mux = &alc861_capture_source,
14601 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014602 [ALC861_ASUS_LAPTOP] = {
14603 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14604 .init_verbs = { alc861_asus_init_verbs,
14605 alc861_asus_laptop_init_verbs },
14606 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14607 .dac_nids = alc861_dac_nids,
14608 .dig_out_nid = ALC861_DIGOUT_NID,
14609 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14610 .channel_mode = alc883_3ST_2ch_modes,
14611 .need_dac_fix = 1,
14612 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14613 .adc_nids = alc861_adc_nids,
14614 .input_mux = &alc861_capture_source,
14615 },
14616};
Kailang Yangdf694da2005-12-05 19:42:22 +010014617
14618
14619static int patch_alc861(struct hda_codec *codec)
14620{
14621 struct alc_spec *spec;
14622 int board_config;
14623 int err;
14624
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014625 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014626 if (spec == NULL)
14627 return -ENOMEM;
14628
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014629 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014630
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014631 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14632 alc861_models,
14633 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014634
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014635 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020014636 printk(KERN_INFO "hda_codec: Unknown model for %s, "
14637 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014638 board_config = ALC861_AUTO;
14639 }
14640
14641 if (board_config == ALC861_AUTO) {
14642 /* automatic parse from the BIOS config */
14643 err = alc861_parse_auto_config(codec);
14644 if (err < 0) {
14645 alc_free(codec);
14646 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014647 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014648 printk(KERN_INFO
14649 "hda_codec: Cannot set up configuration "
14650 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014651 board_config = ALC861_3ST_DIG;
14652 }
14653 }
14654
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014655 err = snd_hda_attach_beep_device(codec, 0x23);
14656 if (err < 0) {
14657 alc_free(codec);
14658 return err;
14659 }
14660
Kailang Yangdf694da2005-12-05 19:42:22 +010014661 if (board_config != ALC861_AUTO)
14662 setup_preset(spec, &alc861_presets[board_config]);
14663
Kailang Yangdf694da2005-12-05 19:42:22 +010014664 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14665 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14666
Kailang Yangdf694da2005-12-05 19:42:22 +010014667 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14668 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14669
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014670 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14671
Takashi Iwai2134ea42008-01-10 16:53:55 +010014672 spec->vmaster_nid = 0x03;
14673
Kailang Yangdf694da2005-12-05 19:42:22 +010014674 codec->patch_ops = alc_patch_ops;
14675 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014676 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014677#ifdef CONFIG_SND_HDA_POWER_SAVE
14678 if (!spec->loopback.amplist)
14679 spec->loopback.amplist = alc861_loopbacks;
14680#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014681 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014682
Kailang Yangdf694da2005-12-05 19:42:22 +010014683 return 0;
14684}
14685
14686/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014687 * ALC861-VD support
14688 *
14689 * Based on ALC882
14690 *
14691 * In addition, an independent DAC
14692 */
14693#define ALC861VD_DIGOUT_NID 0x06
14694
14695static hda_nid_t alc861vd_dac_nids[4] = {
14696 /* front, surr, clfe, side surr */
14697 0x02, 0x03, 0x04, 0x05
14698};
14699
14700/* dac_nids for ALC660vd are in a different order - according to
14701 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014702 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014703 * of ALC660vd codecs, but for now there is only 3stack mixer
14704 * - and it is the same as in 861vd.
14705 * adc_nids in ALC660vd are (is) the same as in 861vd
14706 */
14707static hda_nid_t alc660vd_dac_nids[3] = {
14708 /* front, rear, clfe, rear_surr */
14709 0x02, 0x04, 0x03
14710};
14711
14712static hda_nid_t alc861vd_adc_nids[1] = {
14713 /* ADC0 */
14714 0x09,
14715};
14716
Takashi Iwaie1406342008-02-11 18:32:32 +010014717static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14718
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014719/* input MUX */
14720/* FIXME: should be a matrix-type input source selection */
14721static struct hda_input_mux alc861vd_capture_source = {
14722 .num_items = 4,
14723 .items = {
14724 { "Mic", 0x0 },
14725 { "Front Mic", 0x1 },
14726 { "Line", 0x2 },
14727 { "CD", 0x4 },
14728 },
14729};
14730
Kailang Yang272a5272007-05-14 11:00:38 +020014731static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014732 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014733 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014734 { "Ext Mic", 0x0 },
14735 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014736 },
14737};
14738
Kailang Yangd1a991a2007-08-15 16:21:59 +020014739static struct hda_input_mux alc861vd_hp_capture_source = {
14740 .num_items = 2,
14741 .items = {
14742 { "Front Mic", 0x0 },
14743 { "ATAPI Mic", 0x1 },
14744 },
14745};
14746
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014747/*
14748 * 2ch mode
14749 */
14750static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14751 { 2, NULL }
14752};
14753
14754/*
14755 * 6ch mode
14756 */
14757static struct hda_verb alc861vd_6stack_ch6_init[] = {
14758 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14759 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14760 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14761 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14762 { } /* end */
14763};
14764
14765/*
14766 * 8ch mode
14767 */
14768static struct hda_verb alc861vd_6stack_ch8_init[] = {
14769 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14770 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14771 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14772 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14773 { } /* end */
14774};
14775
14776static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14777 { 6, alc861vd_6stack_ch6_init },
14778 { 8, alc861vd_6stack_ch8_init },
14779};
14780
14781static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14782 {
14783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14784 .name = "Channel Mode",
14785 .info = alc_ch_mode_info,
14786 .get = alc_ch_mode_get,
14787 .put = alc_ch_mode_put,
14788 },
14789 { } /* end */
14790};
14791
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014792/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14793 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14794 */
14795static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14796 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14797 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14798
14799 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14800 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14801
14802 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14803 HDA_OUTPUT),
14804 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14805 HDA_OUTPUT),
14806 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14807 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14808
14809 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14810 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14811
14812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14813
14814 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14816 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14817
14818 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14819 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14820 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14821
14822 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14823 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14824
14825 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14826 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14827
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014828 { } /* end */
14829};
14830
14831static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14832 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14833 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
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("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14846 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14847
14848 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14849 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14850
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014851 { } /* end */
14852};
14853
Kailang Yangbdd148a2007-05-08 15:19:08 +020014854static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14855 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14856 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14857 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14858
14859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14860
14861 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14862 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14863 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14864
14865 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14866 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14867 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14868
14869 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14870 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14871
14872 { } /* end */
14873};
14874
Tobin Davisb419f342008-03-07 11:57:51 +010014875/* Pin assignment: Speaker=0x14, HP = 0x15,
14876 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014877 */
14878static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014879 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14880 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014881 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14882 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014883 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14884 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14885 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14886 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14887 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14888 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014889 { } /* end */
14890};
14891
Kailang Yangd1a991a2007-08-15 16:21:59 +020014892/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14893 * Front Mic=0x18, ATAPI Mic = 0x19,
14894 */
14895static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14896 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14897 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14898 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14899 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14900 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14901 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14902 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14903 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014904
Kailang Yangd1a991a2007-08-15 16:21:59 +020014905 { } /* end */
14906};
14907
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014908/*
14909 * generic initialization of ADC, input mixers and output mixers
14910 */
14911static struct hda_verb alc861vd_volume_init_verbs[] = {
14912 /*
14913 * Unmute ADC0 and set the default input to mic-in
14914 */
14915 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14916 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14917
14918 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14919 * the analog-loopback mixer widget
14920 */
14921 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014922 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14923 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14924 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14925 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014927
14928 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014929 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14930 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14931 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014932 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014933
14934 /*
14935 * Set up output mixers (0x02 - 0x05)
14936 */
14937 /* set vol=0 to output mixers */
14938 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14939 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14940 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14941 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14942
14943 /* set up input amps for analog loopback */
14944 /* Amp Indices: DAC = 0, mixer = 1 */
14945 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14946 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14947 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14948 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14949 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14950 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14951 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14952 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14953
14954 { }
14955};
14956
14957/*
14958 * 3-stack pin configuration:
14959 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14960 */
14961static struct hda_verb alc861vd_3stack_init_verbs[] = {
14962 /*
14963 * Set pin mode and muting
14964 */
14965 /* set front pin widgets 0x14 for output */
14966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14968 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14969
14970 /* Mic (rear) pin: input vref at 80% */
14971 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14972 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14973 /* Front Mic pin: input vref at 80% */
14974 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14975 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14976 /* Line In pin: input */
14977 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14978 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14979 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14980 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14981 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14982 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14983 /* CD pin widget for input */
14984 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14985
14986 { }
14987};
14988
14989/*
14990 * 6-stack pin configuration:
14991 */
14992static struct hda_verb alc861vd_6stack_init_verbs[] = {
14993 /*
14994 * Set pin mode and muting
14995 */
14996 /* set front pin widgets 0x14 for output */
14997 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14998 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14999 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15000
15001 /* Rear Pin: output 1 (0x0d) */
15002 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15003 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15004 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15005 /* CLFE Pin: output 2 (0x0e) */
15006 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15007 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15008 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15009 /* Side Pin: output 3 (0x0f) */
15010 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15011 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15012 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15013
15014 /* Mic (rear) pin: input vref at 80% */
15015 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15016 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15017 /* Front Mic pin: input vref at 80% */
15018 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15019 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15020 /* Line In pin: input */
15021 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15022 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15023 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15024 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15025 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15026 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15027 /* CD pin widget for input */
15028 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15029
15030 { }
15031};
15032
Kailang Yangbdd148a2007-05-08 15:19:08 +020015033static struct hda_verb alc861vd_eapd_verbs[] = {
15034 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15035 { }
15036};
15037
Kailang Yangf9423e72008-05-27 12:32:25 +020015038static struct hda_verb alc660vd_eapd_verbs[] = {
15039 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15040 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15041 { }
15042};
15043
Kailang Yangbdd148a2007-05-08 15:19:08 +020015044static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15045 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15047 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15048 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015049 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015050 {}
15051};
15052
Kailang Yangbdd148a2007-05-08 15:19:08 +020015053static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15054{
15055 unsigned int present;
15056 unsigned char bits;
15057
15058 present = snd_hda_codec_read(codec, 0x18, 0,
15059 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015060 bits = present ? HDA_AMP_MUTE : 0;
15061 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15062 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015063}
15064
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015065static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015066{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015067 struct alc_spec *spec = codec->spec;
15068
15069 spec->autocfg.hp_pins[0] = 0x1b;
15070 spec->autocfg.speaker_pins[0] = 0x14;
15071 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015072 alc861vd_lenovo_mic_automute(codec);
15073}
15074
15075static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15076 unsigned int res)
15077{
15078 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015079 case ALC880_MIC_EVENT:
15080 alc861vd_lenovo_mic_automute(codec);
15081 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015082 default:
15083 alc_automute_amp_unsol_event(codec, res);
15084 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015085 }
15086}
15087
Kailang Yang272a5272007-05-14 11:00:38 +020015088static struct hda_verb alc861vd_dallas_verbs[] = {
15089 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15090 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15091 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15092 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15093
15094 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15095 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15096 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15097 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15098 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15099 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15100 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15101 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015102
Kailang Yang272a5272007-05-14 11:00:38 +020015103 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15104 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15105 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15106 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15107 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15108 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15109 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15110 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15111
15112 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15113 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15114 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15115 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15116 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15117 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15118 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15119 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15120
15121 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15123 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15124 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15125
15126 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015127 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015128 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15129
15130 { } /* end */
15131};
15132
15133/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015134static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015135{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015136 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015137
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015138 spec->autocfg.hp_pins[0] = 0x15;
15139 spec->autocfg.speaker_pins[0] = 0x14;
15140 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020015141}
15142
Takashi Iwaicb53c622007-08-10 17:21:45 +020015143#ifdef CONFIG_SND_HDA_POWER_SAVE
15144#define alc861vd_loopbacks alc880_loopbacks
15145#endif
15146
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015147/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015148#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15149#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15150#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15151#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15152
15153/*
15154 * configuration and preset
15155 */
15156static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15157 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015158 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015159 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015160 [ALC861VD_3ST] = "3stack",
15161 [ALC861VD_3ST_DIG] = "3stack-digout",
15162 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015163 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015164 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015165 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015166 [ALC861VD_AUTO] = "auto",
15167};
15168
15169static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015170 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15171 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015172 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015173 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010015174 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015175 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015176 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015177 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015178 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015179 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015180 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015181 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015182 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015183 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015184 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015185 {}
15186};
15187
15188static struct alc_config_preset alc861vd_presets[] = {
15189 [ALC660VD_3ST] = {
15190 .mixers = { alc861vd_3st_mixer },
15191 .init_verbs = { alc861vd_volume_init_verbs,
15192 alc861vd_3stack_init_verbs },
15193 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15194 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015195 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15196 .channel_mode = alc861vd_3stack_2ch_modes,
15197 .input_mux = &alc861vd_capture_source,
15198 },
Mike Crash6963f842007-06-25 12:12:51 +020015199 [ALC660VD_3ST_DIG] = {
15200 .mixers = { alc861vd_3st_mixer },
15201 .init_verbs = { alc861vd_volume_init_verbs,
15202 alc861vd_3stack_init_verbs },
15203 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15204 .dac_nids = alc660vd_dac_nids,
15205 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015206 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15207 .channel_mode = alc861vd_3stack_2ch_modes,
15208 .input_mux = &alc861vd_capture_source,
15209 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015210 [ALC861VD_3ST] = {
15211 .mixers = { alc861vd_3st_mixer },
15212 .init_verbs = { alc861vd_volume_init_verbs,
15213 alc861vd_3stack_init_verbs },
15214 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15215 .dac_nids = alc861vd_dac_nids,
15216 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15217 .channel_mode = alc861vd_3stack_2ch_modes,
15218 .input_mux = &alc861vd_capture_source,
15219 },
15220 [ALC861VD_3ST_DIG] = {
15221 .mixers = { alc861vd_3st_mixer },
15222 .init_verbs = { alc861vd_volume_init_verbs,
15223 alc861vd_3stack_init_verbs },
15224 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15225 .dac_nids = alc861vd_dac_nids,
15226 .dig_out_nid = ALC861VD_DIGOUT_NID,
15227 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15228 .channel_mode = alc861vd_3stack_2ch_modes,
15229 .input_mux = &alc861vd_capture_source,
15230 },
15231 [ALC861VD_6ST_DIG] = {
15232 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15233 .init_verbs = { alc861vd_volume_init_verbs,
15234 alc861vd_6stack_init_verbs },
15235 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15236 .dac_nids = alc861vd_dac_nids,
15237 .dig_out_nid = ALC861VD_DIGOUT_NID,
15238 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15239 .channel_mode = alc861vd_6stack_modes,
15240 .input_mux = &alc861vd_capture_source,
15241 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015242 [ALC861VD_LENOVO] = {
15243 .mixers = { alc861vd_lenovo_mixer },
15244 .init_verbs = { alc861vd_volume_init_verbs,
15245 alc861vd_3stack_init_verbs,
15246 alc861vd_eapd_verbs,
15247 alc861vd_lenovo_unsol_verbs },
15248 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15249 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015250 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15251 .channel_mode = alc861vd_3stack_2ch_modes,
15252 .input_mux = &alc861vd_capture_source,
15253 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015254 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015255 },
Kailang Yang272a5272007-05-14 11:00:38 +020015256 [ALC861VD_DALLAS] = {
15257 .mixers = { alc861vd_dallas_mixer },
15258 .init_verbs = { alc861vd_dallas_verbs },
15259 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15260 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015261 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15262 .channel_mode = alc861vd_3stack_2ch_modes,
15263 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015264 .unsol_event = alc_automute_amp_unsol_event,
15265 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015266 },
15267 [ALC861VD_HP] = {
15268 .mixers = { alc861vd_hp_mixer },
15269 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15270 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15271 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015272 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015273 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15274 .channel_mode = alc861vd_3stack_2ch_modes,
15275 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015276 .unsol_event = alc_automute_amp_unsol_event,
15277 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020015278 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015279 [ALC660VD_ASUS_V1S] = {
15280 .mixers = { alc861vd_lenovo_mixer },
15281 .init_verbs = { alc861vd_volume_init_verbs,
15282 alc861vd_3stack_init_verbs,
15283 alc861vd_eapd_verbs,
15284 alc861vd_lenovo_unsol_verbs },
15285 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15286 .dac_nids = alc660vd_dac_nids,
15287 .dig_out_nid = ALC861VD_DIGOUT_NID,
15288 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15289 .channel_mode = alc861vd_3stack_2ch_modes,
15290 .input_mux = &alc861vd_capture_source,
15291 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015292 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015293 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015294};
15295
15296/*
15297 * BIOS auto configuration
15298 */
15299static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15300 hda_nid_t nid, int pin_type, int dac_idx)
15301{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015302 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015303}
15304
15305static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15306{
15307 struct alc_spec *spec = codec->spec;
15308 int i;
15309
15310 for (i = 0; i <= HDA_SIDE; i++) {
15311 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015312 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015313 if (nid)
15314 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015315 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015316 }
15317}
15318
15319
15320static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15321{
15322 struct alc_spec *spec = codec->spec;
15323 hda_nid_t pin;
15324
15325 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015326 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015327 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015328 pin = spec->autocfg.speaker_pins[0];
15329 if (pin)
15330 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015331}
15332
15333#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15334#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15335
15336static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15337{
15338 struct alc_spec *spec = codec->spec;
15339 int i;
15340
15341 for (i = 0; i < AUTO_PIN_LAST; i++) {
15342 hda_nid_t nid = spec->autocfg.input_pins[i];
15343 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015344 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015345 if (nid != ALC861VD_PIN_CD_NID &&
15346 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015347 snd_hda_codec_write(codec, nid, 0,
15348 AC_VERB_SET_AMP_GAIN_MUTE,
15349 AMP_OUT_MUTE);
15350 }
15351 }
15352}
15353
Takashi Iwaif511b012008-08-15 16:46:42 +020015354#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15355
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015356#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15357#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15358
15359/* add playback controls from the parsed DAC table */
15360/* Based on ALC880 version. But ALC861VD has separate,
15361 * different NIDs for mute/unmute switch and volume control */
15362static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15363 const struct auto_pin_cfg *cfg)
15364{
15365 char name[32];
15366 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15367 hda_nid_t nid_v, nid_s;
15368 int i, err;
15369
15370 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015371 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015372 continue;
15373 nid_v = alc861vd_idx_to_mixer_vol(
15374 alc880_dac_to_idx(
15375 spec->multiout.dac_nids[i]));
15376 nid_s = alc861vd_idx_to_mixer_switch(
15377 alc880_dac_to_idx(
15378 spec->multiout.dac_nids[i]));
15379
15380 if (i == 2) {
15381 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015382 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15383 "Center Playback Volume",
15384 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15385 HDA_OUTPUT));
15386 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015387 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015388 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15389 "LFE Playback Volume",
15390 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15391 HDA_OUTPUT));
15392 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015393 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015394 err = add_control(spec, ALC_CTL_BIND_MUTE,
15395 "Center Playback Switch",
15396 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15397 HDA_INPUT));
15398 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015399 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015400 err = add_control(spec, ALC_CTL_BIND_MUTE,
15401 "LFE Playback Switch",
15402 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15403 HDA_INPUT));
15404 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015405 return err;
15406 } else {
15407 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015408 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15409 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15410 HDA_OUTPUT));
15411 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015412 return err;
15413 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015414 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015415 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015416 HDA_INPUT));
15417 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015418 return err;
15419 }
15420 }
15421 return 0;
15422}
15423
15424/* add playback controls for speaker and HP outputs */
15425/* Based on ALC880 version. But ALC861VD has separate,
15426 * different NIDs for mute/unmute switch and volume control */
15427static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15428 hda_nid_t pin, const char *pfx)
15429{
15430 hda_nid_t nid_v, nid_s;
15431 int err;
15432 char name[32];
15433
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015434 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015435 return 0;
15436
15437 if (alc880_is_fixed_pin(pin)) {
15438 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15439 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015440 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015441 spec->multiout.hp_nid = nid_v;
15442 else
15443 spec->multiout.extra_out_nid[0] = nid_v;
15444 /* control HP volume/switch on the output mixer amp */
15445 nid_v = alc861vd_idx_to_mixer_vol(
15446 alc880_fixed_pin_idx(pin));
15447 nid_s = alc861vd_idx_to_mixer_switch(
15448 alc880_fixed_pin_idx(pin));
15449
15450 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015451 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15452 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15453 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015454 return err;
15455 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015456 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15457 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15458 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015459 return err;
15460 } else if (alc880_is_multi_pin(pin)) {
15461 /* set manual connection */
15462 /* we have only a switch on HP-out PIN */
15463 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015464 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15465 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15466 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015467 return err;
15468 }
15469 return 0;
15470}
15471
15472/* parse the BIOS configuration and set up the alc_spec
15473 * return 1 if successful, 0 if the proper config is not found,
15474 * or a negative error code
15475 * Based on ALC880 version - had to change it to override
15476 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15477static int alc861vd_parse_auto_config(struct hda_codec *codec)
15478{
15479 struct alc_spec *spec = codec->spec;
15480 int err;
15481 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15482
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015483 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15484 alc861vd_ignore);
15485 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015486 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015487 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015488 return 0; /* can't find valid BIOS pin config */
15489
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015490 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15491 if (err < 0)
15492 return err;
15493 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15494 if (err < 0)
15495 return err;
15496 err = alc861vd_auto_create_extra_out(spec,
15497 spec->autocfg.speaker_pins[0],
15498 "Speaker");
15499 if (err < 0)
15500 return err;
15501 err = alc861vd_auto_create_extra_out(spec,
15502 spec->autocfg.hp_pins[0],
15503 "Headphone");
15504 if (err < 0)
15505 return err;
15506 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15507 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015508 return err;
15509
15510 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15511
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015512 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015513 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15514
Takashi Iwai603c4012008-07-30 15:01:44 +020015515 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015516 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015517
Takashi Iwaid88897e2008-10-31 15:01:37 +010015518 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015519
15520 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015521 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015522
Takashi Iwai776e1842007-08-29 15:07:11 +020015523 err = alc_auto_add_mic_boost(codec);
15524 if (err < 0)
15525 return err;
15526
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015527 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15528
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015529 return 1;
15530}
15531
15532/* additional initialization for auto-configuration model */
15533static void alc861vd_auto_init(struct hda_codec *codec)
15534{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015535 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015536 alc861vd_auto_init_multi_out(codec);
15537 alc861vd_auto_init_hp_out(codec);
15538 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015539 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015540 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015541 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015542}
15543
15544static int patch_alc861vd(struct hda_codec *codec)
15545{
15546 struct alc_spec *spec;
15547 int err, board_config;
15548
15549 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15550 if (spec == NULL)
15551 return -ENOMEM;
15552
15553 codec->spec = spec;
15554
15555 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15556 alc861vd_models,
15557 alc861vd_cfg_tbl);
15558
15559 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020015560 printk(KERN_INFO "hda_codec: Unknown model for %s, "
15561 "trying auto-probe from BIOS...\n", codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015562 board_config = ALC861VD_AUTO;
15563 }
15564
15565 if (board_config == ALC861VD_AUTO) {
15566 /* automatic parse from the BIOS config */
15567 err = alc861vd_parse_auto_config(codec);
15568 if (err < 0) {
15569 alc_free(codec);
15570 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015571 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015572 printk(KERN_INFO
15573 "hda_codec: Cannot set up configuration "
15574 "from BIOS. Using base mode...\n");
15575 board_config = ALC861VD_3ST;
15576 }
15577 }
15578
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015579 err = snd_hda_attach_beep_device(codec, 0x23);
15580 if (err < 0) {
15581 alc_free(codec);
15582 return err;
15583 }
15584
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015585 if (board_config != ALC861VD_AUTO)
15586 setup_preset(spec, &alc861vd_presets[board_config]);
15587
Kailang Yang2f893282008-05-27 12:14:47 +020015588 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015589 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015590 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015591 }
15592
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015593 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15594 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15595
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015596 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15597 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15598
Takashi Iwaidd704692009-08-11 08:45:11 +020015599 if (!spec->adc_nids) {
15600 spec->adc_nids = alc861vd_adc_nids;
15601 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15602 }
15603 if (!spec->capsrc_nids)
15604 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015605
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015606 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015607 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015608
Takashi Iwai2134ea42008-01-10 16:53:55 +010015609 spec->vmaster_nid = 0x02;
15610
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015611 codec->patch_ops = alc_patch_ops;
15612
15613 if (board_config == ALC861VD_AUTO)
15614 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015615#ifdef CONFIG_SND_HDA_POWER_SAVE
15616 if (!spec->loopback.amplist)
15617 spec->loopback.amplist = alc861vd_loopbacks;
15618#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015619 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015620
15621 return 0;
15622}
15623
15624/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015625 * ALC662 support
15626 *
15627 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15628 * configuration. Each pin widget can choose any input DACs and a mixer.
15629 * Each ADC is connected from a mixer of all inputs. This makes possible
15630 * 6-channel independent captures.
15631 *
15632 * In addition, an independent DAC for the multi-playback (not used in this
15633 * driver yet).
15634 */
15635#define ALC662_DIGOUT_NID 0x06
15636#define ALC662_DIGIN_NID 0x0a
15637
15638static hda_nid_t alc662_dac_nids[4] = {
15639 /* front, rear, clfe, rear_surr */
15640 0x02, 0x03, 0x04
15641};
15642
Kailang Yang622e84c2009-04-21 07:39:04 +020015643static hda_nid_t alc272_dac_nids[2] = {
15644 0x02, 0x03
15645};
15646
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015647static hda_nid_t alc662_adc_nids[1] = {
15648 /* ADC1-2 */
15649 0x09,
15650};
Takashi Iwaie1406342008-02-11 18:32:32 +010015651
Kailang Yang622e84c2009-04-21 07:39:04 +020015652static hda_nid_t alc272_adc_nids[1] = {
15653 /* ADC1-2 */
15654 0x08,
15655};
15656
Kailang Yang77a261b2008-02-19 11:38:05 +010015657static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015658static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15659
Takashi Iwaie1406342008-02-11 18:32:32 +010015660
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015661/* input MUX */
15662/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015663static struct hda_input_mux alc662_capture_source = {
15664 .num_items = 4,
15665 .items = {
15666 { "Mic", 0x0 },
15667 { "Front Mic", 0x1 },
15668 { "Line", 0x2 },
15669 { "CD", 0x4 },
15670 },
15671};
15672
15673static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15674 .num_items = 2,
15675 .items = {
15676 { "Mic", 0x1 },
15677 { "Line", 0x2 },
15678 },
15679};
Kailang Yang291702f2007-10-16 14:28:03 +020015680
15681static struct hda_input_mux alc662_eeepc_capture_source = {
15682 .num_items = 2,
15683 .items = {
15684 { "i-Mic", 0x1 },
15685 { "e-Mic", 0x0 },
15686 },
15687};
15688
Kailang Yang6dda9f42008-05-27 12:05:31 +020015689static struct hda_input_mux alc663_capture_source = {
15690 .num_items = 3,
15691 .items = {
15692 { "Mic", 0x0 },
15693 { "Front Mic", 0x1 },
15694 { "Line", 0x2 },
15695 },
15696};
15697
15698static struct hda_input_mux alc663_m51va_capture_source = {
15699 .num_items = 2,
15700 .items = {
15701 { "Ext-Mic", 0x0 },
15702 { "D-Mic", 0x9 },
15703 },
15704};
15705
Chris Pockelé9541ba12009-05-12 08:08:53 +020015706#if 1 /* set to 0 for testing other input sources below */
15707static struct hda_input_mux alc272_nc10_capture_source = {
15708 .num_items = 2,
15709 .items = {
15710 { "Autoselect Mic", 0x0 },
15711 { "Internal Mic", 0x1 },
15712 },
15713};
15714#else
15715static struct hda_input_mux alc272_nc10_capture_source = {
15716 .num_items = 16,
15717 .items = {
15718 { "Autoselect Mic", 0x0 },
15719 { "Internal Mic", 0x1 },
15720 { "In-0x02", 0x2 },
15721 { "In-0x03", 0x3 },
15722 { "In-0x04", 0x4 },
15723 { "In-0x05", 0x5 },
15724 { "In-0x06", 0x6 },
15725 { "In-0x07", 0x7 },
15726 { "In-0x08", 0x8 },
15727 { "In-0x09", 0x9 },
15728 { "In-0x0a", 0x0a },
15729 { "In-0x0b", 0x0b },
15730 { "In-0x0c", 0x0c },
15731 { "In-0x0d", 0x0d },
15732 { "In-0x0e", 0x0e },
15733 { "In-0x0f", 0x0f },
15734 },
15735};
15736#endif
15737
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015738/*
15739 * 2ch mode
15740 */
15741static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15742 { 2, NULL }
15743};
15744
15745/*
15746 * 2ch mode
15747 */
15748static struct hda_verb alc662_3ST_ch2_init[] = {
15749 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15750 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15751 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15752 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15753 { } /* end */
15754};
15755
15756/*
15757 * 6ch mode
15758 */
15759static struct hda_verb alc662_3ST_ch6_init[] = {
15760 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15761 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15762 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15763 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15764 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15765 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15766 { } /* end */
15767};
15768
15769static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15770 { 2, alc662_3ST_ch2_init },
15771 { 6, alc662_3ST_ch6_init },
15772};
15773
15774/*
15775 * 2ch mode
15776 */
15777static struct hda_verb alc662_sixstack_ch6_init[] = {
15778 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15779 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15780 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15781 { } /* end */
15782};
15783
15784/*
15785 * 6ch mode
15786 */
15787static struct hda_verb alc662_sixstack_ch8_init[] = {
15788 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15789 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15790 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15791 { } /* end */
15792};
15793
15794static struct hda_channel_mode alc662_5stack_modes[2] = {
15795 { 2, alc662_sixstack_ch6_init },
15796 { 6, alc662_sixstack_ch8_init },
15797};
15798
15799/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15800 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15801 */
15802
15803static struct snd_kcontrol_new alc662_base_mixer[] = {
15804 /* output mixer control */
15805 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015806 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015807 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015808 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015809 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15810 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015811 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15812 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015813 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15814
15815 /*Input mixer control */
15816 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15817 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15818 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15819 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15820 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15821 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15822 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15823 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015824 { } /* end */
15825};
15826
15827static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15828 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015829 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015830 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15831 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15832 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15833 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15834 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15837 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15838 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015839 { } /* end */
15840};
15841
15842static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15843 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015844 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015845 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015846 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015847 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15848 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015849 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15850 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015851 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15852 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15853 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15854 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15855 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15856 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15858 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15859 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015860 { } /* end */
15861};
15862
15863static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15864 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15865 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015866 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15867 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015868 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15869 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15870 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15871 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15872 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015873 { } /* end */
15874};
15875
Kailang Yang291702f2007-10-16 14:28:03 +020015876static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015877 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15878 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015879
15880 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15881 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15882 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15883
15884 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15885 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15886 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15887 { } /* end */
15888};
15889
Kailang Yang8c427222008-01-10 13:03:59 +010015890static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015891 ALC262_HIPPO_MASTER_SWITCH,
15892 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015893 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015894 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15895 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015896 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15897 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15898 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15899 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15900 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15901 { } /* end */
15902};
15903
Kailang Yangf1d4e282008-08-26 14:03:29 +020015904static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15905 .ops = &snd_hda_bind_vol,
15906 .values = {
15907 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15908 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15909 0
15910 },
15911};
15912
15913static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15914 .ops = &snd_hda_bind_sw,
15915 .values = {
15916 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15917 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15918 0
15919 },
15920};
15921
Kailang Yang6dda9f42008-05-27 12:05:31 +020015922static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015923 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15924 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15925 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15926 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15927 { } /* end */
15928};
15929
15930static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15931 .ops = &snd_hda_bind_sw,
15932 .values = {
15933 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15934 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15935 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15936 0
15937 },
15938};
15939
15940static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15941 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15942 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15943 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15944 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15945 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15946 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15947
15948 { } /* end */
15949};
15950
15951static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15952 .ops = &snd_hda_bind_sw,
15953 .values = {
15954 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15955 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15956 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15957 0
15958 },
15959};
15960
15961static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15962 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15963 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15964 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15965 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15966 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15967 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15968 { } /* end */
15969};
15970
15971static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015972 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15973 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015974 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15975 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15976 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15977 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15978 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15979 { } /* end */
15980};
15981
15982static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15983 .ops = &snd_hda_bind_vol,
15984 .values = {
15985 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15986 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15987 0
15988 },
15989};
15990
15991static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15992 .ops = &snd_hda_bind_sw,
15993 .values = {
15994 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15995 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15996 0
15997 },
15998};
15999
16000static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16001 HDA_BIND_VOL("Master Playback Volume",
16002 &alc663_asus_two_bind_master_vol),
16003 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16004 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016008 { } /* end */
16009};
16010
16011static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16012 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16013 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16014 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16015 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16016 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16017 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016018 { } /* end */
16019};
16020
16021static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16022 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16023 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16024 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16025 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16026 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16027
16028 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16029 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16030 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16031 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16032 { } /* end */
16033};
16034
16035static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16036 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16037 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16038 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16039
16040 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16041 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16042 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16043 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16044 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16045 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16046 { } /* end */
16047};
16048
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016049static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16050 {
16051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16052 .name = "Channel Mode",
16053 .info = alc_ch_mode_info,
16054 .get = alc_ch_mode_get,
16055 .put = alc_ch_mode_put,
16056 },
16057 { } /* end */
16058};
16059
16060static struct hda_verb alc662_init_verbs[] = {
16061 /* ADC: mute amp left and right */
16062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16063 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16064 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16065
Takashi Iwaicb53c622007-08-10 17:21:45 +020016066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16067 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016071
Kailang Yangb60dd392007-09-20 12:50:29 +020016072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16073 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16074 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16075 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16077 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016078
16079 /* Front Pin: output 0 (0x0c) */
16080 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16081 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16082
16083 /* Rear Pin: output 1 (0x0d) */
16084 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16085 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16086
16087 /* CLFE Pin: output 2 (0x0e) */
16088 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16089 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16090
16091 /* Mic (rear) pin: input vref at 80% */
16092 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16093 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16094 /* Front Mic pin: input vref at 80% */
16095 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16096 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16097 /* Line In pin: input */
16098 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16099 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16100 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16101 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16102 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16103 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16104 /* CD pin widget for input */
16105 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16106
16107 /* FIXME: use matrix-type input source selection */
16108 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16109 /* Input mixer */
16110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016111 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016112
16113 /* always trun on EAPD */
16114 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16115 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16116
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016117 { }
16118};
16119
16120static struct hda_verb alc662_sue_init_verbs[] = {
16121 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16122 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016123 {}
16124};
16125
16126static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16127 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16128 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16129 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016130};
16131
Kailang Yang8c427222008-01-10 13:03:59 +010016132/* Set Unsolicited Event*/
16133static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16134 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16135 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16136 {}
16137};
16138
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016139/*
16140 * generic initialization of ADC, input mixers and output mixers
16141 */
16142static struct hda_verb alc662_auto_init_verbs[] = {
16143 /*
16144 * Unmute ADC and set the default input to mic-in
16145 */
16146 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16147 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16148
16149 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16150 * mixer widget
16151 * Note: PASD motherboards uses the Line In 2 as the input for front
16152 * panel mic (mic 2)
16153 */
16154 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016155 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16156 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16157 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16158 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16159 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016160
16161 /*
16162 * Set up output mixers (0x0c - 0x0f)
16163 */
16164 /* set vol=0 to output mixers */
16165 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16166 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16167 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16168
16169 /* set up input amps for analog loopback */
16170 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016171 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16172 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16173 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16174 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16175 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16176 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016177
16178
16179 /* FIXME: use matrix-type input source selection */
16180 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16181 /* Input mixer */
16182 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016183 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016184 { }
16185};
16186
Takashi Iwai24fb9172008-09-02 14:48:20 +020016187/* additional verbs for ALC663 */
16188static struct hda_verb alc663_auto_init_verbs[] = {
16189 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16190 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16191 { }
16192};
16193
Kailang Yang6dda9f42008-05-27 12:05:31 +020016194static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016195 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16196 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016197 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16198 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016199 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16200 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16201 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016202 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16203 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16204 {}
16205};
16206
Kailang Yangf1d4e282008-08-26 14:03:29 +020016207static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16208 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16209 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16210 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16211 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16212 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16213 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16214 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16215 {}
16216};
16217
16218static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16219 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16220 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16221 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16222 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16223 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16224 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16225 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16226 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16227 {}
16228};
16229
16230static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16231 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16232 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16233 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16234 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16235 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16236 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16237 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16238 {}
16239};
16240
16241static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16242 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16243 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16244 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16245 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16246 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16247 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16248 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16249 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16250 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16251 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16252 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16253 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16254 {}
16255};
16256
16257static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16258 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16259 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16260 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16261 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16263 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16264 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16266 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16267 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16268 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16269 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16270 {}
16271};
16272
Kailang Yang6dda9f42008-05-27 12:05:31 +020016273static struct hda_verb alc663_g71v_init_verbs[] = {
16274 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16275 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16276 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16277
16278 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16279 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16280 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16281
16282 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16283 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16284 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16285 {}
16286};
16287
16288static struct hda_verb alc663_g50v_init_verbs[] = {
16289 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16290 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16291 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16292
16293 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16294 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16295 {}
16296};
16297
Kailang Yangf1d4e282008-08-26 14:03:29 +020016298static struct hda_verb alc662_ecs_init_verbs[] = {
16299 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16300 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16301 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16302 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16303 {}
16304};
16305
Kailang Yang622e84c2009-04-21 07:39:04 +020016306static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16307 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16308 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16309 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16310 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16311 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16312 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16313 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16316 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16317 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16318 {}
16319};
16320
16321static struct hda_verb alc272_dell_init_verbs[] = {
16322 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16323 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16324 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16325 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16326 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16327 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16328 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16329 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16330 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16331 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16332 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16333 {}
16334};
16335
Kailang Yangf1d4e282008-08-26 14:03:29 +020016336static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16337 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16338 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16339 { } /* end */
16340};
16341
Kailang Yang622e84c2009-04-21 07:39:04 +020016342static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16343 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16344 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16345 { } /* end */
16346};
16347
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016348static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16349{
16350 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016351 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016352
16353 present = snd_hda_codec_read(codec, 0x14, 0,
16354 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016355 bits = present ? HDA_AMP_MUTE : 0;
16356 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16357 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016358}
16359
16360static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16361{
16362 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016363 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016364
16365 present = snd_hda_codec_read(codec, 0x1b, 0,
16366 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016367 bits = present ? HDA_AMP_MUTE : 0;
16368 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16369 HDA_AMP_MUTE, bits);
16370 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16371 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016372}
16373
16374static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16375 unsigned int res)
16376{
16377 if ((res >> 26) == ALC880_HP_EVENT)
16378 alc662_lenovo_101e_all_automute(codec);
16379 if ((res >> 26) == ALC880_FRONT_EVENT)
16380 alc662_lenovo_101e_ispeaker_automute(codec);
16381}
16382
Kailang Yang291702f2007-10-16 14:28:03 +020016383static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16384{
16385 unsigned int present;
16386
16387 present = snd_hda_codec_read(codec, 0x18, 0,
16388 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16389 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16390 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16391 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16392 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16393 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16394 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16395 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16396 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16397}
16398
16399/* unsolicited event for HP jack sensing */
16400static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16401 unsigned int res)
16402{
Kailang Yang291702f2007-10-16 14:28:03 +020016403 if ((res >> 26) == ALC880_MIC_EVENT)
16404 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016405 else
16406 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016407}
16408
16409static void alc662_eeepc_inithook(struct hda_codec *codec)
16410{
Takashi Iwai42171c12009-05-08 14:11:43 +020016411 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020016412 alc662_eeepc_mic_automute(codec);
16413}
16414
Kailang Yang8c427222008-01-10 13:03:59 +010016415static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16416{
Takashi Iwai42171c12009-05-08 14:11:43 +020016417 struct alc_spec *spec = codec->spec;
16418
16419 spec->autocfg.hp_pins[0] = 0x14;
16420 spec->autocfg.speaker_pins[0] = 0x1b;
16421 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010016422}
16423
Kailang Yang6dda9f42008-05-27 12:05:31 +020016424static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16425{
16426 unsigned int present;
16427 unsigned char bits;
16428
16429 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016430 AC_VERB_GET_PIN_SENSE, 0)
16431 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016432 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016433 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16434 AMP_IN_MUTE(0), bits);
16435 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16436 AMP_IN_MUTE(0), bits);
16437}
16438
16439static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16440{
16441 unsigned int present;
16442 unsigned char bits;
16443
16444 present = snd_hda_codec_read(codec, 0x21, 0,
16445 AC_VERB_GET_PIN_SENSE, 0)
16446 & AC_PINSENSE_PRESENCE;
16447 bits = present ? HDA_AMP_MUTE : 0;
16448 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16449 AMP_IN_MUTE(0), bits);
16450 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16451 AMP_IN_MUTE(0), bits);
16452 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16453 AMP_IN_MUTE(0), bits);
16454 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16455 AMP_IN_MUTE(0), bits);
16456}
16457
16458static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16459{
16460 unsigned int present;
16461 unsigned char bits;
16462
16463 present = snd_hda_codec_read(codec, 0x15, 0,
16464 AC_VERB_GET_PIN_SENSE, 0)
16465 & AC_PINSENSE_PRESENCE;
16466 bits = present ? HDA_AMP_MUTE : 0;
16467 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16468 AMP_IN_MUTE(0), bits);
16469 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16470 AMP_IN_MUTE(0), bits);
16471 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16472 AMP_IN_MUTE(0), bits);
16473 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16474 AMP_IN_MUTE(0), bits);
16475}
16476
16477static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16478{
16479 unsigned int present;
16480 unsigned char bits;
16481
16482 present = snd_hda_codec_read(codec, 0x1b, 0,
16483 AC_VERB_GET_PIN_SENSE, 0)
16484 & AC_PINSENSE_PRESENCE;
16485 bits = present ? 0 : PIN_OUT;
16486 snd_hda_codec_write(codec, 0x14, 0,
16487 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16488}
16489
16490static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16491{
16492 unsigned int present1, present2;
16493
16494 present1 = snd_hda_codec_read(codec, 0x21, 0,
16495 AC_VERB_GET_PIN_SENSE, 0)
16496 & AC_PINSENSE_PRESENCE;
16497 present2 = snd_hda_codec_read(codec, 0x15, 0,
16498 AC_VERB_GET_PIN_SENSE, 0)
16499 & AC_PINSENSE_PRESENCE;
16500
16501 if (present1 || present2) {
16502 snd_hda_codec_write_cache(codec, 0x14, 0,
16503 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16504 } else {
16505 snd_hda_codec_write_cache(codec, 0x14, 0,
16506 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16507 }
16508}
16509
16510static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16511{
16512 unsigned int present1, present2;
16513
16514 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16515 AC_VERB_GET_PIN_SENSE, 0)
16516 & AC_PINSENSE_PRESENCE;
16517 present2 = snd_hda_codec_read(codec, 0x15, 0,
16518 AC_VERB_GET_PIN_SENSE, 0)
16519 & AC_PINSENSE_PRESENCE;
16520
16521 if (present1 || present2) {
16522 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16523 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16524 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16525 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16526 } else {
16527 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16528 AMP_IN_MUTE(0), 0);
16529 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16530 AMP_IN_MUTE(0), 0);
16531 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016532}
16533
16534static void alc663_m51va_mic_automute(struct hda_codec *codec)
16535{
16536 unsigned int present;
16537
16538 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016539 AC_VERB_GET_PIN_SENSE, 0)
16540 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016541 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016542 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016543 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016544 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016545 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016546 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016547 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016548 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016549}
16550
16551static void alc663_m51va_unsol_event(struct hda_codec *codec,
16552 unsigned int res)
16553{
16554 switch (res >> 26) {
16555 case ALC880_HP_EVENT:
16556 alc663_m51va_speaker_automute(codec);
16557 break;
16558 case ALC880_MIC_EVENT:
16559 alc663_m51va_mic_automute(codec);
16560 break;
16561 }
16562}
16563
16564static void alc663_m51va_inithook(struct hda_codec *codec)
16565{
16566 alc663_m51va_speaker_automute(codec);
16567 alc663_m51va_mic_automute(codec);
16568}
16569
Kailang Yangf1d4e282008-08-26 14:03:29 +020016570/* ***************** Mode1 ******************************/
16571static void alc663_mode1_unsol_event(struct hda_codec *codec,
16572 unsigned int res)
16573{
16574 switch (res >> 26) {
16575 case ALC880_HP_EVENT:
16576 alc663_m51va_speaker_automute(codec);
16577 break;
16578 case ALC880_MIC_EVENT:
16579 alc662_eeepc_mic_automute(codec);
16580 break;
16581 }
16582}
16583
16584static void alc663_mode1_inithook(struct hda_codec *codec)
16585{
16586 alc663_m51va_speaker_automute(codec);
16587 alc662_eeepc_mic_automute(codec);
16588}
16589/* ***************** Mode2 ******************************/
16590static void alc662_mode2_unsol_event(struct hda_codec *codec,
16591 unsigned int res)
16592{
16593 switch (res >> 26) {
16594 case ALC880_HP_EVENT:
16595 alc662_f5z_speaker_automute(codec);
16596 break;
16597 case ALC880_MIC_EVENT:
16598 alc662_eeepc_mic_automute(codec);
16599 break;
16600 }
16601}
16602
16603static void alc662_mode2_inithook(struct hda_codec *codec)
16604{
16605 alc662_f5z_speaker_automute(codec);
16606 alc662_eeepc_mic_automute(codec);
16607}
16608/* ***************** Mode3 ******************************/
16609static void alc663_mode3_unsol_event(struct hda_codec *codec,
16610 unsigned int res)
16611{
16612 switch (res >> 26) {
16613 case ALC880_HP_EVENT:
16614 alc663_two_hp_m1_speaker_automute(codec);
16615 break;
16616 case ALC880_MIC_EVENT:
16617 alc662_eeepc_mic_automute(codec);
16618 break;
16619 }
16620}
16621
16622static void alc663_mode3_inithook(struct hda_codec *codec)
16623{
16624 alc663_two_hp_m1_speaker_automute(codec);
16625 alc662_eeepc_mic_automute(codec);
16626}
16627/* ***************** Mode4 ******************************/
16628static void alc663_mode4_unsol_event(struct hda_codec *codec,
16629 unsigned int res)
16630{
16631 switch (res >> 26) {
16632 case ALC880_HP_EVENT:
16633 alc663_21jd_two_speaker_automute(codec);
16634 break;
16635 case ALC880_MIC_EVENT:
16636 alc662_eeepc_mic_automute(codec);
16637 break;
16638 }
16639}
16640
16641static void alc663_mode4_inithook(struct hda_codec *codec)
16642{
16643 alc663_21jd_two_speaker_automute(codec);
16644 alc662_eeepc_mic_automute(codec);
16645}
16646/* ***************** Mode5 ******************************/
16647static void alc663_mode5_unsol_event(struct hda_codec *codec,
16648 unsigned int res)
16649{
16650 switch (res >> 26) {
16651 case ALC880_HP_EVENT:
16652 alc663_15jd_two_speaker_automute(codec);
16653 break;
16654 case ALC880_MIC_EVENT:
16655 alc662_eeepc_mic_automute(codec);
16656 break;
16657 }
16658}
16659
16660static void alc663_mode5_inithook(struct hda_codec *codec)
16661{
16662 alc663_15jd_two_speaker_automute(codec);
16663 alc662_eeepc_mic_automute(codec);
16664}
16665/* ***************** Mode6 ******************************/
16666static void alc663_mode6_unsol_event(struct hda_codec *codec,
16667 unsigned int res)
16668{
16669 switch (res >> 26) {
16670 case ALC880_HP_EVENT:
16671 alc663_two_hp_m2_speaker_automute(codec);
16672 break;
16673 case ALC880_MIC_EVENT:
16674 alc662_eeepc_mic_automute(codec);
16675 break;
16676 }
16677}
16678
16679static void alc663_mode6_inithook(struct hda_codec *codec)
16680{
16681 alc663_two_hp_m2_speaker_automute(codec);
16682 alc662_eeepc_mic_automute(codec);
16683}
16684
Kailang Yang6dda9f42008-05-27 12:05:31 +020016685static void alc663_g71v_hp_automute(struct hda_codec *codec)
16686{
16687 unsigned int present;
16688 unsigned char bits;
16689
16690 present = snd_hda_codec_read(codec, 0x21, 0,
16691 AC_VERB_GET_PIN_SENSE, 0)
16692 & AC_PINSENSE_PRESENCE;
16693 bits = present ? HDA_AMP_MUTE : 0;
16694 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16695 HDA_AMP_MUTE, bits);
16696 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16697 HDA_AMP_MUTE, bits);
16698}
16699
16700static void alc663_g71v_front_automute(struct hda_codec *codec)
16701{
16702 unsigned int present;
16703 unsigned char bits;
16704
16705 present = snd_hda_codec_read(codec, 0x15, 0,
16706 AC_VERB_GET_PIN_SENSE, 0)
16707 & AC_PINSENSE_PRESENCE;
16708 bits = present ? HDA_AMP_MUTE : 0;
16709 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16710 HDA_AMP_MUTE, bits);
16711}
16712
16713static void alc663_g71v_unsol_event(struct hda_codec *codec,
16714 unsigned int res)
16715{
16716 switch (res >> 26) {
16717 case ALC880_HP_EVENT:
16718 alc663_g71v_hp_automute(codec);
16719 break;
16720 case ALC880_FRONT_EVENT:
16721 alc663_g71v_front_automute(codec);
16722 break;
16723 case ALC880_MIC_EVENT:
16724 alc662_eeepc_mic_automute(codec);
16725 break;
16726 }
16727}
16728
16729static void alc663_g71v_inithook(struct hda_codec *codec)
16730{
16731 alc663_g71v_front_automute(codec);
16732 alc663_g71v_hp_automute(codec);
16733 alc662_eeepc_mic_automute(codec);
16734}
16735
16736static void alc663_g50v_unsol_event(struct hda_codec *codec,
16737 unsigned int res)
16738{
16739 switch (res >> 26) {
16740 case ALC880_HP_EVENT:
16741 alc663_m51va_speaker_automute(codec);
16742 break;
16743 case ALC880_MIC_EVENT:
16744 alc662_eeepc_mic_automute(codec);
16745 break;
16746 }
16747}
16748
16749static void alc663_g50v_inithook(struct hda_codec *codec)
16750{
16751 alc663_m51va_speaker_automute(codec);
16752 alc662_eeepc_mic_automute(codec);
16753}
16754
Kailang Yangf1d4e282008-08-26 14:03:29 +020016755static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16756 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016757 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016758
16759 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16760 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16761 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16762
16763 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16764 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16765 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16766 { } /* end */
16767};
16768
Chris Pockelé9541ba12009-05-12 08:08:53 +020016769static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16770 /* Master Playback automatically created from Speaker and Headphone */
16771 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16772 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16773 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16774 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16775
16776 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16777 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16778 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16779
16780 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16781 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16782 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16783 { } /* end */
16784};
16785
Takashi Iwaicb53c622007-08-10 17:21:45 +020016786#ifdef CONFIG_SND_HDA_POWER_SAVE
16787#define alc662_loopbacks alc880_loopbacks
16788#endif
16789
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016790
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016791/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016792#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16793#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16794#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16795#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16796
16797/*
16798 * configuration and preset
16799 */
16800static const char *alc662_models[ALC662_MODEL_LAST] = {
16801 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16802 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16803 [ALC662_3ST_6ch] = "3stack-6ch",
16804 [ALC662_5ST_DIG] = "6stack-dig",
16805 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016806 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016807 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016808 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016809 [ALC663_ASUS_M51VA] = "m51va",
16810 [ALC663_ASUS_G71V] = "g71v",
16811 [ALC663_ASUS_H13] = "h13",
16812 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016813 [ALC663_ASUS_MODE1] = "asus-mode1",
16814 [ALC662_ASUS_MODE2] = "asus-mode2",
16815 [ALC663_ASUS_MODE3] = "asus-mode3",
16816 [ALC663_ASUS_MODE4] = "asus-mode4",
16817 [ALC663_ASUS_MODE5] = "asus-mode5",
16818 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016819 [ALC272_DELL] = "dell",
16820 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016821 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016822 [ALC662_AUTO] = "auto",
16823};
16824
16825static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016826 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016827 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16828 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016829 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16830 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16831 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16832 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16833 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16834 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16835 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16836 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16837 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16838 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16839 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16840 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016841 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16842 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16843 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016844 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16845 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16846 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16847 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016848 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016849 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16850 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016851 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016852 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16853 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16854 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016855 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16856 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16857 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016858 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16859 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16860 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016861 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016862 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16863 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016864 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016865 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016866 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016867 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16868 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16869 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016870 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016871 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16872 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016873 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016874 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016875 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016876 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016877 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16878 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016879 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016880 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16881 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016882 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016883 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016884 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016885 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016886 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016887 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16888 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016889 {}
16890};
16891
16892static struct alc_config_preset alc662_presets[] = {
16893 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016894 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016895 .init_verbs = { alc662_init_verbs },
16896 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16897 .dac_nids = alc662_dac_nids,
16898 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016899 .dig_in_nid = ALC662_DIGIN_NID,
16900 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16901 .channel_mode = alc662_3ST_2ch_modes,
16902 .input_mux = &alc662_capture_source,
16903 },
16904 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016905 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016906 .init_verbs = { alc662_init_verbs },
16907 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16908 .dac_nids = alc662_dac_nids,
16909 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016910 .dig_in_nid = ALC662_DIGIN_NID,
16911 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16912 .channel_mode = alc662_3ST_6ch_modes,
16913 .need_dac_fix = 1,
16914 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016915 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016916 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016917 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016918 .init_verbs = { alc662_init_verbs },
16919 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16920 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016921 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16922 .channel_mode = alc662_3ST_6ch_modes,
16923 .need_dac_fix = 1,
16924 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016925 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016926 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016927 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016928 .init_verbs = { alc662_init_verbs },
16929 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16930 .dac_nids = alc662_dac_nids,
16931 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016932 .dig_in_nid = ALC662_DIGIN_NID,
16933 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16934 .channel_mode = alc662_5stack_modes,
16935 .input_mux = &alc662_capture_source,
16936 },
16937 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016938 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016939 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16940 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16941 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016942 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16943 .channel_mode = alc662_3ST_2ch_modes,
16944 .input_mux = &alc662_lenovo_101e_capture_source,
16945 .unsol_event = alc662_lenovo_101e_unsol_event,
16946 .init_hook = alc662_lenovo_101e_all_automute,
16947 },
Kailang Yang291702f2007-10-16 14:28:03 +020016948 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016949 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016950 .init_verbs = { alc662_init_verbs,
16951 alc662_eeepc_sue_init_verbs },
16952 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16953 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016954 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16955 .channel_mode = alc662_3ST_2ch_modes,
16956 .input_mux = &alc662_eeepc_capture_source,
16957 .unsol_event = alc662_eeepc_unsol_event,
16958 .init_hook = alc662_eeepc_inithook,
16959 },
Kailang Yang8c427222008-01-10 13:03:59 +010016960 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016961 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016962 alc662_chmode_mixer },
16963 .init_verbs = { alc662_init_verbs,
16964 alc662_eeepc_ep20_sue_init_verbs },
16965 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16966 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016967 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16968 .channel_mode = alc662_3ST_6ch_modes,
16969 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016970 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016971 .init_hook = alc662_eeepc_ep20_inithook,
16972 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016973 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016974 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016975 .init_verbs = { alc662_init_verbs,
16976 alc662_ecs_init_verbs },
16977 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16978 .dac_nids = alc662_dac_nids,
16979 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16980 .channel_mode = alc662_3ST_2ch_modes,
16981 .input_mux = &alc662_eeepc_capture_source,
16982 .unsol_event = alc662_eeepc_unsol_event,
16983 .init_hook = alc662_eeepc_inithook,
16984 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016985 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016986 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016987 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16988 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16989 .dac_nids = alc662_dac_nids,
16990 .dig_out_nid = ALC662_DIGOUT_NID,
16991 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16992 .channel_mode = alc662_3ST_2ch_modes,
16993 .input_mux = &alc663_m51va_capture_source,
16994 .unsol_event = alc663_m51va_unsol_event,
16995 .init_hook = alc663_m51va_inithook,
16996 },
16997 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016998 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016999 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17000 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17001 .dac_nids = alc662_dac_nids,
17002 .dig_out_nid = ALC662_DIGOUT_NID,
17003 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17004 .channel_mode = alc662_3ST_2ch_modes,
17005 .input_mux = &alc662_eeepc_capture_source,
17006 .unsol_event = alc663_g71v_unsol_event,
17007 .init_hook = alc663_g71v_inithook,
17008 },
17009 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017010 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017011 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17012 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17013 .dac_nids = alc662_dac_nids,
17014 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17015 .channel_mode = alc662_3ST_2ch_modes,
17016 .input_mux = &alc663_m51va_capture_source,
17017 .unsol_event = alc663_m51va_unsol_event,
17018 .init_hook = alc663_m51va_inithook,
17019 },
17020 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017021 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017022 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17023 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17024 .dac_nids = alc662_dac_nids,
17025 .dig_out_nid = ALC662_DIGOUT_NID,
17026 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17027 .channel_mode = alc662_3ST_6ch_modes,
17028 .input_mux = &alc663_capture_source,
17029 .unsol_event = alc663_g50v_unsol_event,
17030 .init_hook = alc663_g50v_inithook,
17031 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017032 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017033 .mixers = { alc663_m51va_mixer },
17034 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017035 .init_verbs = { alc662_init_verbs,
17036 alc663_21jd_amic_init_verbs },
17037 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17038 .hp_nid = 0x03,
17039 .dac_nids = alc662_dac_nids,
17040 .dig_out_nid = ALC662_DIGOUT_NID,
17041 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17042 .channel_mode = alc662_3ST_2ch_modes,
17043 .input_mux = &alc662_eeepc_capture_source,
17044 .unsol_event = alc663_mode1_unsol_event,
17045 .init_hook = alc663_mode1_inithook,
17046 },
17047 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017048 .mixers = { alc662_1bjd_mixer },
17049 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017050 .init_verbs = { alc662_init_verbs,
17051 alc662_1bjd_amic_init_verbs },
17052 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17053 .dac_nids = alc662_dac_nids,
17054 .dig_out_nid = ALC662_DIGOUT_NID,
17055 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17056 .channel_mode = alc662_3ST_2ch_modes,
17057 .input_mux = &alc662_eeepc_capture_source,
17058 .unsol_event = alc662_mode2_unsol_event,
17059 .init_hook = alc662_mode2_inithook,
17060 },
17061 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017062 .mixers = { alc663_two_hp_m1_mixer },
17063 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017064 .init_verbs = { alc662_init_verbs,
17065 alc663_two_hp_amic_m1_init_verbs },
17066 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17067 .hp_nid = 0x03,
17068 .dac_nids = alc662_dac_nids,
17069 .dig_out_nid = ALC662_DIGOUT_NID,
17070 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17071 .channel_mode = alc662_3ST_2ch_modes,
17072 .input_mux = &alc662_eeepc_capture_source,
17073 .unsol_event = alc663_mode3_unsol_event,
17074 .init_hook = alc663_mode3_inithook,
17075 },
17076 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017077 .mixers = { alc663_asus_21jd_clfe_mixer },
17078 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017079 .init_verbs = { alc662_init_verbs,
17080 alc663_21jd_amic_init_verbs},
17081 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17082 .hp_nid = 0x03,
17083 .dac_nids = alc662_dac_nids,
17084 .dig_out_nid = ALC662_DIGOUT_NID,
17085 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17086 .channel_mode = alc662_3ST_2ch_modes,
17087 .input_mux = &alc662_eeepc_capture_source,
17088 .unsol_event = alc663_mode4_unsol_event,
17089 .init_hook = alc663_mode4_inithook,
17090 },
17091 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017092 .mixers = { alc663_asus_15jd_clfe_mixer },
17093 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017094 .init_verbs = { alc662_init_verbs,
17095 alc663_15jd_amic_init_verbs },
17096 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17097 .hp_nid = 0x03,
17098 .dac_nids = alc662_dac_nids,
17099 .dig_out_nid = ALC662_DIGOUT_NID,
17100 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17101 .channel_mode = alc662_3ST_2ch_modes,
17102 .input_mux = &alc662_eeepc_capture_source,
17103 .unsol_event = alc663_mode5_unsol_event,
17104 .init_hook = alc663_mode5_inithook,
17105 },
17106 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017107 .mixers = { alc663_two_hp_m2_mixer },
17108 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017109 .init_verbs = { alc662_init_verbs,
17110 alc663_two_hp_amic_m2_init_verbs },
17111 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17112 .hp_nid = 0x03,
17113 .dac_nids = alc662_dac_nids,
17114 .dig_out_nid = ALC662_DIGOUT_NID,
17115 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17116 .channel_mode = alc662_3ST_2ch_modes,
17117 .input_mux = &alc662_eeepc_capture_source,
17118 .unsol_event = alc663_mode6_unsol_event,
17119 .init_hook = alc663_mode6_inithook,
17120 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017121 [ALC272_DELL] = {
17122 .mixers = { alc663_m51va_mixer },
17123 .cap_mixer = alc272_auto_capture_mixer,
17124 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17125 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17126 .dac_nids = alc662_dac_nids,
17127 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17128 .adc_nids = alc272_adc_nids,
17129 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17130 .capsrc_nids = alc272_capsrc_nids,
17131 .channel_mode = alc662_3ST_2ch_modes,
17132 .input_mux = &alc663_m51va_capture_source,
17133 .unsol_event = alc663_m51va_unsol_event,
17134 .init_hook = alc663_m51va_inithook,
17135 },
17136 [ALC272_DELL_ZM1] = {
17137 .mixers = { alc663_m51va_mixer },
17138 .cap_mixer = alc662_auto_capture_mixer,
17139 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17140 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17141 .dac_nids = alc662_dac_nids,
17142 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17143 .adc_nids = alc662_adc_nids,
17144 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
17145 .capsrc_nids = alc662_capsrc_nids,
17146 .channel_mode = alc662_3ST_2ch_modes,
17147 .input_mux = &alc663_m51va_capture_source,
17148 .unsol_event = alc663_m51va_unsol_event,
17149 .init_hook = alc663_m51va_inithook,
17150 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017151 [ALC272_SAMSUNG_NC10] = {
17152 .mixers = { alc272_nc10_mixer },
17153 .init_verbs = { alc662_init_verbs,
17154 alc663_21jd_amic_init_verbs },
17155 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17156 .dac_nids = alc272_dac_nids,
17157 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17158 .channel_mode = alc662_3ST_2ch_modes,
17159 .input_mux = &alc272_nc10_capture_source,
17160 .unsol_event = alc663_mode4_unsol_event,
17161 .init_hook = alc663_mode4_inithook,
17162 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017163};
17164
17165
17166/*
17167 * BIOS auto configuration
17168 */
17169
17170/* add playback controls from the parsed DAC table */
17171static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17172 const struct auto_pin_cfg *cfg)
17173{
17174 char name[32];
17175 static const char *chname[4] = {
17176 "Front", "Surround", NULL /*CLFE*/, "Side"
17177 };
17178 hda_nid_t nid;
17179 int i, err;
17180
17181 for (i = 0; i < cfg->line_outs; i++) {
17182 if (!spec->multiout.dac_nids[i])
17183 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020017184 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017185 if (i == 2) {
17186 /* Center/LFE */
17187 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17188 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017189 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17190 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017191 if (err < 0)
17192 return err;
17193 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17194 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017195 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17196 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017197 if (err < 0)
17198 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017199 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017200 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017201 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017202 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017203 if (err < 0)
17204 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017205 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017206 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017207 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017208 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017209 if (err < 0)
17210 return err;
17211 } else {
17212 sprintf(name, "%s Playback Volume", chname[i]);
17213 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017214 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17215 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017216 if (err < 0)
17217 return err;
17218 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017219 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17220 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17221 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017222 if (err < 0)
17223 return err;
17224 }
17225 }
17226 return 0;
17227}
17228
17229/* add playback controls for speaker and HP outputs */
17230static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17231 const char *pfx)
17232{
17233 hda_nid_t nid;
17234 int err;
17235 char name[32];
17236
17237 if (!pin)
17238 return 0;
17239
Takashi Iwai24fb9172008-09-02 14:48:20 +020017240 if (pin == 0x17) {
17241 /* ALC663 has a mono output pin on 0x17 */
17242 sprintf(name, "%s Playback Switch", pfx);
17243 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17244 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17245 return err;
17246 }
17247
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017248 if (alc880_is_fixed_pin(pin)) {
17249 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017250 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017251 /* specify the DAC as the extra output */
17252 if (!spec->multiout.hp_nid)
17253 spec->multiout.hp_nid = nid;
17254 else
17255 spec->multiout.extra_out_nid[0] = nid;
17256 /* control HP volume/switch on the output mixer amp */
17257 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17258 sprintf(name, "%s Playback Volume", pfx);
17259 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17260 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17261 if (err < 0)
17262 return err;
17263 sprintf(name, "%s Playback Switch", pfx);
17264 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17265 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17266 if (err < 0)
17267 return err;
17268 } else if (alc880_is_multi_pin(pin)) {
17269 /* set manual connection */
17270 /* we have only a switch on HP-out PIN */
17271 sprintf(name, "%s Playback Switch", pfx);
17272 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17273 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17274 if (err < 0)
17275 return err;
17276 }
17277 return 0;
17278}
17279
Takashi Iwai2d864c42009-03-20 12:52:47 +010017280/* return the index of the src widget from the connection list of the nid.
17281 * return -1 if not found
17282 */
17283static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
17284 hda_nid_t src)
17285{
17286 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
17287 int i, conns;
17288
17289 conns = snd_hda_get_connections(codec, nid, conn_list,
17290 ARRAY_SIZE(conn_list));
17291 if (conns < 0)
17292 return -1;
17293 for (i = 0; i < conns; i++)
17294 if (conn_list[i] == src)
17295 return i;
17296 return -1;
17297}
17298
17299static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17300{
Takashi Iwai1327a322009-03-23 13:07:47 +010017301 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010017302 return (pincap & AC_PINCAP_IN) != 0;
17303}
17304
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017305/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010017306static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017307 const struct auto_pin_cfg *cfg)
17308{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017309 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017310 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017311 int i, err, idx;
17312
17313 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017314 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
17315 idx = alc662_input_pin_idx(codec, 0x0b,
17316 cfg->input_pins[i]);
17317 if (idx >= 0) {
17318 err = new_analog_input(spec, cfg->input_pins[i],
17319 auto_pin_cfg_labels[i],
17320 idx, 0x0b);
17321 if (err < 0)
17322 return err;
17323 }
17324 idx = alc662_input_pin_idx(codec, 0x22,
17325 cfg->input_pins[i]);
17326 if (idx >= 0) {
17327 imux->items[imux->num_items].label =
17328 auto_pin_cfg_labels[i];
17329 imux->items[imux->num_items].index = idx;
17330 imux->num_items++;
17331 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017332 }
17333 }
17334 return 0;
17335}
17336
17337static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17338 hda_nid_t nid, int pin_type,
17339 int dac_idx)
17340{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017341 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017342 /* need the manual connection? */
17343 if (alc880_is_multi_pin(nid)) {
17344 struct alc_spec *spec = codec->spec;
17345 int idx = alc880_multi_pin_idx(nid);
17346 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17347 AC_VERB_SET_CONNECT_SEL,
17348 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17349 }
17350}
17351
17352static void alc662_auto_init_multi_out(struct hda_codec *codec)
17353{
17354 struct alc_spec *spec = codec->spec;
17355 int i;
17356
17357 for (i = 0; i <= HDA_SIDE; i++) {
17358 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017359 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017360 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017361 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017362 i);
17363 }
17364}
17365
17366static void alc662_auto_init_hp_out(struct hda_codec *codec)
17367{
17368 struct alc_spec *spec = codec->spec;
17369 hda_nid_t pin;
17370
17371 pin = spec->autocfg.hp_pins[0];
17372 if (pin) /* connect to front */
17373 /* use dac 0 */
17374 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017375 pin = spec->autocfg.speaker_pins[0];
17376 if (pin)
17377 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017378}
17379
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017380#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17381
17382static void alc662_auto_init_analog_input(struct hda_codec *codec)
17383{
17384 struct alc_spec *spec = codec->spec;
17385 int i;
17386
17387 for (i = 0; i < AUTO_PIN_LAST; i++) {
17388 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017389 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017390 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017391 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017392 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017393 snd_hda_codec_write(codec, nid, 0,
17394 AC_VERB_SET_AMP_GAIN_MUTE,
17395 AMP_OUT_MUTE);
17396 }
17397 }
17398}
17399
Takashi Iwaif511b012008-08-15 16:46:42 +020017400#define alc662_auto_init_input_src alc882_auto_init_input_src
17401
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017402static int alc662_parse_auto_config(struct hda_codec *codec)
17403{
17404 struct alc_spec *spec = codec->spec;
17405 int err;
17406 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17407
17408 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17409 alc662_ignore);
17410 if (err < 0)
17411 return err;
17412 if (!spec->autocfg.line_outs)
17413 return 0; /* can't find valid BIOS pin config */
17414
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017415 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17416 if (err < 0)
17417 return err;
17418 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17419 if (err < 0)
17420 return err;
17421 err = alc662_auto_create_extra_out(spec,
17422 spec->autocfg.speaker_pins[0],
17423 "Speaker");
17424 if (err < 0)
17425 return err;
17426 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17427 "Headphone");
17428 if (err < 0)
17429 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017430 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017431 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017432 return err;
17433
17434 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17435
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017436 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017437 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17438
Takashi Iwai603c4012008-07-30 15:01:44 +020017439 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017440 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017441
17442 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017443 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017444
Takashi Iwaid88897e2008-10-31 15:01:37 +010017445 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017446 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017447 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017448
17449 err = alc_auto_add_mic_boost(codec);
17450 if (err < 0)
17451 return err;
17452
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017453 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17454
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017455 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017456}
17457
17458/* additional initialization for auto-configuration model */
17459static void alc662_auto_init(struct hda_codec *codec)
17460{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017461 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017462 alc662_auto_init_multi_out(codec);
17463 alc662_auto_init_hp_out(codec);
17464 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017465 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017466 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017467 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017468}
17469
17470static int patch_alc662(struct hda_codec *codec)
17471{
17472 struct alc_spec *spec;
17473 int err, board_config;
17474
17475 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17476 if (!spec)
17477 return -ENOMEM;
17478
17479 codec->spec = spec;
17480
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017481 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17482
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017483 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17484 alc662_models,
17485 alc662_cfg_tbl);
17486 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020017487 printk(KERN_INFO "hda_codec: Unknown model for %s, "
17488 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017489 board_config = ALC662_AUTO;
17490 }
17491
17492 if (board_config == ALC662_AUTO) {
17493 /* automatic parse from the BIOS config */
17494 err = alc662_parse_auto_config(codec);
17495 if (err < 0) {
17496 alc_free(codec);
17497 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017498 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017499 printk(KERN_INFO
17500 "hda_codec: Cannot set up configuration "
17501 "from BIOS. Using base mode...\n");
17502 board_config = ALC662_3ST_2ch_DIG;
17503 }
17504 }
17505
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017506 err = snd_hda_attach_beep_device(codec, 0x1);
17507 if (err < 0) {
17508 alc_free(codec);
17509 return err;
17510 }
17511
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017512 if (board_config != ALC662_AUTO)
17513 setup_preset(spec, &alc662_presets[board_config]);
17514
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017515 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17516 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17517
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017518 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17519 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17520
Takashi Iwaidd704692009-08-11 08:45:11 +020017521 if (!spec->adc_nids) {
17522 spec->adc_nids = alc662_adc_nids;
17523 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17524 }
17525 if (!spec->capsrc_nids)
17526 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017527
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017528 if (!spec->cap_mixer)
17529 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017530 if (codec->vendor_id == 0x10ec0662)
17531 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17532 else
17533 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017534
Takashi Iwai2134ea42008-01-10 16:53:55 +010017535 spec->vmaster_nid = 0x02;
17536
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017537 codec->patch_ops = alc_patch_ops;
17538 if (board_config == ALC662_AUTO)
17539 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017540#ifdef CONFIG_SND_HDA_POWER_SAVE
17541 if (!spec->loopback.amplist)
17542 spec->loopback.amplist = alc662_loopbacks;
17543#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017544 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017545
17546 return 0;
17547}
17548
17549/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017550 * patch entries
17551 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017552static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017553 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017554 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017555 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017556 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017557 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017558 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017559 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017560 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017561 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17562 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17563 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017564 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17565 .patch = patch_alc883 },
17566 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17567 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017568 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017569 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017570 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017571 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017572 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17573 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017574 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017575 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017576 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017577 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017578 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17579 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017580 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017581 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017582 {} /* terminator */
17583};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017584
17585MODULE_ALIAS("snd-hda-codec-id:10ec*");
17586
17587MODULE_LICENSE("GPL");
17588MODULE_DESCRIPTION("Realtek HD-audio codec");
17589
17590static struct hda_codec_preset_list realtek_list = {
17591 .preset = snd_hda_preset_realtek,
17592 .owner = THIS_MODULE,
17593};
17594
17595static int __init patch_realtek_init(void)
17596{
17597 return snd_hda_add_codec_preset(&realtek_list);
17598}
17599
17600static void __exit patch_realtek_exit(void)
17601{
17602 snd_hda_delete_codec_preset(&realtek_list);
17603}
17604
17605module_init(patch_realtek_init)
17606module_exit(patch_realtek_exit)