blob: 6f683e451f2bfc09dca7d0fa2d3bd5193f000b8a [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/*
6426 * 6ch mode
6427 */
6428static struct hda_verb alc885_mbp_ch6_init[] = {
6429 { 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
6437static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6438 { 2, alc885_mbp_ch2_init },
6439 { 6, alc885_mbp_ch6_init },
6440};
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 Iwai2134ea42008-01-10 16:53:55 +01006500 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6501 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6502 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6503 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6504 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6505 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6507 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006508 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006509 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6510 { } /* end */
6511};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006512
6513static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006514 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6515 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6516 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6517 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6518 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6519 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6520 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6521 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006522 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6523 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6524 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6525 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6526 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6527 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6528 { } /* end */
6529};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006530
Kailang Yangbdd148a2007-05-08 15:19:08 +02006531static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6532 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6533 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6534 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6535 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6536 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6537 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6539 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6540 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006541 { } /* end */
6542};
6543
Kailang Yang272a5272007-05-14 11:00:38 +02006544static struct snd_kcontrol_new alc882_targa_mixer[] = {
6545 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6546 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6547 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6548 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6549 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6550 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6551 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6552 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6553 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006554 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006555 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6556 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006557 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006558 { } /* end */
6559};
6560
6561/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6562 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6563 */
6564static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6565 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6566 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6567 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6568 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6569 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6570 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6571 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6572 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6573 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6574 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6575 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6576 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006577 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006578 { } /* end */
6579};
6580
Takashi Iwai914759b2007-09-06 14:52:04 +02006581static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6582 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6583 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6584 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6585 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6586 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6587 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6588 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6590 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6591 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006592 { } /* end */
6593};
6594
Kailang Yangdf694da2005-12-05 19:42:22 +01006595static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6596 {
6597 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6598 .name = "Channel Mode",
6599 .info = alc_ch_mode_info,
6600 .get = alc_ch_mode_get,
6601 .put = alc_ch_mode_put,
6602 },
6603 { } /* end */
6604};
6605
Linus Torvalds1da177e2005-04-16 15:20:36 -07006606static struct hda_verb alc882_init_verbs[] = {
6607 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006608 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6609 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6610 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006611 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006612 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6613 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6614 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006615 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006616 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6617 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6618 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006619 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006620 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6621 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6622 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006623
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006624 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006625 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006627 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006628 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006629 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006630 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006631 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006632 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006633 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006634 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006635 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006636 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006637 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006638 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006639 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006640 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006641 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006642 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6643 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006644 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006645 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6646 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006647 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006648 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6649 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6651 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6652 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006653 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006654 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006655
6656 /* FIXME: use matrix-type input source selection */
6657 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6658 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006659 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6660 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6661 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006663 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006668 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006669 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6673 /* ADC1: mute amp left and right */
6674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006675 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006676 /* ADC2: mute amp left and right */
6677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006678 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006679 /* ADC3: mute amp left and right */
6680 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006681 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006682
6683 { }
6684};
6685
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006686static struct hda_verb alc882_eapd_verbs[] = {
6687 /* change to EAPD mode */
6688 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006689 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006690 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006691};
6692
Tobin Davis9102cd12006-12-15 10:02:12 +01006693/* Mac Pro test */
6694static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6695 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6696 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6697 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6698 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6699 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006700 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006701 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6702 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006703 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006704 { } /* end */
6705};
6706
6707static struct hda_verb alc882_macpro_init_verbs[] = {
6708 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6709 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6710 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6712 /* Front Pin: output 0 (0x0c) */
6713 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6714 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6715 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6716 /* Front Mic pin: input vref at 80% */
6717 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6718 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6719 /* Speaker: output */
6720 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6721 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6722 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6723 /* Headphone output (output 0 - 0x0c) */
6724 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6725 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6726 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6727
6728 /* FIXME: use matrix-type input source selection */
6729 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6730 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6731 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6732 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6733 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6734 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6735 /* Input mixer2 */
6736 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6737 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6738 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6739 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6740 /* Input mixer3 */
6741 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6742 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6743 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6744 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6745 /* ADC1: mute amp left and right */
6746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6747 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6748 /* ADC2: mute amp left and right */
6749 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6750 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6751 /* ADC3: mute amp left and right */
6752 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6753 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6754
6755 { }
6756};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006757
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006758/* Macbook 5,1 */
6759static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006760 /* DACs */
6761 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6762 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6763 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6764 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006765 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6767 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6768 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006769 /* Surround mixer */
6770 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6771 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6772 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6773 /* LFE mixer */
6774 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6775 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6776 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6777 /* HP mixer */
6778 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6779 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6780 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6781 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006782 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6783 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006784 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6785 /* LFE Pin (0x0e) */
6786 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
6787 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6788 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
6789 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006790 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6791 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006792 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006793 /* Front Mic pin: input vref at 80% */
6794 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6795 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6796 /* Line In pin */
6797 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6798 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6799
6800 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6801 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6802 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6803 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6804 { }
6805};
6806
Takashi Iwai87350ad2007-08-16 18:19:38 +02006807/* Macbook Pro rev3 */
6808static struct hda_verb alc885_mbp3_init_verbs[] = {
6809 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6810 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6812 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6813 /* Rear mixer */
6814 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6815 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6816 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6817 /* Front Pin: output 0 (0x0c) */
6818 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6819 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6820 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6821 /* HP Pin: output 0 (0x0d) */
6822 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6823 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6824 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6825 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6826 /* Mic (rear) pin: input vref at 80% */
6827 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6828 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6829 /* Front Mic pin: input vref at 80% */
6830 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6831 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6832 /* Line In pin: use output 1 when in LineOut mode */
6833 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6834 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6835 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6836
6837 /* FIXME: use matrix-type input source selection */
6838 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6839 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6840 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6841 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6842 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6843 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6844 /* Input mixer2 */
6845 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6846 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6847 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6848 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6849 /* Input mixer3 */
6850 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6851 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6852 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6853 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6854 /* ADC1: mute amp left and right */
6855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6856 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6857 /* ADC2: mute amp left and right */
6858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6859 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6860 /* ADC3: mute amp left and right */
6861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6862 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6863
6864 { }
6865};
6866
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006867/* iMac 24 mixer. */
6868static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6869 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6870 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6871 { } /* end */
6872};
6873
6874/* iMac 24 init verbs. */
6875static struct hda_verb alc885_imac24_init_verbs[] = {
6876 /* Internal speakers: output 0 (0x0c) */
6877 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6878 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6879 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6880 /* Internal speakers: output 0 (0x0c) */
6881 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6882 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6883 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6884 /* Headphone: output 0 (0x0c) */
6885 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6886 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6887 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6888 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6889 /* Front Mic: input vref at 80% */
6890 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6891 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6892 { }
6893};
6894
6895/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006896static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006897{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006898 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006899
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006900 spec->autocfg.hp_pins[0] = 0x14;
6901 spec->autocfg.speaker_pins[0] = 0x18;
6902 spec->autocfg.speaker_pins[1] = 0x1a;
6903 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006904}
6905
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006906static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006907{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006908 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006909
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006910 spec->autocfg.hp_pins[0] = 0x15;
6911 spec->autocfg.speaker_pins[0] = 0x14;
6912 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02006913}
6914
6915
Kailang Yang272a5272007-05-14 11:00:38 +02006916static struct hda_verb alc882_targa_verbs[] = {
6917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6918 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6919
6920 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6921 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006922
Kailang Yang272a5272007-05-14 11:00:38 +02006923 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6924 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6925 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6926
6927 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02006928 { } /* end */
6929};
6930
6931/* toggle speaker-output according to the hp-jack state */
6932static void alc882_targa_automute(struct hda_codec *codec)
6933{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006934 struct alc_spec *spec = codec->spec;
6935 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006936 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006937 spec->jack_present ? 1 : 3);
6938}
6939
6940static void alc882_targa_init_hook(struct hda_codec *codec)
6941{
6942 struct alc_spec *spec = codec->spec;
6943
6944 spec->autocfg.hp_pins[0] = 0x14;
6945 spec->autocfg.speaker_pins[0] = 0x1b;
6946 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006947}
6948
6949static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6950{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02006951 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02006952 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02006953}
6954
6955static struct hda_verb alc882_asus_a7j_verbs[] = {
6956 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6957 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6958
6959 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6960 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6961 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006962
Kailang Yang272a5272007-05-14 11:00:38 +02006963 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6964 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6965 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6966
6967 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6968 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6969 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6970 { } /* end */
6971};
6972
Takashi Iwai914759b2007-09-06 14:52:04 +02006973static struct hda_verb alc882_asus_a7m_verbs[] = {
6974 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6975 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6976
6977 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6978 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6979 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006980
Takashi Iwai914759b2007-09-06 14:52:04 +02006981 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6982 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6983 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6984
6985 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6986 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6987 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6988 { } /* end */
6989};
6990
Tobin Davis9102cd12006-12-15 10:02:12 +01006991static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6992{
6993 unsigned int gpiostate, gpiomask, gpiodir;
6994
6995 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6996 AC_VERB_GET_GPIO_DATA, 0);
6997
6998 if (!muted)
6999 gpiostate |= (1 << pin);
7000 else
7001 gpiostate &= ~(1 << pin);
7002
7003 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7004 AC_VERB_GET_GPIO_MASK, 0);
7005 gpiomask |= (1 << pin);
7006
7007 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7008 AC_VERB_GET_GPIO_DIRECTION, 0);
7009 gpiodir |= (1 << pin);
7010
7011
7012 snd_hda_codec_write(codec, codec->afg, 0,
7013 AC_VERB_SET_GPIO_MASK, gpiomask);
7014 snd_hda_codec_write(codec, codec->afg, 0,
7015 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7016
7017 msleep(1);
7018
7019 snd_hda_codec_write(codec, codec->afg, 0,
7020 AC_VERB_SET_GPIO_DATA, gpiostate);
7021}
7022
Takashi Iwai7debbe52007-08-16 15:01:03 +02007023/* set up GPIO at initialization */
7024static void alc885_macpro_init_hook(struct hda_codec *codec)
7025{
7026 alc882_gpio_mute(codec, 0, 0);
7027 alc882_gpio_mute(codec, 1, 0);
7028}
7029
7030/* set up GPIO and update auto-muting at initialization */
7031static void alc885_imac24_init_hook(struct hda_codec *codec)
7032{
7033 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007034 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007035}
7036
Kailang Yangdf694da2005-12-05 19:42:22 +01007037/*
7038 * generic initialization of ADC, input mixers and output mixers
7039 */
7040static struct hda_verb alc882_auto_init_verbs[] = {
7041 /*
7042 * Unmute ADC0-2 and set the default input to mic-in
7043 */
7044 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7045 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7046 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7047 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7048 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7049 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7050
Takashi Iwaicb53c622007-08-10 17:21:45 +02007051 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007052 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007053 * Note: PASD motherboards uses the Line In 2 as the input for
7054 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007055 */
7056 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007057 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7058 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7059 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7060 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007062
7063 /*
7064 * Set up output mixers (0x0c - 0x0f)
7065 */
7066 /* set vol=0 to output mixers */
7067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7068 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7069 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7070 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7071 /* set up input amps for analog loopback */
7072 /* Amp Indices: DAC = 0, mixer = 1 */
7073 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7075 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7076 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7077 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7078 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7079 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7080 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7081 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7082 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7083
7084 /* FIXME: use matrix-type input source selection */
7085 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7086 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7087 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7088 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7089 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7090 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7091 /* Input mixer2 */
7092 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7093 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7094 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7095 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7096 /* Input mixer3 */
7097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7101
7102 { }
7103};
7104
Takashi Iwaicb53c622007-08-10 17:21:45 +02007105#ifdef CONFIG_SND_HDA_POWER_SAVE
7106#define alc882_loopbacks alc880_loopbacks
7107#endif
7108
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007109/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007110#define alc882_pcm_analog_playback alc880_pcm_analog_playback
7111#define alc882_pcm_analog_capture alc880_pcm_analog_capture
7112#define alc882_pcm_digital_playback alc880_pcm_digital_playback
7113#define alc882_pcm_digital_capture alc880_pcm_digital_capture
7114
7115/*
7116 * configuration and preset
7117 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007118static const char *alc882_models[ALC882_MODEL_LAST] = {
7119 [ALC882_3ST_DIG] = "3stack-dig",
7120 [ALC882_6ST_DIG] = "6stack-dig",
7121 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02007122 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02007123 [ALC882_TARGA] = "targa",
7124 [ALC882_ASUS_A7J] = "asus-a7j",
7125 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01007126 [ALC885_MACPRO] = "macpro",
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007127 [ALC885_MB5] = "mb5",
Takashi Iwai87350ad2007-08-16 18:19:38 +02007128 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007129 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007130 [ALC882_AUTO] = "auto",
7131};
7132
7133static struct snd_pci_quirk alc882_cfg_tbl[] = {
7134 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02007135 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02007136 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02007137 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007138 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02007139 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01007140 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007141 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01007142 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007143 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
7144 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
7145 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01007146 {}
7147};
7148
7149static struct alc_config_preset alc882_presets[] = {
7150 [ALC882_3ST_DIG] = {
7151 .mixers = { alc882_base_mixer },
7152 .init_verbs = { alc882_init_verbs },
7153 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7154 .dac_nids = alc882_dac_nids,
7155 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007156 .dig_in_nid = ALC882_DIGIN_NID,
7157 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7158 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02007159 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01007160 .input_mux = &alc882_capture_source,
7161 },
7162 [ALC882_6ST_DIG] = {
7163 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7164 .init_verbs = { alc882_init_verbs },
7165 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7166 .dac_nids = alc882_dac_nids,
7167 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01007168 .dig_in_nid = ALC882_DIGIN_NID,
7169 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7170 .channel_mode = alc882_sixstack_modes,
7171 .input_mux = &alc882_capture_source,
7172 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007173 [ALC882_ARIMA] = {
7174 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
7175 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
7176 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7177 .dac_nids = alc882_dac_nids,
7178 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
7179 .channel_mode = alc882_sixstack_modes,
7180 .input_mux = &alc882_capture_source,
7181 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02007182 [ALC882_W2JC] = {
7183 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
7184 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7185 alc880_gpio1_init_verbs },
7186 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7187 .dac_nids = alc882_dac_nids,
7188 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7189 .channel_mode = alc880_threestack_modes,
7190 .need_dac_fix = 1,
7191 .input_mux = &alc882_capture_source,
7192 .dig_out_nid = ALC882_DIGOUT_NID,
7193 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007194 [ALC885_MBP3] = {
7195 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
7196 .init_verbs = { alc885_mbp3_init_verbs,
7197 alc880_gpio1_init_verbs },
7198 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7199 .dac_nids = alc882_dac_nids,
7200 .channel_mode = alc885_mbp_6ch_modes,
7201 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
7202 .input_mux = &alc882_capture_source,
7203 .dig_out_nid = ALC882_DIGOUT_NID,
7204 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007205 .unsol_event = alc_automute_amp_unsol_event,
7206 .init_hook = alc885_mbp3_init_hook,
Takashi Iwai87350ad2007-08-16 18:19:38 +02007207 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007208 [ALC885_MB5] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007209 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007210 .init_verbs = { alc885_mb5_init_verbs,
7211 alc880_gpio1_init_verbs },
7212 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7213 .dac_nids = alc882_dac_nids,
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007214 .channel_mode = alc885_mb5_6ch_modes,
7215 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007216 .input_mux = &mb5_capture_source,
7217 .dig_out_nid = ALC882_DIGOUT_NID,
7218 .dig_in_nid = ALC882_DIGIN_NID,
7219 },
Tobin Davis9102cd12006-12-15 10:02:12 +01007220 [ALC885_MACPRO] = {
7221 .mixers = { alc882_macpro_mixer },
7222 .init_verbs = { alc882_macpro_init_verbs },
7223 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7224 .dac_nids = alc882_dac_nids,
7225 .dig_out_nid = ALC882_DIGOUT_NID,
7226 .dig_in_nid = ALC882_DIGIN_NID,
7227 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7228 .channel_mode = alc882_ch_modes,
7229 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007230 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01007231 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007232 [ALC885_IMAC24] = {
7233 .mixers = { alc885_imac24_mixer },
7234 .init_verbs = { alc885_imac24_init_verbs },
7235 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7236 .dac_nids = alc882_dac_nids,
7237 .dig_out_nid = ALC882_DIGOUT_NID,
7238 .dig_in_nid = ALC882_DIGIN_NID,
7239 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
7240 .channel_mode = alc882_ch_modes,
7241 .input_mux = &alc882_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007242 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02007243 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007244 },
Kailang Yang272a5272007-05-14 11:00:38 +02007245 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007246 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02007247 .init_verbs = { alc882_init_verbs, alc880_gpio3_init_verbs,
7248 alc882_targa_verbs},
Kailang Yang272a5272007-05-14 11:00:38 +02007249 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7250 .dac_nids = alc882_dac_nids,
7251 .dig_out_nid = ALC882_DIGOUT_NID,
7252 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7253 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007254 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007255 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7256 .channel_mode = alc882_3ST_6ch_modes,
7257 .need_dac_fix = 1,
7258 .input_mux = &alc882_capture_source,
7259 .unsol_event = alc882_targa_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007260 .init_hook = alc882_targa_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02007261 },
7262 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007263 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02007264 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
7265 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7266 .dac_nids = alc882_dac_nids,
7267 .dig_out_nid = ALC882_DIGOUT_NID,
7268 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
7269 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01007270 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02007271 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
7272 .channel_mode = alc882_3ST_6ch_modes,
7273 .need_dac_fix = 1,
7274 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007275 },
Takashi Iwai914759b2007-09-06 14:52:04 +02007276 [ALC882_ASUS_A7M] = {
7277 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
7278 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
7279 alc880_gpio1_init_verbs,
7280 alc882_asus_a7m_verbs },
7281 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
7282 .dac_nids = alc882_dac_nids,
7283 .dig_out_nid = ALC882_DIGOUT_NID,
7284 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
7285 .channel_mode = alc880_threestack_modes,
7286 .need_dac_fix = 1,
7287 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02007288 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007289};
7290
7291
7292/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02007293 * Pin config fixes
7294 */
Kailang Yangea1fb292008-08-26 12:58:38 +02007295enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02007296 PINFIX_ABIT_AW9D_MAX
7297};
7298
7299static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
7300 { 0x15, 0x01080104 }, /* side */
7301 { 0x16, 0x01011012 }, /* rear */
7302 { 0x17, 0x01016011 }, /* clfe */
7303 { }
7304};
7305
7306static const struct alc_pincfg *alc882_pin_fixes[] = {
7307 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
7308};
7309
7310static struct snd_pci_quirk alc882_pinfix_tbl[] = {
7311 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
7312 {}
7313};
7314
7315/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007316 * BIOS auto configuration
7317 */
7318static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
7319 hda_nid_t nid, int pin_type,
7320 int dac_idx)
7321{
7322 /* set as output */
7323 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007324 int idx;
7325
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007326 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007327 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7328 idx = 4;
7329 else
7330 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01007331 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7332
7333}
7334
7335static void alc882_auto_init_multi_out(struct hda_codec *codec)
7336{
7337 struct alc_spec *spec = codec->spec;
7338 int i;
7339
7340 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007341 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007342 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01007343 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02007344 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007345 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01007346 }
7347}
7348
7349static void alc882_auto_init_hp_out(struct hda_codec *codec)
7350{
7351 struct alc_spec *spec = codec->spec;
7352 hda_nid_t pin;
7353
Takashi Iwaieb06ed82006-09-20 17:10:27 +02007354 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007355 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007356 /* use dac 0 */
7357 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007358 pin = spec->autocfg.speaker_pins[0];
7359 if (pin)
7360 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01007361}
7362
7363#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
7364#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
7365
7366static void alc882_auto_init_analog_input(struct hda_codec *codec)
7367{
7368 struct alc_spec *spec = codec->spec;
7369 int i;
7370
7371 for (i = 0; i < AUTO_PIN_LAST; i++) {
7372 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01007373 if (!nid)
7374 continue;
Takashi Iwai23f0c042009-02-26 13:03:58 +01007375 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
Takashi Iwai7194cae2008-03-06 16:58:17 +01007376 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
7377 snd_hda_codec_write(codec, nid, 0,
7378 AC_VERB_SET_AMP_GAIN_MUTE,
7379 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01007380 }
7381}
7382
Takashi Iwaif511b012008-08-15 16:46:42 +02007383static void alc882_auto_init_input_src(struct hda_codec *codec)
7384{
7385 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02007386 int c;
7387
7388 for (c = 0; c < spec->num_adc_nids; c++) {
7389 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
7390 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007391 unsigned int mux_idx;
7392 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02007393 int conns, mute, idx, item;
7394
7395 conns = snd_hda_get_connections(codec, nid, conn_list,
7396 ARRAY_SIZE(conn_list));
7397 if (conns < 0)
7398 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007399 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7400 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02007401 for (idx = 0; idx < conns; idx++) {
7402 /* if the current connection is the selected one,
7403 * unmute it as default - otherwise mute it
7404 */
7405 mute = AMP_IN_MUTE(idx);
7406 for (item = 0; item < imux->num_items; item++) {
7407 if (imux->items[item].index == idx) {
7408 if (spec->cur_mux[c] == item)
7409 mute = AMP_IN_UNMUTE(idx);
7410 break;
7411 }
7412 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02007413 /* check if we have a selector or mixer
7414 * we could check for the widget type instead, but
7415 * just check for Amp-In presence (in case of mixer
7416 * without amp-in there is something wrong, this
7417 * function shouldn't be used or capsrc nid is wrong)
7418 */
7419 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7420 snd_hda_codec_write(codec, nid, 0,
7421 AC_VERB_SET_AMP_GAIN_MUTE,
7422 mute);
7423 else if (mute != AMP_IN_MUTE(idx))
7424 snd_hda_codec_write(codec, nid, 0,
7425 AC_VERB_SET_CONNECT_SEL,
7426 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007427 }
7428 }
7429}
7430
Takashi Iwai776e1842007-08-29 15:07:11 +02007431/* add mic boosts if needed */
7432static int alc_auto_add_mic_boost(struct hda_codec *codec)
7433{
7434 struct alc_spec *spec = codec->spec;
7435 int err;
7436 hda_nid_t nid;
7437
7438 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007439 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007440 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7441 "Mic Boost",
7442 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7443 if (err < 0)
7444 return err;
7445 }
7446 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007447 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007448 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7449 "Front Mic Boost",
7450 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7451 if (err < 0)
7452 return err;
7453 }
7454 return 0;
7455}
7456
Kailang Yangdf694da2005-12-05 19:42:22 +01007457/* almost identical with ALC880 parser... */
7458static int alc882_parse_auto_config(struct hda_codec *codec)
7459{
7460 struct alc_spec *spec = codec->spec;
7461 int err = alc880_parse_auto_config(codec);
7462
7463 if (err < 0)
7464 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007465 else if (!err)
7466 return 0; /* no config found */
7467
7468 err = alc_auto_add_mic_boost(codec);
7469 if (err < 0)
7470 return err;
7471
7472 /* hack - override the init verbs */
7473 spec->init_verbs[0] = alc882_auto_init_verbs;
7474
7475 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007476}
7477
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007478/* additional initialization for auto-configuration model */
7479static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007480{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007481 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007482 alc882_auto_init_multi_out(codec);
7483 alc882_auto_init_hp_out(codec);
7484 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007485 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007486 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007487 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007488}
7489
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007490static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7491
Linus Torvalds1da177e2005-04-16 15:20:36 -07007492static int patch_alc882(struct hda_codec *codec)
7493{
7494 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007495 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007496
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007497 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007498 if (spec == NULL)
7499 return -ENOMEM;
7500
Linus Torvalds1da177e2005-04-16 15:20:36 -07007501 codec->spec = spec;
7502
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007503 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7504 alc882_models,
7505 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007506
Kailang Yangdf694da2005-12-05 19:42:22 +01007507 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007508 /* Pick up systems that don't supply PCI SSID */
7509 switch (codec->subsystem_id) {
7510 case 0x106b0c00: /* Mac Pro */
7511 board_config = ALC885_MACPRO;
7512 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007513 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007514 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007515 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007516 board_config = ALC885_IMAC24;
7517 break;
Luke Yelavich2d466382009-02-23 13:00:33 +11007518 case 0x106b00a0: /* MacBookPro3,1 - Another revision */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007519 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007520 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007521 case 0x106b2c00: /* Macbook Pro rev3 */
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007522 /* Macbook 3.1 (0x106b3600) is handled by patch_alc883() */
Luke Yelavich2a884642009-01-28 15:58:38 +11007523 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007524 board_config = ALC885_MBP3;
7525 break;
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007526 case 0x106b3f00: /* Macbook 5,1 */
Takashi Iwai7442f9d2009-05-14 18:20:33 +02007527 case 0x106b4000: /* Macbook Pro 5,1 - FIXME: HP jack sense
7528 * seems not working, so apparently
7529 * no perfect solution yet
7530 */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007531 board_config = ALC885_MB5;
7532 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007533 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007534 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007535 if (codec->revision_id == 0x100101 ||
7536 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007537 alc_free(codec);
7538 return patch_alc883(codec);
7539 }
Takashi Iwai6c627f32009-05-18 12:33:36 +02007540 printk(KERN_INFO "hda_codec: Unknown model for %s, "
7541 "trying auto-probe from BIOS...\n",
7542 codec->chip_name);
Tobin Davis081d17c2007-02-15 17:46:18 +01007543 board_config = ALC882_AUTO;
7544 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007545 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007546
Takashi Iwaif95474e2007-07-10 00:47:43 +02007547 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7548
Kailang Yangdf694da2005-12-05 19:42:22 +01007549 if (board_config == ALC882_AUTO) {
7550 /* automatic parse from the BIOS config */
7551 err = alc882_parse_auto_config(codec);
7552 if (err < 0) {
7553 alc_free(codec);
7554 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007555 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007556 printk(KERN_INFO
7557 "hda_codec: Cannot set up configuration "
7558 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007559 board_config = ALC882_3ST_DIG;
7560 }
7561 }
7562
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007563 err = snd_hda_attach_beep_device(codec, 0x1);
7564 if (err < 0) {
7565 alc_free(codec);
7566 return err;
7567 }
7568
Kailang Yangdf694da2005-12-05 19:42:22 +01007569 if (board_config != ALC882_AUTO)
7570 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007571
Kailang Yangdf694da2005-12-05 19:42:22 +01007572 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7573 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007574 /* FIXME: setup DAC5 */
7575 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7576 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007577
Kailang Yangdf694da2005-12-05 19:42:22 +01007578 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7579 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007580
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007581 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007582 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007583 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007584 /* get type */
7585 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007586 if (wcap != AC_WID_AUD_IN) {
7587 spec->adc_nids = alc882_adc_nids_alt;
7588 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007589 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007590 } else {
7591 spec->adc_nids = alc882_adc_nids;
7592 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007593 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007594 }
7595 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007596 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007597 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007598
Takashi Iwai2134ea42008-01-10 16:53:55 +01007599 spec->vmaster_nid = 0x0c;
7600
Linus Torvalds1da177e2005-04-16 15:20:36 -07007601 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007602 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007603 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007604#ifdef CONFIG_SND_HDA_POWER_SAVE
7605 if (!spec->loopback.amplist)
7606 spec->loopback.amplist = alc882_loopbacks;
7607#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007608 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007609
7610 return 0;
7611}
7612
7613/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007614 * ALC883 support
7615 *
7616 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7617 * configuration. Each pin widget can choose any input DACs and a mixer.
7618 * Each ADC is connected from a mixer of all inputs. This makes possible
7619 * 6-channel independent captures.
7620 *
7621 * In addition, an independent DAC for the multi-playback (not used in this
7622 * driver yet).
7623 */
7624#define ALC883_DIGOUT_NID 0x06
7625#define ALC883_DIGIN_NID 0x0a
7626
Wu Fengguang3ab90932008-11-17 09:51:09 +01007627#define ALC1200_DIGOUT_NID 0x10
7628
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007629static hda_nid_t alc883_dac_nids[4] = {
7630 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007631 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007632};
7633
7634static hda_nid_t alc883_adc_nids[2] = {
7635 /* ADC1-2 */
7636 0x08, 0x09,
7637};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007638
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007639static hda_nid_t alc883_adc_nids_alt[1] = {
7640 /* ADC1 */
7641 0x08,
7642};
7643
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007644static hda_nid_t alc883_adc_nids_rev[2] = {
7645 /* ADC2-1 */
7646 0x09, 0x08
7647};
7648
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007649#define alc889_adc_nids alc880_adc_nids
7650
Takashi Iwaie1406342008-02-11 18:32:32 +01007651static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7652
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007653static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7654
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007655#define alc889_capsrc_nids alc882_capsrc_nids
7656
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007657/* input MUX */
7658/* FIXME: should be a matrix-type input source selection */
7659
7660static struct hda_input_mux alc883_capture_source = {
7661 .num_items = 4,
7662 .items = {
7663 { "Mic", 0x0 },
7664 { "Front Mic", 0x1 },
7665 { "Line", 0x2 },
7666 { "CD", 0x4 },
7667 },
7668};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007669
Jiang zhe17bba1b2008-06-04 12:11:07 +02007670static struct hda_input_mux alc883_3stack_6ch_intel = {
7671 .num_items = 4,
7672 .items = {
7673 { "Mic", 0x1 },
7674 { "Front Mic", 0x0 },
7675 { "Line", 0x2 },
7676 { "CD", 0x4 },
7677 },
7678};
7679
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007680static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7681 .num_items = 2,
7682 .items = {
7683 { "Mic", 0x1 },
7684 { "Line", 0x2 },
7685 },
7686};
7687
Kailang Yang272a5272007-05-14 11:00:38 +02007688static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7689 .num_items = 4,
7690 .items = {
7691 { "Mic", 0x0 },
7692 { "iMic", 0x1 },
7693 { "Line", 0x2 },
7694 { "CD", 0x4 },
7695 },
7696};
7697
Jiang zhefb97dc62008-03-06 11:07:11 +01007698static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7699 .num_items = 2,
7700 .items = {
7701 { "Mic", 0x0 },
7702 { "Int Mic", 0x1 },
7703 },
7704};
7705
Kailang Yange2757d52008-08-26 13:17:46 +02007706static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7707 .num_items = 3,
7708 .items = {
7709 { "Mic", 0x0 },
7710 { "Front Mic", 0x1 },
7711 { "Line", 0x4 },
7712 },
7713};
7714
7715static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7716 .num_items = 2,
7717 .items = {
7718 { "Mic", 0x0 },
7719 { "Line", 0x2 },
7720 },
7721};
7722
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007723static struct hda_input_mux alc889A_mb31_capture_source = {
7724 .num_items = 2,
7725 .items = {
7726 { "Mic", 0x0 },
7727 /* Front Mic (0x01) unused */
7728 { "Line", 0x2 },
7729 /* Line 2 (0x03) unused */
7730 /* CD (0x04) unsused? */
7731 },
7732};
7733
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007734/*
7735 * 2ch mode
7736 */
7737static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7738 { 2, NULL }
7739};
7740
7741/*
7742 * 2ch mode
7743 */
7744static struct hda_verb alc883_3ST_ch2_init[] = {
7745 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7746 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7747 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7748 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7749 { } /* end */
7750};
7751
7752/*
Tobin Davisb2011312007-09-17 12:45:11 +02007753 * 4ch mode
7754 */
7755static struct hda_verb alc883_3ST_ch4_init[] = {
7756 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7757 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7758 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7759 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7760 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7761 { } /* end */
7762};
7763
7764/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007765 * 6ch mode
7766 */
7767static struct hda_verb alc883_3ST_ch6_init[] = {
7768 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7769 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7770 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7771 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7772 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7773 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7774 { } /* end */
7775};
7776
Tobin Davisb2011312007-09-17 12:45:11 +02007777static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007778 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007779 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007780 { 6, alc883_3ST_ch6_init },
7781};
7782
David Heidelberger64a8be72009-06-08 16:15:18 +02007783
7784/*
7785 * 2ch mode
7786 */
7787static struct hda_verb alc883_4ST_ch2_init[] = {
Takashi Iwaif03ecf52009-06-08 16:38:17 +02007788 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
David Heidelberger64a8be72009-06-08 16:15:18 +02007789 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7790 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7791 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7792 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7793 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7794 { } /* end */
7795};
7796
7797/*
7798 * 4ch mode
7799 */
7800static struct hda_verb alc883_4ST_ch4_init[] = {
7801 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7802 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7803 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7804 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7805 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7806 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7807 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7808 { } /* end */
7809};
7810
7811/*
7812 * 6ch mode
7813 */
7814static struct hda_verb alc883_4ST_ch6_init[] = {
7815 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7816 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7817 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7818 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7819 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7820 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7821 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7822 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7823 { } /* end */
7824};
7825
7826/*
7827 * 8ch mode
7828 */
7829static struct hda_verb alc883_4ST_ch8_init[] = {
7830 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7831 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7832 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7833 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7834 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7835 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7836 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7837 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7838 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7839 { } /* end */
7840};
7841
7842static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7843 { 2, alc883_4ST_ch2_init },
7844 { 4, alc883_4ST_ch4_init },
7845 { 6, alc883_4ST_ch6_init },
7846 { 8, alc883_4ST_ch8_init },
7847};
7848
7849
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007850/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007851 * 2ch mode
7852 */
7853static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7854 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7855 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7856 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7857 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7858 { } /* end */
7859};
7860
7861/*
7862 * 4ch mode
7863 */
7864static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7865 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7866 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7867 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7868 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7869 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7870 { } /* end */
7871};
7872
7873/*
7874 * 6ch mode
7875 */
7876static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7877 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7878 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7879 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7880 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7881 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7882 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7883 { } /* end */
7884};
7885
7886static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7887 { 2, alc883_3ST_ch2_intel_init },
7888 { 4, alc883_3ST_ch4_intel_init },
7889 { 6, alc883_3ST_ch6_intel_init },
7890};
7891
7892/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007893 * 6ch mode
7894 */
7895static struct hda_verb alc883_sixstack_ch6_init[] = {
7896 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7897 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7898 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7899 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7900 { } /* end */
7901};
7902
7903/*
7904 * 8ch mode
7905 */
7906static struct hda_verb alc883_sixstack_ch8_init[] = {
7907 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7908 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7909 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7910 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7911 { } /* end */
7912};
7913
7914static struct hda_channel_mode alc883_sixstack_modes[2] = {
7915 { 6, alc883_sixstack_ch6_init },
7916 { 8, alc883_sixstack_ch8_init },
7917};
7918
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007919/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7920static struct hda_verb alc889A_mb31_ch2_init[] = {
7921 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7922 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7923 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7924 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7925 { } /* end */
7926};
7927
7928/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7929static struct hda_verb alc889A_mb31_ch4_init[] = {
7930 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7931 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7932 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7933 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7934 { } /* end */
7935};
7936
7937/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7938static struct hda_verb alc889A_mb31_ch5_init[] = {
7939 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7940 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7941 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7942 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7943 { } /* end */
7944};
7945
7946/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7947static struct hda_verb alc889A_mb31_ch6_init[] = {
7948 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7949 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7950 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7951 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7952 { } /* end */
7953};
7954
7955static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7956 { 2, alc889A_mb31_ch2_init },
7957 { 4, alc889A_mb31_ch4_init },
7958 { 5, alc889A_mb31_ch5_init },
7959 { 6, alc889A_mb31_ch6_init },
7960};
7961
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007962static struct hda_verb alc883_medion_eapd_verbs[] = {
7963 /* eanable EAPD on medion laptop */
7964 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7965 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7966 { }
7967};
7968
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007969/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7970 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7971 */
7972
7973static struct snd_kcontrol_new alc883_base_mixer[] = {
7974 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7975 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7976 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7977 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7978 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7979 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7980 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7981 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7982 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7983 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7984 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7985 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7986 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7987 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7988 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007990 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007991 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007993 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007994 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007995 { } /* end */
7996};
7997
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007998static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7999 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8000 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8001 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8002 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8003 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8004 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8007 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8009 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8010 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8011 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008012 { } /* end */
8013};
8014
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008015static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008016 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8017 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8018 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8019 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8021 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8022 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8023 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8024 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8025 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008026 { } /* end */
8027};
8028
Jiang zhefb97dc62008-03-06 11:07:11 +01008029static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8030 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8031 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8032 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8033 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8034 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8035 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8036 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8037 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8038 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8039 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008040 { } /* end */
8041};
8042
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008043static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8044 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8045 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8046 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8047 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8048 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8049 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8050 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8051 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008052 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008053 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8054 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008055 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008056 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008057 { } /* end */
8058};
8059
8060static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8061 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8062 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8063 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8064 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8065 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8066 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8067 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8068 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8069 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8070 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8071 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8072 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8073 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8074 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008075 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008076 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8077 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008078 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008079 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008080 { } /* end */
8081};
8082
Jiang zhe17bba1b2008-06-04 12:11:07 +02008083static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8084 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8085 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8086 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8087 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8088 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8089 HDA_OUTPUT),
8090 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8091 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8092 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8093 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8094 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8095 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8096 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8097 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8099 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8100 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8101 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8102 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8103 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008104 { } /* end */
8105};
8106
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008107static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008108 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008109 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008110 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008111 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008112 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8113 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008114 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8115 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008116 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8117 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8118 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8119 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8120 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8121 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008122 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8124 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008125 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008126 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008127 { } /* end */
8128};
8129
Sasha Alexandrc2592492009-06-16 14:52:54 -04008130static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008131 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8132 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8133 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8134 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8135 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8136 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8137 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8138 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8139 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8140 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8141 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8142 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8143 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008145 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008146 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008147 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008148};
Kailang Yangccc656c2006-10-17 12:32:26 +02008149
Sasha Alexandrc2592492009-06-16 14:52:54 -04008150static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008151 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8152 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8153 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8154 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8155 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008157 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008158 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008159 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8160 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8161 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008162 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008163};
Kailang Yangccc656c2006-10-17 12:32:26 +02008164
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008165static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8166 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8167 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008168 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8169 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008170 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8171 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8172 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8173 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008174 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008175};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008176
Kailang Yang272a5272007-05-14 11:00:38 +02008177static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8178 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8179 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8180 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8181 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8182 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8183 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8184 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8185 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8186 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008187 { } /* end */
8188};
8189
8190static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8191 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8192 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8193 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8194 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8195 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8196 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8197 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8198 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8199 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008200 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008201};
Kailang Yang272a5272007-05-14 11:00:38 +02008202
Tobin Davis2880a862007-08-07 11:50:26 +02008203static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008204 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8205 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008206 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008207 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8208 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008209 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8210 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008212 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008213};
Tobin Davis2880a862007-08-07 11:50:26 +02008214
Tony Vroond2fd4b02009-06-21 00:40:10 +01008215static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8216 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8217 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8218 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8219 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008220 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8221 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008222 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8223 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8224 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8225 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8226 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8227 { } /* end */
8228};
8229
Kailang Yange2757d52008-08-26 13:17:46 +02008230static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8231 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8232 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8233 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8234 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8235 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8236 0x0d, 1, 0x0, HDA_OUTPUT),
8237 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8238 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8239 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8240 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8241 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008242 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8243 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8244 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8245 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8247 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8248 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8249 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8250 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8251 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008252 { } /* end */
8253};
8254
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008255static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8256 /* Output mixers */
8257 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8258 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8259 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8260 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8261 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8262 HDA_OUTPUT),
8263 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8264 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8265 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8266 /* Output switches */
8267 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8268 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8269 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8270 /* Boost mixers */
8271 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8272 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8273 /* Input mixers */
8274 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8275 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8276 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8277 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8278 { } /* end */
8279};
8280
Guido Günther3e1647c2009-06-05 00:47:26 +02008281static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8282 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8283 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8284 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8285 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8286 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8287 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8288 { } /* end */
8289};
8290
Kailang Yange2757d52008-08-26 13:17:46 +02008291static struct hda_bind_ctls alc883_bind_cap_vol = {
8292 .ops = &snd_hda_bind_vol,
8293 .values = {
8294 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8295 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8296 0
8297 },
8298};
8299
8300static struct hda_bind_ctls alc883_bind_cap_switch = {
8301 .ops = &snd_hda_bind_sw,
8302 .values = {
8303 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8304 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8305 0
8306 },
8307};
8308
8309static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8310 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8311 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8312 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8313 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8314 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8316 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8317 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008318 { } /* end */
8319};
8320
8321static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008322 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8323 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8324 {
8325 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8326 /* .name = "Capture Source", */
8327 .name = "Input Source",
8328 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008329 .info = alc_mux_enum_info,
8330 .get = alc_mux_enum_get,
8331 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008332 },
8333 { } /* end */
8334};
8335
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008336static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8337 {
8338 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8339 .name = "Channel Mode",
8340 .info = alc_ch_mode_info,
8341 .get = alc_ch_mode_get,
8342 .put = alc_ch_mode_put,
8343 },
8344 { } /* end */
8345};
8346
8347static struct hda_verb alc883_init_verbs[] = {
8348 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02008349 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008350 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8351 /* ADC2: mute amp left and right */
8352 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8353 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8354 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8355 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8356 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8357 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8358 /* Rear mixer */
8359 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8360 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8361 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8362 /* CLFE mixer */
8363 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8364 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8365 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8366 /* Side mixer */
8367 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8368 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8369 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8370
Takashi Iwaicb53c622007-08-10 17:21:45 +02008371 /* mute analog input loopbacks */
8372 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8373 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8374 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8375 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8376 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008377
8378 /* Front Pin: output 0 (0x0c) */
8379 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8380 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8381 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8382 /* Rear Pin: output 1 (0x0d) */
8383 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8384 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8385 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8386 /* CLFE Pin: output 2 (0x0e) */
8387 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8388 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8389 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8390 /* Side Pin: output 3 (0x0f) */
8391 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8392 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8393 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8394 /* Mic (rear) pin: input vref at 80% */
8395 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8396 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8397 /* Front Mic pin: input vref at 80% */
8398 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8399 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8400 /* Line In pin: input */
8401 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8402 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8403 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8404 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8405 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8406 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8407 /* CD pin widget for input */
8408 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8409
8410 /* FIXME: use matrix-type input source selection */
8411 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8412 /* Input mixer2 */
8413 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008414 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8416 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008417 /* Input mixer3 */
8418 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02008419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8420 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8421 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008422 { }
8423};
8424
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008425/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008426static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008427{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008428 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008429
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008430 spec->autocfg.hp_pins[0] = 0x15;
8431 spec->autocfg.speaker_pins[0] = 0x14;
8432 spec->autocfg.speaker_pins[1] = 0x17;
8433 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008434}
8435
8436/* auto-toggle front mic */
8437/*
8438static void alc883_mitac_mic_automute(struct hda_codec *codec)
8439{
8440 unsigned int present;
8441 unsigned char bits;
8442
8443 present = snd_hda_codec_read(codec, 0x18, 0,
8444 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8445 bits = present ? HDA_AMP_MUTE : 0;
8446 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8447}
8448*/
8449
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008450static struct hda_verb alc883_mitac_verbs[] = {
8451 /* HP */
8452 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8453 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8454 /* Subwoofer */
8455 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8456 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8457
8458 /* enable unsolicited event */
8459 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8460 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8461
8462 { } /* end */
8463};
8464
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008465static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008466 /* HP */
8467 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8468 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8469 /* Int speaker */
8470 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8471 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8472
8473 /* enable unsolicited event */
8474 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008475 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008476
8477 { } /* end */
8478};
8479
Jiang zhefb97dc62008-03-06 11:07:11 +01008480static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8481 /* HP */
8482 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8483 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8484 /* Subwoofer */
8485 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8486 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8487
8488 /* enable unsolicited event */
8489 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8490
8491 { } /* end */
8492};
8493
Sasha Alexandrc2592492009-06-16 14:52:54 -04008494static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008495 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8496 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8497
8498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8499 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008500
David Heidelberger64a8be72009-06-08 16:15:18 +02008501/* Connect Line-Out side jack (SPDIF) to Side */
8502 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8503 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8504 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8505/* Connect Mic jack to CLFE */
8506 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8507 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8508 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8509/* Connect Line-in jack to Surround */
8510 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8511 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8512 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8513/* Connect HP out jack to Front */
8514 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8515 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8516 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008517
8518 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008519
8520 { } /* end */
8521};
8522
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008523static struct hda_verb alc883_lenovo_101e_verbs[] = {
8524 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8525 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8526 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8527 { } /* end */
8528};
8529
Kailang Yang272a5272007-05-14 11:00:38 +02008530static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8531 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8532 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8533 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8534 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8535 { } /* end */
8536};
8537
8538static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8541 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8542 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8543 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8544 { } /* end */
8545};
8546
Kailang Yang189609a2007-08-20 11:31:23 +02008547static struct hda_verb alc883_haier_w66_verbs[] = {
8548 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8549 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8550
8551 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8552
8553 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8554 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8555 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8556 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8557 { } /* end */
8558};
8559
Kailang Yange2757d52008-08-26 13:17:46 +02008560static struct hda_verb alc888_lenovo_sky_verbs[] = {
8561 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8562 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8563 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8564 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8565 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8566 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8567 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8568 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8569 { } /* end */
8570};
8571
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008572static struct hda_verb alc888_6st_dell_verbs[] = {
8573 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8574 { }
8575};
8576
Guido Günther3e1647c2009-06-05 00:47:26 +02008577static struct hda_verb alc883_vaiott_verbs[] = {
8578 /* HP */
8579 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8580 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8581
8582 /* enable unsolicited event */
8583 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8584
8585 { } /* end */
8586};
8587
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008588static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008589{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008590 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008591
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008592 spec->autocfg.hp_pins[0] = 0x1b;
8593 spec->autocfg.speaker_pins[0] = 0x14;
8594 spec->autocfg.speaker_pins[1] = 0x16;
8595 spec->autocfg.speaker_pins[2] = 0x18;
8596 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008597}
8598
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008599static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008600 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008601 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8602 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008603 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008604 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008605};
8606
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008607/*
8608 * 2ch mode
8609 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008610static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008611 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8612 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8613 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8614 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008615 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008616};
8617
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008618/*
8619 * 4ch mode
8620 */
8621static struct hda_verb alc888_3st_hp_4ch_init[] = {
8622 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8623 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8624 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8625 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8626 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8627 { } /* end */
8628};
8629
8630/*
8631 * 6ch mode
8632 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008633static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008634 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8635 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008636 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008637 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8638 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008639 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8640 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008641};
8642
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008643static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008644 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008645 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008646 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008647};
8648
Kailang Yang272a5272007-05-14 11:00:38 +02008649/* toggle front-jack and RCA according to the hp-jack state */
8650static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8651{
8652 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008653
Kailang Yang272a5272007-05-14 11:00:38 +02008654 present = snd_hda_codec_read(codec, 0x1b, 0,
8655 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008656 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8657 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8658 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8659 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008660}
8661
8662/* toggle RCA according to the front-jack state */
8663static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8664{
8665 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008666
Kailang Yang272a5272007-05-14 11:00:38 +02008667 present = snd_hda_codec_read(codec, 0x14, 0,
8668 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008669 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8670 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008671}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008672
Kailang Yang272a5272007-05-14 11:00:38 +02008673static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8674 unsigned int res)
8675{
8676 if ((res >> 26) == ALC880_HP_EVENT)
8677 alc888_lenovo_ms7195_front_automute(codec);
8678 if ((res >> 26) == ALC880_FRONT_EVENT)
8679 alc888_lenovo_ms7195_rca_automute(codec);
8680}
8681
8682static struct hda_verb alc883_medion_md2_verbs[] = {
8683 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8684 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8685
8686 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8687
8688 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8689 { } /* end */
8690};
8691
8692/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008693static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008694{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008695 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008696
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008697 spec->autocfg.hp_pins[0] = 0x14;
8698 spec->autocfg.speaker_pins[0] = 0x15;
8699 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008700}
8701
Kailang Yangccc656c2006-10-17 12:32:26 +02008702/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008703#define alc883_targa_init_hook alc882_targa_init_hook
8704#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008705
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008706static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8707{
8708 unsigned int present;
8709
8710 present = snd_hda_codec_read(codec, 0x18, 0,
8711 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8712 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8713 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8714}
8715
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008716static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008717{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008718 struct alc_spec *spec = codec->spec;
8719
8720 spec->autocfg.hp_pins[0] = 0x15;
8721 spec->autocfg.speaker_pins[0] = 0x14;
8722 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008723 alc883_clevo_m720_mic_automute(codec);
8724}
8725
8726static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008727 unsigned int res)
8728{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008729 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008730 case ALC880_MIC_EVENT:
8731 alc883_clevo_m720_mic_automute(codec);
8732 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008733 default:
8734 alc_automute_amp_unsol_event(codec, res);
8735 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008736 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008737}
8738
Jiang zhefb97dc62008-03-06 11:07:11 +01008739/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008740static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008741{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008742 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008743
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008744 spec->autocfg.hp_pins[0] = 0x14;
8745 spec->autocfg.speaker_pins[0] = 0x15;
8746 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008747}
8748
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008749static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008750{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008751 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008752
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008753 spec->autocfg.hp_pins[0] = 0x1b;
8754 spec->autocfg.speaker_pins[0] = 0x14;
8755 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008756}
8757
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008758static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8759{
8760 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008761 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008762
David Heidelberger64a8be72009-06-08 16:15:18 +02008763 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8764 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008765 bits = present ? HDA_AMP_MUTE : 0;
8766 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8767 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008768}
8769
8770static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8771{
8772 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008773 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008774
8775 present = snd_hda_codec_read(codec, 0x1b, 0,
8776 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008777 bits = present ? HDA_AMP_MUTE : 0;
8778 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8779 HDA_AMP_MUTE, bits);
8780 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8781 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008782}
8783
8784static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8785 unsigned int res)
8786{
8787 if ((res >> 26) == ALC880_HP_EVENT)
8788 alc883_lenovo_101e_all_automute(codec);
8789 if ((res >> 26) == ALC880_FRONT_EVENT)
8790 alc883_lenovo_101e_ispeaker_automute(codec);
8791}
8792
Takashi Iwai676a9b52007-08-16 15:23:35 +02008793/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008794static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008795{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008796 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008797
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008798 spec->autocfg.hp_pins[0] = 0x14;
8799 spec->autocfg.speaker_pins[0] = 0x15;
8800 spec->autocfg.speaker_pins[1] = 0x16;
8801 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008802}
8803
Kailang Yangd1a991a2007-08-15 16:21:59 +02008804static struct hda_verb alc883_acer_eapd_verbs[] = {
8805 /* HP Pin: output 0 (0x0c) */
8806 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8807 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8808 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8809 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008810 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8811 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008812 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008813 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8814 /* eanable EAPD on medion laptop */
8815 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8816 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008817 /* enable unsolicited event */
8818 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008819 { }
8820};
8821
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008822static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008823{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008824 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008825
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008826 spec->autocfg.hp_pins[0] = 0x1b;
8827 spec->autocfg.speaker_pins[0] = 0x14;
8828 spec->autocfg.speaker_pins[1] = 0x15;
8829 spec->autocfg.speaker_pins[2] = 0x16;
8830 spec->autocfg.speaker_pins[3] = 0x17;
8831 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008832}
8833
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008834static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008835{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008836 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008837
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008838 spec->autocfg.hp_pins[0] = 0x1b;
8839 spec->autocfg.speaker_pins[0] = 0x14;
8840 spec->autocfg.speaker_pins[1] = 0x15;
8841 spec->autocfg.speaker_pins[2] = 0x16;
8842 spec->autocfg.speaker_pins[3] = 0x17;
8843 spec->autocfg.speaker_pins[4] = 0x1a;
8844 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008845}
8846
Guido Günther3e1647c2009-06-05 00:47:26 +02008847static void alc883_vaiott_init_hook(struct hda_codec *codec)
8848{
8849 struct alc_spec *spec = codec->spec;
8850
8851 spec->autocfg.hp_pins[0] = 0x15;
8852 spec->autocfg.speaker_pins[0] = 0x14;
8853 spec->autocfg.speaker_pins[1] = 0x17;
8854 alc_automute_amp(codec);
8855}
8856
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008857/*
8858 * generic initialization of ADC, input mixers and output mixers
8859 */
8860static struct hda_verb alc883_auto_init_verbs[] = {
8861 /*
8862 * Unmute ADC0-2 and set the default input to mic-in
8863 */
8864 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8865 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8866 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8867 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8868
Takashi Iwaicb53c622007-08-10 17:21:45 +02008869 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008870 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008871 * Note: PASD motherboards uses the Line In 2 as the input for
8872 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008873 */
8874 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008875 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8876 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8877 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8878 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8879 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008880
8881 /*
8882 * Set up output mixers (0x0c - 0x0f)
8883 */
8884 /* set vol=0 to output mixers */
8885 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8886 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8887 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8888 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8889 /* set up input amps for analog loopback */
8890 /* Amp Indices: DAC = 0, mixer = 1 */
8891 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8893 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8895 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8896 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8897 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8898 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8899 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8900 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8901
8902 /* FIXME: use matrix-type input source selection */
8903 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8904 /* Input mixer1 */
8905 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8906 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8907 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008908 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008909 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8910 /* Input mixer2 */
8911 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8913 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008914 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008915 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008916
8917 { }
8918};
8919
Kailang Yange2757d52008-08-26 13:17:46 +02008920static struct hda_verb alc888_asus_m90v_verbs[] = {
8921 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8922 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8923 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8924 /* enable unsolicited event */
8925 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8926 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8927 { } /* end */
8928};
8929
8930static void alc883_nb_mic_automute(struct hda_codec *codec)
8931{
8932 unsigned int present;
8933
8934 present = snd_hda_codec_read(codec, 0x18, 0,
8935 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8936 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8937 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8938 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8939 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8940}
8941
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008942static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008943{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008944 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008945
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008946 spec->autocfg.hp_pins[0] = 0x1b;
8947 spec->autocfg.speaker_pins[0] = 0x14;
8948 spec->autocfg.speaker_pins[1] = 0x15;
8949 spec->autocfg.speaker_pins[2] = 0x16;
8950 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008951}
8952
8953static void alc883_mode2_unsol_event(struct hda_codec *codec,
8954 unsigned int res)
8955{
8956 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008957 case ALC880_MIC_EVENT:
8958 alc883_nb_mic_automute(codec);
8959 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008960 default:
8961 alc_sku_unsol_event(codec, res);
8962 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008963 }
8964}
8965
8966static void alc883_mode2_inithook(struct hda_codec *codec)
8967{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008968 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008969 alc883_nb_mic_automute(codec);
8970}
8971
8972static struct hda_verb alc888_asus_eee1601_verbs[] = {
8973 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8974 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8975 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8976 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8977 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8978 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8979 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8980 /* enable unsolicited event */
8981 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8982 { } /* end */
8983};
8984
Kailang Yange2757d52008-08-26 13:17:46 +02008985static void alc883_eee1601_inithook(struct hda_codec *codec)
8986{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008987 struct alc_spec *spec = codec->spec;
8988
8989 spec->autocfg.hp_pins[0] = 0x14;
8990 spec->autocfg.speaker_pins[0] = 0x1b;
8991 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008992}
8993
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008994static struct hda_verb alc889A_mb31_verbs[] = {
8995 /* Init rear pin (used as headphone output) */
8996 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8997 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8998 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8999 /* Init line pin (used as output in 4ch and 6ch mode) */
9000 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9001 /* Init line 2 pin (used as headphone out by default) */
9002 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9003 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9004 { } /* end */
9005};
9006
9007/* Mute speakers according to the headphone jack state */
9008static void alc889A_mb31_automute(struct hda_codec *codec)
9009{
9010 unsigned int present;
9011
9012 /* Mute only in 2ch or 4ch mode */
9013 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9014 == 0x00) {
9015 present = snd_hda_codec_read(codec, 0x15, 0,
9016 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
9017 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9018 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9019 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9020 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9021 }
9022}
9023
9024static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9025{
9026 if ((res >> 26) == ALC880_HP_EVENT)
9027 alc889A_mb31_automute(codec);
9028}
9029
Takashi Iwaicb53c622007-08-10 17:21:45 +02009030#ifdef CONFIG_SND_HDA_POWER_SAVE
9031#define alc883_loopbacks alc880_loopbacks
9032#endif
9033
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009034/* pcm configuration: identical with ALC880 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009035#define alc883_pcm_analog_playback alc880_pcm_analog_playback
9036#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01009037#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009038#define alc883_pcm_digital_playback alc880_pcm_digital_playback
9039#define alc883_pcm_digital_capture alc880_pcm_digital_capture
9040
9041/*
9042 * configuration and preset
9043 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009044static const char *alc883_models[ALC883_MODEL_LAST] = {
9045 [ALC883_3ST_2ch_DIG] = "3stack-dig",
9046 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9047 [ALC883_3ST_6ch] = "3stack-6ch",
9048 [ALC883_6ST_DIG] = "6stack-dig",
9049 [ALC883_TARGA_DIG] = "targa-dig",
9050 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009051 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009052 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009053 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009054 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009055 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009056 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009057 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009058 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009059 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009060 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009061 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9062 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009063 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009064 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009065 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009066 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009067 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009068 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009069 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009070 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009071 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009072 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009073 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009074 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009075 [ALC883_AUTO] = "auto",
9076};
9077
9078static struct snd_pci_quirk alc883_cfg_tbl[] = {
9079 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009080 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009081 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009082 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009083 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9084 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009085 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009086 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9087 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009088 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
9089 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009090 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9091 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009092 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9093 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaib3bdb302009-02-18 13:16:26 +01009094 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01009095 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009096 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009097 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009098 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009099 ALC888_ACER_ASPIRE_6530G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009100 /* default Acer -- disabled as it causes more problems.
9101 * model=auto should work fine now
9102 */
9103 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009104 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02009105 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009106 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9107 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009108 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009109 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009110 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009111 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009112 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009113 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009114 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009115 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02009116 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009117 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009118 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009119 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9120 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009121 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009122 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02009123 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009124 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9125 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9126 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02009127 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009128 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009129 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009130 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9131 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9132 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9133 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9134 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9135 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
9136 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9137 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9138 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009139 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009140 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9141 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009142 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009143 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009144 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009145 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009146 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009147 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009148 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009149 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009150 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9151 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009152 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009153 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009154 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009155 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009156 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009157 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009158 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009159 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009160 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009161 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9162 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009163 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009164 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009165 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009166 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009167 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02009168 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9169 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009170 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08009171 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009172 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Guido Günther3e1647c2009-06-05 00:47:26 +02009173 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009174 {}
9175};
9176
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009177static hda_nid_t alc883_slave_dig_outs[] = {
9178 ALC1200_DIGOUT_NID, 0,
9179};
9180
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009181static hda_nid_t alc1200_slave_dig_outs[] = {
9182 ALC883_DIGOUT_NID, 0,
9183};
9184
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009185static struct alc_config_preset alc883_presets[] = {
9186 [ALC883_3ST_2ch_DIG] = {
9187 .mixers = { alc883_3ST_2ch_mixer },
9188 .init_verbs = { alc883_init_verbs },
9189 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9190 .dac_nids = alc883_dac_nids,
9191 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009192 .dig_in_nid = ALC883_DIGIN_NID,
9193 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9194 .channel_mode = alc883_3ST_2ch_modes,
9195 .input_mux = &alc883_capture_source,
9196 },
9197 [ALC883_3ST_6ch_DIG] = {
9198 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9199 .init_verbs = { alc883_init_verbs },
9200 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9201 .dac_nids = alc883_dac_nids,
9202 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009203 .dig_in_nid = ALC883_DIGIN_NID,
9204 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9205 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009206 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009207 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009208 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009209 [ALC883_3ST_6ch] = {
9210 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9211 .init_verbs = { alc883_init_verbs },
9212 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9213 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009214 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9215 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009216 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009217 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009218 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009219 [ALC883_3ST_6ch_INTEL] = {
9220 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9221 .init_verbs = { alc883_init_verbs },
9222 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9223 .dac_nids = alc883_dac_nids,
9224 .dig_out_nid = ALC883_DIGOUT_NID,
9225 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009226 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009227 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9228 .channel_mode = alc883_3ST_6ch_intel_modes,
9229 .need_dac_fix = 1,
9230 .input_mux = &alc883_3stack_6ch_intel,
9231 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009232 [ALC883_6ST_DIG] = {
9233 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9234 .init_verbs = { alc883_init_verbs },
9235 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9236 .dac_nids = alc883_dac_nids,
9237 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009238 .dig_in_nid = ALC883_DIGIN_NID,
9239 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9240 .channel_mode = alc883_sixstack_modes,
9241 .input_mux = &alc883_capture_source,
9242 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009243 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009244 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009245 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9246 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009247 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9248 .dac_nids = alc883_dac_nids,
9249 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009250 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9251 .channel_mode = alc883_3ST_6ch_modes,
9252 .need_dac_fix = 1,
9253 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009254 .unsol_event = alc883_targa_unsol_event,
9255 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009256 },
9257 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009258 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009259 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9260 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009261 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9262 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009263 .adc_nids = alc883_adc_nids_alt,
9264 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009265 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009266 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9267 .channel_mode = alc883_3ST_2ch_modes,
9268 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009269 .unsol_event = alc883_targa_unsol_event,
9270 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009271 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009272 [ALC883_TARGA_8ch_DIG] = {
9273 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9274 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009275 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009276 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9277 .dac_nids = alc883_dac_nids,
9278 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9279 .adc_nids = alc883_adc_nids_rev,
9280 .capsrc_nids = alc883_capsrc_nids_rev,
9281 .dig_out_nid = ALC883_DIGOUT_NID,
9282 .dig_in_nid = ALC883_DIGIN_NID,
9283 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9284 .channel_mode = alc883_4ST_8ch_modes,
9285 .need_dac_fix = 1,
9286 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009287 .unsol_event = alc883_targa_unsol_event,
9288 .init_hook = alc883_targa_init_hook,
David Heidelberger64a8be72009-06-08 16:15:18 +02009289 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009290 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009291 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009292 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9293 * and the headphone jack. Turn this on and rely on the
9294 * standard mute methods whenever the user wants to turn
9295 * these outputs off.
9296 */
9297 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9298 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9299 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009300 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9301 .channel_mode = alc883_3ST_2ch_modes,
9302 .input_mux = &alc883_capture_source,
9303 },
Tobin Davis2880a862007-08-07 11:50:26 +02009304 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009305 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009306 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009307 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9308 .dac_nids = alc883_dac_nids,
9309 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009310 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9311 .channel_mode = alc883_3ST_2ch_modes,
9312 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009313 .unsol_event = alc_automute_amp_unsol_event,
9314 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009315 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009316 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009317 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009318 alc883_chmode_mixer },
9319 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9320 alc888_acer_aspire_4930g_verbs },
9321 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9322 .dac_nids = alc883_dac_nids,
9323 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9324 .adc_nids = alc883_adc_nids_rev,
9325 .capsrc_nids = alc883_capsrc_nids_rev,
9326 .dig_out_nid = ALC883_DIGOUT_NID,
9327 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9328 .channel_mode = alc883_3ST_6ch_modes,
9329 .need_dac_fix = 1,
9330 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009331 ARRAY_SIZE(alc888_2_capture_sources),
9332 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009333 .unsol_event = alc_automute_amp_unsol_event,
9334 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009335 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009336 [ALC888_ACER_ASPIRE_6530G] = {
9337 .mixers = { alc888_acer_aspire_6530_mixer },
9338 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9339 alc888_acer_aspire_6530g_verbs },
9340 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9341 .dac_nids = alc883_dac_nids,
9342 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9343 .adc_nids = alc883_adc_nids_rev,
9344 .capsrc_nids = alc883_capsrc_nids_rev,
9345 .dig_out_nid = ALC883_DIGOUT_NID,
9346 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9347 .channel_mode = alc883_3ST_2ch_modes,
9348 .num_mux_defs =
9349 ARRAY_SIZE(alc888_2_capture_sources),
9350 .input_mux = alc888_acer_aspire_6530_sources,
9351 .unsol_event = alc_automute_amp_unsol_event,
Emilio López320d5922009-06-25 08:18:44 +02009352 .init_hook = alc888_acer_aspire_6530g_init_hook,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009353 },
Hector Martin3b315d72009-06-02 10:54:19 +02009354 [ALC888_ACER_ASPIRE_8930G] = {
9355 .mixers = { alc888_base_mixer,
9356 alc883_chmode_mixer },
9357 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009358 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009359 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9360 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009361 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9362 .adc_nids = alc889_adc_nids,
9363 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009364 .dig_out_nid = ALC883_DIGOUT_NID,
9365 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9366 .channel_mode = alc883_3ST_6ch_modes,
9367 .need_dac_fix = 1,
9368 .const_channel_count = 6,
9369 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009370 ARRAY_SIZE(alc889_capture_sources),
9371 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009372 .unsol_event = alc_automute_amp_unsol_event,
Hector Martin018df412009-06-04 00:13:40 +02009373 .init_hook = alc889_acer_aspire_8930g_init_hook,
Hector Martin3b315d72009-06-02 10:54:19 +02009374 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009375 [ALC883_MEDION] = {
9376 .mixers = { alc883_fivestack_mixer,
9377 alc883_chmode_mixer },
9378 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009379 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009380 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9381 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009382 .adc_nids = alc883_adc_nids_alt,
9383 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009384 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9385 .channel_mode = alc883_sixstack_modes,
9386 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009387 },
Kailang Yang272a5272007-05-14 11:00:38 +02009388 [ALC883_MEDION_MD2] = {
9389 .mixers = { alc883_medion_md2_mixer},
9390 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9391 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9392 .dac_nids = alc883_dac_nids,
9393 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009394 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9395 .channel_mode = alc883_3ST_2ch_modes,
9396 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009397 .unsol_event = alc_automute_amp_unsol_event,
9398 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02009399 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009400 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009401 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009402 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9403 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9404 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009405 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9406 .channel_mode = alc883_3ST_2ch_modes,
9407 .input_mux = &alc883_capture_source,
9408 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009409 [ALC883_CLEVO_M720] = {
9410 .mixers = { alc883_clevo_m720_mixer },
9411 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009412 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9413 .dac_nids = alc883_dac_nids,
9414 .dig_out_nid = ALC883_DIGOUT_NID,
9415 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9416 .channel_mode = alc883_3ST_2ch_modes,
9417 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009418 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009419 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009420 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009421 [ALC883_LENOVO_101E_2ch] = {
9422 .mixers = { alc883_lenovo_101e_2ch_mixer},
9423 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9424 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9425 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009426 .adc_nids = alc883_adc_nids_alt,
9427 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009428 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9429 .channel_mode = alc883_3ST_2ch_modes,
9430 .input_mux = &alc883_lenovo_101e_capture_source,
9431 .unsol_event = alc883_lenovo_101e_unsol_event,
9432 .init_hook = alc883_lenovo_101e_all_automute,
9433 },
Kailang Yang272a5272007-05-14 11:00:38 +02009434 [ALC883_LENOVO_NB0763] = {
9435 .mixers = { alc883_lenovo_nb0763_mixer },
9436 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9437 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9438 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009439 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9440 .channel_mode = alc883_3ST_2ch_modes,
9441 .need_dac_fix = 1,
9442 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009443 .unsol_event = alc_automute_amp_unsol_event,
9444 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02009445 },
9446 [ALC888_LENOVO_MS7195_DIG] = {
9447 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9448 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9449 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9450 .dac_nids = alc883_dac_nids,
9451 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009452 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9453 .channel_mode = alc883_3ST_6ch_modes,
9454 .need_dac_fix = 1,
9455 .input_mux = &alc883_capture_source,
9456 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9457 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009458 },
9459 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009460 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009461 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9462 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9463 .dac_nids = alc883_dac_nids,
9464 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009465 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9466 .channel_mode = alc883_3ST_2ch_modes,
9467 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009468 .unsol_event = alc_automute_amp_unsol_event,
9469 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009470 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009471 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009472 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009473 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009474 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9475 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009476 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9477 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009478 .need_dac_fix = 1,
9479 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009480 .unsol_event = alc_automute_amp_unsol_event,
9481 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009482 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009483 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009484 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009485 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9486 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9487 .dac_nids = alc883_dac_nids,
9488 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009489 .dig_in_nid = ALC883_DIGIN_NID,
9490 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9491 .channel_mode = alc883_sixstack_modes,
9492 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009493 .unsol_event = alc_automute_amp_unsol_event,
9494 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009495 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009496 [ALC883_MITAC] = {
9497 .mixers = { alc883_mitac_mixer },
9498 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9499 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9500 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009501 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9502 .channel_mode = alc883_3ST_2ch_modes,
9503 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009504 .unsol_event = alc_automute_amp_unsol_event,
9505 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009506 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009507 [ALC883_FUJITSU_PI2515] = {
9508 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9509 .init_verbs = { alc883_init_verbs,
9510 alc883_2ch_fujitsu_pi2515_verbs},
9511 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9512 .dac_nids = alc883_dac_nids,
9513 .dig_out_nid = ALC883_DIGOUT_NID,
9514 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9515 .channel_mode = alc883_3ST_2ch_modes,
9516 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009517 .unsol_event = alc_automute_amp_unsol_event,
9518 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01009519 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009520 [ALC888_FUJITSU_XA3530] = {
9521 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9522 .init_verbs = { alc883_init_verbs,
9523 alc888_fujitsu_xa3530_verbs },
9524 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9525 .dac_nids = alc883_dac_nids,
9526 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9527 .adc_nids = alc883_adc_nids_rev,
9528 .capsrc_nids = alc883_capsrc_nids_rev,
9529 .dig_out_nid = ALC883_DIGOUT_NID,
9530 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9531 .channel_mode = alc888_4ST_8ch_intel_modes,
9532 .num_mux_defs =
9533 ARRAY_SIZE(alc888_2_capture_sources),
9534 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009535 .unsol_event = alc_automute_amp_unsol_event,
9536 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009537 },
Kailang Yange2757d52008-08-26 13:17:46 +02009538 [ALC888_LENOVO_SKY] = {
9539 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9540 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9541 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9542 .dac_nids = alc883_dac_nids,
9543 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009544 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9545 .channel_mode = alc883_sixstack_modes,
9546 .need_dac_fix = 1,
9547 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009548 .unsol_event = alc_automute_amp_unsol_event,
9549 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009550 },
9551 [ALC888_ASUS_M90V] = {
9552 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9553 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9554 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9555 .dac_nids = alc883_dac_nids,
9556 .dig_out_nid = ALC883_DIGOUT_NID,
9557 .dig_in_nid = ALC883_DIGIN_NID,
9558 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9559 .channel_mode = alc883_3ST_6ch_modes,
9560 .need_dac_fix = 1,
9561 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9562 .unsol_event = alc883_mode2_unsol_event,
9563 .init_hook = alc883_mode2_inithook,
9564 },
9565 [ALC888_ASUS_EEE1601] = {
9566 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009567 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009568 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9569 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9570 .dac_nids = alc883_dac_nids,
9571 .dig_out_nid = ALC883_DIGOUT_NID,
9572 .dig_in_nid = ALC883_DIGIN_NID,
9573 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9574 .channel_mode = alc883_3ST_2ch_modes,
9575 .need_dac_fix = 1,
9576 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009577 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009578 .init_hook = alc883_eee1601_inithook,
9579 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009580 [ALC1200_ASUS_P5Q] = {
9581 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9582 .init_verbs = { alc883_init_verbs },
9583 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9584 .dac_nids = alc883_dac_nids,
9585 .dig_out_nid = ALC1200_DIGOUT_NID,
9586 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009587 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009588 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9589 .channel_mode = alc883_sixstack_modes,
9590 .input_mux = &alc883_capture_source,
9591 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009592 [ALC889A_MB31] = {
9593 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9594 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9595 alc880_gpio1_init_verbs },
9596 .adc_nids = alc883_adc_nids,
9597 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9598 .dac_nids = alc883_dac_nids,
9599 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9600 .channel_mode = alc889A_mb31_6ch_modes,
9601 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9602 .input_mux = &alc889A_mb31_capture_source,
9603 .dig_out_nid = ALC883_DIGOUT_NID,
9604 .unsol_event = alc889A_mb31_unsol_event,
9605 .init_hook = alc889A_mb31_automute,
9606 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009607 [ALC883_SONY_VAIO_TT] = {
9608 .mixers = { alc883_vaiott_mixer },
9609 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9610 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9611 .dac_nids = alc883_dac_nids,
9612 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9613 .channel_mode = alc883_3ST_2ch_modes,
9614 .input_mux = &alc883_capture_source,
9615 .unsol_event = alc_automute_amp_unsol_event,
9616 .init_hook = alc883_vaiott_init_hook,
9617 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009618};
9619
9620
9621/*
9622 * BIOS auto configuration
9623 */
9624static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
9625 hda_nid_t nid, int pin_type,
9626 int dac_idx)
9627{
9628 /* set as output */
9629 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009630 int idx;
9631
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009632 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009633 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9634 idx = 4;
9635 else
9636 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009637 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9638
9639}
9640
9641static void alc883_auto_init_multi_out(struct hda_codec *codec)
9642{
9643 struct alc_spec *spec = codec->spec;
9644 int i;
9645
9646 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009647 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009648 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009649 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009650 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009651 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009652 }
9653}
9654
9655static void alc883_auto_init_hp_out(struct hda_codec *codec)
9656{
9657 struct alc_spec *spec = codec->spec;
9658 hda_nid_t pin;
9659
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009660 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009661 if (pin) /* connect to front */
9662 /* use dac 0 */
9663 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009664 pin = spec->autocfg.speaker_pins[0];
9665 if (pin)
9666 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009667}
9668
9669#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9670#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9671
9672static void alc883_auto_init_analog_input(struct hda_codec *codec)
9673{
9674 struct alc_spec *spec = codec->spec;
9675 int i;
9676
9677 for (i = 0; i < AUTO_PIN_LAST; i++) {
9678 hda_nid_t nid = spec->autocfg.input_pins[i];
9679 if (alc883_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01009680 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01009681 if (nid != ALC883_PIN_CD_NID &&
9682 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009683 snd_hda_codec_write(codec, nid, 0,
9684 AC_VERB_SET_AMP_GAIN_MUTE,
9685 AMP_OUT_MUTE);
9686 }
9687 }
9688}
9689
Takashi Iwaif511b012008-08-15 16:46:42 +02009690#define alc883_auto_init_input_src alc882_auto_init_input_src
9691
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009692/* almost identical with ALC880 parser... */
9693static int alc883_parse_auto_config(struct hda_codec *codec)
9694{
9695 struct alc_spec *spec = codec->spec;
9696 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009697 struct auto_pin_cfg *cfg = &spec->autocfg;
9698 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009699
9700 if (err < 0)
9701 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009702 else if (!err)
9703 return 0; /* no config found */
9704
9705 err = alc_auto_add_mic_boost(codec);
9706 if (err < 0)
9707 return err;
9708
9709 /* hack - override the init verbs */
9710 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009711
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009712 /* setup input_mux for ALC889 */
9713 if (codec->vendor_id == 0x10ec0889) {
9714 /* digital-mic input pin is excluded in alc880_auto_create..()
9715 * because it's under 0x18
9716 */
9717 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9718 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9719 struct hda_input_mux *imux = &spec->private_imux[0];
9720 for (i = 1; i < 3; i++)
9721 memcpy(&spec->private_imux[i],
9722 &spec->private_imux[0],
9723 sizeof(spec->private_imux[0]));
9724 imux->items[imux->num_items].label = "Int DMic";
9725 imux->items[imux->num_items].index = 0x0b;
9726 imux->num_items++;
9727 spec->num_mux_defs = 3;
9728 spec->input_mux = spec->private_imux;
9729 }
9730 }
9731
Takashi Iwai776e1842007-08-29 15:07:11 +02009732 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009733}
9734
9735/* additional initialization for auto-configuration model */
9736static void alc883_auto_init(struct hda_codec *codec)
9737{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009738 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009739 alc883_auto_init_multi_out(codec);
9740 alc883_auto_init_hp_out(codec);
9741 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009742 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009743 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009744 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009745}
9746
9747static int patch_alc883(struct hda_codec *codec)
9748{
9749 struct alc_spec *spec;
9750 int err, board_config;
9751
9752 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9753 if (spec == NULL)
9754 return -ENOMEM;
9755
9756 codec->spec = spec;
9757
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009758 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9759
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009760 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9761 alc883_models,
9762 alc883_cfg_tbl);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009763 if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
9764 /* Pick up systems that don't supply PCI SSID */
9765 switch (codec->subsystem_id) {
9766 case 0x106b3600: /* Macbook 3.1 */
9767 board_config = ALC889A_MB31;
9768 break;
9769 default:
9770 printk(KERN_INFO
9771 "hda_codec: Unknown model for %s, trying "
9772 "auto-probe from BIOS...\n", codec->chip_name);
9773 board_config = ALC883_AUTO;
9774 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009775 }
9776
9777 if (board_config == ALC883_AUTO) {
9778 /* automatic parse from the BIOS config */
9779 err = alc883_parse_auto_config(codec);
9780 if (err < 0) {
9781 alc_free(codec);
9782 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009783 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009784 printk(KERN_INFO
9785 "hda_codec: Cannot set up configuration "
9786 "from BIOS. Using base mode...\n");
9787 board_config = ALC883_3ST_2ch_DIG;
9788 }
9789 }
9790
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009791 err = snd_hda_attach_beep_device(codec, 0x1);
9792 if (err < 0) {
9793 alc_free(codec);
9794 return err;
9795 }
9796
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009797 if (board_config != ALC883_AUTO)
9798 setup_preset(spec, &alc883_presets[board_config]);
9799
Kailang Yang2f893282008-05-27 12:14:47 +02009800 switch (codec->vendor_id) {
9801 case 0x10ec0888:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009802 if (!spec->num_adc_nids) {
9803 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9804 spec->adc_nids = alc883_adc_nids;
9805 }
9806 if (!spec->capsrc_nids)
9807 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009808 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Kailang Yang2f893282008-05-27 12:14:47 +02009809 break;
9810 case 0x10ec0889:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009811 if (!spec->num_adc_nids) {
9812 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9813 spec->adc_nids = alc889_adc_nids;
9814 }
9815 if (!spec->capsrc_nids)
9816 spec->capsrc_nids = alc889_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009817 break;
9818 default:
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009819 if (!spec->num_adc_nids) {
9820 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9821 spec->adc_nids = alc883_adc_nids;
9822 }
9823 if (!spec->capsrc_nids)
9824 spec->capsrc_nids = alc883_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009825 break;
9826 }
9827
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009828 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9829 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009830 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009831
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009832 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9833 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9834
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009835 if (!spec->cap_mixer)
9836 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009837 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009838
Takashi Iwai2134ea42008-01-10 16:53:55 +01009839 spec->vmaster_nid = 0x0c;
9840
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009841 codec->patch_ops = alc_patch_ops;
9842 if (board_config == ALC883_AUTO)
9843 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009844
Takashi Iwaicb53c622007-08-10 17:21:45 +02009845#ifdef CONFIG_SND_HDA_POWER_SAVE
9846 if (!spec->loopback.amplist)
9847 spec->loopback.amplist = alc883_loopbacks;
9848#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009849 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009850
9851 return 0;
9852}
9853
9854/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009855 * ALC262 support
9856 */
9857
9858#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9859#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9860
9861#define alc262_dac_nids alc260_dac_nids
9862#define alc262_adc_nids alc882_adc_nids
9863#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009864#define alc262_capsrc_nids alc882_capsrc_nids
9865#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009866
9867#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009868#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009869
Kailang Yang4e555fe2008-08-26 13:05:55 +02009870static hda_nid_t alc262_dmic_adc_nids[1] = {
9871 /* ADC0 */
9872 0x09
9873};
9874
9875static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9876
Kailang Yangdf694da2005-12-05 19:42:22 +01009877static struct snd_kcontrol_new alc262_base_mixer[] = {
9878 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9879 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9880 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9881 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9882 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9883 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9884 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9885 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009886 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009887 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9888 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009889 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009890 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9891 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9892 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9893 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009894 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009895};
9896
Takashi Iwaice875f02008-01-28 18:17:43 +01009897/* update HP, line and mono-out pins according to the master switch */
9898static void alc262_hp_master_update(struct hda_codec *codec)
9899{
9900 struct alc_spec *spec = codec->spec;
9901 int val = spec->master_sw;
9902
9903 /* HP & line-out */
9904 snd_hda_codec_write_cache(codec, 0x1b, 0,
9905 AC_VERB_SET_PIN_WIDGET_CONTROL,
9906 val ? PIN_HP : 0);
9907 snd_hda_codec_write_cache(codec, 0x15, 0,
9908 AC_VERB_SET_PIN_WIDGET_CONTROL,
9909 val ? PIN_HP : 0);
9910 /* mono (speaker) depending on the HP jack sense */
9911 val = val && !spec->jack_present;
9912 snd_hda_codec_write_cache(codec, 0x16, 0,
9913 AC_VERB_SET_PIN_WIDGET_CONTROL,
9914 val ? PIN_OUT : 0);
9915}
9916
9917static void alc262_hp_bpc_automute(struct hda_codec *codec)
9918{
9919 struct alc_spec *spec = codec->spec;
9920 unsigned int presence;
9921 presence = snd_hda_codec_read(codec, 0x1b, 0,
9922 AC_VERB_GET_PIN_SENSE, 0);
9923 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9924 alc262_hp_master_update(codec);
9925}
9926
9927static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9928{
9929 if ((res >> 26) != ALC880_HP_EVENT)
9930 return;
9931 alc262_hp_bpc_automute(codec);
9932}
9933
9934static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9935{
9936 struct alc_spec *spec = codec->spec;
9937 unsigned int presence;
9938 presence = snd_hda_codec_read(codec, 0x15, 0,
9939 AC_VERB_GET_PIN_SENSE, 0);
9940 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9941 alc262_hp_master_update(codec);
9942}
9943
9944static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9945 unsigned int res)
9946{
9947 if ((res >> 26) != ALC880_HP_EVENT)
9948 return;
9949 alc262_hp_wildwest_automute(codec);
9950}
9951
Takashi Iwaib72519b2009-05-08 14:31:55 +02009952#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009953
9954static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9955 struct snd_ctl_elem_value *ucontrol)
9956{
9957 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9958 struct alc_spec *spec = codec->spec;
9959 int val = !!*ucontrol->value.integer.value;
9960
9961 if (val == spec->master_sw)
9962 return 0;
9963 spec->master_sw = val;
9964 alc262_hp_master_update(codec);
9965 return 1;
9966}
9967
Takashi Iwaib72519b2009-05-08 14:31:55 +02009968#define ALC262_HP_MASTER_SWITCH \
9969 { \
9970 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9971 .name = "Master Playback Switch", \
9972 .info = snd_ctl_boolean_mono_info, \
9973 .get = alc262_hp_master_sw_get, \
9974 .put = alc262_hp_master_sw_put, \
9975 }
9976
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009977static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009978 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009979 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9980 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9981 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009982 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9983 HDA_OUTPUT),
9984 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9985 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009986 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9987 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009988 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009989 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9990 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009991 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009992 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9993 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9994 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9995 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009996 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9997 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9998 { } /* end */
9999};
10000
Kailang Yangcd7509a2007-01-26 18:33:17 +010010001static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010002 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010003 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10004 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10005 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010007 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10008 HDA_OUTPUT),
10009 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10010 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010011 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10012 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010013 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010014 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10015 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10016 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10017 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010018 { } /* end */
10019};
10020
10021static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10022 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10023 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010024 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010025 { } /* end */
10026};
10027
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010028/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010029static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010030{
10031 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010032
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010033 spec->autocfg.hp_pins[0] = 0x15;
10034 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
10035 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010036}
10037
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010038static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010039 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10040 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010041 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10042 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10043 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10044 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10045 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10046 { } /* end */
10047};
10048
10049static struct hda_verb alc262_hp_t5735_verbs[] = {
10050 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10051 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10052
10053 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10054 { }
10055};
10056
Kailang Yang8c427222008-01-10 13:03:59 +010010057static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010058 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10059 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010060 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10061 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010062 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10063 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10064 { } /* end */
10065};
10066
10067static struct hda_verb alc262_hp_rp5700_verbs[] = {
10068 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10069 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10070 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10071 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10072 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10073 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10074 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10075 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10076 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10077 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10078 {}
10079};
10080
10081static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10082 .num_items = 1,
10083 .items = {
10084 { "Line", 0x1 },
10085 },
10086};
10087
Takashi Iwai42171c12009-05-08 14:11:43 +020010088/* bind hp and internal speaker mute (with plug check) as master switch */
10089static void alc262_hippo_master_update(struct hda_codec *codec)
10090{
10091 struct alc_spec *spec = codec->spec;
10092 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10093 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10094 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10095 unsigned int mute;
10096
10097 /* HP */
10098 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10099 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10100 HDA_AMP_MUTE, mute);
10101 /* mute internal speaker per jack sense */
10102 if (spec->jack_present)
10103 mute = HDA_AMP_MUTE;
10104 if (line_nid)
10105 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10106 HDA_AMP_MUTE, mute);
10107 if (speaker_nid && speaker_nid != line_nid)
10108 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10109 HDA_AMP_MUTE, mute);
10110}
10111
10112#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10113
10114static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10115 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010116{
10117 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010118 struct alc_spec *spec = codec->spec;
10119 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010120
Takashi Iwai42171c12009-05-08 14:11:43 +020010121 if (val == spec->master_sw)
10122 return 0;
10123 spec->master_sw = val;
10124 alc262_hippo_master_update(codec);
10125 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010126}
Takashi Iwai5b319542007-07-26 11:49:22 +020010127
Takashi Iwai42171c12009-05-08 14:11:43 +020010128#define ALC262_HIPPO_MASTER_SWITCH \
10129 { \
10130 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10131 .name = "Master Playback Switch", \
10132 .info = snd_ctl_boolean_mono_info, \
10133 .get = alc262_hippo_master_sw_get, \
10134 .put = alc262_hippo_master_sw_put, \
10135 }
10136
10137static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10138 ALC262_HIPPO_MASTER_SWITCH,
10139 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10140 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10141 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10142 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10143 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10146 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10147 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10148 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10149 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10150 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10151 { } /* end */
10152};
10153
10154static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10155 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10156 ALC262_HIPPO_MASTER_SWITCH,
10157 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10158 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10159 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10160 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10161 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10162 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10163 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10164 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10165 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10166 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10167 { } /* end */
10168};
10169
10170/* mute/unmute internal speaker according to the hp jack and mute state */
10171static void alc262_hippo_automute(struct hda_codec *codec)
10172{
10173 struct alc_spec *spec = codec->spec;
10174 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10175 unsigned int present;
10176
10177 /* need to execute and sync at first */
10178 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10179 present = snd_hda_codec_read(codec, hp_nid, 0,
10180 AC_VERB_GET_PIN_SENSE, 0);
10181 spec->jack_present = (present & 0x80000000) != 0;
10182 alc262_hippo_master_update(codec);
10183}
10184
10185static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10186{
10187 if ((res >> 26) != ALC880_HP_EVENT)
10188 return;
10189 alc262_hippo_automute(codec);
10190}
10191
10192static void alc262_hippo_init_hook(struct hda_codec *codec)
10193{
10194 struct alc_spec *spec = codec->spec;
10195
10196 spec->autocfg.hp_pins[0] = 0x15;
10197 spec->autocfg.speaker_pins[0] = 0x14;
10198 alc262_hippo_automute(codec);
10199}
10200
10201static void alc262_hippo1_init_hook(struct hda_codec *codec)
10202{
10203 struct alc_spec *spec = codec->spec;
10204
10205 spec->autocfg.hp_pins[0] = 0x1b;
10206 spec->autocfg.speaker_pins[0] = 0x14;
10207 alc262_hippo_automute(codec);
10208}
10209
10210
Kailang Yang272a5272007-05-14 11:00:38 +020010211static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010212 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010213 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10215 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10216 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10217 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10218 { } /* end */
10219};
10220
Kailang Yang83c34212007-07-05 11:43:05 +020010221static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010222 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10223 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010224 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10226 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10227 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10228 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10229 { } /* end */
10230};
Kailang Yang272a5272007-05-14 11:00:38 +020010231
Tony Vroonba340e82009-02-02 19:01:30 +000010232static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10233 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10234 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10235 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10236 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10237 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10238 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10239 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10240 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10241 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10242 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10243 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10244 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10245 { } /* end */
10246};
10247
10248static struct hda_verb alc262_tyan_verbs[] = {
10249 /* Headphone automute */
10250 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10251 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10252 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10253
10254 /* P11 AUX_IN, white 4-pin connector */
10255 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10256 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10257 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10258 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10259
10260 {}
10261};
10262
10263/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010264static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010265{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010266 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010267
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010268 spec->autocfg.hp_pins[0] = 0x1b;
10269 spec->autocfg.speaker_pins[0] = 0x15;
10270 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +000010271}
10272
Tony Vroonba340e82009-02-02 19:01:30 +000010273
Kailang Yangdf694da2005-12-05 19:42:22 +010010274#define alc262_capture_mixer alc882_capture_mixer
10275#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10276
10277/*
10278 * generic initialization of ADC, input mixers and output mixers
10279 */
10280static struct hda_verb alc262_init_verbs[] = {
10281 /*
10282 * Unmute ADC0-2 and set the default input to mic-in
10283 */
10284 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10285 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10286 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10287 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10288 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10289 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10290
Takashi Iwaicb53c622007-08-10 17:21:45 +020010291 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010292 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010293 * Note: PASD motherboards uses the Line In 2 as the input for
10294 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010295 */
10296 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010297 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10298 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10299 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10300 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10301 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010302
10303 /*
10304 * Set up output mixers (0x0c - 0x0e)
10305 */
10306 /* set vol=0 to output mixers */
10307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10308 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10309 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10310 /* set up input amps for analog loopback */
10311 /* Amp Indices: DAC = 0, mixer = 1 */
10312 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10313 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10314 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10315 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10316 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10317 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10318
10319 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10320 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10321 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10322 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10323 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10324 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10325
10326 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10327 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10328 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10329 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10330 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010331
Kailang Yangdf694da2005-12-05 19:42:22 +010010332 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10333 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010334
Kailang Yangdf694da2005-12-05 19:42:22 +010010335 /* FIXME: use matrix-type input source selection */
10336 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10337 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10338 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10339 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10340 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10341 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10342 /* Input mixer2 */
10343 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10344 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10345 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10346 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10347 /* Input mixer3 */
10348 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10349 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10350 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010351 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010352
10353 { }
10354};
10355
Kailang Yang4e555fe2008-08-26 13:05:55 +020010356static struct hda_verb alc262_eapd_verbs[] = {
10357 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10358 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10359 { }
10360};
10361
Kailang Yangccc656c2006-10-17 12:32:26 +020010362static struct hda_verb alc262_hippo_unsol_verbs[] = {
10363 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10364 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10365 {}
10366};
10367
10368static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10369 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10370 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10371 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10372
10373 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10374 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10375 {}
10376};
10377
Kailang Yang272a5272007-05-14 11:00:38 +020010378static struct hda_verb alc262_sony_unsol_verbs[] = {
10379 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10380 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10381 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10382
10383 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10384 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010385 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010386};
10387
Kailang Yang4e555fe2008-08-26 13:05:55 +020010388static struct hda_input_mux alc262_dmic_capture_source = {
10389 .num_items = 2,
10390 .items = {
10391 { "Int DMic", 0x9 },
10392 { "Mic", 0x0 },
10393 },
10394};
10395
10396static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10397 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10398 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10399 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10400 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10401 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010402 { } /* end */
10403};
10404
10405static struct hda_verb alc262_toshiba_s06_verbs[] = {
10406 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10407 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10408 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10409 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10410 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10411 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10412 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10413 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10414 {}
10415};
10416
10417static void alc262_dmic_automute(struct hda_codec *codec)
10418{
10419 unsigned int present;
10420
10421 present = snd_hda_codec_read(codec, 0x18, 0,
10422 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10423 snd_hda_codec_write(codec, 0x22, 0,
10424 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10425}
10426
Kailang Yang4e555fe2008-08-26 13:05:55 +020010427
10428/* unsolicited event for HP jack sensing */
10429static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10430 unsigned int res)
10431{
Kailang Yang4e555fe2008-08-26 13:05:55 +020010432 if ((res >> 26) == ALC880_MIC_EVENT)
10433 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010434 else
10435 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010436}
10437
10438static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10439{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010440 struct alc_spec *spec = codec->spec;
10441
10442 spec->autocfg.hp_pins[0] = 0x15;
10443 spec->autocfg.speaker_pins[0] = 0x14;
10444 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010445 alc262_dmic_automute(codec);
10446}
10447
Takashi Iwai834be882006-03-01 14:16:17 +010010448/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010449 * nec model
10450 * 0x15 = headphone
10451 * 0x16 = internal speaker
10452 * 0x18 = external mic
10453 */
10454
10455static struct snd_kcontrol_new alc262_nec_mixer[] = {
10456 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10457 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10458
10459 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10460 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10461 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10462
10463 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10464 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10465 { } /* end */
10466};
10467
10468static struct hda_verb alc262_nec_verbs[] = {
10469 /* Unmute Speaker */
10470 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10471
10472 /* Headphone */
10473 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10475
10476 /* External mic to headphone */
10477 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10478 /* External mic to speaker */
10479 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10480 {}
10481};
10482
10483/*
Takashi Iwai834be882006-03-01 14:16:17 +010010484 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010485 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10486 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010487 */
10488
10489#define ALC_HP_EVENT 0x37
10490
10491static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10492 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10493 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010494 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10495 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010496 {}
10497};
10498
Jiang zhe0e31daf2008-03-20 12:12:39 +010010499static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10500 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10501 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10502 {}
10503};
10504
Takashi Iwai834be882006-03-01 14:16:17 +010010505static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010506 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010507 .items = {
10508 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010509 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010510 { "CD", 0x4 },
10511 },
10512};
10513
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010514static struct hda_input_mux alc262_HP_capture_source = {
10515 .num_items = 5,
10516 .items = {
10517 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010518 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010519 { "Line", 0x2 },
10520 { "CD", 0x4 },
10521 { "AUX IN", 0x6 },
10522 },
10523};
10524
zhejiangaccbe492007-08-31 12:36:05 +020010525static struct hda_input_mux alc262_HP_D7000_capture_source = {
10526 .num_items = 4,
10527 .items = {
10528 { "Mic", 0x0 },
10529 { "Front Mic", 0x2 },
10530 { "Line", 0x1 },
10531 { "CD", 0x4 },
10532 },
10533};
10534
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010535/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010536static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10537{
10538 struct alc_spec *spec = codec->spec;
10539 unsigned int mute;
10540
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010541 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010542 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010543 /* need to execute and sync at first */
10544 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010545 /* check laptop HP jack */
10546 present = snd_hda_codec_read(codec, 0x14, 0,
10547 AC_VERB_GET_PIN_SENSE, 0);
10548 /* need to execute and sync at first */
10549 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10550 /* check docking HP jack */
10551 present |= snd_hda_codec_read(codec, 0x1b, 0,
10552 AC_VERB_GET_PIN_SENSE, 0);
10553 if (present & AC_PINSENSE_PRESENCE)
10554 spec->jack_present = 1;
10555 else
10556 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010557 spec->sense_updated = 1;
10558 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010559 /* unmute internal speaker only if both HPs are unplugged and
10560 * master switch is on
10561 */
10562 if (spec->jack_present)
10563 mute = HDA_AMP_MUTE;
10564 else
Takashi Iwai834be882006-03-01 14:16:17 +010010565 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010566 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10567 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010568}
10569
10570/* unsolicited event for HP jack sensing */
10571static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10572 unsigned int res)
10573{
10574 if ((res >> 26) != ALC_HP_EVENT)
10575 return;
10576 alc262_fujitsu_automute(codec, 1);
10577}
10578
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010579static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10580{
10581 alc262_fujitsu_automute(codec, 1);
10582}
10583
Takashi Iwai834be882006-03-01 14:16:17 +010010584/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010585static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10586 .ops = &snd_hda_bind_vol,
10587 .values = {
10588 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10589 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10590 0
10591 },
10592};
Takashi Iwai834be882006-03-01 14:16:17 +010010593
Jiang zhe0e31daf2008-03-20 12:12:39 +010010594/* mute/unmute internal speaker according to the hp jack and mute state */
10595static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10596{
10597 struct alc_spec *spec = codec->spec;
10598 unsigned int mute;
10599
10600 if (force || !spec->sense_updated) {
10601 unsigned int present_int_hp;
10602 /* need to execute and sync at first */
10603 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10604 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10605 AC_VERB_GET_PIN_SENSE, 0);
10606 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10607 spec->sense_updated = 1;
10608 }
10609 if (spec->jack_present) {
10610 /* mute internal speaker */
10611 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10612 HDA_AMP_MUTE, HDA_AMP_MUTE);
10613 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10614 HDA_AMP_MUTE, HDA_AMP_MUTE);
10615 } else {
10616 /* unmute internal speaker if necessary */
10617 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10618 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10619 HDA_AMP_MUTE, mute);
10620 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10621 HDA_AMP_MUTE, mute);
10622 }
10623}
10624
10625/* unsolicited event for HP jack sensing */
10626static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10627 unsigned int res)
10628{
10629 if ((res >> 26) != ALC_HP_EVENT)
10630 return;
10631 alc262_lenovo_3000_automute(codec, 1);
10632}
10633
Takashi Iwai8de56b72009-07-24 16:51:47 +020010634static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10635 int dir, int idx, long *valp)
10636{
10637 int i, change = 0;
10638
10639 for (i = 0; i < 2; i++, valp++)
10640 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10641 HDA_AMP_MUTE,
10642 *valp ? 0 : HDA_AMP_MUTE);
10643 return change;
10644}
10645
Takashi Iwai834be882006-03-01 14:16:17 +010010646/* bind hp and internal speaker mute (with plug check) */
10647static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10648 struct snd_ctl_elem_value *ucontrol)
10649{
10650 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10651 long *valp = ucontrol->value.integer.value;
10652 int change;
10653
Takashi Iwai8de56b72009-07-24 16:51:47 +020010654 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10655 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010656 if (change)
10657 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010658 return change;
10659}
10660
10661static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010662 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010663 {
10664 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10665 .name = "Master Playback Switch",
10666 .info = snd_hda_mixer_amp_switch_info,
10667 .get = snd_hda_mixer_amp_switch_get,
10668 .put = alc262_fujitsu_master_sw_put,
10669 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10670 },
10671 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10672 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10673 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10674 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10675 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010676 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10677 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10678 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010679 { } /* end */
10680};
10681
Jiang zhe0e31daf2008-03-20 12:12:39 +010010682/* bind hp and internal speaker mute (with plug check) */
10683static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10684 struct snd_ctl_elem_value *ucontrol)
10685{
10686 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10687 long *valp = ucontrol->value.integer.value;
10688 int change;
10689
Takashi Iwai8de56b72009-07-24 16:51:47 +020010690 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010691 if (change)
10692 alc262_lenovo_3000_automute(codec, 0);
10693 return change;
10694}
10695
10696static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10697 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10698 {
10699 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10700 .name = "Master Playback Switch",
10701 .info = snd_hda_mixer_amp_switch_info,
10702 .get = snd_hda_mixer_amp_switch_get,
10703 .put = alc262_lenovo_3000_master_sw_put,
10704 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10705 },
10706 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10707 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10708 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10709 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10710 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10711 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10712 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10713 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10714 { } /* end */
10715};
10716
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010717static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10718 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010719 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010720 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10721 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10722 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10723 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10724 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10725 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10726 { } /* end */
10727};
10728
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010729/* additional init verbs for Benq laptops */
10730static struct hda_verb alc262_EAPD_verbs[] = {
10731 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10732 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10733 {}
10734};
10735
Kailang Yang83c34212007-07-05 11:43:05 +020010736static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10737 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10738 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10739
10740 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10741 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10742 {}
10743};
10744
Tobin Davisf651b502007-10-26 12:40:47 +020010745/* Samsung Q1 Ultra Vista model setup */
10746static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010747 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10748 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010749 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10750 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10751 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010752 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010753 { } /* end */
10754};
10755
10756static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010757 /* output mixer */
10758 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10759 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10760 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10761 /* speaker */
10762 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10763 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10764 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10765 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10766 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010767 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010768 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10769 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10770 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10771 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10772 /* internal mic */
10773 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10774 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10775 /* ADC, choose mic */
10776 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10777 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10778 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10779 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10780 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10781 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10782 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10783 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10784 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10785 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010786 {}
10787};
10788
Tobin Davisf651b502007-10-26 12:40:47 +020010789/* mute/unmute internal speaker according to the hp jack and mute state */
10790static void alc262_ultra_automute(struct hda_codec *codec)
10791{
10792 struct alc_spec *spec = codec->spec;
10793 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010794
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010795 mute = 0;
10796 /* auto-mute only when HP is used as HP */
10797 if (!spec->cur_mux[0]) {
10798 unsigned int present;
10799 /* need to execute and sync at first */
10800 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10801 present = snd_hda_codec_read(codec, 0x15, 0,
10802 AC_VERB_GET_PIN_SENSE, 0);
10803 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10804 if (spec->jack_present)
10805 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010806 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010807 /* mute/unmute internal speaker */
10808 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10809 HDA_AMP_MUTE, mute);
10810 /* mute/unmute HP */
10811 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10812 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010813}
10814
10815/* unsolicited event for HP jack sensing */
10816static void alc262_ultra_unsol_event(struct hda_codec *codec,
10817 unsigned int res)
10818{
10819 if ((res >> 26) != ALC880_HP_EVENT)
10820 return;
10821 alc262_ultra_automute(codec);
10822}
10823
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010824static struct hda_input_mux alc262_ultra_capture_source = {
10825 .num_items = 2,
10826 .items = {
10827 { "Mic", 0x1 },
10828 { "Headphone", 0x7 },
10829 },
10830};
10831
10832static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10833 struct snd_ctl_elem_value *ucontrol)
10834{
10835 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10836 struct alc_spec *spec = codec->spec;
10837 int ret;
10838
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010839 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010840 if (!ret)
10841 return 0;
10842 /* reprogram the HP pin as mic or HP according to the input source */
10843 snd_hda_codec_write_cache(codec, 0x15, 0,
10844 AC_VERB_SET_PIN_WIDGET_CONTROL,
10845 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10846 alc262_ultra_automute(codec); /* mute/unmute HP */
10847 return ret;
10848}
10849
10850static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10851 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10852 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10853 {
10854 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10855 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010856 .info = alc_mux_enum_info,
10857 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010858 .put = alc262_ultra_mux_enum_put,
10859 },
10860 { } /* end */
10861};
10862
Kailang Yangdf694da2005-12-05 19:42:22 +010010863/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010864static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10865 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010866{
10867 hda_nid_t nid;
10868 int err;
10869
10870 spec->multiout.num_dacs = 1; /* only use one dac */
10871 spec->multiout.dac_nids = spec->private_dac_nids;
10872 spec->multiout.dac_nids[0] = 2;
10873
10874 nid = cfg->line_out_pins[0];
10875 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010876 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10877 "Front Playback Volume",
10878 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10879 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010880 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010881 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10882 "Front Playback Switch",
10883 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10884 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010885 return err;
10886 }
10887
Takashi Iwai82bc9552006-03-21 11:24:42 +010010888 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010889 if (nid) {
10890 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010891 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10892 "Speaker Playback Volume",
10893 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10894 HDA_OUTPUT));
10895 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010896 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010897 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10898 "Speaker Playback Switch",
10899 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10900 HDA_OUTPUT));
10901 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010902 return err;
10903 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010904 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10905 "Speaker Playback Switch",
10906 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10907 HDA_OUTPUT));
10908 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010909 return err;
10910 }
10911 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010912 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010913 if (nid) {
10914 /* spec->multiout.hp_nid = 2; */
10915 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010916 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10917 "Headphone Playback Volume",
10918 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10919 HDA_OUTPUT));
10920 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010921 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010922 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10923 "Headphone Playback Switch",
10924 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10925 HDA_OUTPUT));
10926 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010927 return err;
10928 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010929 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10930 "Headphone Playback Switch",
10931 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10932 HDA_OUTPUT));
10933 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010934 return err;
10935 }
10936 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010937 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010938}
10939
Takashi Iwai8c927b42009-06-22 10:56:54 +020010940static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec,
10941 const struct auto_pin_cfg *cfg)
10942{
10943 int err;
10944
10945 err = alc880_auto_create_analog_input_ctls(spec, cfg);
10946 if (err < 0)
10947 return err;
10948 /* digital-mic input pin is excluded in alc880_auto_create..()
10949 * because it's under 0x18
10950 */
10951 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
10952 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
10953 struct hda_input_mux *imux = &spec->private_imux[0];
10954 imux->items[imux->num_items].label = "Int Mic";
10955 imux->items[imux->num_items].index = 0x09;
10956 imux->num_items++;
10957 }
10958 return 0;
10959}
10960
Kailang Yangdf694da2005-12-05 19:42:22 +010010961
10962/*
10963 * generic initialization of ADC, input mixers and output mixers
10964 */
10965static struct hda_verb alc262_volume_init_verbs[] = {
10966 /*
10967 * Unmute ADC0-2 and set the default input to mic-in
10968 */
10969 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10971 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10972 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10973 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10974 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10975
Takashi Iwaicb53c622007-08-10 17:21:45 +020010976 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010977 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010978 * Note: PASD motherboards uses the Line In 2 as the input for
10979 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010980 */
10981 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010982 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10983 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10984 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10986 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010987
10988 /*
10989 * Set up output mixers (0x0c - 0x0f)
10990 */
10991 /* set vol=0 to output mixers */
10992 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10993 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10994 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010995
Kailang Yangdf694da2005-12-05 19:42:22 +010010996 /* set up input amps for analog loopback */
10997 /* Amp Indices: DAC = 0, mixer = 1 */
10998 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10999 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11000 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11001 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11002 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11003 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11004
11005 /* FIXME: use matrix-type input source selection */
11006 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11007 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11008 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11009 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11010 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11011 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11012 /* Input mixer2 */
11013 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11014 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11015 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11016 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11017 /* Input mixer3 */
11018 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11019 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11020 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11021 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11022
11023 { }
11024};
11025
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011026static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11027 /*
11028 * Unmute ADC0-2 and set the default input to mic-in
11029 */
11030 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11032 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11033 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11034 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11035 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11036
Takashi Iwaicb53c622007-08-10 17:21:45 +020011037 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011038 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011039 * Note: PASD motherboards uses the Line In 2 as the input for
11040 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011041 */
11042 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11045 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11046 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11047 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11048 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11049 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011050
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011051 /*
11052 * Set up output mixers (0x0c - 0x0e)
11053 */
11054 /* set vol=0 to output mixers */
11055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11056 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11057 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11058
11059 /* set up input amps for analog loopback */
11060 /* Amp Indices: DAC = 0, mixer = 1 */
11061 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11062 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11063 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11064 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11065 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11066 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11067
Takashi Iwaice875f02008-01-28 18:17:43 +010011068 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011069 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11070 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11071
11072 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11074
11075 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11076 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11077
11078 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11079 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11080 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11081 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11082 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11083
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011084 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011085 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11086 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011087 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011088 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11089 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11090
11091
11092 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011093 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11094 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011095 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011096 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11097 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11098 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11099 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11100 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11101 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11102 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11103 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011104 /* Input mixer2 */
11105 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011106 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11107 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11108 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11109 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11110 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11111 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11112 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11113 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011114 /* Input mixer3 */
11115 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11120 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11121 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11123 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011124
Takashi Iwaice875f02008-01-28 18:17:43 +010011125 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11126
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011127 { }
11128};
11129
Kailang Yangcd7509a2007-01-26 18:33:17 +010011130static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11131 /*
11132 * Unmute ADC0-2 and set the default input to mic-in
11133 */
11134 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11135 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11136 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11137 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11138 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11139 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11140
Takashi Iwaicb53c622007-08-10 17:21:45 +020011141 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011142 * mixer widget
11143 * Note: PASD motherboards uses the Line In 2 as the input for front
11144 * panel mic (mic 2)
11145 */
11146 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011147 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11149 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11151 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11152 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11153 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11154 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011155 /*
11156 * Set up output mixers (0x0c - 0x0e)
11157 */
11158 /* set vol=0 to output mixers */
11159 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11160 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11161 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11162
11163 /* set up input amps for analog loopback */
11164 /* Amp Indices: DAC = 0, mixer = 1 */
11165 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11166 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11167 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11168 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11169 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11170 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11171
11172
11173 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11174 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11175 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11176 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11177 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11178 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11179 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11180
11181 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11182 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11183
11184 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11185 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11186
11187 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11188 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11189 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11190 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11191 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11192 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11193
11194 /* FIXME: use matrix-type input source selection */
11195 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11196 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11197 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11200 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11201 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11202 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11203 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11204 /* Input mixer2 */
11205 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11206 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11207 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11208 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11209 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11210 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11211 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11212 /* Input mixer3 */
11213 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11214 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11215 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11218 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11220
Takashi Iwaice875f02008-01-28 18:17:43 +010011221 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11222
Kailang Yangcd7509a2007-01-26 18:33:17 +010011223 { }
11224};
11225
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011226static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11227
11228 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11229 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11230 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11231
11232 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11233 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11234 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11235 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11236
11237 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11239 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11240 {}
11241};
11242
11243
Takashi Iwaicb53c622007-08-10 17:21:45 +020011244#ifdef CONFIG_SND_HDA_POWER_SAVE
11245#define alc262_loopbacks alc880_loopbacks
11246#endif
11247
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011248/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011249#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11250#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11251#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11252#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11253
11254/*
11255 * BIOS auto configuration
11256 */
11257static int alc262_parse_auto_config(struct hda_codec *codec)
11258{
11259 struct alc_spec *spec = codec->spec;
11260 int err;
11261 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11262
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011263 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11264 alc262_ignore);
11265 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011266 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011267 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011268 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011269 spec->multiout.max_channels = 2;
11270 spec->no_analog = 1;
11271 goto dig_only;
11272 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011273 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011274 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011275 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11276 if (err < 0)
11277 return err;
11278 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
11279 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011280 return err;
11281
11282 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11283
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011284 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011285 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011286 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011287 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011288 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011289 if (spec->autocfg.dig_in_pin)
11290 spec->dig_in_nid = ALC262_DIGIN_NID;
11291
Takashi Iwai603c4012008-07-30 15:01:44 +020011292 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011293 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011294
Takashi Iwaid88897e2008-10-31 15:01:37 +010011295 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011296 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011297 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011298
Takashi Iwai776e1842007-08-29 15:07:11 +020011299 err = alc_auto_add_mic_boost(codec);
11300 if (err < 0)
11301 return err;
11302
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011303 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11304
Kailang Yangdf694da2005-12-05 19:42:22 +010011305 return 1;
11306}
11307
11308#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11309#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11310#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011311#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011312
11313
11314/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011315static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011316{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011317 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011318 alc262_auto_init_multi_out(codec);
11319 alc262_auto_init_hp_out(codec);
11320 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011321 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011322 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011323 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011324}
11325
11326/*
11327 * configuration and preset
11328 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011329static const char *alc262_models[ALC262_MODEL_LAST] = {
11330 [ALC262_BASIC] = "basic",
11331 [ALC262_HIPPO] = "hippo",
11332 [ALC262_HIPPO_1] = "hippo_1",
11333 [ALC262_FUJITSU] = "fujitsu",
11334 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011335 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011336 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011337 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011338 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011339 [ALC262_BENQ_T31] = "benq-t31",
11340 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011341 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011342 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011343 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011344 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011345 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011346 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011347 [ALC262_AUTO] = "auto",
11348};
11349
11350static struct snd_pci_quirk alc262_cfg_tbl[] = {
11351 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011352 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011353 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11354 ALC262_HP_BPC),
11355 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11356 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011357 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11358 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011359 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011360 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011361 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011362 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011363 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011364 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011365 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011366 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011367 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11368 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11369 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011370 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11371 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011372 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011373 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011374 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011375 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011376 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011377 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011378 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11379 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011380 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011381 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011382 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011383 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011384 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011385 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011386 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11387 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011388 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011389 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011390 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011391 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011392 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011393 {}
11394};
11395
11396static struct alc_config_preset alc262_presets[] = {
11397 [ALC262_BASIC] = {
11398 .mixers = { alc262_base_mixer },
11399 .init_verbs = { alc262_init_verbs },
11400 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11401 .dac_nids = alc262_dac_nids,
11402 .hp_nid = 0x03,
11403 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11404 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011405 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011406 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011407 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011408 .mixers = { alc262_hippo_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +020011409 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
11410 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11411 .dac_nids = alc262_dac_nids,
11412 .hp_nid = 0x03,
11413 .dig_out_nid = ALC262_DIGOUT_NID,
11414 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11415 .channel_mode = alc262_modes,
11416 .input_mux = &alc262_capture_source,
11417 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011418 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011419 },
11420 [ALC262_HIPPO_1] = {
11421 .mixers = { alc262_hippo1_mixer },
11422 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11423 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11424 .dac_nids = alc262_dac_nids,
11425 .hp_nid = 0x02,
11426 .dig_out_nid = ALC262_DIGOUT_NID,
11427 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11428 .channel_mode = alc262_modes,
11429 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011430 .unsol_event = alc262_hippo_unsol_event,
11431 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011432 },
Takashi Iwai834be882006-03-01 14:16:17 +010011433 [ALC262_FUJITSU] = {
11434 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011435 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11436 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011437 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11438 .dac_nids = alc262_dac_nids,
11439 .hp_nid = 0x03,
11440 .dig_out_nid = ALC262_DIGOUT_NID,
11441 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11442 .channel_mode = alc262_modes,
11443 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011444 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011445 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011446 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011447 [ALC262_HP_BPC] = {
11448 .mixers = { alc262_HP_BPC_mixer },
11449 .init_verbs = { alc262_HP_BPC_init_verbs },
11450 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11451 .dac_nids = alc262_dac_nids,
11452 .hp_nid = 0x03,
11453 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11454 .channel_mode = alc262_modes,
11455 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011456 .unsol_event = alc262_hp_bpc_unsol_event,
11457 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011458 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011459 [ALC262_HP_BPC_D7000_WF] = {
11460 .mixers = { alc262_HP_BPC_WildWest_mixer },
11461 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11462 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11463 .dac_nids = alc262_dac_nids,
11464 .hp_nid = 0x03,
11465 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11466 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011467 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011468 .unsol_event = alc262_hp_wildwest_unsol_event,
11469 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011470 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011471 [ALC262_HP_BPC_D7000_WL] = {
11472 .mixers = { alc262_HP_BPC_WildWest_mixer,
11473 alc262_HP_BPC_WildWest_option_mixer },
11474 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11475 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11476 .dac_nids = alc262_dac_nids,
11477 .hp_nid = 0x03,
11478 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11479 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011480 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011481 .unsol_event = alc262_hp_wildwest_unsol_event,
11482 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011483 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011484 [ALC262_HP_TC_T5735] = {
11485 .mixers = { alc262_hp_t5735_mixer },
11486 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11487 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11488 .dac_nids = alc262_dac_nids,
11489 .hp_nid = 0x03,
11490 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11491 .channel_mode = alc262_modes,
11492 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011493 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011494 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011495 },
11496 [ALC262_HP_RP5700] = {
11497 .mixers = { alc262_hp_rp5700_mixer },
11498 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11499 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11500 .dac_nids = alc262_dac_nids,
11501 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11502 .channel_mode = alc262_modes,
11503 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011504 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011505 [ALC262_BENQ_ED8] = {
11506 .mixers = { alc262_base_mixer },
11507 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11508 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11509 .dac_nids = alc262_dac_nids,
11510 .hp_nid = 0x03,
11511 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11512 .channel_mode = alc262_modes,
11513 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011514 },
Kailang Yang272a5272007-05-14 11:00:38 +020011515 [ALC262_SONY_ASSAMD] = {
11516 .mixers = { alc262_sony_mixer },
11517 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11518 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11519 .dac_nids = alc262_dac_nids,
11520 .hp_nid = 0x02,
11521 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11522 .channel_mode = alc262_modes,
11523 .input_mux = &alc262_capture_source,
11524 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011525 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011526 },
11527 [ALC262_BENQ_T31] = {
11528 .mixers = { alc262_benq_t31_mixer },
11529 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
11530 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11531 .dac_nids = alc262_dac_nids,
11532 .hp_nid = 0x03,
11533 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11534 .channel_mode = alc262_modes,
11535 .input_mux = &alc262_capture_source,
11536 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011537 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011538 },
Tobin Davisf651b502007-10-26 12:40:47 +020011539 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011540 .mixers = { alc262_ultra_mixer },
11541 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011542 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011543 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11544 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011545 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11546 .channel_mode = alc262_modes,
11547 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011548 .adc_nids = alc262_adc_nids, /* ADC0 */
11549 .capsrc_nids = alc262_capsrc_nids,
11550 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011551 .unsol_event = alc262_ultra_unsol_event,
11552 .init_hook = alc262_ultra_automute,
11553 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011554 [ALC262_LENOVO_3000] = {
11555 .mixers = { alc262_lenovo_3000_mixer },
11556 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11557 alc262_lenovo_3000_unsol_verbs },
11558 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11559 .dac_nids = alc262_dac_nids,
11560 .hp_nid = 0x03,
11561 .dig_out_nid = ALC262_DIGOUT_NID,
11562 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11563 .channel_mode = alc262_modes,
11564 .input_mux = &alc262_fujitsu_capture_source,
11565 .unsol_event = alc262_lenovo_3000_unsol_event,
11566 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011567 [ALC262_NEC] = {
11568 .mixers = { alc262_nec_mixer },
11569 .init_verbs = { alc262_nec_verbs },
11570 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11571 .dac_nids = alc262_dac_nids,
11572 .hp_nid = 0x03,
11573 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11574 .channel_mode = alc262_modes,
11575 .input_mux = &alc262_capture_source,
11576 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011577 [ALC262_TOSHIBA_S06] = {
11578 .mixers = { alc262_toshiba_s06_mixer },
11579 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11580 alc262_eapd_verbs },
11581 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11582 .capsrc_nids = alc262_dmic_capsrc_nids,
11583 .dac_nids = alc262_dac_nids,
11584 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011585 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011586 .dig_out_nid = ALC262_DIGOUT_NID,
11587 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11588 .channel_mode = alc262_modes,
11589 .input_mux = &alc262_dmic_capture_source,
11590 .unsol_event = alc262_toshiba_s06_unsol_event,
11591 .init_hook = alc262_toshiba_s06_init_hook,
11592 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011593 [ALC262_TOSHIBA_RX1] = {
11594 .mixers = { alc262_toshiba_rx1_mixer },
11595 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11596 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11597 .dac_nids = alc262_dac_nids,
11598 .hp_nid = 0x03,
11599 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11600 .channel_mode = alc262_modes,
11601 .input_mux = &alc262_capture_source,
11602 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011603 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011604 },
Tony Vroonba340e82009-02-02 19:01:30 +000011605 [ALC262_TYAN] = {
11606 .mixers = { alc262_tyan_mixer },
11607 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11608 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11609 .dac_nids = alc262_dac_nids,
11610 .hp_nid = 0x02,
11611 .dig_out_nid = ALC262_DIGOUT_NID,
11612 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11613 .channel_mode = alc262_modes,
11614 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011615 .unsol_event = alc_automute_amp_unsol_event,
11616 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011617 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011618};
11619
11620static int patch_alc262(struct hda_codec *codec)
11621{
11622 struct alc_spec *spec;
11623 int board_config;
11624 int err;
11625
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011626 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011627 if (spec == NULL)
11628 return -ENOMEM;
11629
11630 codec->spec = spec;
11631#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011632 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11633 * under-run
11634 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011635 {
11636 int tmp;
11637 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11638 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11639 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11640 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11641 }
11642#endif
11643
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011644 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11645
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011646 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11647 alc262_models,
11648 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011649
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011650 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020011651 printk(KERN_INFO "hda_codec: Unknown model for %s, "
11652 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011653 board_config = ALC262_AUTO;
11654 }
11655
11656 if (board_config == ALC262_AUTO) {
11657 /* automatic parse from the BIOS config */
11658 err = alc262_parse_auto_config(codec);
11659 if (err < 0) {
11660 alc_free(codec);
11661 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011662 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011663 printk(KERN_INFO
11664 "hda_codec: Cannot set up configuration "
11665 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011666 board_config = ALC262_BASIC;
11667 }
11668 }
11669
Takashi Iwai07eba612009-02-19 08:06:35 +010011670 if (!spec->no_analog) {
11671 err = snd_hda_attach_beep_device(codec, 0x1);
11672 if (err < 0) {
11673 alc_free(codec);
11674 return err;
11675 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011676 }
11677
Kailang Yangdf694da2005-12-05 19:42:22 +010011678 if (board_config != ALC262_AUTO)
11679 setup_preset(spec, &alc262_presets[board_config]);
11680
Kailang Yangdf694da2005-12-05 19:42:22 +010011681 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11682 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011683
Kailang Yangdf694da2005-12-05 19:42:22 +010011684 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11685 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11686
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011687 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011688 int i;
11689 /* check whether the digital-mic has to be supported */
11690 for (i = 0; i < spec->input_mux->num_items; i++) {
11691 if (spec->input_mux->items[i].index >= 9)
11692 break;
11693 }
11694 if (i < spec->input_mux->num_items) {
11695 /* use only ADC0 */
11696 spec->adc_nids = alc262_dmic_adc_nids;
11697 spec->num_adc_nids = 1;
11698 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011699 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011700 /* all analog inputs */
11701 /* check whether NID 0x07 is valid */
11702 unsigned int wcap = get_wcaps(codec, 0x07);
11703
11704 /* get type */
11705 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
11706 if (wcap != AC_WID_AUD_IN) {
11707 spec->adc_nids = alc262_adc_nids_alt;
11708 spec->num_adc_nids =
11709 ARRAY_SIZE(alc262_adc_nids_alt);
11710 spec->capsrc_nids = alc262_capsrc_nids_alt;
11711 } else {
11712 spec->adc_nids = alc262_adc_nids;
11713 spec->num_adc_nids =
11714 ARRAY_SIZE(alc262_adc_nids);
11715 spec->capsrc_nids = alc262_capsrc_nids;
11716 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011717 }
11718 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011719 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011720 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011721 if (!spec->no_analog)
11722 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011723
Takashi Iwai2134ea42008-01-10 16:53:55 +010011724 spec->vmaster_nid = 0x0c;
11725
Kailang Yangdf694da2005-12-05 19:42:22 +010011726 codec->patch_ops = alc_patch_ops;
11727 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011728 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011729#ifdef CONFIG_SND_HDA_POWER_SAVE
11730 if (!spec->loopback.amplist)
11731 spec->loopback.amplist = alc262_loopbacks;
11732#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011733 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011734
Kailang Yangdf694da2005-12-05 19:42:22 +010011735 return 0;
11736}
11737
Kailang Yangdf694da2005-12-05 19:42:22 +010011738/*
Kailang Yanga361d842007-06-05 12:30:55 +020011739 * ALC268 channel source setting (2 channel)
11740 */
11741#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11742#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011743
Kailang Yanga361d842007-06-05 12:30:55 +020011744static hda_nid_t alc268_dac_nids[2] = {
11745 /* front, hp */
11746 0x02, 0x03
11747};
11748
11749static hda_nid_t alc268_adc_nids[2] = {
11750 /* ADC0-1 */
11751 0x08, 0x07
11752};
11753
11754static hda_nid_t alc268_adc_nids_alt[1] = {
11755 /* ADC0 */
11756 0x08
11757};
11758
Takashi Iwaie1406342008-02-11 18:32:32 +010011759static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11760
Kailang Yanga361d842007-06-05 12:30:55 +020011761static struct snd_kcontrol_new alc268_base_mixer[] = {
11762 /* output mixer control */
11763 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11764 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11765 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11766 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011767 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11768 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11769 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011770 { }
11771};
11772
Takashi Iwai42171c12009-05-08 14:11:43 +020011773static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11774 /* output mixer control */
11775 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11776 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11777 ALC262_HIPPO_MASTER_SWITCH,
11778 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11779 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11780 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11781 { }
11782};
11783
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011784/* bind Beep switches of both NID 0x0f and 0x10 */
11785static struct hda_bind_ctls alc268_bind_beep_sw = {
11786 .ops = &snd_hda_bind_sw,
11787 .values = {
11788 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11789 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11790 0
11791 },
11792};
11793
11794static struct snd_kcontrol_new alc268_beep_mixer[] = {
11795 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11796 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11797 { }
11798};
11799
Kailang Yangd1a991a2007-08-15 16:21:59 +020011800static struct hda_verb alc268_eapd_verbs[] = {
11801 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11802 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11803 { }
11804};
11805
Takashi Iwaid2738092007-08-16 14:59:45 +020011806/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011807static struct hda_verb alc268_toshiba_verbs[] = {
11808 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11809 { } /* end */
11810};
11811
Kailang Yang8ef355d2008-08-26 13:10:22 +020011812static struct hda_input_mux alc268_acer_lc_capture_source = {
11813 .num_items = 2,
11814 .items = {
11815 { "i-Mic", 0x6 },
11816 { "E-Mic", 0x0 },
11817 },
11818};
11819
Takashi Iwaid2738092007-08-16 14:59:45 +020011820/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011821/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011822static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11823 .ops = &snd_hda_bind_vol,
11824 .values = {
11825 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11826 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11827 0
11828 },
11829};
11830
Takashi Iwai889c4392007-08-23 18:56:52 +020011831/* mute/unmute internal speaker according to the hp jack and mute state */
11832static void alc268_acer_automute(struct hda_codec *codec, int force)
11833{
11834 struct alc_spec *spec = codec->spec;
11835 unsigned int mute;
11836
11837 if (force || !spec->sense_updated) {
11838 unsigned int present;
11839 present = snd_hda_codec_read(codec, 0x14, 0,
11840 AC_VERB_GET_PIN_SENSE, 0);
11841 spec->jack_present = (present & 0x80000000) != 0;
11842 spec->sense_updated = 1;
11843 }
11844 if (spec->jack_present)
11845 mute = HDA_AMP_MUTE; /* mute internal speaker */
11846 else /* unmute internal speaker if necessary */
11847 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11848 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11849 HDA_AMP_MUTE, mute);
11850}
11851
11852
11853/* bind hp and internal speaker mute (with plug check) */
11854static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11855 struct snd_ctl_elem_value *ucontrol)
11856{
11857 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11858 long *valp = ucontrol->value.integer.value;
11859 int change;
11860
Takashi Iwai8de56b72009-07-24 16:51:47 +020011861 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020011862 if (change)
11863 alc268_acer_automute(codec, 0);
11864 return change;
11865}
Takashi Iwaid2738092007-08-16 14:59:45 +020011866
Kailang Yang8ef355d2008-08-26 13:10:22 +020011867static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11868 /* output mixer control */
11869 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11870 {
11871 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11872 .name = "Master Playback Switch",
11873 .info = snd_hda_mixer_amp_switch_info,
11874 .get = snd_hda_mixer_amp_switch_get,
11875 .put = alc268_acer_master_sw_put,
11876 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11877 },
11878 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11879 { }
11880};
11881
Takashi Iwaid2738092007-08-16 14:59:45 +020011882static struct snd_kcontrol_new alc268_acer_mixer[] = {
11883 /* output mixer control */
11884 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11885 {
11886 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11887 .name = "Master Playback Switch",
11888 .info = snd_hda_mixer_amp_switch_info,
11889 .get = snd_hda_mixer_amp_switch_get,
11890 .put = alc268_acer_master_sw_put,
11891 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11892 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011893 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11894 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11895 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011896 { }
11897};
11898
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011899static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11900 /* output mixer control */
11901 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11902 {
11903 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11904 .name = "Master Playback Switch",
11905 .info = snd_hda_mixer_amp_switch_info,
11906 .get = snd_hda_mixer_amp_switch_get,
11907 .put = alc268_acer_master_sw_put,
11908 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11909 },
11910 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11911 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11912 { }
11913};
11914
Kailang Yang8ef355d2008-08-26 13:10:22 +020011915static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11916 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11917 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11918 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11919 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11920 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11921 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11922 { }
11923};
11924
Takashi Iwaid2738092007-08-16 14:59:45 +020011925static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011926 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11927 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011928 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11929 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011930 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11931 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011932 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11933 { }
11934};
11935
11936/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011937#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11938#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011939
11940static void alc268_acer_unsol_event(struct hda_codec *codec,
11941 unsigned int res)
11942{
Takashi Iwai889c4392007-08-23 18:56:52 +020011943 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011944 return;
11945 alc268_acer_automute(codec, 1);
11946}
11947
Takashi Iwai889c4392007-08-23 18:56:52 +020011948static void alc268_acer_init_hook(struct hda_codec *codec)
11949{
11950 alc268_acer_automute(codec, 1);
11951}
11952
Kailang Yang8ef355d2008-08-26 13:10:22 +020011953/* toggle speaker-output according to the hp-jack state */
11954static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11955{
11956 unsigned int present;
11957 unsigned char bits;
11958
11959 present = snd_hda_codec_read(codec, 0x15, 0,
11960 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11961 bits = present ? AMP_IN_MUTE(0) : 0;
11962 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11963 AMP_IN_MUTE(0), bits);
11964 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11965 AMP_IN_MUTE(0), bits);
11966}
11967
11968
11969static void alc268_acer_mic_automute(struct hda_codec *codec)
11970{
11971 unsigned int present;
11972
11973 present = snd_hda_codec_read(codec, 0x18, 0,
11974 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11975 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11976 present ? 0x0 : 0x6);
11977}
11978
11979static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11980 unsigned int res)
11981{
11982 if ((res >> 26) == ALC880_HP_EVENT)
11983 alc268_aspire_one_speaker_automute(codec);
11984 if ((res >> 26) == ALC880_MIC_EVENT)
11985 alc268_acer_mic_automute(codec);
11986}
11987
11988static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11989{
11990 alc268_aspire_one_speaker_automute(codec);
11991 alc268_acer_mic_automute(codec);
11992}
11993
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011994static struct snd_kcontrol_new alc268_dell_mixer[] = {
11995 /* output mixer control */
11996 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11997 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11998 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11999 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12000 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12001 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12002 { }
12003};
12004
12005static struct hda_verb alc268_dell_verbs[] = {
12006 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12007 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12008 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12009 { }
12010};
12011
12012/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012013static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012014{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012015 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012016
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012017 spec->autocfg.hp_pins[0] = 0x15;
12018 spec->autocfg.speaker_pins[0] = 0x14;
12019 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012020}
12021
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012022static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12023 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12024 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12025 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12026 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12027 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12028 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12029 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12030 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12031 { }
12032};
12033
12034static struct hda_verb alc267_quanta_il1_verbs[] = {
12035 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12036 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12037 { }
12038};
12039
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012040static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
12041{
12042 unsigned int present;
12043
12044 present = snd_hda_codec_read(codec, 0x18, 0,
12045 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12046 snd_hda_codec_write(codec, 0x23, 0,
12047 AC_VERB_SET_CONNECT_SEL,
12048 present ? 0x00 : 0x01);
12049}
12050
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012051static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012052{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012053 struct alc_spec *spec = codec->spec;
12054
12055 spec->autocfg.hp_pins[0] = 0x15;
12056 spec->autocfg.speaker_pins[0] = 0x14;
12057 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012058 alc267_quanta_il1_mic_automute(codec);
12059}
12060
12061static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
12062 unsigned int res)
12063{
12064 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012065 case ALC880_MIC_EVENT:
12066 alc267_quanta_il1_mic_automute(codec);
12067 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012068 default:
12069 alc_sku_unsol_event(codec, res);
12070 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012071 }
12072}
12073
Kailang Yanga361d842007-06-05 12:30:55 +020012074/*
12075 * generic initialization of ADC, input mixers and output mixers
12076 */
12077static struct hda_verb alc268_base_init_verbs[] = {
12078 /* Unmute DAC0-1 and set vol = 0 */
12079 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012080 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012081
12082 /*
12083 * Set up output mixers (0x0c - 0x0e)
12084 */
12085 /* set vol=0 to output mixers */
12086 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012087 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12088
12089 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12090 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12091
12092 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12093 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12094 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12095 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12096 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12097 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12098 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12099 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12100
12101 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12102 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12103 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12104 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012105 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012106
12107 /* set PCBEEP vol = 0, mute connections */
12108 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12109 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12110 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012111
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012112 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012113
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012114 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12115 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12116 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12117 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012118
Kailang Yanga361d842007-06-05 12:30:55 +020012119 { }
12120};
12121
12122/*
12123 * generic initialization of ADC, input mixers and output mixers
12124 */
12125static struct hda_verb alc268_volume_init_verbs[] = {
12126 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012127 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12128 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012129
12130 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12131 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12132 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12133 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12134 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12135
Kailang Yanga361d842007-06-05 12:30:55 +020012136 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012137 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12138 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12139
12140 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012141 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012142
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012143 /* set PCBEEP vol = 0, mute connections */
12144 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12145 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12146 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012147
12148 { }
12149};
12150
Kailang Yanga361d842007-06-05 12:30:55 +020012151static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12152 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12153 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12154 {
12155 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12156 /* The multiple "Capture Source" controls confuse alsamixer
12157 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012158 */
12159 /* .name = "Capture Source", */
12160 .name = "Input Source",
12161 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012162 .info = alc_mux_enum_info,
12163 .get = alc_mux_enum_get,
12164 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012165 },
12166 { } /* end */
12167};
12168
12169static struct snd_kcontrol_new alc268_capture_mixer[] = {
12170 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12171 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12172 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12173 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12174 {
12175 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12176 /* The multiple "Capture Source" controls confuse alsamixer
12177 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012178 */
12179 /* .name = "Capture Source", */
12180 .name = "Input Source",
12181 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012182 .info = alc_mux_enum_info,
12183 .get = alc_mux_enum_get,
12184 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012185 },
12186 { } /* end */
12187};
12188
12189static struct hda_input_mux alc268_capture_source = {
12190 .num_items = 4,
12191 .items = {
12192 { "Mic", 0x0 },
12193 { "Front Mic", 0x1 },
12194 { "Line", 0x2 },
12195 { "CD", 0x3 },
12196 },
12197};
12198
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012199static struct hda_input_mux alc268_acer_capture_source = {
12200 .num_items = 3,
12201 .items = {
12202 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012203 { "Internal Mic", 0x1 },
12204 { "Line", 0x2 },
12205 },
12206};
12207
12208static struct hda_input_mux alc268_acer_dmic_capture_source = {
12209 .num_items = 3,
12210 .items = {
12211 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012212 { "Internal Mic", 0x6 },
12213 { "Line", 0x2 },
12214 },
12215};
12216
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012217#ifdef CONFIG_SND_DEBUG
12218static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012219 /* Volume widgets */
12220 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12221 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12222 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12223 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12224 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12225 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12226 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12227 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12228 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12229 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12230 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12231 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12232 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012233 /* The below appears problematic on some hardwares */
12234 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012235 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12236 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12237 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12238 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12239
12240 /* Modes for retasking pin widgets */
12241 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12242 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12243 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12244 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12245
12246 /* Controls for GPIO pins, assuming they are configured as outputs */
12247 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12248 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12249 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12250 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12251
12252 /* Switches to allow the digital SPDIF output pin to be enabled.
12253 * The ALC268 does not have an SPDIF input.
12254 */
12255 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12256
12257 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12258 * this output to turn on an external amplifier.
12259 */
12260 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12261 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12262
12263 { } /* end */
12264};
12265#endif
12266
Kailang Yanga361d842007-06-05 12:30:55 +020012267/* create input playback/capture controls for the given pin */
12268static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12269 const char *ctlname, int idx)
12270{
12271 char name[32];
12272 int err;
12273
12274 sprintf(name, "%s Playback Volume", ctlname);
12275 if (nid == 0x14) {
12276 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12277 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
12278 HDA_OUTPUT));
12279 if (err < 0)
12280 return err;
12281 } else if (nid == 0x15) {
12282 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12283 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
12284 HDA_OUTPUT));
12285 if (err < 0)
12286 return err;
12287 } else
12288 return -1;
12289 sprintf(name, "%s Playback Switch", ctlname);
12290 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12291 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
12292 if (err < 0)
12293 return err;
12294 return 0;
12295}
12296
12297/* add playback controls from the parsed DAC table */
12298static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12299 const struct auto_pin_cfg *cfg)
12300{
12301 hda_nid_t nid;
12302 int err;
12303
12304 spec->multiout.num_dacs = 2; /* only use one dac */
12305 spec->multiout.dac_nids = spec->private_dac_nids;
12306 spec->multiout.dac_nids[0] = 2;
12307 spec->multiout.dac_nids[1] = 3;
12308
12309 nid = cfg->line_out_pins[0];
12310 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020012311 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020012312
12313 nid = cfg->speaker_pins[0];
12314 if (nid == 0x1d) {
12315 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12316 "Speaker Playback Volume",
12317 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12318 if (err < 0)
12319 return err;
12320 }
12321 nid = cfg->hp_pins[0];
12322 if (nid)
12323 alc268_new_analog_output(spec, nid, "Headphone", 0);
12324
12325 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12326 if (nid == 0x16) {
12327 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12328 "Mono Playback Switch",
12329 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
12330 if (err < 0)
12331 return err;
12332 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012333 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012334}
12335
12336/* create playback/capture controls for input pins */
12337static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12338 const struct auto_pin_cfg *cfg)
12339{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012340 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012341 int i, idx1;
12342
12343 for (i = 0; i < AUTO_PIN_LAST; i++) {
12344 switch(cfg->input_pins[i]) {
12345 case 0x18:
12346 idx1 = 0; /* Mic 1 */
12347 break;
12348 case 0x19:
12349 idx1 = 1; /* Mic 2 */
12350 break;
12351 case 0x1a:
12352 idx1 = 2; /* Line In */
12353 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012354 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012355 idx1 = 3; /* CD */
12356 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012357 case 0x12:
12358 case 0x13:
12359 idx1 = 6; /* digital mics */
12360 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012361 default:
12362 continue;
12363 }
12364 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12365 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012366 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012367 }
12368 return 0;
12369}
12370
12371static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12372{
12373 struct alc_spec *spec = codec->spec;
12374 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12375 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12376 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12377 unsigned int dac_vol1, dac_vol2;
12378
12379 if (speaker_nid) {
12380 snd_hda_codec_write(codec, speaker_nid, 0,
12381 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12382 snd_hda_codec_write(codec, 0x0f, 0,
12383 AC_VERB_SET_AMP_GAIN_MUTE,
12384 AMP_IN_UNMUTE(1));
12385 snd_hda_codec_write(codec, 0x10, 0,
12386 AC_VERB_SET_AMP_GAIN_MUTE,
12387 AMP_IN_UNMUTE(1));
12388 } else {
12389 snd_hda_codec_write(codec, 0x0f, 0,
12390 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12391 snd_hda_codec_write(codec, 0x10, 0,
12392 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12393 }
12394
12395 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012396 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012397 dac_vol2 = AMP_OUT_ZERO;
12398 else if (line_nid == 0x15)
12399 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012400 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012401 dac_vol2 = AMP_OUT_ZERO;
12402 else if (hp_nid == 0x15)
12403 dac_vol1 = AMP_OUT_ZERO;
12404 if (line_nid != 0x16 || hp_nid != 0x16 ||
12405 spec->autocfg.line_out_pins[1] != 0x16 ||
12406 spec->autocfg.line_out_pins[2] != 0x16)
12407 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12408
12409 snd_hda_codec_write(codec, 0x02, 0,
12410 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12411 snd_hda_codec_write(codec, 0x03, 0,
12412 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12413}
12414
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012415/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012416#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12417#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012418#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012419#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12420
12421/*
12422 * BIOS auto configuration
12423 */
12424static int alc268_parse_auto_config(struct hda_codec *codec)
12425{
12426 struct alc_spec *spec = codec->spec;
12427 int err;
12428 static hda_nid_t alc268_ignore[] = { 0 };
12429
12430 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12431 alc268_ignore);
12432 if (err < 0)
12433 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012434 if (!spec->autocfg.line_outs) {
12435 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12436 spec->multiout.max_channels = 2;
12437 spec->no_analog = 1;
12438 goto dig_only;
12439 }
Kailang Yanga361d842007-06-05 12:30:55 +020012440 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012441 }
Kailang Yanga361d842007-06-05 12:30:55 +020012442 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12443 if (err < 0)
12444 return err;
12445 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12446 if (err < 0)
12447 return err;
12448
12449 spec->multiout.max_channels = 2;
12450
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012451 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012452 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012453 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012454 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012455 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12456 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012457 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012458 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012459
Takashi Iwai892981f2009-03-02 08:04:35 +010012460 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012461 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012462
Takashi Iwaid88897e2008-10-31 15:01:37 +010012463 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012464 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012465 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012466
Takashi Iwai776e1842007-08-29 15:07:11 +020012467 err = alc_auto_add_mic_boost(codec);
12468 if (err < 0)
12469 return err;
12470
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012471 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12472
Kailang Yanga361d842007-06-05 12:30:55 +020012473 return 1;
12474}
12475
12476#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12477#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12478#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12479
12480/* init callback for auto-configuration model -- overriding the default init */
12481static void alc268_auto_init(struct hda_codec *codec)
12482{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012483 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012484 alc268_auto_init_multi_out(codec);
12485 alc268_auto_init_hp_out(codec);
12486 alc268_auto_init_mono_speaker_out(codec);
12487 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012488 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012489 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012490}
12491
12492/*
12493 * configuration and preset
12494 */
12495static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012496 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012497 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012498 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012499 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012500 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012501 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012502 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012503 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012504#ifdef CONFIG_SND_DEBUG
12505 [ALC268_TEST] = "test",
12506#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012507 [ALC268_AUTO] = "auto",
12508};
12509
12510static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012511 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012512 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012513 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012514 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012515 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012516 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12517 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012518 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012519 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012520 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12521 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012522 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012523 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012524 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012525 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012526 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012527 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012528 {}
12529};
12530
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012531/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12532static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12533 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12534 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12535 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12536 ALC268_TOSHIBA),
12537 {}
12538};
12539
Kailang Yanga361d842007-06-05 12:30:55 +020012540static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012541 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012542 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012543 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12544 alc267_quanta_il1_verbs },
12545 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12546 .dac_nids = alc268_dac_nids,
12547 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12548 .adc_nids = alc268_adc_nids_alt,
12549 .hp_nid = 0x03,
12550 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12551 .channel_mode = alc268_modes,
12552 .input_mux = &alc268_capture_source,
12553 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012554 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012555 },
Kailang Yanga361d842007-06-05 12:30:55 +020012556 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012557 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12558 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012559 .init_verbs = { alc268_base_init_verbs },
12560 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12561 .dac_nids = alc268_dac_nids,
12562 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12563 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012564 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012565 .hp_nid = 0x03,
12566 .dig_out_nid = ALC268_DIGOUT_NID,
12567 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12568 .channel_mode = alc268_modes,
12569 .input_mux = &alc268_capture_source,
12570 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012571 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012572 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012573 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012574 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12575 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012576 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12577 .dac_nids = alc268_dac_nids,
12578 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12579 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012580 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012581 .hp_nid = 0x03,
12582 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12583 .channel_mode = alc268_modes,
12584 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012585 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012586 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012587 },
12588 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012589 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12590 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012591 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12592 alc268_acer_verbs },
12593 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12594 .dac_nids = alc268_dac_nids,
12595 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12596 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012597 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012598 .hp_nid = 0x02,
12599 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12600 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012601 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012602 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012603 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012604 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012605 [ALC268_ACER_DMIC] = {
12606 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12607 alc268_beep_mixer },
12608 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12609 alc268_acer_verbs },
12610 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12611 .dac_nids = alc268_dac_nids,
12612 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12613 .adc_nids = alc268_adc_nids_alt,
12614 .capsrc_nids = alc268_capsrc_nids,
12615 .hp_nid = 0x02,
12616 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12617 .channel_mode = alc268_modes,
12618 .input_mux = &alc268_acer_dmic_capture_source,
12619 .unsol_event = alc268_acer_unsol_event,
12620 .init_hook = alc268_acer_init_hook,
12621 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012622 [ALC268_ACER_ASPIRE_ONE] = {
12623 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012624 alc268_beep_mixer,
12625 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012626 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12627 alc268_acer_aspire_one_verbs },
12628 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12629 .dac_nids = alc268_dac_nids,
12630 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12631 .adc_nids = alc268_adc_nids_alt,
12632 .capsrc_nids = alc268_capsrc_nids,
12633 .hp_nid = 0x03,
12634 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12635 .channel_mode = alc268_modes,
12636 .input_mux = &alc268_acer_lc_capture_source,
12637 .unsol_event = alc268_acer_lc_unsol_event,
12638 .init_hook = alc268_acer_lc_init_hook,
12639 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012640 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012641 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012642 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12643 alc268_dell_verbs },
12644 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12645 .dac_nids = alc268_dac_nids,
12646 .hp_nid = 0x02,
12647 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12648 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012649 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012650 .init_hook = alc268_dell_init_hook,
12651 .input_mux = &alc268_capture_source,
12652 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012653 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012654 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12655 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012656 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12657 alc268_toshiba_verbs },
12658 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12659 .dac_nids = alc268_dac_nids,
12660 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12661 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012662 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012663 .hp_nid = 0x03,
12664 .dig_out_nid = ALC268_DIGOUT_NID,
12665 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12666 .channel_mode = alc268_modes,
12667 .input_mux = &alc268_capture_source,
12668 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012669 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012670 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012671#ifdef CONFIG_SND_DEBUG
12672 [ALC268_TEST] = {
12673 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12674 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12675 alc268_volume_init_verbs },
12676 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12677 .dac_nids = alc268_dac_nids,
12678 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12679 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012680 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012681 .hp_nid = 0x03,
12682 .dig_out_nid = ALC268_DIGOUT_NID,
12683 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12684 .channel_mode = alc268_modes,
12685 .input_mux = &alc268_capture_source,
12686 },
12687#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012688};
12689
12690static int patch_alc268(struct hda_codec *codec)
12691{
12692 struct alc_spec *spec;
12693 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012694 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012695
12696 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12697 if (spec == NULL)
12698 return -ENOMEM;
12699
12700 codec->spec = spec;
12701
12702 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12703 alc268_models,
12704 alc268_cfg_tbl);
12705
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012706 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12707 board_config = snd_hda_check_board_codec_sid_config(codec,
12708 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12709
Kailang Yanga361d842007-06-05 12:30:55 +020012710 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020012711 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12712 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012713 board_config = ALC268_AUTO;
12714 }
12715
12716 if (board_config == ALC268_AUTO) {
12717 /* automatic parse from the BIOS config */
12718 err = alc268_parse_auto_config(codec);
12719 if (err < 0) {
12720 alc_free(codec);
12721 return err;
12722 } else if (!err) {
12723 printk(KERN_INFO
12724 "hda_codec: Cannot set up configuration "
12725 "from BIOS. Using base mode...\n");
12726 board_config = ALC268_3ST;
12727 }
12728 }
12729
12730 if (board_config != ALC268_AUTO)
12731 setup_preset(spec, &alc268_presets[board_config]);
12732
Kailang Yanga361d842007-06-05 12:30:55 +020012733 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12734 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012735 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012736
Kailang Yanga361d842007-06-05 12:30:55 +020012737 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12738
Takashi Iwai22971e32009-02-10 11:56:44 +010012739 has_beep = 0;
12740 for (i = 0; i < spec->num_mixers; i++) {
12741 if (spec->mixers[i] == alc268_beep_mixer) {
12742 has_beep = 1;
12743 break;
12744 }
12745 }
12746
12747 if (has_beep) {
12748 err = snd_hda_attach_beep_device(codec, 0x1);
12749 if (err < 0) {
12750 alc_free(codec);
12751 return err;
12752 }
12753 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12754 /* override the amp caps for beep generator */
12755 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012756 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12757 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12758 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12759 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012760 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012761
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012762 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012763 /* check whether NID 0x07 is valid */
12764 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012765 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012766
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012767 /* get type */
12768 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012769 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012770 spec->adc_nids = alc268_adc_nids_alt;
12771 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012772 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012773 } else {
12774 spec->adc_nids = alc268_adc_nids;
12775 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012776 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012777 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012778 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012779 /* set default input source */
12780 for (i = 0; i < spec->num_adc_nids; i++)
12781 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12782 0, AC_VERB_SET_CONNECT_SEL,
12783 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012784 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012785
12786 spec->vmaster_nid = 0x02;
12787
Kailang Yanga361d842007-06-05 12:30:55 +020012788 codec->patch_ops = alc_patch_ops;
12789 if (board_config == ALC268_AUTO)
12790 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012791
Takashi Iwaidaead532008-11-28 12:55:36 +010012792 codec->proc_widget_hook = print_realtek_coef;
12793
Kailang Yanga361d842007-06-05 12:30:55 +020012794 return 0;
12795}
12796
12797/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012798 * ALC269 channel source setting (2 channel)
12799 */
12800#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12801
12802#define alc269_dac_nids alc260_dac_nids
12803
12804static hda_nid_t alc269_adc_nids[1] = {
12805 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012806 0x08,
12807};
12808
Takashi Iwaie01bf502008-08-21 16:25:07 +020012809static hda_nid_t alc269_capsrc_nids[1] = {
12810 0x23,
12811};
12812
12813/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12814 * not a mux!
12815 */
12816
Kailang Yangf53281e2008-07-18 12:36:43 +020012817static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12818 .num_items = 2,
12819 .items = {
12820 { "i-Mic", 0x5 },
12821 { "e-Mic", 0x0 },
12822 },
12823};
12824
12825static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12826 .num_items = 2,
12827 .items = {
12828 { "i-Mic", 0x1 },
12829 { "e-Mic", 0x0 },
12830 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012831};
12832
12833#define alc269_modes alc260_modes
12834#define alc269_capture_source alc880_lg_lw_capture_source
12835
12836static struct snd_kcontrol_new alc269_base_mixer[] = {
12837 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12838 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12839 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12840 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12841 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12842 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12843 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12844 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12845 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12846 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12847 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12848 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12849 { } /* end */
12850};
12851
Kailang Yang60db6b52008-08-26 13:13:00 +020012852static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12853 /* output mixer control */
12854 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12855 {
12856 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12857 .name = "Master Playback Switch",
12858 .info = snd_hda_mixer_amp_switch_info,
12859 .get = snd_hda_mixer_amp_switch_get,
12860 .put = alc268_acer_master_sw_put,
12861 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12862 },
12863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12864 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12865 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12866 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12867 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12868 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012869 { }
12870};
12871
Tony Vroon64154832008-11-06 15:08:49 +000012872static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12873 /* output mixer control */
12874 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12875 {
12876 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12877 .name = "Master Playback Switch",
12878 .info = snd_hda_mixer_amp_switch_info,
12879 .get = snd_hda_mixer_amp_switch_get,
12880 .put = alc268_acer_master_sw_put,
12881 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12882 },
12883 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12884 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12885 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12886 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12887 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12888 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12889 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12890 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12891 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012892 { }
12893};
12894
Kailang Yangf53281e2008-07-18 12:36:43 +020012895static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012896 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012897 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012898 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012899 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012900 { } /* end */
12901};
12902
Kailang Yangf6a92242007-12-13 16:52:54 +010012903/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012904static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12905 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12906 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012907 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12908 { } /* end */
12909};
12910
12911/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012912#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012913
Kailang Yang60db6b52008-08-26 13:13:00 +020012914static struct hda_verb alc269_quanta_fl1_verbs[] = {
12915 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12916 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12917 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12918 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12919 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12920 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12921 { }
12922};
12923
Tony Vroon64154832008-11-06 15:08:49 +000012924static struct hda_verb alc269_lifebook_verbs[] = {
12925 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12926 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12927 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12928 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12929 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12930 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12931 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12932 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12933 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12934 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12935 { }
12936};
12937
Kailang Yang60db6b52008-08-26 13:13:00 +020012938/* toggle speaker-output according to the hp-jack state */
12939static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12940{
12941 unsigned int present;
12942 unsigned char bits;
12943
12944 present = snd_hda_codec_read(codec, 0x15, 0,
12945 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12946 bits = present ? AMP_IN_MUTE(0) : 0;
12947 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12948 AMP_IN_MUTE(0), bits);
12949 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12950 AMP_IN_MUTE(0), bits);
12951
12952 snd_hda_codec_write(codec, 0x20, 0,
12953 AC_VERB_SET_COEF_INDEX, 0x0c);
12954 snd_hda_codec_write(codec, 0x20, 0,
12955 AC_VERB_SET_PROC_COEF, 0x680);
12956
12957 snd_hda_codec_write(codec, 0x20, 0,
12958 AC_VERB_SET_COEF_INDEX, 0x0c);
12959 snd_hda_codec_write(codec, 0x20, 0,
12960 AC_VERB_SET_PROC_COEF, 0x480);
12961}
12962
Tony Vroon64154832008-11-06 15:08:49 +000012963/* toggle speaker-output according to the hp-jacks state */
12964static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12965{
12966 unsigned int present;
12967 unsigned char bits;
12968
12969 /* Check laptop headphone socket */
12970 present = snd_hda_codec_read(codec, 0x15, 0,
12971 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12972
12973 /* Check port replicator headphone socket */
12974 present |= snd_hda_codec_read(codec, 0x1a, 0,
12975 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12976
12977 bits = present ? AMP_IN_MUTE(0) : 0;
12978 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12979 AMP_IN_MUTE(0), bits);
12980 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12981 AMP_IN_MUTE(0), bits);
12982
12983 snd_hda_codec_write(codec, 0x20, 0,
12984 AC_VERB_SET_COEF_INDEX, 0x0c);
12985 snd_hda_codec_write(codec, 0x20, 0,
12986 AC_VERB_SET_PROC_COEF, 0x680);
12987
12988 snd_hda_codec_write(codec, 0x20, 0,
12989 AC_VERB_SET_COEF_INDEX, 0x0c);
12990 snd_hda_codec_write(codec, 0x20, 0,
12991 AC_VERB_SET_PROC_COEF, 0x480);
12992}
12993
Kailang Yang60db6b52008-08-26 13:13:00 +020012994static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12995{
12996 unsigned int present;
12997
12998 present = snd_hda_codec_read(codec, 0x18, 0,
12999 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13000 snd_hda_codec_write(codec, 0x23, 0,
13001 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
13002}
13003
Tony Vroon64154832008-11-06 15:08:49 +000013004static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13005{
13006 unsigned int present_laptop;
13007 unsigned int present_dock;
13008
13009 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
13010 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13011
13012 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
13013 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13014
13015 /* Laptop mic port overrides dock mic port, design decision */
13016 if (present_dock)
13017 snd_hda_codec_write(codec, 0x23, 0,
13018 AC_VERB_SET_CONNECT_SEL, 0x3);
13019 if (present_laptop)
13020 snd_hda_codec_write(codec, 0x23, 0,
13021 AC_VERB_SET_CONNECT_SEL, 0x0);
13022 if (!present_dock && !present_laptop)
13023 snd_hda_codec_write(codec, 0x23, 0,
13024 AC_VERB_SET_CONNECT_SEL, 0x1);
13025}
13026
Kailang Yang60db6b52008-08-26 13:13:00 +020013027static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13028 unsigned int res)
13029{
13030 if ((res >> 26) == ALC880_HP_EVENT)
13031 alc269_quanta_fl1_speaker_automute(codec);
13032 if ((res >> 26) == ALC880_MIC_EVENT)
13033 alc269_quanta_fl1_mic_automute(codec);
13034}
13035
Tony Vroon64154832008-11-06 15:08:49 +000013036static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13037 unsigned int res)
13038{
13039 if ((res >> 26) == ALC880_HP_EVENT)
13040 alc269_lifebook_speaker_automute(codec);
13041 if ((res >> 26) == ALC880_MIC_EVENT)
13042 alc269_lifebook_mic_autoswitch(codec);
13043}
13044
Kailang Yang60db6b52008-08-26 13:13:00 +020013045static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13046{
13047 alc269_quanta_fl1_speaker_automute(codec);
13048 alc269_quanta_fl1_mic_automute(codec);
13049}
13050
Tony Vroon64154832008-11-06 15:08:49 +000013051static void alc269_lifebook_init_hook(struct hda_codec *codec)
13052{
13053 alc269_lifebook_speaker_automute(codec);
13054 alc269_lifebook_mic_autoswitch(codec);
13055}
13056
Kailang Yang60db6b52008-08-26 13:13:00 +020013057static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13058 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13059 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13060 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13061 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13062 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13063 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13064 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13065 {}
13066};
13067
13068static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13069 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13070 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13071 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13072 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13073 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13074 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13075 {}
13076};
13077
13078/* toggle speaker-output according to the hp-jack state */
13079static void alc269_speaker_automute(struct hda_codec *codec)
13080{
13081 unsigned int present;
13082 unsigned char bits;
13083
13084 present = snd_hda_codec_read(codec, 0x15, 0,
13085 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13086 bits = present ? AMP_IN_MUTE(0) : 0;
13087 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13088 AMP_IN_MUTE(0), bits);
13089 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13090 AMP_IN_MUTE(0), bits);
13091}
13092
13093static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
13094{
13095 unsigned int present;
13096
13097 present = snd_hda_codec_read(codec, 0x18, 0,
13098 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13099 snd_hda_codec_write(codec, 0x23, 0,
13100 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
13101}
13102
13103static void alc269_eeepc_amic_automute(struct hda_codec *codec)
13104{
13105 unsigned int present;
13106
13107 present = snd_hda_codec_read(codec, 0x18, 0,
13108 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13109 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13110 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13111 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13112 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13113}
13114
13115/* unsolicited event for HP jack sensing */
13116static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
13117 unsigned int res)
13118{
13119 if ((res >> 26) == ALC880_HP_EVENT)
13120 alc269_speaker_automute(codec);
13121
13122 if ((res >> 26) == ALC880_MIC_EVENT)
13123 alc269_eeepc_dmic_automute(codec);
13124}
13125
13126static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
13127{
13128 alc269_speaker_automute(codec);
13129 alc269_eeepc_dmic_automute(codec);
13130}
13131
13132/* unsolicited event for HP jack sensing */
13133static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
13134 unsigned int res)
13135{
13136 if ((res >> 26) == ALC880_HP_EVENT)
13137 alc269_speaker_automute(codec);
13138
13139 if ((res >> 26) == ALC880_MIC_EVENT)
13140 alc269_eeepc_amic_automute(codec);
13141}
13142
13143static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
13144{
13145 alc269_speaker_automute(codec);
13146 alc269_eeepc_amic_automute(codec);
13147}
13148
Kailang Yangf6a92242007-12-13 16:52:54 +010013149/*
13150 * generic initialization of ADC, input mixers and output mixers
13151 */
13152static struct hda_verb alc269_init_verbs[] = {
13153 /*
13154 * Unmute ADC0 and set the default input to mic-in
13155 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013156 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013157
13158 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13159 * analog-loopback mixer widget
13160 * Note: PASD motherboards uses the Line In 2 as the input for
13161 * front panel mic (mic 2)
13162 */
13163 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13164 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13165 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13166 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13167 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13168 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13169
13170 /*
13171 * Set up output mixers (0x0c - 0x0e)
13172 */
13173 /* set vol=0 to output mixers */
13174 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13175 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13176
13177 /* set up input amps for analog loopback */
13178 /* Amp Indices: DAC = 0, mixer = 1 */
13179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13180 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13181 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13182 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13183 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13184 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13185
13186 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13187 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13188 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13189 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13190 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13191 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13192 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13193
13194 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13195 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13196 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13197 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13198 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13199 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13200 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13201
13202 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13203 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13204
13205 /* FIXME: use matrix-type input source selection */
13206 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13207 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013208 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13212
13213 /* set EAPD */
13214 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13215 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13216 { }
13217};
13218
13219/* add playback controls from the parsed DAC table */
13220static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
13221 const struct auto_pin_cfg *cfg)
13222{
13223 hda_nid_t nid;
13224 int err;
13225
13226 spec->multiout.num_dacs = 1; /* only use one dac */
13227 spec->multiout.dac_nids = spec->private_dac_nids;
13228 spec->multiout.dac_nids[0] = 2;
13229
13230 nid = cfg->line_out_pins[0];
13231 if (nid) {
13232 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13233 "Front Playback Volume",
13234 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
13235 if (err < 0)
13236 return err;
13237 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13238 "Front Playback Switch",
13239 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13240 if (err < 0)
13241 return err;
13242 }
13243
13244 nid = cfg->speaker_pins[0];
13245 if (nid) {
13246 if (!cfg->line_out_pins[0]) {
13247 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13248 "Speaker Playback Volume",
13249 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13250 HDA_OUTPUT));
13251 if (err < 0)
13252 return err;
13253 }
13254 if (nid == 0x16) {
13255 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13256 "Speaker Playback Switch",
13257 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13258 HDA_OUTPUT));
13259 if (err < 0)
13260 return err;
13261 } else {
13262 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13263 "Speaker Playback Switch",
13264 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13265 HDA_OUTPUT));
13266 if (err < 0)
13267 return err;
13268 }
13269 }
13270 nid = cfg->hp_pins[0];
13271 if (nid) {
13272 /* spec->multiout.hp_nid = 2; */
13273 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
13274 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13275 "Headphone Playback Volume",
13276 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13277 HDA_OUTPUT));
13278 if (err < 0)
13279 return err;
13280 }
13281 if (nid == 0x16) {
13282 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13283 "Headphone Playback Switch",
13284 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13285 HDA_OUTPUT));
13286 if (err < 0)
13287 return err;
13288 } else {
13289 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13290 "Headphone Playback Switch",
13291 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13292 HDA_OUTPUT));
13293 if (err < 0)
13294 return err;
13295 }
13296 }
13297 return 0;
13298}
13299
Takashi Iwai8c927b42009-06-22 10:56:54 +020013300#define alc269_auto_create_analog_input_ctls \
13301 alc262_auto_create_analog_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013302
13303#ifdef CONFIG_SND_HDA_POWER_SAVE
13304#define alc269_loopbacks alc880_loopbacks
13305#endif
13306
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013307/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013308#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13309#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13310#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13311#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13312
Takashi Iwaif03d3112009-03-05 14:18:16 +010013313static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13314 .substreams = 1,
13315 .channels_min = 2,
13316 .channels_max = 8,
13317 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13318 /* NID is set in alc_build_pcms */
13319 .ops = {
13320 .open = alc880_playback_pcm_open,
13321 .prepare = alc880_playback_pcm_prepare,
13322 .cleanup = alc880_playback_pcm_cleanup
13323 },
13324};
13325
13326static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13327 .substreams = 1,
13328 .channels_min = 2,
13329 .channels_max = 2,
13330 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13331 /* NID is set in alc_build_pcms */
13332};
13333
Kailang Yangf6a92242007-12-13 16:52:54 +010013334/*
13335 * BIOS auto configuration
13336 */
13337static int alc269_parse_auto_config(struct hda_codec *codec)
13338{
13339 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013340 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013341 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13342
13343 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13344 alc269_ignore);
13345 if (err < 0)
13346 return err;
13347
13348 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13349 if (err < 0)
13350 return err;
13351 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13352 if (err < 0)
13353 return err;
13354
13355 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13356
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013357 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013358 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13359
Takashi Iwai603c4012008-07-30 15:01:44 +020013360 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013361 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013362
Takashi Iwaid88897e2008-10-31 15:01:37 +010013363 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013364 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013365 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013366 /* set default input source */
13367 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13368 0, AC_VERB_SET_CONNECT_SEL,
13369 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013370
13371 err = alc_auto_add_mic_boost(codec);
13372 if (err < 0)
13373 return err;
13374
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013375 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013376 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013377
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013378 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13379
Kailang Yangf6a92242007-12-13 16:52:54 +010013380 return 1;
13381}
13382
13383#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13384#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13385#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13386
13387
13388/* init callback for auto-configuration model -- overriding the default init */
13389static void alc269_auto_init(struct hda_codec *codec)
13390{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013391 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013392 alc269_auto_init_multi_out(codec);
13393 alc269_auto_init_hp_out(codec);
13394 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013395 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013396 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013397}
13398
13399/*
13400 * configuration and preset
13401 */
13402static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013403 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013404 [ALC269_QUANTA_FL1] = "quanta",
13405 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013406 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013407 [ALC269_FUJITSU] = "fujitsu",
13408 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013409};
13410
13411static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013412 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013413 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13414 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013415 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13416 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13417 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13418 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13419 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13420 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013421 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13422 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013423 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13424 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013425 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013426 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013427 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013428 {}
13429};
13430
13431static struct alc_config_preset alc269_presets[] = {
13432 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013433 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013434 .init_verbs = { alc269_init_verbs },
13435 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13436 .dac_nids = alc269_dac_nids,
13437 .hp_nid = 0x03,
13438 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13439 .channel_mode = alc269_modes,
13440 .input_mux = &alc269_capture_source,
13441 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013442 [ALC269_QUANTA_FL1] = {
13443 .mixers = { alc269_quanta_fl1_mixer },
13444 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13445 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13446 .dac_nids = alc269_dac_nids,
13447 .hp_nid = 0x03,
13448 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13449 .channel_mode = alc269_modes,
13450 .input_mux = &alc269_capture_source,
13451 .unsol_event = alc269_quanta_fl1_unsol_event,
13452 .init_hook = alc269_quanta_fl1_init_hook,
13453 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013454 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013455 .mixers = { alc269_eeepc_mixer },
13456 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013457 .init_verbs = { alc269_init_verbs,
13458 alc269_eeepc_amic_init_verbs },
13459 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13460 .dac_nids = alc269_dac_nids,
13461 .hp_nid = 0x03,
13462 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13463 .channel_mode = alc269_modes,
13464 .input_mux = &alc269_eeepc_amic_capture_source,
13465 .unsol_event = alc269_eeepc_amic_unsol_event,
13466 .init_hook = alc269_eeepc_amic_inithook,
13467 },
13468 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013469 .mixers = { alc269_eeepc_mixer },
13470 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013471 .init_verbs = { alc269_init_verbs,
13472 alc269_eeepc_dmic_init_verbs },
13473 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13474 .dac_nids = alc269_dac_nids,
13475 .hp_nid = 0x03,
13476 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13477 .channel_mode = alc269_modes,
13478 .input_mux = &alc269_eeepc_dmic_capture_source,
13479 .unsol_event = alc269_eeepc_dmic_unsol_event,
13480 .init_hook = alc269_eeepc_dmic_inithook,
13481 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013482 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013483 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013484 .cap_mixer = alc269_epc_capture_mixer,
13485 .init_verbs = { alc269_init_verbs,
13486 alc269_eeepc_dmic_init_verbs },
13487 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13488 .dac_nids = alc269_dac_nids,
13489 .hp_nid = 0x03,
13490 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13491 .channel_mode = alc269_modes,
13492 .input_mux = &alc269_eeepc_dmic_capture_source,
13493 .unsol_event = alc269_eeepc_dmic_unsol_event,
13494 .init_hook = alc269_eeepc_dmic_inithook,
13495 },
Tony Vroon64154832008-11-06 15:08:49 +000013496 [ALC269_LIFEBOOK] = {
13497 .mixers = { alc269_lifebook_mixer },
13498 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13499 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13500 .dac_nids = alc269_dac_nids,
13501 .hp_nid = 0x03,
13502 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13503 .channel_mode = alc269_modes,
13504 .input_mux = &alc269_capture_source,
13505 .unsol_event = alc269_lifebook_unsol_event,
13506 .init_hook = alc269_lifebook_init_hook,
13507 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013508};
13509
13510static int patch_alc269(struct hda_codec *codec)
13511{
13512 struct alc_spec *spec;
13513 int board_config;
13514 int err;
13515
13516 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13517 if (spec == NULL)
13518 return -ENOMEM;
13519
13520 codec->spec = spec;
13521
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013522 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13523
Kailang Yangf6a92242007-12-13 16:52:54 +010013524 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13525 alc269_models,
13526 alc269_cfg_tbl);
13527
13528 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020013529 printk(KERN_INFO "hda_codec: Unknown model for %s, "
13530 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013531 board_config = ALC269_AUTO;
13532 }
13533
13534 if (board_config == ALC269_AUTO) {
13535 /* automatic parse from the BIOS config */
13536 err = alc269_parse_auto_config(codec);
13537 if (err < 0) {
13538 alc_free(codec);
13539 return err;
13540 } else if (!err) {
13541 printk(KERN_INFO
13542 "hda_codec: Cannot set up configuration "
13543 "from BIOS. Using base mode...\n");
13544 board_config = ALC269_BASIC;
13545 }
13546 }
13547
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013548 err = snd_hda_attach_beep_device(codec, 0x1);
13549 if (err < 0) {
13550 alc_free(codec);
13551 return err;
13552 }
13553
Kailang Yangf6a92242007-12-13 16:52:54 +010013554 if (board_config != ALC269_AUTO)
13555 setup_preset(spec, &alc269_presets[board_config]);
13556
Takashi Iwaif03d3112009-03-05 14:18:16 +010013557 if (codec->subsystem_id == 0x17aa3bf8) {
13558 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13559 * fix the sample rate of analog I/O to 44.1kHz
13560 */
13561 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13562 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13563 } else {
13564 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13565 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13566 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013567 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13568 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13569
13570 spec->adc_nids = alc269_adc_nids;
13571 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013572 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013573 if (!spec->cap_mixer)
13574 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013575 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013576
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013577 spec->vmaster_nid = 0x02;
13578
Kailang Yangf6a92242007-12-13 16:52:54 +010013579 codec->patch_ops = alc_patch_ops;
13580 if (board_config == ALC269_AUTO)
13581 spec->init_hook = alc269_auto_init;
13582#ifdef CONFIG_SND_HDA_POWER_SAVE
13583 if (!spec->loopback.amplist)
13584 spec->loopback.amplist = alc269_loopbacks;
13585#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013586 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013587
13588 return 0;
13589}
13590
13591/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013592 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13593 */
13594
13595/*
13596 * set the path ways for 2 channel output
13597 * need to set the codec line out and mic 1 pin widgets to inputs
13598 */
13599static struct hda_verb alc861_threestack_ch2_init[] = {
13600 /* set pin widget 1Ah (line in) for input */
13601 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013602 /* set pin widget 18h (mic1/2) for input, for mic also enable
13603 * the vref
13604 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013605 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13606
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013607 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13608#if 0
13609 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13610 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13611#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013612 { } /* end */
13613};
13614/*
13615 * 6ch mode
13616 * need to set the codec line out and mic 1 pin widgets to outputs
13617 */
13618static struct hda_verb alc861_threestack_ch6_init[] = {
13619 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13620 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13621 /* set pin widget 18h (mic1) for output (CLFE)*/
13622 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13623
13624 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013625 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013626
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013627 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13628#if 0
13629 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13630 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13631#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013632 { } /* end */
13633};
13634
13635static struct hda_channel_mode alc861_threestack_modes[2] = {
13636 { 2, alc861_threestack_ch2_init },
13637 { 6, alc861_threestack_ch6_init },
13638};
Takashi Iwai22309c32006-08-09 16:57:28 +020013639/* Set mic1 as input and unmute the mixer */
13640static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13641 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13642 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13643 { } /* end */
13644};
13645/* Set mic1 as output and mute mixer */
13646static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13647 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13648 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13649 { } /* end */
13650};
13651
13652static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13653 { 2, alc861_uniwill_m31_ch2_init },
13654 { 4, alc861_uniwill_m31_ch4_init },
13655};
Kailang Yangdf694da2005-12-05 19:42:22 +010013656
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013657/* Set mic1 and line-in as input and unmute the mixer */
13658static struct hda_verb alc861_asus_ch2_init[] = {
13659 /* set pin widget 1Ah (line in) for input */
13660 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013661 /* set pin widget 18h (mic1/2) for input, for mic also enable
13662 * the vref
13663 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013664 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13665
13666 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13667#if 0
13668 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13669 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13670#endif
13671 { } /* end */
13672};
13673/* Set mic1 nad line-in as output and mute mixer */
13674static struct hda_verb alc861_asus_ch6_init[] = {
13675 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13676 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13677 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13678 /* set pin widget 18h (mic1) for output (CLFE)*/
13679 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13680 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13681 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13682 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13683
13684 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13685#if 0
13686 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13687 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13688#endif
13689 { } /* end */
13690};
13691
13692static struct hda_channel_mode alc861_asus_modes[2] = {
13693 { 2, alc861_asus_ch2_init },
13694 { 6, alc861_asus_ch6_init },
13695};
13696
Kailang Yangdf694da2005-12-05 19:42:22 +010013697/* patch-ALC861 */
13698
13699static struct snd_kcontrol_new alc861_base_mixer[] = {
13700 /* output mixer control */
13701 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13702 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13703 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13704 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13705 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13706
13707 /*Input mixer control */
13708 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13709 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13710 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13711 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13712 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13713 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13714 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13715 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13716 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13717 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013718
Kailang Yangdf694da2005-12-05 19:42:22 +010013719 { } /* end */
13720};
13721
13722static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13723 /* output mixer control */
13724 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13725 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13726 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13727 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13728 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13729
13730 /* Input mixer control */
13731 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13732 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13733 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13734 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13735 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13736 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13737 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13738 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13739 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13740 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013741
Kailang Yangdf694da2005-12-05 19:42:22 +010013742 {
13743 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13744 .name = "Channel Mode",
13745 .info = alc_ch_mode_info,
13746 .get = alc_ch_mode_get,
13747 .put = alc_ch_mode_put,
13748 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13749 },
13750 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013751};
13752
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013753static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013754 /* output mixer control */
13755 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13756 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13757 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013758
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013759 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013760};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013761
Takashi Iwai22309c32006-08-09 16:57:28 +020013762static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13763 /* output mixer control */
13764 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13765 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13766 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13767 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13768 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13769
13770 /* Input mixer control */
13771 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13772 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13773 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13774 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13775 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13776 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13777 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13778 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13779 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13780 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013781
Takashi Iwai22309c32006-08-09 16:57:28 +020013782 {
13783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13784 .name = "Channel Mode",
13785 .info = alc_ch_mode_info,
13786 .get = alc_ch_mode_get,
13787 .put = alc_ch_mode_put,
13788 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13789 },
13790 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013791};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013792
13793static struct snd_kcontrol_new alc861_asus_mixer[] = {
13794 /* output mixer control */
13795 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13796 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13797 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13798 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13799 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13800
13801 /* Input mixer control */
13802 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13803 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13804 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13805 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13806 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13807 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13809 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13810 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013811 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13812
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013813 {
13814 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13815 .name = "Channel Mode",
13816 .info = alc_ch_mode_info,
13817 .get = alc_ch_mode_get,
13818 .put = alc_ch_mode_put,
13819 .private_value = ARRAY_SIZE(alc861_asus_modes),
13820 },
13821 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013822};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013823
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013824/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013825static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013826 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13827 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013828 { }
13829};
13830
Kailang Yangdf694da2005-12-05 19:42:22 +010013831/*
13832 * generic initialization of ADC, input mixers and output mixers
13833 */
13834static struct hda_verb alc861_base_init_verbs[] = {
13835 /*
13836 * Unmute ADC0 and set the default input to mic-in
13837 */
13838 /* port-A for surround (rear panel) */
13839 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13840 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13841 /* port-B for mic-in (rear panel) with vref */
13842 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13843 /* port-C for line-in (rear panel) */
13844 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13845 /* port-D for Front */
13846 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13847 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13848 /* port-E for HP out (front panel) */
13849 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13850 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013851 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013852 /* port-F for mic-in (front panel) with vref */
13853 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13854 /* port-G for CLFE (rear panel) */
13855 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13856 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13857 /* port-H for side (rear panel) */
13858 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13859 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13860 /* CD-in */
13861 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13862 /* route front mic to ADC1*/
13863 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13864 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013865
Kailang Yangdf694da2005-12-05 19:42:22 +010013866 /* Unmute DAC0~3 & spdif out*/
13867 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13868 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13869 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13870 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13871 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013872
Kailang Yangdf694da2005-12-05 19:42:22 +010013873 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13874 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13875 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13876 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13877 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013878
Kailang Yangdf694da2005-12-05 19:42:22 +010013879 /* Unmute Stereo Mixer 15 */
13880 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013883 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013884
13885 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13886 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13887 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13888 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13889 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13890 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13891 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13892 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013893 /* hp used DAC 3 (Front) */
13894 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013895 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13896
13897 { }
13898};
13899
13900static struct hda_verb alc861_threestack_init_verbs[] = {
13901 /*
13902 * Unmute ADC0 and set the default input to mic-in
13903 */
13904 /* port-A for surround (rear panel) */
13905 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13906 /* port-B for mic-in (rear panel) with vref */
13907 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13908 /* port-C for line-in (rear panel) */
13909 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13910 /* port-D for Front */
13911 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13912 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13913 /* port-E for HP out (front panel) */
13914 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13915 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013916 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013917 /* port-F for mic-in (front panel) with vref */
13918 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13919 /* port-G for CLFE (rear panel) */
13920 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13921 /* port-H for side (rear panel) */
13922 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13923 /* CD-in */
13924 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13925 /* route front mic to ADC1*/
13926 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13927 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13928 /* Unmute DAC0~3 & spdif out*/
13929 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13930 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13931 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13932 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13933 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013934
Kailang Yangdf694da2005-12-05 19:42:22 +010013935 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13936 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13937 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13938 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13939 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013940
Kailang Yangdf694da2005-12-05 19:42:22 +010013941 /* Unmute Stereo Mixer 15 */
13942 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13943 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13944 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013945 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013946
13947 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13948 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13949 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13950 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13951 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13952 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13953 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13954 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013955 /* hp used DAC 3 (Front) */
13956 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013957 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13958 { }
13959};
Takashi Iwai22309c32006-08-09 16:57:28 +020013960
13961static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13962 /*
13963 * Unmute ADC0 and set the default input to mic-in
13964 */
13965 /* port-A for surround (rear panel) */
13966 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13967 /* port-B for mic-in (rear panel) with vref */
13968 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13969 /* port-C for line-in (rear panel) */
13970 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13971 /* port-D for Front */
13972 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13973 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13974 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013975 /* this has to be set to VREF80 */
13976 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013977 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013978 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013979 /* port-F for mic-in (front panel) with vref */
13980 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13981 /* port-G for CLFE (rear panel) */
13982 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13983 /* port-H for side (rear panel) */
13984 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13985 /* CD-in */
13986 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13987 /* route front mic to ADC1*/
13988 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13989 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13990 /* Unmute DAC0~3 & spdif out*/
13991 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13992 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13993 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13994 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13995 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013996
Takashi Iwai22309c32006-08-09 16:57:28 +020013997 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13998 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13999 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14000 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14001 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014002
Takashi Iwai22309c32006-08-09 16:57:28 +020014003 /* Unmute Stereo Mixer 15 */
14004 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14006 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014007 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014008
14009 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14010 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14011 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14012 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14013 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14014 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14015 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14016 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014017 /* hp used DAC 3 (Front) */
14018 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014019 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14020 { }
14021};
14022
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014023static struct hda_verb alc861_asus_init_verbs[] = {
14024 /*
14025 * Unmute ADC0 and set the default input to mic-in
14026 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014027 /* port-A for surround (rear panel)
14028 * according to codec#0 this is the HP jack
14029 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014030 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14031 /* route front PCM to HP */
14032 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14033 /* port-B for mic-in (rear panel) with vref */
14034 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14035 /* port-C for line-in (rear panel) */
14036 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14037 /* port-D for Front */
14038 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14039 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14040 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014041 /* this has to be set to VREF80 */
14042 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014043 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014044 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014045 /* port-F for mic-in (front panel) with vref */
14046 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14047 /* port-G for CLFE (rear panel) */
14048 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14049 /* port-H for side (rear panel) */
14050 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14051 /* CD-in */
14052 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14053 /* route front mic to ADC1*/
14054 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14055 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14056 /* Unmute DAC0~3 & spdif out*/
14057 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14058 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14059 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14060 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14061 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14062 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14063 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14064 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14065 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14066 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014067
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014068 /* Unmute Stereo Mixer 15 */
14069 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14070 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14071 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014073
14074 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14075 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14076 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14077 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14078 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14079 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14080 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14081 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014082 /* hp used DAC 3 (Front) */
14083 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014084 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14085 { }
14086};
14087
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014088/* additional init verbs for ASUS laptops */
14089static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14090 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14091 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14092 { }
14093};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014094
Kailang Yangdf694da2005-12-05 19:42:22 +010014095/*
14096 * generic initialization of ADC, input mixers and output mixers
14097 */
14098static struct hda_verb alc861_auto_init_verbs[] = {
14099 /*
14100 * Unmute ADC0 and set the default input to mic-in
14101 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014102 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014103 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014104
Kailang Yangdf694da2005-12-05 19:42:22 +010014105 /* Unmute DAC0~3 & spdif out*/
14106 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14107 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14108 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14109 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14110 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014111
Kailang Yangdf694da2005-12-05 19:42:22 +010014112 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14113 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14114 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14115 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14116 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014117
Kailang Yangdf694da2005-12-05 19:42:22 +010014118 /* Unmute Stereo Mixer 15 */
14119 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14120 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14121 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14122 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14123
14124 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14125 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14126 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14127 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14128 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14129 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14130 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14131 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14132
14133 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14134 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014135 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14136 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014137 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14138 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014139 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14140 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014141
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014142 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014143
14144 { }
14145};
14146
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014147static struct hda_verb alc861_toshiba_init_verbs[] = {
14148 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014149
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014150 { }
14151};
14152
14153/* toggle speaker-output according to the hp-jack state */
14154static void alc861_toshiba_automute(struct hda_codec *codec)
14155{
14156 unsigned int present;
14157
14158 present = snd_hda_codec_read(codec, 0x0f, 0,
14159 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014160 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14161 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14162 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14163 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014164}
14165
14166static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14167 unsigned int res)
14168{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014169 if ((res >> 26) == ALC880_HP_EVENT)
14170 alc861_toshiba_automute(codec);
14171}
14172
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014173/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014174#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14175#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14176#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14177#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14178
14179
14180#define ALC861_DIGOUT_NID 0x07
14181
14182static struct hda_channel_mode alc861_8ch_modes[1] = {
14183 { 8, NULL }
14184};
14185
14186static hda_nid_t alc861_dac_nids[4] = {
14187 /* front, surround, clfe, side */
14188 0x03, 0x06, 0x05, 0x04
14189};
14190
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014191static hda_nid_t alc660_dac_nids[3] = {
14192 /* front, clfe, surround */
14193 0x03, 0x05, 0x06
14194};
14195
Kailang Yangdf694da2005-12-05 19:42:22 +010014196static hda_nid_t alc861_adc_nids[1] = {
14197 /* ADC0-2 */
14198 0x08,
14199};
14200
14201static struct hda_input_mux alc861_capture_source = {
14202 .num_items = 5,
14203 .items = {
14204 { "Mic", 0x0 },
14205 { "Front Mic", 0x3 },
14206 { "Line", 0x1 },
14207 { "CD", 0x4 },
14208 { "Mixer", 0x5 },
14209 },
14210};
14211
14212/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014213static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
14214 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014215{
14216 int i;
14217 hda_nid_t nid;
14218
14219 spec->multiout.dac_nids = spec->private_dac_nids;
14220 for (i = 0; i < cfg->line_outs; i++) {
14221 nid = cfg->line_out_pins[i];
14222 if (nid) {
14223 if (i >= ARRAY_SIZE(alc861_dac_nids))
14224 continue;
14225 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
14226 }
14227 }
14228 spec->multiout.num_dacs = cfg->line_outs;
14229 return 0;
14230}
14231
14232/* add playback controls from the parsed DAC table */
14233static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
14234 const struct auto_pin_cfg *cfg)
14235{
14236 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014237 static const char *chname[4] = {
14238 "Front", "Surround", NULL /*CLFE*/, "Side"
14239 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014240 hda_nid_t nid;
14241 int i, idx, err;
14242
14243 for (i = 0; i < cfg->line_outs; i++) {
14244 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014245 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014246 continue;
14247 if (nid == 0x05) {
14248 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014249 err = add_control(spec, ALC_CTL_BIND_MUTE,
14250 "Center Playback Switch",
14251 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14252 HDA_OUTPUT));
14253 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014254 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014255 err = add_control(spec, ALC_CTL_BIND_MUTE,
14256 "LFE Playback Switch",
14257 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14258 HDA_OUTPUT));
14259 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014260 return err;
14261 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014262 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
14263 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010014264 if (nid == alc861_dac_nids[idx])
14265 break;
14266 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014267 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14268 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14269 HDA_OUTPUT));
14270 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014271 return err;
14272 }
14273 }
14274 return 0;
14275}
14276
14277static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
14278{
14279 int err;
14280 hda_nid_t nid;
14281
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014282 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014283 return 0;
14284
14285 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
14286 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014287 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
14288 "Headphone Playback Switch",
14289 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14290 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014291 return err;
14292 spec->multiout.hp_nid = nid;
14293 }
14294 return 0;
14295}
14296
14297/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014298static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
14299 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014300{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014301 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014302 int i, err, idx, idx1;
14303
14304 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014305 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014306 case 0x0c:
14307 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014308 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014309 break;
14310 case 0x0f:
14311 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014312 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014313 break;
14314 case 0x0d:
14315 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014316 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014317 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014318 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014319 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014320 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014321 break;
14322 case 0x11:
14323 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014324 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014325 break;
14326 default:
14327 continue;
14328 }
14329
Takashi Iwai4a471b72005-12-07 13:56:29 +010014330 err = new_analog_input(spec, cfg->input_pins[i],
14331 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014332 if (err < 0)
14333 return err;
14334
Takashi Iwai4a471b72005-12-07 13:56:29 +010014335 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014336 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014337 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014338 }
14339 return 0;
14340}
14341
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014342static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14343 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010014344 int pin_type, int dac_idx)
14345{
Jacek Luczak564c5be2008-05-03 18:41:23 +020014346 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14347 pin_type);
14348 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14349 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010014350}
14351
14352static void alc861_auto_init_multi_out(struct hda_codec *codec)
14353{
14354 struct alc_spec *spec = codec->spec;
14355 int i;
14356
14357 for (i = 0; i < spec->autocfg.line_outs; i++) {
14358 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014359 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014360 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014361 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014362 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014363 }
14364}
14365
14366static void alc861_auto_init_hp_out(struct hda_codec *codec)
14367{
14368 struct alc_spec *spec = codec->spec;
14369 hda_nid_t pin;
14370
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014371 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014372 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014373 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
14374 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014375 pin = spec->autocfg.speaker_pins[0];
14376 if (pin)
14377 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014378}
14379
14380static void alc861_auto_init_analog_input(struct hda_codec *codec)
14381{
14382 struct alc_spec *spec = codec->spec;
14383 int i;
14384
14385 for (i = 0; i < AUTO_PIN_LAST; i++) {
14386 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014387 if (nid >= 0x0c && nid <= 0x11)
14388 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014389 }
14390}
14391
14392/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014393/* return 1 if successful, 0 if the proper config is not found,
14394 * or a negative error code
14395 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014396static int alc861_parse_auto_config(struct hda_codec *codec)
14397{
14398 struct alc_spec *spec = codec->spec;
14399 int err;
14400 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14401
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014402 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14403 alc861_ignore);
14404 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014405 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014406 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014407 return 0; /* can't find valid BIOS pin config */
14408
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014409 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
14410 if (err < 0)
14411 return err;
14412 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
14413 if (err < 0)
14414 return err;
14415 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
14416 if (err < 0)
14417 return err;
14418 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
14419 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014420 return err;
14421
14422 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14423
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014424 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014425 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14426
Takashi Iwai603c4012008-07-30 15:01:44 +020014427 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014428 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014429
Takashi Iwaid88897e2008-10-31 15:01:37 +010014430 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014431
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014432 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014433 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014434
14435 spec->adc_nids = alc861_adc_nids;
14436 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014437 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014438
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014439 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14440
Kailang Yangdf694da2005-12-05 19:42:22 +010014441 return 1;
14442}
14443
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014444/* additional initialization for auto-configuration model */
14445static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014446{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014447 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014448 alc861_auto_init_multi_out(codec);
14449 alc861_auto_init_hp_out(codec);
14450 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014451 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014452 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014453}
14454
Takashi Iwaicb53c622007-08-10 17:21:45 +020014455#ifdef CONFIG_SND_HDA_POWER_SAVE
14456static struct hda_amp_list alc861_loopbacks[] = {
14457 { 0x15, HDA_INPUT, 0 },
14458 { 0x15, HDA_INPUT, 1 },
14459 { 0x15, HDA_INPUT, 2 },
14460 { 0x15, HDA_INPUT, 3 },
14461 { } /* end */
14462};
14463#endif
14464
Kailang Yangdf694da2005-12-05 19:42:22 +010014465
14466/*
14467 * configuration and preset
14468 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014469static const char *alc861_models[ALC861_MODEL_LAST] = {
14470 [ALC861_3ST] = "3stack",
14471 [ALC660_3ST] = "3stack-660",
14472 [ALC861_3ST_DIG] = "3stack-dig",
14473 [ALC861_6ST_DIG] = "6stack-dig",
14474 [ALC861_UNIWILL_M31] = "uniwill-m31",
14475 [ALC861_TOSHIBA] = "toshiba",
14476 [ALC861_ASUS] = "asus",
14477 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14478 [ALC861_AUTO] = "auto",
14479};
14480
14481static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014482 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014483 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14484 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14485 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014486 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014487 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014488 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014489 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14490 * Any other models that need this preset?
14491 */
14492 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014493 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14494 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014495 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14496 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14497 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14498 /* FIXME: the below seems conflict */
14499 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14500 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14501 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014502 {}
14503};
14504
14505static struct alc_config_preset alc861_presets[] = {
14506 [ALC861_3ST] = {
14507 .mixers = { alc861_3ST_mixer },
14508 .init_verbs = { alc861_threestack_init_verbs },
14509 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14510 .dac_nids = alc861_dac_nids,
14511 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14512 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014513 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014514 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14515 .adc_nids = alc861_adc_nids,
14516 .input_mux = &alc861_capture_source,
14517 },
14518 [ALC861_3ST_DIG] = {
14519 .mixers = { alc861_base_mixer },
14520 .init_verbs = { alc861_threestack_init_verbs },
14521 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14522 .dac_nids = alc861_dac_nids,
14523 .dig_out_nid = ALC861_DIGOUT_NID,
14524 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14525 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014526 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014527 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14528 .adc_nids = alc861_adc_nids,
14529 .input_mux = &alc861_capture_source,
14530 },
14531 [ALC861_6ST_DIG] = {
14532 .mixers = { alc861_base_mixer },
14533 .init_verbs = { alc861_base_init_verbs },
14534 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14535 .dac_nids = alc861_dac_nids,
14536 .dig_out_nid = ALC861_DIGOUT_NID,
14537 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14538 .channel_mode = alc861_8ch_modes,
14539 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14540 .adc_nids = alc861_adc_nids,
14541 .input_mux = &alc861_capture_source,
14542 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014543 [ALC660_3ST] = {
14544 .mixers = { alc861_3ST_mixer },
14545 .init_verbs = { alc861_threestack_init_verbs },
14546 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14547 .dac_nids = alc660_dac_nids,
14548 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14549 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014550 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014551 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14552 .adc_nids = alc861_adc_nids,
14553 .input_mux = &alc861_capture_source,
14554 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014555 [ALC861_UNIWILL_M31] = {
14556 .mixers = { alc861_uniwill_m31_mixer },
14557 .init_verbs = { alc861_uniwill_m31_init_verbs },
14558 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14559 .dac_nids = alc861_dac_nids,
14560 .dig_out_nid = ALC861_DIGOUT_NID,
14561 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14562 .channel_mode = alc861_uniwill_m31_modes,
14563 .need_dac_fix = 1,
14564 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14565 .adc_nids = alc861_adc_nids,
14566 .input_mux = &alc861_capture_source,
14567 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014568 [ALC861_TOSHIBA] = {
14569 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014570 .init_verbs = { alc861_base_init_verbs,
14571 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014572 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14573 .dac_nids = alc861_dac_nids,
14574 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14575 .channel_mode = alc883_3ST_2ch_modes,
14576 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14577 .adc_nids = alc861_adc_nids,
14578 .input_mux = &alc861_capture_source,
14579 .unsol_event = alc861_toshiba_unsol_event,
14580 .init_hook = alc861_toshiba_automute,
14581 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014582 [ALC861_ASUS] = {
14583 .mixers = { alc861_asus_mixer },
14584 .init_verbs = { alc861_asus_init_verbs },
14585 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14586 .dac_nids = alc861_dac_nids,
14587 .dig_out_nid = ALC861_DIGOUT_NID,
14588 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14589 .channel_mode = alc861_asus_modes,
14590 .need_dac_fix = 1,
14591 .hp_nid = 0x06,
14592 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14593 .adc_nids = alc861_adc_nids,
14594 .input_mux = &alc861_capture_source,
14595 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014596 [ALC861_ASUS_LAPTOP] = {
14597 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14598 .init_verbs = { alc861_asus_init_verbs,
14599 alc861_asus_laptop_init_verbs },
14600 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14601 .dac_nids = alc861_dac_nids,
14602 .dig_out_nid = ALC861_DIGOUT_NID,
14603 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14604 .channel_mode = alc883_3ST_2ch_modes,
14605 .need_dac_fix = 1,
14606 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14607 .adc_nids = alc861_adc_nids,
14608 .input_mux = &alc861_capture_source,
14609 },
14610};
Kailang Yangdf694da2005-12-05 19:42:22 +010014611
14612
14613static int patch_alc861(struct hda_codec *codec)
14614{
14615 struct alc_spec *spec;
14616 int board_config;
14617 int err;
14618
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014619 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014620 if (spec == NULL)
14621 return -ENOMEM;
14622
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014623 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014624
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014625 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14626 alc861_models,
14627 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014628
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014629 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020014630 printk(KERN_INFO "hda_codec: Unknown model for %s, "
14631 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014632 board_config = ALC861_AUTO;
14633 }
14634
14635 if (board_config == ALC861_AUTO) {
14636 /* automatic parse from the BIOS config */
14637 err = alc861_parse_auto_config(codec);
14638 if (err < 0) {
14639 alc_free(codec);
14640 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014641 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014642 printk(KERN_INFO
14643 "hda_codec: Cannot set up configuration "
14644 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014645 board_config = ALC861_3ST_DIG;
14646 }
14647 }
14648
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014649 err = snd_hda_attach_beep_device(codec, 0x23);
14650 if (err < 0) {
14651 alc_free(codec);
14652 return err;
14653 }
14654
Kailang Yangdf694da2005-12-05 19:42:22 +010014655 if (board_config != ALC861_AUTO)
14656 setup_preset(spec, &alc861_presets[board_config]);
14657
Kailang Yangdf694da2005-12-05 19:42:22 +010014658 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14659 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14660
Kailang Yangdf694da2005-12-05 19:42:22 +010014661 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14662 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14663
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014664 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14665
Takashi Iwai2134ea42008-01-10 16:53:55 +010014666 spec->vmaster_nid = 0x03;
14667
Kailang Yangdf694da2005-12-05 19:42:22 +010014668 codec->patch_ops = alc_patch_ops;
14669 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014670 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014671#ifdef CONFIG_SND_HDA_POWER_SAVE
14672 if (!spec->loopback.amplist)
14673 spec->loopback.amplist = alc861_loopbacks;
14674#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014675 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014676
Kailang Yangdf694da2005-12-05 19:42:22 +010014677 return 0;
14678}
14679
14680/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014681 * ALC861-VD support
14682 *
14683 * Based on ALC882
14684 *
14685 * In addition, an independent DAC
14686 */
14687#define ALC861VD_DIGOUT_NID 0x06
14688
14689static hda_nid_t alc861vd_dac_nids[4] = {
14690 /* front, surr, clfe, side surr */
14691 0x02, 0x03, 0x04, 0x05
14692};
14693
14694/* dac_nids for ALC660vd are in a different order - according to
14695 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014696 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014697 * of ALC660vd codecs, but for now there is only 3stack mixer
14698 * - and it is the same as in 861vd.
14699 * adc_nids in ALC660vd are (is) the same as in 861vd
14700 */
14701static hda_nid_t alc660vd_dac_nids[3] = {
14702 /* front, rear, clfe, rear_surr */
14703 0x02, 0x04, 0x03
14704};
14705
14706static hda_nid_t alc861vd_adc_nids[1] = {
14707 /* ADC0 */
14708 0x09,
14709};
14710
Takashi Iwaie1406342008-02-11 18:32:32 +010014711static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14712
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014713/* input MUX */
14714/* FIXME: should be a matrix-type input source selection */
14715static struct hda_input_mux alc861vd_capture_source = {
14716 .num_items = 4,
14717 .items = {
14718 { "Mic", 0x0 },
14719 { "Front Mic", 0x1 },
14720 { "Line", 0x2 },
14721 { "CD", 0x4 },
14722 },
14723};
14724
Kailang Yang272a5272007-05-14 11:00:38 +020014725static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014726 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014727 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014728 { "Ext Mic", 0x0 },
14729 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014730 },
14731};
14732
Kailang Yangd1a991a2007-08-15 16:21:59 +020014733static struct hda_input_mux alc861vd_hp_capture_source = {
14734 .num_items = 2,
14735 .items = {
14736 { "Front Mic", 0x0 },
14737 { "ATAPI Mic", 0x1 },
14738 },
14739};
14740
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014741/*
14742 * 2ch mode
14743 */
14744static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14745 { 2, NULL }
14746};
14747
14748/*
14749 * 6ch mode
14750 */
14751static struct hda_verb alc861vd_6stack_ch6_init[] = {
14752 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14753 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14754 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14755 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14756 { } /* end */
14757};
14758
14759/*
14760 * 8ch mode
14761 */
14762static struct hda_verb alc861vd_6stack_ch8_init[] = {
14763 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14764 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14765 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14766 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14767 { } /* end */
14768};
14769
14770static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14771 { 6, alc861vd_6stack_ch6_init },
14772 { 8, alc861vd_6stack_ch8_init },
14773};
14774
14775static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14776 {
14777 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14778 .name = "Channel Mode",
14779 .info = alc_ch_mode_info,
14780 .get = alc_ch_mode_get,
14781 .put = alc_ch_mode_put,
14782 },
14783 { } /* end */
14784};
14785
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014786/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14787 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14788 */
14789static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14790 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14791 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14792
14793 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14794 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14795
14796 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14797 HDA_OUTPUT),
14798 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14799 HDA_OUTPUT),
14800 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14801 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14802
14803 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14804 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14805
14806 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14807
14808 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14811
14812 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14813 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14814 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14815
14816 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14817 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14818
14819 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14820 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14821
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014822 { } /* end */
14823};
14824
14825static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14826 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14827 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14828
14829 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14830
14831 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14833 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14834
14835 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14836 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14837 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14838
14839 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14840 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14841
14842 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14843 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14844
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014845 { } /* end */
14846};
14847
Kailang Yangbdd148a2007-05-08 15:19:08 +020014848static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14849 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14850 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14851 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14852
14853 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14854
14855 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14856 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14858
14859 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14860 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14861 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14862
14863 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14864 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14865
14866 { } /* end */
14867};
14868
Tobin Davisb419f342008-03-07 11:57:51 +010014869/* Pin assignment: Speaker=0x14, HP = 0x15,
14870 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014871 */
14872static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014873 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14874 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014875 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14876 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014877 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14878 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14879 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14880 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14881 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14882 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014883 { } /* end */
14884};
14885
Kailang Yangd1a991a2007-08-15 16:21:59 +020014886/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14887 * Front Mic=0x18, ATAPI Mic = 0x19,
14888 */
14889static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14890 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14891 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14892 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14893 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14894 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14895 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14896 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14897 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014898
Kailang Yangd1a991a2007-08-15 16:21:59 +020014899 { } /* end */
14900};
14901
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014902/*
14903 * generic initialization of ADC, input mixers and output mixers
14904 */
14905static struct hda_verb alc861vd_volume_init_verbs[] = {
14906 /*
14907 * Unmute ADC0 and set the default input to mic-in
14908 */
14909 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14910 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14911
14912 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14913 * the analog-loopback mixer widget
14914 */
14915 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014916 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14917 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14919 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14920 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014921
14922 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014923 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14924 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14925 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014927
14928 /*
14929 * Set up output mixers (0x02 - 0x05)
14930 */
14931 /* set vol=0 to output mixers */
14932 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14933 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14934 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14935 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14936
14937 /* set up input amps for analog loopback */
14938 /* Amp Indices: DAC = 0, mixer = 1 */
14939 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14940 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14941 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14942 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14943 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14944 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14945 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14946 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14947
14948 { }
14949};
14950
14951/*
14952 * 3-stack pin configuration:
14953 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14954 */
14955static struct hda_verb alc861vd_3stack_init_verbs[] = {
14956 /*
14957 * Set pin mode and muting
14958 */
14959 /* set front pin widgets 0x14 for output */
14960 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14961 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14962 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14963
14964 /* Mic (rear) pin: input vref at 80% */
14965 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14966 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14967 /* Front Mic pin: input vref at 80% */
14968 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14969 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14970 /* Line In pin: input */
14971 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14972 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14973 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14974 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14975 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14976 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14977 /* CD pin widget for input */
14978 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14979
14980 { }
14981};
14982
14983/*
14984 * 6-stack pin configuration:
14985 */
14986static struct hda_verb alc861vd_6stack_init_verbs[] = {
14987 /*
14988 * Set pin mode and muting
14989 */
14990 /* set front pin widgets 0x14 for output */
14991 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14992 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14993 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14994
14995 /* Rear Pin: output 1 (0x0d) */
14996 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14997 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14998 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14999 /* CLFE Pin: output 2 (0x0e) */
15000 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15001 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15002 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15003 /* Side Pin: output 3 (0x0f) */
15004 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15005 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15006 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15007
15008 /* Mic (rear) pin: input vref at 80% */
15009 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15010 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15011 /* Front Mic pin: input vref at 80% */
15012 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15013 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15014 /* Line In pin: input */
15015 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15016 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15017 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15018 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15019 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15020 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15021 /* CD pin widget for input */
15022 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15023
15024 { }
15025};
15026
Kailang Yangbdd148a2007-05-08 15:19:08 +020015027static struct hda_verb alc861vd_eapd_verbs[] = {
15028 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15029 { }
15030};
15031
Kailang Yangf9423e72008-05-27 12:32:25 +020015032static struct hda_verb alc660vd_eapd_verbs[] = {
15033 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15034 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15035 { }
15036};
15037
Kailang Yangbdd148a2007-05-08 15:19:08 +020015038static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15040 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15042 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015043 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015044 {}
15045};
15046
Kailang Yangbdd148a2007-05-08 15:19:08 +020015047static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15048{
15049 unsigned int present;
15050 unsigned char bits;
15051
15052 present = snd_hda_codec_read(codec, 0x18, 0,
15053 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015054 bits = present ? HDA_AMP_MUTE : 0;
15055 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15056 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015057}
15058
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015059static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015060{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015061 struct alc_spec *spec = codec->spec;
15062
15063 spec->autocfg.hp_pins[0] = 0x1b;
15064 spec->autocfg.speaker_pins[0] = 0x14;
15065 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015066 alc861vd_lenovo_mic_automute(codec);
15067}
15068
15069static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15070 unsigned int res)
15071{
15072 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015073 case ALC880_MIC_EVENT:
15074 alc861vd_lenovo_mic_automute(codec);
15075 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015076 default:
15077 alc_automute_amp_unsol_event(codec, res);
15078 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015079 }
15080}
15081
Kailang Yang272a5272007-05-14 11:00:38 +020015082static struct hda_verb alc861vd_dallas_verbs[] = {
15083 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15084 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15085 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15086 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15087
15088 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15090 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15091 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15092 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15093 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15094 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15095 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015096
Kailang Yang272a5272007-05-14 11:00:38 +020015097 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15098 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15099 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15100 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15101 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15102 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15103 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15104 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15105
15106 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15107 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15108 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15109 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15110 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15111 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15112 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15113 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15114
15115 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15119
15120 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015121 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015122 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15123
15124 { } /* end */
15125};
15126
15127/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015128static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015129{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015130 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015131
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015132 spec->autocfg.hp_pins[0] = 0x15;
15133 spec->autocfg.speaker_pins[0] = 0x14;
15134 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020015135}
15136
Takashi Iwaicb53c622007-08-10 17:21:45 +020015137#ifdef CONFIG_SND_HDA_POWER_SAVE
15138#define alc861vd_loopbacks alc880_loopbacks
15139#endif
15140
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015141/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015142#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15143#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15144#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15145#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15146
15147/*
15148 * configuration and preset
15149 */
15150static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15151 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015152 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015153 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015154 [ALC861VD_3ST] = "3stack",
15155 [ALC861VD_3ST_DIG] = "3stack-digout",
15156 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015157 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015158 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015159 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015160 [ALC861VD_AUTO] = "auto",
15161};
15162
15163static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015164 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15165 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015166 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015167 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010015168 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015169 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015170 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015171 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015172 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015173 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015174 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015175 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015176 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015177 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015178 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015179 {}
15180};
15181
15182static struct alc_config_preset alc861vd_presets[] = {
15183 [ALC660VD_3ST] = {
15184 .mixers = { alc861vd_3st_mixer },
15185 .init_verbs = { alc861vd_volume_init_verbs,
15186 alc861vd_3stack_init_verbs },
15187 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15188 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015189 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15190 .channel_mode = alc861vd_3stack_2ch_modes,
15191 .input_mux = &alc861vd_capture_source,
15192 },
Mike Crash6963f842007-06-25 12:12:51 +020015193 [ALC660VD_3ST_DIG] = {
15194 .mixers = { alc861vd_3st_mixer },
15195 .init_verbs = { alc861vd_volume_init_verbs,
15196 alc861vd_3stack_init_verbs },
15197 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15198 .dac_nids = alc660vd_dac_nids,
15199 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015200 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15201 .channel_mode = alc861vd_3stack_2ch_modes,
15202 .input_mux = &alc861vd_capture_source,
15203 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015204 [ALC861VD_3ST] = {
15205 .mixers = { alc861vd_3st_mixer },
15206 .init_verbs = { alc861vd_volume_init_verbs,
15207 alc861vd_3stack_init_verbs },
15208 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15209 .dac_nids = alc861vd_dac_nids,
15210 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15211 .channel_mode = alc861vd_3stack_2ch_modes,
15212 .input_mux = &alc861vd_capture_source,
15213 },
15214 [ALC861VD_3ST_DIG] = {
15215 .mixers = { alc861vd_3st_mixer },
15216 .init_verbs = { alc861vd_volume_init_verbs,
15217 alc861vd_3stack_init_verbs },
15218 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15219 .dac_nids = alc861vd_dac_nids,
15220 .dig_out_nid = ALC861VD_DIGOUT_NID,
15221 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15222 .channel_mode = alc861vd_3stack_2ch_modes,
15223 .input_mux = &alc861vd_capture_source,
15224 },
15225 [ALC861VD_6ST_DIG] = {
15226 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15227 .init_verbs = { alc861vd_volume_init_verbs,
15228 alc861vd_6stack_init_verbs },
15229 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15230 .dac_nids = alc861vd_dac_nids,
15231 .dig_out_nid = ALC861VD_DIGOUT_NID,
15232 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15233 .channel_mode = alc861vd_6stack_modes,
15234 .input_mux = &alc861vd_capture_source,
15235 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015236 [ALC861VD_LENOVO] = {
15237 .mixers = { alc861vd_lenovo_mixer },
15238 .init_verbs = { alc861vd_volume_init_verbs,
15239 alc861vd_3stack_init_verbs,
15240 alc861vd_eapd_verbs,
15241 alc861vd_lenovo_unsol_verbs },
15242 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15243 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015244 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15245 .channel_mode = alc861vd_3stack_2ch_modes,
15246 .input_mux = &alc861vd_capture_source,
15247 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015248 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015249 },
Kailang Yang272a5272007-05-14 11:00:38 +020015250 [ALC861VD_DALLAS] = {
15251 .mixers = { alc861vd_dallas_mixer },
15252 .init_verbs = { alc861vd_dallas_verbs },
15253 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15254 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015255 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15256 .channel_mode = alc861vd_3stack_2ch_modes,
15257 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015258 .unsol_event = alc_automute_amp_unsol_event,
15259 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015260 },
15261 [ALC861VD_HP] = {
15262 .mixers = { alc861vd_hp_mixer },
15263 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15264 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15265 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015266 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015267 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15268 .channel_mode = alc861vd_3stack_2ch_modes,
15269 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015270 .unsol_event = alc_automute_amp_unsol_event,
15271 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020015272 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015273 [ALC660VD_ASUS_V1S] = {
15274 .mixers = { alc861vd_lenovo_mixer },
15275 .init_verbs = { alc861vd_volume_init_verbs,
15276 alc861vd_3stack_init_verbs,
15277 alc861vd_eapd_verbs,
15278 alc861vd_lenovo_unsol_verbs },
15279 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15280 .dac_nids = alc660vd_dac_nids,
15281 .dig_out_nid = ALC861VD_DIGOUT_NID,
15282 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15283 .channel_mode = alc861vd_3stack_2ch_modes,
15284 .input_mux = &alc861vd_capture_source,
15285 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015286 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015287 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015288};
15289
15290/*
15291 * BIOS auto configuration
15292 */
15293static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15294 hda_nid_t nid, int pin_type, int dac_idx)
15295{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015296 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015297}
15298
15299static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15300{
15301 struct alc_spec *spec = codec->spec;
15302 int i;
15303
15304 for (i = 0; i <= HDA_SIDE; i++) {
15305 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015306 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015307 if (nid)
15308 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015309 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015310 }
15311}
15312
15313
15314static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15315{
15316 struct alc_spec *spec = codec->spec;
15317 hda_nid_t pin;
15318
15319 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015320 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015321 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015322 pin = spec->autocfg.speaker_pins[0];
15323 if (pin)
15324 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015325}
15326
15327#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15328#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15329
15330static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15331{
15332 struct alc_spec *spec = codec->spec;
15333 int i;
15334
15335 for (i = 0; i < AUTO_PIN_LAST; i++) {
15336 hda_nid_t nid = spec->autocfg.input_pins[i];
15337 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015338 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015339 if (nid != ALC861VD_PIN_CD_NID &&
15340 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015341 snd_hda_codec_write(codec, nid, 0,
15342 AC_VERB_SET_AMP_GAIN_MUTE,
15343 AMP_OUT_MUTE);
15344 }
15345 }
15346}
15347
Takashi Iwaif511b012008-08-15 16:46:42 +020015348#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15349
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015350#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15351#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15352
15353/* add playback controls from the parsed DAC table */
15354/* Based on ALC880 version. But ALC861VD has separate,
15355 * different NIDs for mute/unmute switch and volume control */
15356static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15357 const struct auto_pin_cfg *cfg)
15358{
15359 char name[32];
15360 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15361 hda_nid_t nid_v, nid_s;
15362 int i, err;
15363
15364 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015365 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015366 continue;
15367 nid_v = alc861vd_idx_to_mixer_vol(
15368 alc880_dac_to_idx(
15369 spec->multiout.dac_nids[i]));
15370 nid_s = alc861vd_idx_to_mixer_switch(
15371 alc880_dac_to_idx(
15372 spec->multiout.dac_nids[i]));
15373
15374 if (i == 2) {
15375 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015376 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15377 "Center Playback Volume",
15378 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15379 HDA_OUTPUT));
15380 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015381 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015382 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15383 "LFE Playback Volume",
15384 HDA_COMPOSE_AMP_VAL(nid_v, 2, 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_BIND_MUTE,
15389 "Center Playback Switch",
15390 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15391 HDA_INPUT));
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 "LFE Playback Switch",
15396 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15397 HDA_INPUT));
15398 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015399 return err;
15400 } else {
15401 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015402 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15403 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15404 HDA_OUTPUT));
15405 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015406 return err;
15407 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015408 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015409 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015410 HDA_INPUT));
15411 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015412 return err;
15413 }
15414 }
15415 return 0;
15416}
15417
15418/* add playback controls for speaker and HP outputs */
15419/* Based on ALC880 version. But ALC861VD has separate,
15420 * different NIDs for mute/unmute switch and volume control */
15421static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15422 hda_nid_t pin, const char *pfx)
15423{
15424 hda_nid_t nid_v, nid_s;
15425 int err;
15426 char name[32];
15427
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015428 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015429 return 0;
15430
15431 if (alc880_is_fixed_pin(pin)) {
15432 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15433 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015434 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015435 spec->multiout.hp_nid = nid_v;
15436 else
15437 spec->multiout.extra_out_nid[0] = nid_v;
15438 /* control HP volume/switch on the output mixer amp */
15439 nid_v = alc861vd_idx_to_mixer_vol(
15440 alc880_fixed_pin_idx(pin));
15441 nid_s = alc861vd_idx_to_mixer_switch(
15442 alc880_fixed_pin_idx(pin));
15443
15444 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015445 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15446 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15447 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015448 return err;
15449 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015450 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15451 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15452 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015453 return err;
15454 } else if (alc880_is_multi_pin(pin)) {
15455 /* set manual connection */
15456 /* we have only a switch on HP-out PIN */
15457 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015458 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15459 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15460 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015461 return err;
15462 }
15463 return 0;
15464}
15465
15466/* parse the BIOS configuration and set up the alc_spec
15467 * return 1 if successful, 0 if the proper config is not found,
15468 * or a negative error code
15469 * Based on ALC880 version - had to change it to override
15470 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15471static int alc861vd_parse_auto_config(struct hda_codec *codec)
15472{
15473 struct alc_spec *spec = codec->spec;
15474 int err;
15475 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15476
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015477 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15478 alc861vd_ignore);
15479 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015480 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015481 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015482 return 0; /* can't find valid BIOS pin config */
15483
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015484 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15485 if (err < 0)
15486 return err;
15487 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15488 if (err < 0)
15489 return err;
15490 err = alc861vd_auto_create_extra_out(spec,
15491 spec->autocfg.speaker_pins[0],
15492 "Speaker");
15493 if (err < 0)
15494 return err;
15495 err = alc861vd_auto_create_extra_out(spec,
15496 spec->autocfg.hp_pins[0],
15497 "Headphone");
15498 if (err < 0)
15499 return err;
15500 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15501 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015502 return err;
15503
15504 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15505
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015506 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015507 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15508
Takashi Iwai603c4012008-07-30 15:01:44 +020015509 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015510 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015511
Takashi Iwaid88897e2008-10-31 15:01:37 +010015512 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015513
15514 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015515 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015516
Takashi Iwai776e1842007-08-29 15:07:11 +020015517 err = alc_auto_add_mic_boost(codec);
15518 if (err < 0)
15519 return err;
15520
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015521 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15522
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015523 return 1;
15524}
15525
15526/* additional initialization for auto-configuration model */
15527static void alc861vd_auto_init(struct hda_codec *codec)
15528{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015529 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015530 alc861vd_auto_init_multi_out(codec);
15531 alc861vd_auto_init_hp_out(codec);
15532 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015533 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015534 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015535 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015536}
15537
15538static int patch_alc861vd(struct hda_codec *codec)
15539{
15540 struct alc_spec *spec;
15541 int err, board_config;
15542
15543 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15544 if (spec == NULL)
15545 return -ENOMEM;
15546
15547 codec->spec = spec;
15548
15549 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15550 alc861vd_models,
15551 alc861vd_cfg_tbl);
15552
15553 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020015554 printk(KERN_INFO "hda_codec: Unknown model for %s, "
15555 "trying auto-probe from BIOS...\n", codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015556 board_config = ALC861VD_AUTO;
15557 }
15558
15559 if (board_config == ALC861VD_AUTO) {
15560 /* automatic parse from the BIOS config */
15561 err = alc861vd_parse_auto_config(codec);
15562 if (err < 0) {
15563 alc_free(codec);
15564 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015565 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015566 printk(KERN_INFO
15567 "hda_codec: Cannot set up configuration "
15568 "from BIOS. Using base mode...\n");
15569 board_config = ALC861VD_3ST;
15570 }
15571 }
15572
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015573 err = snd_hda_attach_beep_device(codec, 0x23);
15574 if (err < 0) {
15575 alc_free(codec);
15576 return err;
15577 }
15578
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015579 if (board_config != ALC861VD_AUTO)
15580 setup_preset(spec, &alc861vd_presets[board_config]);
15581
Kailang Yang2f893282008-05-27 12:14:47 +020015582 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015583 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015584 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015585 }
15586
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015587 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15588 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15589
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015590 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15591 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15592
Takashi Iwaidd704692009-08-11 08:45:11 +020015593 if (!spec->adc_nids) {
15594 spec->adc_nids = alc861vd_adc_nids;
15595 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15596 }
15597 if (!spec->capsrc_nids)
15598 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015599
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015600 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015601 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015602
Takashi Iwai2134ea42008-01-10 16:53:55 +010015603 spec->vmaster_nid = 0x02;
15604
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015605 codec->patch_ops = alc_patch_ops;
15606
15607 if (board_config == ALC861VD_AUTO)
15608 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015609#ifdef CONFIG_SND_HDA_POWER_SAVE
15610 if (!spec->loopback.amplist)
15611 spec->loopback.amplist = alc861vd_loopbacks;
15612#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015613 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015614
15615 return 0;
15616}
15617
15618/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015619 * ALC662 support
15620 *
15621 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15622 * configuration. Each pin widget can choose any input DACs and a mixer.
15623 * Each ADC is connected from a mixer of all inputs. This makes possible
15624 * 6-channel independent captures.
15625 *
15626 * In addition, an independent DAC for the multi-playback (not used in this
15627 * driver yet).
15628 */
15629#define ALC662_DIGOUT_NID 0x06
15630#define ALC662_DIGIN_NID 0x0a
15631
15632static hda_nid_t alc662_dac_nids[4] = {
15633 /* front, rear, clfe, rear_surr */
15634 0x02, 0x03, 0x04
15635};
15636
Kailang Yang622e84c2009-04-21 07:39:04 +020015637static hda_nid_t alc272_dac_nids[2] = {
15638 0x02, 0x03
15639};
15640
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015641static hda_nid_t alc662_adc_nids[1] = {
15642 /* ADC1-2 */
15643 0x09,
15644};
Takashi Iwaie1406342008-02-11 18:32:32 +010015645
Kailang Yang622e84c2009-04-21 07:39:04 +020015646static hda_nid_t alc272_adc_nids[1] = {
15647 /* ADC1-2 */
15648 0x08,
15649};
15650
Kailang Yang77a261b2008-02-19 11:38:05 +010015651static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015652static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15653
Takashi Iwaie1406342008-02-11 18:32:32 +010015654
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015655/* input MUX */
15656/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015657static struct hda_input_mux alc662_capture_source = {
15658 .num_items = 4,
15659 .items = {
15660 { "Mic", 0x0 },
15661 { "Front Mic", 0x1 },
15662 { "Line", 0x2 },
15663 { "CD", 0x4 },
15664 },
15665};
15666
15667static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15668 .num_items = 2,
15669 .items = {
15670 { "Mic", 0x1 },
15671 { "Line", 0x2 },
15672 },
15673};
Kailang Yang291702f2007-10-16 14:28:03 +020015674
15675static struct hda_input_mux alc662_eeepc_capture_source = {
15676 .num_items = 2,
15677 .items = {
15678 { "i-Mic", 0x1 },
15679 { "e-Mic", 0x0 },
15680 },
15681};
15682
Kailang Yang6dda9f42008-05-27 12:05:31 +020015683static struct hda_input_mux alc663_capture_source = {
15684 .num_items = 3,
15685 .items = {
15686 { "Mic", 0x0 },
15687 { "Front Mic", 0x1 },
15688 { "Line", 0x2 },
15689 },
15690};
15691
15692static struct hda_input_mux alc663_m51va_capture_source = {
15693 .num_items = 2,
15694 .items = {
15695 { "Ext-Mic", 0x0 },
15696 { "D-Mic", 0x9 },
15697 },
15698};
15699
Chris Pockelé9541ba12009-05-12 08:08:53 +020015700#if 1 /* set to 0 for testing other input sources below */
15701static struct hda_input_mux alc272_nc10_capture_source = {
15702 .num_items = 2,
15703 .items = {
15704 { "Autoselect Mic", 0x0 },
15705 { "Internal Mic", 0x1 },
15706 },
15707};
15708#else
15709static struct hda_input_mux alc272_nc10_capture_source = {
15710 .num_items = 16,
15711 .items = {
15712 { "Autoselect Mic", 0x0 },
15713 { "Internal Mic", 0x1 },
15714 { "In-0x02", 0x2 },
15715 { "In-0x03", 0x3 },
15716 { "In-0x04", 0x4 },
15717 { "In-0x05", 0x5 },
15718 { "In-0x06", 0x6 },
15719 { "In-0x07", 0x7 },
15720 { "In-0x08", 0x8 },
15721 { "In-0x09", 0x9 },
15722 { "In-0x0a", 0x0a },
15723 { "In-0x0b", 0x0b },
15724 { "In-0x0c", 0x0c },
15725 { "In-0x0d", 0x0d },
15726 { "In-0x0e", 0x0e },
15727 { "In-0x0f", 0x0f },
15728 },
15729};
15730#endif
15731
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015732/*
15733 * 2ch mode
15734 */
15735static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15736 { 2, NULL }
15737};
15738
15739/*
15740 * 2ch mode
15741 */
15742static struct hda_verb alc662_3ST_ch2_init[] = {
15743 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15744 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15745 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15746 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15747 { } /* end */
15748};
15749
15750/*
15751 * 6ch mode
15752 */
15753static struct hda_verb alc662_3ST_ch6_init[] = {
15754 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15755 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15756 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15757 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15758 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15759 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15760 { } /* end */
15761};
15762
15763static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15764 { 2, alc662_3ST_ch2_init },
15765 { 6, alc662_3ST_ch6_init },
15766};
15767
15768/*
15769 * 2ch mode
15770 */
15771static struct hda_verb alc662_sixstack_ch6_init[] = {
15772 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15773 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15774 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15775 { } /* end */
15776};
15777
15778/*
15779 * 6ch mode
15780 */
15781static struct hda_verb alc662_sixstack_ch8_init[] = {
15782 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15783 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15784 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15785 { } /* end */
15786};
15787
15788static struct hda_channel_mode alc662_5stack_modes[2] = {
15789 { 2, alc662_sixstack_ch6_init },
15790 { 6, alc662_sixstack_ch8_init },
15791};
15792
15793/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15794 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15795 */
15796
15797static struct snd_kcontrol_new alc662_base_mixer[] = {
15798 /* output mixer control */
15799 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015800 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015801 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015802 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015803 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15804 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015805 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15806 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015807 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15808
15809 /*Input mixer control */
15810 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15811 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15812 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15813 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15814 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15815 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15816 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15817 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015818 { } /* end */
15819};
15820
15821static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15822 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015823 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015824 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15825 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15826 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15827 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15828 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15829 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15830 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15831 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15832 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015833 { } /* end */
15834};
15835
15836static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15837 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015838 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015839 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015840 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015841 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15842 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015843 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15844 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015845 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15846 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15847 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15848 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15849 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15850 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15851 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15852 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15853 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015854 { } /* end */
15855};
15856
15857static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15858 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15859 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015860 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15861 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015862 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15863 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15864 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15865 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15866 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015867 { } /* end */
15868};
15869
Kailang Yang291702f2007-10-16 14:28:03 +020015870static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015871 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15872 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015873
15874 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15875 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15876 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15877
15878 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15879 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15880 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15881 { } /* end */
15882};
15883
Kailang Yang8c427222008-01-10 13:03:59 +010015884static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015885 ALC262_HIPPO_MASTER_SWITCH,
15886 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015887 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015888 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15889 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015890 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15891 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15892 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15893 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15894 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15895 { } /* end */
15896};
15897
Kailang Yangf1d4e282008-08-26 14:03:29 +020015898static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15899 .ops = &snd_hda_bind_vol,
15900 .values = {
15901 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15902 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15903 0
15904 },
15905};
15906
15907static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15908 .ops = &snd_hda_bind_sw,
15909 .values = {
15910 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15911 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15912 0
15913 },
15914};
15915
Kailang Yang6dda9f42008-05-27 12:05:31 +020015916static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015917 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15918 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15920 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15921 { } /* end */
15922};
15923
15924static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15925 .ops = &snd_hda_bind_sw,
15926 .values = {
15927 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15928 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15929 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15930 0
15931 },
15932};
15933
15934static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15935 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15936 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15939 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15940 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15941
15942 { } /* end */
15943};
15944
15945static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15946 .ops = &snd_hda_bind_sw,
15947 .values = {
15948 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15949 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15950 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15951 0
15952 },
15953};
15954
15955static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15956 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15957 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15958 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15959 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15960 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15961 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15962 { } /* end */
15963};
15964
15965static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015966 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15967 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15971 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15972 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15973 { } /* end */
15974};
15975
15976static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15977 .ops = &snd_hda_bind_vol,
15978 .values = {
15979 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15980 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15981 0
15982 },
15983};
15984
15985static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15986 .ops = &snd_hda_bind_sw,
15987 .values = {
15988 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15989 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15990 0
15991 },
15992};
15993
15994static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15995 HDA_BIND_VOL("Master Playback Volume",
15996 &alc663_asus_two_bind_master_vol),
15997 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15998 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015999 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16001 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016002 { } /* end */
16003};
16004
16005static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16006 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16007 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16008 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16009 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16010 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16011 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016012 { } /* end */
16013};
16014
16015static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16016 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16017 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16018 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16019 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16020 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16021
16022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16024 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16025 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16026 { } /* end */
16027};
16028
16029static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16030 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16031 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16032 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16033
16034 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16035 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16036 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16037 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16038 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16039 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16040 { } /* end */
16041};
16042
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016043static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16044 {
16045 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16046 .name = "Channel Mode",
16047 .info = alc_ch_mode_info,
16048 .get = alc_ch_mode_get,
16049 .put = alc_ch_mode_put,
16050 },
16051 { } /* end */
16052};
16053
16054static struct hda_verb alc662_init_verbs[] = {
16055 /* ADC: mute amp left and right */
16056 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16057 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16058 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16059
Takashi Iwaicb53c622007-08-10 17:21:45 +020016060 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016065
Kailang Yangb60dd392007-09-20 12:50:29 +020016066 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16068 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16069 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16070 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16071 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016072
16073 /* Front Pin: output 0 (0x0c) */
16074 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16075 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16076
16077 /* Rear Pin: output 1 (0x0d) */
16078 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16079 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16080
16081 /* CLFE Pin: output 2 (0x0e) */
16082 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16083 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16084
16085 /* Mic (rear) pin: input vref at 80% */
16086 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16087 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16088 /* Front Mic pin: input vref at 80% */
16089 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16090 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16091 /* Line In pin: input */
16092 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16093 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16094 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16095 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16096 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16097 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16098 /* CD pin widget for input */
16099 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16100
16101 /* FIXME: use matrix-type input source selection */
16102 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16103 /* Input mixer */
16104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016105 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016106
16107 /* always trun on EAPD */
16108 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16109 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16110
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016111 { }
16112};
16113
16114static struct hda_verb alc662_sue_init_verbs[] = {
16115 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16116 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016117 {}
16118};
16119
16120static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16121 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16122 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16123 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016124};
16125
Kailang Yang8c427222008-01-10 13:03:59 +010016126/* Set Unsolicited Event*/
16127static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16128 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16129 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16130 {}
16131};
16132
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016133/*
16134 * generic initialization of ADC, input mixers and output mixers
16135 */
16136static struct hda_verb alc662_auto_init_verbs[] = {
16137 /*
16138 * Unmute ADC and set the default input to mic-in
16139 */
16140 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16141 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16142
16143 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16144 * mixer widget
16145 * Note: PASD motherboards uses the Line In 2 as the input for front
16146 * panel mic (mic 2)
16147 */
16148 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016149 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16151 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16152 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16153 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016154
16155 /*
16156 * Set up output mixers (0x0c - 0x0f)
16157 */
16158 /* set vol=0 to output mixers */
16159 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16160 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16161 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16162
16163 /* set up input amps for analog loopback */
16164 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016165 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16166 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16167 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16168 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16169 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16170 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016171
16172
16173 /* FIXME: use matrix-type input source selection */
16174 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16175 /* Input mixer */
16176 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016177 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016178 { }
16179};
16180
Takashi Iwai24fb9172008-09-02 14:48:20 +020016181/* additional verbs for ALC663 */
16182static struct hda_verb alc663_auto_init_verbs[] = {
16183 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16184 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16185 { }
16186};
16187
Kailang Yang6dda9f42008-05-27 12:05:31 +020016188static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016189 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16190 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016191 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16192 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016193 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16194 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016196 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16197 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16198 {}
16199};
16200
Kailang Yangf1d4e282008-08-26 14:03:29 +020016201static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16202 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16203 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16204 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16205 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16206 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16207 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16208 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16209 {}
16210};
16211
16212static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16213 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16214 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16215 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16216 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16219 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16220 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16221 {}
16222};
16223
16224static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16225 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16226 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16227 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16228 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16229 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16230 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16231 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16232 {}
16233};
16234
16235static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16236 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16237 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16238 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16239 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16240 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16242 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16243 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16244 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16245 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16246 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16247 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16248 {}
16249};
16250
16251static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16252 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16253 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16254 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16255 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16258 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16259 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16261 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16262 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16263 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16264 {}
16265};
16266
Kailang Yang6dda9f42008-05-27 12:05:31 +020016267static struct hda_verb alc663_g71v_init_verbs[] = {
16268 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16269 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16270 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16271
16272 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16273 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16274 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16275
16276 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16277 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16278 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16279 {}
16280};
16281
16282static struct hda_verb alc663_g50v_init_verbs[] = {
16283 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16284 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16285 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16286
16287 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16288 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16289 {}
16290};
16291
Kailang Yangf1d4e282008-08-26 14:03:29 +020016292static struct hda_verb alc662_ecs_init_verbs[] = {
16293 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16294 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16295 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16296 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16297 {}
16298};
16299
Kailang Yang622e84c2009-04-21 07:39:04 +020016300static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16301 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16302 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16303 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16304 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16305 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16306 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16307 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16308 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16309 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16310 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16311 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16312 {}
16313};
16314
16315static struct hda_verb alc272_dell_init_verbs[] = {
16316 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16317 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16318 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16319 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16320 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16321 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16322 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16323 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16324 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16325 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16326 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16327 {}
16328};
16329
Kailang Yangf1d4e282008-08-26 14:03:29 +020016330static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16331 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16332 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16333 { } /* end */
16334};
16335
Kailang Yang622e84c2009-04-21 07:39:04 +020016336static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16337 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16338 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16339 { } /* end */
16340};
16341
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016342static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16343{
16344 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016345 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016346
16347 present = snd_hda_codec_read(codec, 0x14, 0,
16348 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016349 bits = present ? HDA_AMP_MUTE : 0;
16350 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16351 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016352}
16353
16354static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16355{
16356 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016357 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016358
16359 present = snd_hda_codec_read(codec, 0x1b, 0,
16360 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016361 bits = present ? HDA_AMP_MUTE : 0;
16362 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16363 HDA_AMP_MUTE, bits);
16364 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16365 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016366}
16367
16368static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16369 unsigned int res)
16370{
16371 if ((res >> 26) == ALC880_HP_EVENT)
16372 alc662_lenovo_101e_all_automute(codec);
16373 if ((res >> 26) == ALC880_FRONT_EVENT)
16374 alc662_lenovo_101e_ispeaker_automute(codec);
16375}
16376
Kailang Yang291702f2007-10-16 14:28:03 +020016377static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16378{
16379 unsigned int present;
16380
16381 present = snd_hda_codec_read(codec, 0x18, 0,
16382 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16383 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16384 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16385 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16386 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16387 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16388 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16389 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16390 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16391}
16392
16393/* unsolicited event for HP jack sensing */
16394static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16395 unsigned int res)
16396{
Kailang Yang291702f2007-10-16 14:28:03 +020016397 if ((res >> 26) == ALC880_MIC_EVENT)
16398 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016399 else
16400 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016401}
16402
16403static void alc662_eeepc_inithook(struct hda_codec *codec)
16404{
Takashi Iwai42171c12009-05-08 14:11:43 +020016405 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020016406 alc662_eeepc_mic_automute(codec);
16407}
16408
Kailang Yang8c427222008-01-10 13:03:59 +010016409static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16410{
Takashi Iwai42171c12009-05-08 14:11:43 +020016411 struct alc_spec *spec = codec->spec;
16412
16413 spec->autocfg.hp_pins[0] = 0x14;
16414 spec->autocfg.speaker_pins[0] = 0x1b;
16415 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010016416}
16417
Kailang Yang6dda9f42008-05-27 12:05:31 +020016418static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16419{
16420 unsigned int present;
16421 unsigned char bits;
16422
16423 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016424 AC_VERB_GET_PIN_SENSE, 0)
16425 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016426 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016427 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16428 AMP_IN_MUTE(0), bits);
16429 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16430 AMP_IN_MUTE(0), bits);
16431}
16432
16433static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16434{
16435 unsigned int present;
16436 unsigned char bits;
16437
16438 present = snd_hda_codec_read(codec, 0x21, 0,
16439 AC_VERB_GET_PIN_SENSE, 0)
16440 & AC_PINSENSE_PRESENCE;
16441 bits = present ? HDA_AMP_MUTE : 0;
16442 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16443 AMP_IN_MUTE(0), bits);
16444 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16445 AMP_IN_MUTE(0), bits);
16446 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16447 AMP_IN_MUTE(0), bits);
16448 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16449 AMP_IN_MUTE(0), bits);
16450}
16451
16452static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16453{
16454 unsigned int present;
16455 unsigned char bits;
16456
16457 present = snd_hda_codec_read(codec, 0x15, 0,
16458 AC_VERB_GET_PIN_SENSE, 0)
16459 & AC_PINSENSE_PRESENCE;
16460 bits = present ? HDA_AMP_MUTE : 0;
16461 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16462 AMP_IN_MUTE(0), bits);
16463 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16464 AMP_IN_MUTE(0), bits);
16465 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16466 AMP_IN_MUTE(0), bits);
16467 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16468 AMP_IN_MUTE(0), bits);
16469}
16470
16471static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16472{
16473 unsigned int present;
16474 unsigned char bits;
16475
16476 present = snd_hda_codec_read(codec, 0x1b, 0,
16477 AC_VERB_GET_PIN_SENSE, 0)
16478 & AC_PINSENSE_PRESENCE;
16479 bits = present ? 0 : PIN_OUT;
16480 snd_hda_codec_write(codec, 0x14, 0,
16481 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16482}
16483
16484static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16485{
16486 unsigned int present1, present2;
16487
16488 present1 = snd_hda_codec_read(codec, 0x21, 0,
16489 AC_VERB_GET_PIN_SENSE, 0)
16490 & AC_PINSENSE_PRESENCE;
16491 present2 = snd_hda_codec_read(codec, 0x15, 0,
16492 AC_VERB_GET_PIN_SENSE, 0)
16493 & AC_PINSENSE_PRESENCE;
16494
16495 if (present1 || present2) {
16496 snd_hda_codec_write_cache(codec, 0x14, 0,
16497 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16498 } else {
16499 snd_hda_codec_write_cache(codec, 0x14, 0,
16500 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16501 }
16502}
16503
16504static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16505{
16506 unsigned int present1, present2;
16507
16508 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16509 AC_VERB_GET_PIN_SENSE, 0)
16510 & AC_PINSENSE_PRESENCE;
16511 present2 = snd_hda_codec_read(codec, 0x15, 0,
16512 AC_VERB_GET_PIN_SENSE, 0)
16513 & AC_PINSENSE_PRESENCE;
16514
16515 if (present1 || present2) {
16516 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16517 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16518 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16519 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16520 } else {
16521 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16522 AMP_IN_MUTE(0), 0);
16523 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16524 AMP_IN_MUTE(0), 0);
16525 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016526}
16527
16528static void alc663_m51va_mic_automute(struct hda_codec *codec)
16529{
16530 unsigned int present;
16531
16532 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016533 AC_VERB_GET_PIN_SENSE, 0)
16534 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016535 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016536 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016537 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016538 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016539 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016540 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016541 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016542 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016543}
16544
16545static void alc663_m51va_unsol_event(struct hda_codec *codec,
16546 unsigned int res)
16547{
16548 switch (res >> 26) {
16549 case ALC880_HP_EVENT:
16550 alc663_m51va_speaker_automute(codec);
16551 break;
16552 case ALC880_MIC_EVENT:
16553 alc663_m51va_mic_automute(codec);
16554 break;
16555 }
16556}
16557
16558static void alc663_m51va_inithook(struct hda_codec *codec)
16559{
16560 alc663_m51va_speaker_automute(codec);
16561 alc663_m51va_mic_automute(codec);
16562}
16563
Kailang Yangf1d4e282008-08-26 14:03:29 +020016564/* ***************** Mode1 ******************************/
16565static void alc663_mode1_unsol_event(struct hda_codec *codec,
16566 unsigned int res)
16567{
16568 switch (res >> 26) {
16569 case ALC880_HP_EVENT:
16570 alc663_m51va_speaker_automute(codec);
16571 break;
16572 case ALC880_MIC_EVENT:
16573 alc662_eeepc_mic_automute(codec);
16574 break;
16575 }
16576}
16577
16578static void alc663_mode1_inithook(struct hda_codec *codec)
16579{
16580 alc663_m51va_speaker_automute(codec);
16581 alc662_eeepc_mic_automute(codec);
16582}
16583/* ***************** Mode2 ******************************/
16584static void alc662_mode2_unsol_event(struct hda_codec *codec,
16585 unsigned int res)
16586{
16587 switch (res >> 26) {
16588 case ALC880_HP_EVENT:
16589 alc662_f5z_speaker_automute(codec);
16590 break;
16591 case ALC880_MIC_EVENT:
16592 alc662_eeepc_mic_automute(codec);
16593 break;
16594 }
16595}
16596
16597static void alc662_mode2_inithook(struct hda_codec *codec)
16598{
16599 alc662_f5z_speaker_automute(codec);
16600 alc662_eeepc_mic_automute(codec);
16601}
16602/* ***************** Mode3 ******************************/
16603static void alc663_mode3_unsol_event(struct hda_codec *codec,
16604 unsigned int res)
16605{
16606 switch (res >> 26) {
16607 case ALC880_HP_EVENT:
16608 alc663_two_hp_m1_speaker_automute(codec);
16609 break;
16610 case ALC880_MIC_EVENT:
16611 alc662_eeepc_mic_automute(codec);
16612 break;
16613 }
16614}
16615
16616static void alc663_mode3_inithook(struct hda_codec *codec)
16617{
16618 alc663_two_hp_m1_speaker_automute(codec);
16619 alc662_eeepc_mic_automute(codec);
16620}
16621/* ***************** Mode4 ******************************/
16622static void alc663_mode4_unsol_event(struct hda_codec *codec,
16623 unsigned int res)
16624{
16625 switch (res >> 26) {
16626 case ALC880_HP_EVENT:
16627 alc663_21jd_two_speaker_automute(codec);
16628 break;
16629 case ALC880_MIC_EVENT:
16630 alc662_eeepc_mic_automute(codec);
16631 break;
16632 }
16633}
16634
16635static void alc663_mode4_inithook(struct hda_codec *codec)
16636{
16637 alc663_21jd_two_speaker_automute(codec);
16638 alc662_eeepc_mic_automute(codec);
16639}
16640/* ***************** Mode5 ******************************/
16641static void alc663_mode5_unsol_event(struct hda_codec *codec,
16642 unsigned int res)
16643{
16644 switch (res >> 26) {
16645 case ALC880_HP_EVENT:
16646 alc663_15jd_two_speaker_automute(codec);
16647 break;
16648 case ALC880_MIC_EVENT:
16649 alc662_eeepc_mic_automute(codec);
16650 break;
16651 }
16652}
16653
16654static void alc663_mode5_inithook(struct hda_codec *codec)
16655{
16656 alc663_15jd_two_speaker_automute(codec);
16657 alc662_eeepc_mic_automute(codec);
16658}
16659/* ***************** Mode6 ******************************/
16660static void alc663_mode6_unsol_event(struct hda_codec *codec,
16661 unsigned int res)
16662{
16663 switch (res >> 26) {
16664 case ALC880_HP_EVENT:
16665 alc663_two_hp_m2_speaker_automute(codec);
16666 break;
16667 case ALC880_MIC_EVENT:
16668 alc662_eeepc_mic_automute(codec);
16669 break;
16670 }
16671}
16672
16673static void alc663_mode6_inithook(struct hda_codec *codec)
16674{
16675 alc663_two_hp_m2_speaker_automute(codec);
16676 alc662_eeepc_mic_automute(codec);
16677}
16678
Kailang Yang6dda9f42008-05-27 12:05:31 +020016679static void alc663_g71v_hp_automute(struct hda_codec *codec)
16680{
16681 unsigned int present;
16682 unsigned char bits;
16683
16684 present = snd_hda_codec_read(codec, 0x21, 0,
16685 AC_VERB_GET_PIN_SENSE, 0)
16686 & AC_PINSENSE_PRESENCE;
16687 bits = present ? HDA_AMP_MUTE : 0;
16688 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16689 HDA_AMP_MUTE, bits);
16690 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16691 HDA_AMP_MUTE, bits);
16692}
16693
16694static void alc663_g71v_front_automute(struct hda_codec *codec)
16695{
16696 unsigned int present;
16697 unsigned char bits;
16698
16699 present = snd_hda_codec_read(codec, 0x15, 0,
16700 AC_VERB_GET_PIN_SENSE, 0)
16701 & AC_PINSENSE_PRESENCE;
16702 bits = present ? HDA_AMP_MUTE : 0;
16703 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16704 HDA_AMP_MUTE, bits);
16705}
16706
16707static void alc663_g71v_unsol_event(struct hda_codec *codec,
16708 unsigned int res)
16709{
16710 switch (res >> 26) {
16711 case ALC880_HP_EVENT:
16712 alc663_g71v_hp_automute(codec);
16713 break;
16714 case ALC880_FRONT_EVENT:
16715 alc663_g71v_front_automute(codec);
16716 break;
16717 case ALC880_MIC_EVENT:
16718 alc662_eeepc_mic_automute(codec);
16719 break;
16720 }
16721}
16722
16723static void alc663_g71v_inithook(struct hda_codec *codec)
16724{
16725 alc663_g71v_front_automute(codec);
16726 alc663_g71v_hp_automute(codec);
16727 alc662_eeepc_mic_automute(codec);
16728}
16729
16730static void alc663_g50v_unsol_event(struct hda_codec *codec,
16731 unsigned int res)
16732{
16733 switch (res >> 26) {
16734 case ALC880_HP_EVENT:
16735 alc663_m51va_speaker_automute(codec);
16736 break;
16737 case ALC880_MIC_EVENT:
16738 alc662_eeepc_mic_automute(codec);
16739 break;
16740 }
16741}
16742
16743static void alc663_g50v_inithook(struct hda_codec *codec)
16744{
16745 alc663_m51va_speaker_automute(codec);
16746 alc662_eeepc_mic_automute(codec);
16747}
16748
Kailang Yangf1d4e282008-08-26 14:03:29 +020016749static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16750 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016751 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016752
16753 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16754 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16755 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16756
16757 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16758 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16759 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16760 { } /* end */
16761};
16762
Chris Pockelé9541ba12009-05-12 08:08:53 +020016763static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16764 /* Master Playback automatically created from Speaker and Headphone */
16765 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16766 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16767 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16768 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16769
16770 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16771 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16772 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16773
16774 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16775 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16776 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16777 { } /* end */
16778};
16779
Takashi Iwaicb53c622007-08-10 17:21:45 +020016780#ifdef CONFIG_SND_HDA_POWER_SAVE
16781#define alc662_loopbacks alc880_loopbacks
16782#endif
16783
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016784
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016785/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016786#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16787#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16788#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16789#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16790
16791/*
16792 * configuration and preset
16793 */
16794static const char *alc662_models[ALC662_MODEL_LAST] = {
16795 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16796 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16797 [ALC662_3ST_6ch] = "3stack-6ch",
16798 [ALC662_5ST_DIG] = "6stack-dig",
16799 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016800 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016801 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016802 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016803 [ALC663_ASUS_M51VA] = "m51va",
16804 [ALC663_ASUS_G71V] = "g71v",
16805 [ALC663_ASUS_H13] = "h13",
16806 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016807 [ALC663_ASUS_MODE1] = "asus-mode1",
16808 [ALC662_ASUS_MODE2] = "asus-mode2",
16809 [ALC663_ASUS_MODE3] = "asus-mode3",
16810 [ALC663_ASUS_MODE4] = "asus-mode4",
16811 [ALC663_ASUS_MODE5] = "asus-mode5",
16812 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016813 [ALC272_DELL] = "dell",
16814 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016815 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016816 [ALC662_AUTO] = "auto",
16817};
16818
16819static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016820 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016821 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16822 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016823 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16824 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16825 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16826 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16827 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16828 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16829 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16830 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16831 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16832 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16833 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16834 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016835 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16836 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16837 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016838 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16839 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16840 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16841 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016842 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016843 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16844 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016845 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016846 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16847 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16848 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016849 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16850 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16851 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016852 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16853 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16854 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016855 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016856 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16857 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016858 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016859 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016860 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016861 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16862 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16863 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016864 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016865 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16866 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016867 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016868 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016869 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016870 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016871 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16872 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016873 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016874 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16875 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016876 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016877 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016878 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016879 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016880 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016881 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16882 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016883 {}
16884};
16885
16886static struct alc_config_preset alc662_presets[] = {
16887 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016888 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016889 .init_verbs = { alc662_init_verbs },
16890 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16891 .dac_nids = alc662_dac_nids,
16892 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016893 .dig_in_nid = ALC662_DIGIN_NID,
16894 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16895 .channel_mode = alc662_3ST_2ch_modes,
16896 .input_mux = &alc662_capture_source,
16897 },
16898 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016899 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016900 .init_verbs = { alc662_init_verbs },
16901 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16902 .dac_nids = alc662_dac_nids,
16903 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016904 .dig_in_nid = ALC662_DIGIN_NID,
16905 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16906 .channel_mode = alc662_3ST_6ch_modes,
16907 .need_dac_fix = 1,
16908 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016909 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016910 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016911 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016912 .init_verbs = { alc662_init_verbs },
16913 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16914 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016915 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16916 .channel_mode = alc662_3ST_6ch_modes,
16917 .need_dac_fix = 1,
16918 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016919 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016920 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016921 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016922 .init_verbs = { alc662_init_verbs },
16923 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16924 .dac_nids = alc662_dac_nids,
16925 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016926 .dig_in_nid = ALC662_DIGIN_NID,
16927 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16928 .channel_mode = alc662_5stack_modes,
16929 .input_mux = &alc662_capture_source,
16930 },
16931 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016932 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016933 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16934 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16935 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016936 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16937 .channel_mode = alc662_3ST_2ch_modes,
16938 .input_mux = &alc662_lenovo_101e_capture_source,
16939 .unsol_event = alc662_lenovo_101e_unsol_event,
16940 .init_hook = alc662_lenovo_101e_all_automute,
16941 },
Kailang Yang291702f2007-10-16 14:28:03 +020016942 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016943 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016944 .init_verbs = { alc662_init_verbs,
16945 alc662_eeepc_sue_init_verbs },
16946 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16947 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016948 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16949 .channel_mode = alc662_3ST_2ch_modes,
16950 .input_mux = &alc662_eeepc_capture_source,
16951 .unsol_event = alc662_eeepc_unsol_event,
16952 .init_hook = alc662_eeepc_inithook,
16953 },
Kailang Yang8c427222008-01-10 13:03:59 +010016954 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016955 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016956 alc662_chmode_mixer },
16957 .init_verbs = { alc662_init_verbs,
16958 alc662_eeepc_ep20_sue_init_verbs },
16959 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16960 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016961 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16962 .channel_mode = alc662_3ST_6ch_modes,
16963 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016964 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016965 .init_hook = alc662_eeepc_ep20_inithook,
16966 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016967 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016968 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016969 .init_verbs = { alc662_init_verbs,
16970 alc662_ecs_init_verbs },
16971 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16972 .dac_nids = alc662_dac_nids,
16973 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16974 .channel_mode = alc662_3ST_2ch_modes,
16975 .input_mux = &alc662_eeepc_capture_source,
16976 .unsol_event = alc662_eeepc_unsol_event,
16977 .init_hook = alc662_eeepc_inithook,
16978 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016979 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016980 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016981 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16982 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16983 .dac_nids = alc662_dac_nids,
16984 .dig_out_nid = ALC662_DIGOUT_NID,
16985 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16986 .channel_mode = alc662_3ST_2ch_modes,
16987 .input_mux = &alc663_m51va_capture_source,
16988 .unsol_event = alc663_m51va_unsol_event,
16989 .init_hook = alc663_m51va_inithook,
16990 },
16991 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016992 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016993 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16994 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16995 .dac_nids = alc662_dac_nids,
16996 .dig_out_nid = ALC662_DIGOUT_NID,
16997 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16998 .channel_mode = alc662_3ST_2ch_modes,
16999 .input_mux = &alc662_eeepc_capture_source,
17000 .unsol_event = alc663_g71v_unsol_event,
17001 .init_hook = alc663_g71v_inithook,
17002 },
17003 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017004 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017005 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17006 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17007 .dac_nids = alc662_dac_nids,
17008 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17009 .channel_mode = alc662_3ST_2ch_modes,
17010 .input_mux = &alc663_m51va_capture_source,
17011 .unsol_event = alc663_m51va_unsol_event,
17012 .init_hook = alc663_m51va_inithook,
17013 },
17014 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017015 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017016 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17017 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17018 .dac_nids = alc662_dac_nids,
17019 .dig_out_nid = ALC662_DIGOUT_NID,
17020 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17021 .channel_mode = alc662_3ST_6ch_modes,
17022 .input_mux = &alc663_capture_source,
17023 .unsol_event = alc663_g50v_unsol_event,
17024 .init_hook = alc663_g50v_inithook,
17025 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017026 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017027 .mixers = { alc663_m51va_mixer },
17028 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017029 .init_verbs = { alc662_init_verbs,
17030 alc663_21jd_amic_init_verbs },
17031 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17032 .hp_nid = 0x03,
17033 .dac_nids = alc662_dac_nids,
17034 .dig_out_nid = ALC662_DIGOUT_NID,
17035 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17036 .channel_mode = alc662_3ST_2ch_modes,
17037 .input_mux = &alc662_eeepc_capture_source,
17038 .unsol_event = alc663_mode1_unsol_event,
17039 .init_hook = alc663_mode1_inithook,
17040 },
17041 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017042 .mixers = { alc662_1bjd_mixer },
17043 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017044 .init_verbs = { alc662_init_verbs,
17045 alc662_1bjd_amic_init_verbs },
17046 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17047 .dac_nids = alc662_dac_nids,
17048 .dig_out_nid = ALC662_DIGOUT_NID,
17049 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17050 .channel_mode = alc662_3ST_2ch_modes,
17051 .input_mux = &alc662_eeepc_capture_source,
17052 .unsol_event = alc662_mode2_unsol_event,
17053 .init_hook = alc662_mode2_inithook,
17054 },
17055 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017056 .mixers = { alc663_two_hp_m1_mixer },
17057 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017058 .init_verbs = { alc662_init_verbs,
17059 alc663_two_hp_amic_m1_init_verbs },
17060 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17061 .hp_nid = 0x03,
17062 .dac_nids = alc662_dac_nids,
17063 .dig_out_nid = ALC662_DIGOUT_NID,
17064 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17065 .channel_mode = alc662_3ST_2ch_modes,
17066 .input_mux = &alc662_eeepc_capture_source,
17067 .unsol_event = alc663_mode3_unsol_event,
17068 .init_hook = alc663_mode3_inithook,
17069 },
17070 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017071 .mixers = { alc663_asus_21jd_clfe_mixer },
17072 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017073 .init_verbs = { alc662_init_verbs,
17074 alc663_21jd_amic_init_verbs},
17075 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17076 .hp_nid = 0x03,
17077 .dac_nids = alc662_dac_nids,
17078 .dig_out_nid = ALC662_DIGOUT_NID,
17079 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17080 .channel_mode = alc662_3ST_2ch_modes,
17081 .input_mux = &alc662_eeepc_capture_source,
17082 .unsol_event = alc663_mode4_unsol_event,
17083 .init_hook = alc663_mode4_inithook,
17084 },
17085 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017086 .mixers = { alc663_asus_15jd_clfe_mixer },
17087 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017088 .init_verbs = { alc662_init_verbs,
17089 alc663_15jd_amic_init_verbs },
17090 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17091 .hp_nid = 0x03,
17092 .dac_nids = alc662_dac_nids,
17093 .dig_out_nid = ALC662_DIGOUT_NID,
17094 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17095 .channel_mode = alc662_3ST_2ch_modes,
17096 .input_mux = &alc662_eeepc_capture_source,
17097 .unsol_event = alc663_mode5_unsol_event,
17098 .init_hook = alc663_mode5_inithook,
17099 },
17100 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017101 .mixers = { alc663_two_hp_m2_mixer },
17102 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017103 .init_verbs = { alc662_init_verbs,
17104 alc663_two_hp_amic_m2_init_verbs },
17105 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17106 .hp_nid = 0x03,
17107 .dac_nids = alc662_dac_nids,
17108 .dig_out_nid = ALC662_DIGOUT_NID,
17109 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17110 .channel_mode = alc662_3ST_2ch_modes,
17111 .input_mux = &alc662_eeepc_capture_source,
17112 .unsol_event = alc663_mode6_unsol_event,
17113 .init_hook = alc663_mode6_inithook,
17114 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017115 [ALC272_DELL] = {
17116 .mixers = { alc663_m51va_mixer },
17117 .cap_mixer = alc272_auto_capture_mixer,
17118 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17119 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17120 .dac_nids = alc662_dac_nids,
17121 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17122 .adc_nids = alc272_adc_nids,
17123 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17124 .capsrc_nids = alc272_capsrc_nids,
17125 .channel_mode = alc662_3ST_2ch_modes,
17126 .input_mux = &alc663_m51va_capture_source,
17127 .unsol_event = alc663_m51va_unsol_event,
17128 .init_hook = alc663_m51va_inithook,
17129 },
17130 [ALC272_DELL_ZM1] = {
17131 .mixers = { alc663_m51va_mixer },
17132 .cap_mixer = alc662_auto_capture_mixer,
17133 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17134 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17135 .dac_nids = alc662_dac_nids,
17136 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17137 .adc_nids = alc662_adc_nids,
17138 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
17139 .capsrc_nids = alc662_capsrc_nids,
17140 .channel_mode = alc662_3ST_2ch_modes,
17141 .input_mux = &alc663_m51va_capture_source,
17142 .unsol_event = alc663_m51va_unsol_event,
17143 .init_hook = alc663_m51va_inithook,
17144 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017145 [ALC272_SAMSUNG_NC10] = {
17146 .mixers = { alc272_nc10_mixer },
17147 .init_verbs = { alc662_init_verbs,
17148 alc663_21jd_amic_init_verbs },
17149 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17150 .dac_nids = alc272_dac_nids,
17151 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17152 .channel_mode = alc662_3ST_2ch_modes,
17153 .input_mux = &alc272_nc10_capture_source,
17154 .unsol_event = alc663_mode4_unsol_event,
17155 .init_hook = alc663_mode4_inithook,
17156 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017157};
17158
17159
17160/*
17161 * BIOS auto configuration
17162 */
17163
17164/* add playback controls from the parsed DAC table */
17165static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17166 const struct auto_pin_cfg *cfg)
17167{
17168 char name[32];
17169 static const char *chname[4] = {
17170 "Front", "Surround", NULL /*CLFE*/, "Side"
17171 };
17172 hda_nid_t nid;
17173 int i, err;
17174
17175 for (i = 0; i < cfg->line_outs; i++) {
17176 if (!spec->multiout.dac_nids[i])
17177 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020017178 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017179 if (i == 2) {
17180 /* Center/LFE */
17181 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17182 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017183 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17184 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017185 if (err < 0)
17186 return err;
17187 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17188 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017189 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17190 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017191 if (err < 0)
17192 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017193 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017194 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017195 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017196 HDA_INPUT));
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 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017201 HDA_COMPOSE_AMP_VAL(0x0e, 2, 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;
17205 } else {
17206 sprintf(name, "%s Playback Volume", chname[i]);
17207 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017208 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17209 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017210 if (err < 0)
17211 return err;
17212 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017213 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17214 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17215 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017216 if (err < 0)
17217 return err;
17218 }
17219 }
17220 return 0;
17221}
17222
17223/* add playback controls for speaker and HP outputs */
17224static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17225 const char *pfx)
17226{
17227 hda_nid_t nid;
17228 int err;
17229 char name[32];
17230
17231 if (!pin)
17232 return 0;
17233
Takashi Iwai24fb9172008-09-02 14:48:20 +020017234 if (pin == 0x17) {
17235 /* ALC663 has a mono output pin on 0x17 */
17236 sprintf(name, "%s Playback Switch", pfx);
17237 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17238 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17239 return err;
17240 }
17241
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017242 if (alc880_is_fixed_pin(pin)) {
17243 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017244 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017245 /* specify the DAC as the extra output */
17246 if (!spec->multiout.hp_nid)
17247 spec->multiout.hp_nid = nid;
17248 else
17249 spec->multiout.extra_out_nid[0] = nid;
17250 /* control HP volume/switch on the output mixer amp */
17251 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17252 sprintf(name, "%s Playback Volume", pfx);
17253 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17254 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17255 if (err < 0)
17256 return err;
17257 sprintf(name, "%s Playback Switch", pfx);
17258 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17259 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17260 if (err < 0)
17261 return err;
17262 } else if (alc880_is_multi_pin(pin)) {
17263 /* set manual connection */
17264 /* we have only a switch on HP-out PIN */
17265 sprintf(name, "%s Playback Switch", pfx);
17266 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17267 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17268 if (err < 0)
17269 return err;
17270 }
17271 return 0;
17272}
17273
Takashi Iwai2d864c42009-03-20 12:52:47 +010017274/* return the index of the src widget from the connection list of the nid.
17275 * return -1 if not found
17276 */
17277static int alc662_input_pin_idx(struct hda_codec *codec, hda_nid_t nid,
17278 hda_nid_t src)
17279{
17280 hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
17281 int i, conns;
17282
17283 conns = snd_hda_get_connections(codec, nid, conn_list,
17284 ARRAY_SIZE(conn_list));
17285 if (conns < 0)
17286 return -1;
17287 for (i = 0; i < conns; i++)
17288 if (conn_list[i] == src)
17289 return i;
17290 return -1;
17291}
17292
17293static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17294{
Takashi Iwai1327a322009-03-23 13:07:47 +010017295 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010017296 return (pincap & AC_PINCAP_IN) != 0;
17297}
17298
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017299/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010017300static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017301 const struct auto_pin_cfg *cfg)
17302{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017303 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017304 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017305 int i, err, idx;
17306
17307 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017308 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
17309 idx = alc662_input_pin_idx(codec, 0x0b,
17310 cfg->input_pins[i]);
17311 if (idx >= 0) {
17312 err = new_analog_input(spec, cfg->input_pins[i],
17313 auto_pin_cfg_labels[i],
17314 idx, 0x0b);
17315 if (err < 0)
17316 return err;
17317 }
17318 idx = alc662_input_pin_idx(codec, 0x22,
17319 cfg->input_pins[i]);
17320 if (idx >= 0) {
17321 imux->items[imux->num_items].label =
17322 auto_pin_cfg_labels[i];
17323 imux->items[imux->num_items].index = idx;
17324 imux->num_items++;
17325 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017326 }
17327 }
17328 return 0;
17329}
17330
17331static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17332 hda_nid_t nid, int pin_type,
17333 int dac_idx)
17334{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017335 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017336 /* need the manual connection? */
17337 if (alc880_is_multi_pin(nid)) {
17338 struct alc_spec *spec = codec->spec;
17339 int idx = alc880_multi_pin_idx(nid);
17340 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17341 AC_VERB_SET_CONNECT_SEL,
17342 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17343 }
17344}
17345
17346static void alc662_auto_init_multi_out(struct hda_codec *codec)
17347{
17348 struct alc_spec *spec = codec->spec;
17349 int i;
17350
17351 for (i = 0; i <= HDA_SIDE; i++) {
17352 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017353 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017354 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017355 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017356 i);
17357 }
17358}
17359
17360static void alc662_auto_init_hp_out(struct hda_codec *codec)
17361{
17362 struct alc_spec *spec = codec->spec;
17363 hda_nid_t pin;
17364
17365 pin = spec->autocfg.hp_pins[0];
17366 if (pin) /* connect to front */
17367 /* use dac 0 */
17368 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017369 pin = spec->autocfg.speaker_pins[0];
17370 if (pin)
17371 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017372}
17373
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017374#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17375
17376static void alc662_auto_init_analog_input(struct hda_codec *codec)
17377{
17378 struct alc_spec *spec = codec->spec;
17379 int i;
17380
17381 for (i = 0; i < AUTO_PIN_LAST; i++) {
17382 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017383 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017384 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017385 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017386 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017387 snd_hda_codec_write(codec, nid, 0,
17388 AC_VERB_SET_AMP_GAIN_MUTE,
17389 AMP_OUT_MUTE);
17390 }
17391 }
17392}
17393
Takashi Iwaif511b012008-08-15 16:46:42 +020017394#define alc662_auto_init_input_src alc882_auto_init_input_src
17395
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017396static int alc662_parse_auto_config(struct hda_codec *codec)
17397{
17398 struct alc_spec *spec = codec->spec;
17399 int err;
17400 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17401
17402 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17403 alc662_ignore);
17404 if (err < 0)
17405 return err;
17406 if (!spec->autocfg.line_outs)
17407 return 0; /* can't find valid BIOS pin config */
17408
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017409 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17410 if (err < 0)
17411 return err;
17412 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17413 if (err < 0)
17414 return err;
17415 err = alc662_auto_create_extra_out(spec,
17416 spec->autocfg.speaker_pins[0],
17417 "Speaker");
17418 if (err < 0)
17419 return err;
17420 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17421 "Headphone");
17422 if (err < 0)
17423 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017424 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017425 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017426 return err;
17427
17428 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17429
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017430 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017431 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17432
Takashi Iwai603c4012008-07-30 15:01:44 +020017433 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017434 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017435
17436 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017437 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017438
Takashi Iwaid88897e2008-10-31 15:01:37 +010017439 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017440 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017441 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017442
17443 err = alc_auto_add_mic_boost(codec);
17444 if (err < 0)
17445 return err;
17446
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017447 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17448
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017449 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017450}
17451
17452/* additional initialization for auto-configuration model */
17453static void alc662_auto_init(struct hda_codec *codec)
17454{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017455 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017456 alc662_auto_init_multi_out(codec);
17457 alc662_auto_init_hp_out(codec);
17458 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017459 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017460 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017461 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017462}
17463
17464static int patch_alc662(struct hda_codec *codec)
17465{
17466 struct alc_spec *spec;
17467 int err, board_config;
17468
17469 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17470 if (!spec)
17471 return -ENOMEM;
17472
17473 codec->spec = spec;
17474
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017475 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17476
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017477 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17478 alc662_models,
17479 alc662_cfg_tbl);
17480 if (board_config < 0) {
Takashi Iwai6c627f32009-05-18 12:33:36 +020017481 printk(KERN_INFO "hda_codec: Unknown model for %s, "
17482 "trying auto-probe from BIOS...\n", codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017483 board_config = ALC662_AUTO;
17484 }
17485
17486 if (board_config == ALC662_AUTO) {
17487 /* automatic parse from the BIOS config */
17488 err = alc662_parse_auto_config(codec);
17489 if (err < 0) {
17490 alc_free(codec);
17491 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017492 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017493 printk(KERN_INFO
17494 "hda_codec: Cannot set up configuration "
17495 "from BIOS. Using base mode...\n");
17496 board_config = ALC662_3ST_2ch_DIG;
17497 }
17498 }
17499
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017500 err = snd_hda_attach_beep_device(codec, 0x1);
17501 if (err < 0) {
17502 alc_free(codec);
17503 return err;
17504 }
17505
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017506 if (board_config != ALC662_AUTO)
17507 setup_preset(spec, &alc662_presets[board_config]);
17508
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017509 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17510 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17511
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017512 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17513 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17514
Takashi Iwaidd704692009-08-11 08:45:11 +020017515 if (!spec->adc_nids) {
17516 spec->adc_nids = alc662_adc_nids;
17517 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17518 }
17519 if (!spec->capsrc_nids)
17520 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017521
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017522 if (!spec->cap_mixer)
17523 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017524 if (codec->vendor_id == 0x10ec0662)
17525 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17526 else
17527 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017528
Takashi Iwai2134ea42008-01-10 16:53:55 +010017529 spec->vmaster_nid = 0x02;
17530
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017531 codec->patch_ops = alc_patch_ops;
17532 if (board_config == ALC662_AUTO)
17533 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017534#ifdef CONFIG_SND_HDA_POWER_SAVE
17535 if (!spec->loopback.amplist)
17536 spec->loopback.amplist = alc662_loopbacks;
17537#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017538 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017539
17540 return 0;
17541}
17542
17543/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017544 * patch entries
17545 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017546static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017547 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017548 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017549 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017550 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017551 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017552 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017553 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017554 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017555 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17556 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17557 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017558 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17559 .patch = patch_alc883 },
17560 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17561 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017562 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017563 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017564 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020017565 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020017566 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17567 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020017568 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020017569 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010017570 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020017571 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020017572 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17573 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080017574 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017575 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017576 {} /* terminator */
17577};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017578
17579MODULE_ALIAS("snd-hda-codec-id:10ec*");
17580
17581MODULE_LICENSE("GPL");
17582MODULE_DESCRIPTION("Realtek HD-audio codec");
17583
17584static struct hda_codec_preset_list realtek_list = {
17585 .preset = snd_hda_preset_realtek,
17586 .owner = THIS_MODULE,
17587};
17588
17589static int __init patch_realtek_init(void)
17590{
17591 return snd_hda_add_codec_preset(&realtek_list);
17592}
17593
17594static void __exit patch_realtek_exit(void)
17595{
17596 snd_hda_delete_codec_preset(&realtek_list);
17597}
17598
17599module_init(patch_realtek_init)
17600module_exit(patch_realtek_exit)