blob: a61fbbb41b2923c7bc2fb6e8855e7e4b8009bc85 [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,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200211 ALC883_3ST_2ch_DIG,
212 ALC883_3ST_6ch_DIG,
213 ALC883_3ST_6ch,
214 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200215 ALC883_TARGA_DIG,
216 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200217 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200218 ALC883_ACER,
Tobin Davis2880a8672007-08-07 11:50:26 +0200219 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800220 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100221 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200222 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200223 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200224 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200225 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100226 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200227 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200228 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200229 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200230 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200231 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200232 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100233 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100234 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430235 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100236 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100237 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800238 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200239 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200240 ALC889A_INTEL,
241 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200242 ALC888_ASUS_M90V,
243 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200244 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100245 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200246 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200247 ALC882_AUTO,
248 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200249};
250
Kailang Yangdf694da2005-12-05 19:42:22 +0100251/* for GPIO Poll */
252#define GPIO_MASK 0x03
253
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200254/* extra amp-initialization sequence types */
255enum {
256 ALC_INIT_NONE,
257 ALC_INIT_DEFAULT,
258 ALC_INIT_GPIO1,
259 ALC_INIT_GPIO2,
260 ALC_INIT_GPIO3,
261};
262
Takashi Iwai6c819492009-08-10 18:47:44 +0200263struct alc_mic_route {
264 hda_nid_t pin;
265 unsigned char mux_idx;
266 unsigned char amix_idx;
267};
268
269#define MUX_IDX_UNDEF ((unsigned char)-1)
270
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271struct alc_spec {
272 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100273 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100275 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100276 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Kailang Yangdf694da2005-12-05 19:42:22 +0100278 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200279 * don't forget NULL
280 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200281 */
282 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200284 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 struct hda_pcm_stream *stream_analog_playback;
286 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100287 struct hda_pcm_stream *stream_analog_alt_playback;
288 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200290 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 struct hda_pcm_stream *stream_digital_playback;
292 struct hda_pcm_stream *stream_digital_capture;
293
294 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200295 struct hda_multi_out multiout; /* playback set-up
296 * max_channels, dacs must be set
297 * dig_out_nid and hp_nid are optional
298 */
Takashi Iwai63300792008-01-24 15:31:36 +0100299 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100300 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100301 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
303 /* capture */
304 unsigned int num_adc_nids;
305 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100306 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200307 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
309 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200310 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 const struct hda_input_mux *input_mux;
312 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200313 struct alc_mic_route ext_mic;
314 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
316 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100317 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200319 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200320 int const_channel_count;
321 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
323 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100324 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200325
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200326 /* dynamic controls, init_verbs and input_mux */
327 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200328 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200329 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200330 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200331 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
332 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100333
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100334 /* hooks */
335 void (*init_hook)(struct hda_codec *codec);
336 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
337
Takashi Iwai834be882006-03-01 14:16:17 +0100338 /* for pin sensing */
339 unsigned int sense_updated: 1;
340 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100341 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200342 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200343
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100344 /* other flags */
345 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200346 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100347
Takashi Iwai2134ea42008-01-10 16:53:55 +0100348 /* for virtual master */
349 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200350#ifdef CONFIG_SND_HDA_POWER_SAVE
351 struct hda_loopback_check loopback;
352#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200353
354 /* for PLL fix */
355 hda_nid_t pll_nid;
356 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100357};
358
359/*
360 * configuration template - to be copied to the spec instance
361 */
362struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200363 struct snd_kcontrol_new *mixers[5]; /* should be identical size
364 * with spec
365 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100366 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100367 const struct hda_verb *init_verbs[5];
368 unsigned int num_dacs;
369 hda_nid_t *dac_nids;
370 hda_nid_t dig_out_nid; /* optional */
371 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800372 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100373 unsigned int num_adc_nids;
374 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100375 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100376 hda_nid_t dig_in_nid;
377 unsigned int num_channel_mode;
378 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200379 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200380 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200381 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100382 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100383 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200384 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100385 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200386#ifdef CONFIG_SND_HDA_POWER_SAVE
387 struct hda_amp_list *loopbacks;
388#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389};
390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391
392/*
393 * input MUX handling
394 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200395static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
396 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397{
398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
399 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200400 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
401 if (mux_idx >= spec->num_mux_defs)
402 mux_idx = 0;
403 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404}
405
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200406static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
407 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408{
409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
410 struct alc_spec *spec = codec->spec;
411 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
412
413 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
414 return 0;
415}
416
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200417static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
418 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419{
420 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
421 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100422 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100424 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100425 hda_nid_t nid = spec->capsrc_nids ?
426 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200427 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428
Takashi Iwaicd896c32008-11-18 12:36:33 +0100429 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
430 imux = &spec->input_mux[mux_idx];
431
Takashi Iwaia22d5432009-07-27 12:54:26 +0200432 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200433 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100434 /* Matrix-mixer style (e.g. ALC882) */
435 unsigned int *cur_val = &spec->cur_mux[adc_idx];
436 unsigned int i, idx;
437
438 idx = ucontrol->value.enumerated.item[0];
439 if (idx >= imux->num_items)
440 idx = imux->num_items - 1;
441 if (*cur_val == idx)
442 return 0;
443 for (i = 0; i < imux->num_items; i++) {
444 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
445 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
446 imux->items[i].index,
447 HDA_AMP_MUTE, v);
448 }
449 *cur_val = idx;
450 return 1;
451 } else {
452 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100453 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100454 &spec->cur_mux[adc_idx]);
455 }
456}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200457
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458/*
459 * channel mode setting
460 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200461static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
462 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463{
464 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
465 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100466 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
467 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468}
469
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200470static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
471 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472{
473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
474 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100475 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200476 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200477 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478}
479
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200480static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
481 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482{
483 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
484 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200485 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
486 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200487 &spec->ext_channel_count);
488 if (err >= 0 && !spec->const_channel_count) {
489 spec->multiout.max_channels = spec->ext_channel_count;
490 if (spec->need_dac_fix)
491 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
492 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200493 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494}
495
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100497 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200498 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100499 * being part of a format specifier. Maximum allowed length of a value is
500 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100501 *
502 * Note: some retasking pin complexes seem to ignore requests for input
503 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
504 * are requested. Therefore order this list so that this behaviour will not
505 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200506 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
507 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200508 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100509static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100510 "Mic 50pc bias", "Mic 80pc bias",
511 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512};
513static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100514 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100515};
516/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200517 * in the pin being assumed to be exclusively an input or an output pin. In
518 * addition, "input" pins may or may not process the mic bias option
519 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
520 * accept requests for bias as of chip versions up to March 2006) and/or
521 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200523#define ALC_PIN_DIR_IN 0x00
524#define ALC_PIN_DIR_OUT 0x01
525#define ALC_PIN_DIR_INOUT 0x02
526#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
527#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100528
Kailang Yangea1fb292008-08-26 12:58:38 +0200529/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100530 * For each direction the minimum and maximum values are given.
531 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200532static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100533 { 0, 2 }, /* ALC_PIN_DIR_IN */
534 { 3, 4 }, /* ALC_PIN_DIR_OUT */
535 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200536 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
537 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100538};
539#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
540#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
541#define alc_pin_mode_n_items(_dir) \
542 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
543
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200544static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
545 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200546{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100547 unsigned int item_num = uinfo->value.enumerated.item;
548 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
549
550 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200551 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
553
554 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
555 item_num = alc_pin_mode_min(dir);
556 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200557 return 0;
558}
559
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200560static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
561 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200562{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200564 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
565 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100566 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200567 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200568 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
569 AC_VERB_GET_PIN_WIDGET_CONTROL,
570 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200571
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100572 /* Find enumerated value for current pinctl setting */
573 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200574 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100575 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200576 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100577 return 0;
578}
579
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200580static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
581 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100582{
583 signed int change;
584 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
585 hda_nid_t nid = kcontrol->private_value & 0xffff;
586 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
587 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200588 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
589 AC_VERB_GET_PIN_WIDGET_CONTROL,
590 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100591
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200592 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100593 val = alc_pin_mode_min(dir);
594
595 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100596 if (change) {
597 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200598 snd_hda_codec_write_cache(codec, nid, 0,
599 AC_VERB_SET_PIN_WIDGET_CONTROL,
600 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100601
Kailang Yangea1fb292008-08-26 12:58:38 +0200602 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100603 * for the requested pin mode. Enum values of 2 or less are
604 * input modes.
605 *
606 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200607 * reduces noise slightly (particularly on input) so we'll
608 * do it. However, having both input and output buffers
609 * enabled simultaneously doesn't seem to be problematic if
610 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100611 */
612 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200613 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
614 HDA_AMP_MUTE, HDA_AMP_MUTE);
615 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
616 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100617 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200618 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
619 HDA_AMP_MUTE, HDA_AMP_MUTE);
620 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
621 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100622 }
623 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200624 return change;
625}
626
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100627#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200628 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100629 .info = alc_pin_mode_info, \
630 .get = alc_pin_mode_get, \
631 .put = alc_pin_mode_put, \
632 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100633
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100634/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
635 * together using a mask with more than one bit set. This control is
636 * currently used only by the ALC260 test model. At this stage they are not
637 * needed for any "production" models.
638 */
639#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200640#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200641
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200642static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100644{
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 hda_nid_t nid = kcontrol->private_value & 0xffff;
647 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
648 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200649 unsigned int val = snd_hda_codec_read(codec, nid, 0,
650 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100651
652 *valp = (val & mask) != 0;
653 return 0;
654}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200655static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100657{
658 signed int change;
659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
660 hda_nid_t nid = kcontrol->private_value & 0xffff;
661 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
662 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200663 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
664 AC_VERB_GET_GPIO_DATA,
665 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100666
667 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200668 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
669 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100670 gpio_data &= ~mask;
671 else
672 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200673 snd_hda_codec_write_cache(codec, nid, 0,
674 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100675
676 return change;
677}
678#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
679 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
680 .info = alc_gpio_data_info, \
681 .get = alc_gpio_data_get, \
682 .put = alc_gpio_data_put, \
683 .private_value = nid | (mask<<16) }
684#endif /* CONFIG_SND_DEBUG */
685
Jonathan Woithe92621f12006-02-28 11:47:47 +0100686/* A switch control to allow the enabling of the digital IO pins on the
687 * ALC260. This is incredibly simplistic; the intention of this control is
688 * to provide something in the test model allowing digital outputs to be
689 * identified if present. If models are found which can utilise these
690 * outputs a more complete mixer control can be devised for those models if
691 * necessary.
692 */
693#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200694#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200695
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200696static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
697 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100698{
699 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
700 hda_nid_t nid = kcontrol->private_value & 0xffff;
701 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
702 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200703 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100704 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100705
706 *valp = (val & mask) != 0;
707 return 0;
708}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200709static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
710 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100711{
712 signed int change;
713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
714 hda_nid_t nid = kcontrol->private_value & 0xffff;
715 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
716 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200717 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100718 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200719 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100720
721 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200722 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100723 if (val==0)
724 ctrl_data &= ~mask;
725 else
726 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200727 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
728 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100729
730 return change;
731}
732#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
733 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
734 .info = alc_spdif_ctrl_info, \
735 .get = alc_spdif_ctrl_get, \
736 .put = alc_spdif_ctrl_put, \
737 .private_value = nid | (mask<<16) }
738#endif /* CONFIG_SND_DEBUG */
739
Jonathan Woithef8225f62008-01-08 12:16:54 +0100740/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
741 * Again, this is only used in the ALC26x test models to help identify when
742 * the EAPD line must be asserted for features to work.
743 */
744#ifdef CONFIG_SND_DEBUG
745#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
746
747static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
748 struct snd_ctl_elem_value *ucontrol)
749{
750 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
751 hda_nid_t nid = kcontrol->private_value & 0xffff;
752 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
753 long *valp = ucontrol->value.integer.value;
754 unsigned int val = snd_hda_codec_read(codec, nid, 0,
755 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
756
757 *valp = (val & mask) != 0;
758 return 0;
759}
760
761static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
762 struct snd_ctl_elem_value *ucontrol)
763{
764 int change;
765 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
766 hda_nid_t nid = kcontrol->private_value & 0xffff;
767 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
768 long val = *ucontrol->value.integer.value;
769 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
770 AC_VERB_GET_EAPD_BTLENABLE,
771 0x00);
772
773 /* Set/unset the masked control bit(s) as needed */
774 change = (!val ? 0 : mask) != (ctrl_data & mask);
775 if (!val)
776 ctrl_data &= ~mask;
777 else
778 ctrl_data |= mask;
779 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
780 ctrl_data);
781
782 return change;
783}
784
785#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
786 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
787 .info = alc_eapd_ctrl_info, \
788 .get = alc_eapd_ctrl_get, \
789 .put = alc_eapd_ctrl_put, \
790 .private_value = nid | (mask<<16) }
791#endif /* CONFIG_SND_DEBUG */
792
Kailang Yangdf694da2005-12-05 19:42:22 +0100793/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100794 * set up the input pin config (depending on the given auto-pin type)
795 */
796static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
797 int auto_pin_type)
798{
799 unsigned int val = PIN_IN;
800
801 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
802 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100803 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100804 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
805 if (pincap & AC_PINCAP_VREF_80)
806 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200807 else if (pincap & AC_PINCAP_VREF_50)
808 val = PIN_VREF50;
809 else if (pincap & AC_PINCAP_VREF_100)
810 val = PIN_VREF100;
811 else if (pincap & AC_PINCAP_VREF_GRD)
812 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100813 }
814 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
815}
816
817/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100818 */
819static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
820{
821 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
822 return;
823 spec->mixers[spec->num_mixers++] = mix;
824}
825
826static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
827{
828 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
829 return;
830 spec->init_verbs[spec->num_init_verbs++] = verb;
831}
832
Takashi Iwaidaead532008-11-28 12:55:36 +0100833#ifdef CONFIG_PROC_FS
834/*
835 * hook for proc
836 */
837static void print_realtek_coef(struct snd_info_buffer *buffer,
838 struct hda_codec *codec, hda_nid_t nid)
839{
840 int coeff;
841
842 if (nid != 0x20)
843 return;
844 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
845 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
846 coeff = snd_hda_codec_read(codec, nid, 0,
847 AC_VERB_GET_COEF_INDEX, 0);
848 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
849}
850#else
851#define print_realtek_coef NULL
852#endif
853
Takashi Iwaid88897e2008-10-31 15:01:37 +0100854/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100855 * set up from the preset table
856 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200857static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200858 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100859{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200860 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100861 int i;
862
863 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100864 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100865 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200866 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
867 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100868 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200869
Kailang Yangdf694da2005-12-05 19:42:22 +0100870 spec->channel_mode = preset->channel_mode;
871 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200872 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200873 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100874
Hector Martin3b315d72009-06-02 10:54:19 +0200875 if (preset->const_channel_count)
876 spec->multiout.max_channels = preset->const_channel_count;
877 else
878 spec->multiout.max_channels = spec->channel_mode[0].channels;
879 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100880
881 spec->multiout.num_dacs = preset->num_dacs;
882 spec->multiout.dac_nids = preset->dac_nids;
883 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800884 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100885 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200886
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200887 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200888 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200889 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100890 spec->input_mux = preset->input_mux;
891
892 spec->num_adc_nids = preset->num_adc_nids;
893 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100894 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100895 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100896
897 spec->unsol_event = preset->unsol_event;
898 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200899#ifdef CONFIG_SND_HDA_POWER_SAVE
900 spec->loopback.amplist = preset->loopbacks;
901#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200902
903 if (preset->setup)
904 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100905}
906
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200907/* Enable GPIO mask and set output */
908static struct hda_verb alc_gpio1_init_verbs[] = {
909 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
910 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
911 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
912 { }
913};
914
915static struct hda_verb alc_gpio2_init_verbs[] = {
916 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
917 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
918 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
919 { }
920};
921
Kailang Yangbdd148a2007-05-08 15:19:08 +0200922static struct hda_verb alc_gpio3_init_verbs[] = {
923 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
924 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
925 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
926 { }
927};
928
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200929/*
930 * Fix hardware PLL issue
931 * On some codecs, the analog PLL gating control must be off while
932 * the default value is 1.
933 */
934static void alc_fix_pll(struct hda_codec *codec)
935{
936 struct alc_spec *spec = codec->spec;
937 unsigned int val;
938
939 if (!spec->pll_nid)
940 return;
941 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
942 spec->pll_coef_idx);
943 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
944 AC_VERB_GET_PROC_COEF, 0);
945 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
946 spec->pll_coef_idx);
947 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
948 val & ~(1 << spec->pll_coef_bit));
949}
950
951static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
952 unsigned int coef_idx, unsigned int coef_bit)
953{
954 struct alc_spec *spec = codec->spec;
955 spec->pll_nid = nid;
956 spec->pll_coef_idx = coef_idx;
957 spec->pll_coef_bit = coef_bit;
958 alc_fix_pll(codec);
959}
960
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200961static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200962{
963 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +0200964 unsigned int present, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200965 unsigned int nid = spec->autocfg.hp_pins[0];
966 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200967
Takashi Iwai261c2402009-06-25 08:13:40 +0200968 pincap = snd_hda_query_pin_caps(codec, nid);
969 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
970 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200971 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200972 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200973 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
974 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
975 nid = spec->autocfg.speaker_pins[i];
976 if (!nid)
977 break;
978 snd_hda_codec_write(codec, nid, 0,
979 AC_VERB_SET_PIN_WIDGET_CONTROL,
980 spec->jack_present ? 0 : PIN_OUT);
981 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200982}
983
Takashi Iwai6c819492009-08-10 18:47:44 +0200984static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
985 hda_nid_t nid)
986{
987 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
988 int i, nums;
989
990 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
991 for (i = 0; i < nums; i++)
992 if (conn[i] == nid)
993 return i;
994 return -1;
995}
996
Kailang Yang7fb0d782008-10-15 11:12:35 +0200997static void alc_mic_automute(struct hda_codec *codec)
998{
999 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001000 struct alc_mic_route *dead, *alive;
1001 unsigned int present, type;
1002 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001003
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001004 if (!spec->auto_mic)
1005 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001006 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1007 return;
1008 if (snd_BUG_ON(!spec->adc_nids))
1009 return;
1010
1011 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1012
1013 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
1014 AC_VERB_GET_PIN_SENSE, 0);
1015 present &= AC_PINSENSE_PRESENCE;
1016 if (present) {
1017 alive = &spec->ext_mic;
1018 dead = &spec->int_mic;
1019 } else {
1020 alive = &spec->int_mic;
1021 dead = &spec->ext_mic;
1022 }
1023
Takashi Iwai6c819492009-08-10 18:47:44 +02001024 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1025 if (type == AC_WID_AUD_MIX) {
1026 /* Matrix-mixer style (e.g. ALC882) */
1027 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1028 alive->mux_idx,
1029 HDA_AMP_MUTE, 0);
1030 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1031 dead->mux_idx,
1032 HDA_AMP_MUTE, HDA_AMP_MUTE);
1033 } else {
1034 /* MUX style (e.g. ALC880) */
1035 snd_hda_codec_write_cache(codec, cap_nid, 0,
1036 AC_VERB_SET_CONNECT_SEL,
1037 alive->mux_idx);
1038 }
1039
1040 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001041}
1042
Kailang Yangc9b58002007-10-16 14:30:01 +02001043/* unsolicited event for HP jack sensing */
1044static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1045{
1046 if (codec->vendor_id == 0x10ec0880)
1047 res >>= 28;
1048 else
1049 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001050 switch (res) {
1051 case ALC880_HP_EVENT:
1052 alc_automute_pin(codec);
1053 break;
1054 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001055 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001056 break;
1057 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001058}
1059
1060static void alc_inithook(struct hda_codec *codec)
1061{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001062 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001063 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001064}
1065
Kailang Yangf9423e72008-05-27 12:32:25 +02001066/* additional initialization for ALC888 variants */
1067static void alc888_coef_init(struct hda_codec *codec)
1068{
1069 unsigned int tmp;
1070
1071 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1072 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1073 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001074 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001075 /* alc888S-VC */
1076 snd_hda_codec_read(codec, 0x20, 0,
1077 AC_VERB_SET_PROC_COEF, 0x830);
1078 else
1079 /* alc888-VB */
1080 snd_hda_codec_read(codec, 0x20, 0,
1081 AC_VERB_SET_PROC_COEF, 0x3030);
1082}
1083
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001084static void alc889_coef_init(struct hda_codec *codec)
1085{
1086 unsigned int tmp;
1087
1088 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1089 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1090 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1091 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1092}
1093
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001094static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001095{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001096 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001097
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001098 switch (type) {
1099 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001100 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1101 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001102 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001103 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1104 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001105 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001106 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1107 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001108 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001109 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001110 case 0x10ec0260:
1111 snd_hda_codec_write(codec, 0x0f, 0,
1112 AC_VERB_SET_EAPD_BTLENABLE, 2);
1113 snd_hda_codec_write(codec, 0x10, 0,
1114 AC_VERB_SET_EAPD_BTLENABLE, 2);
1115 break;
1116 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001117 case 0x10ec0267:
1118 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001119 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001120 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001121 case 0x10ec0660:
1122 case 0x10ec0662:
1123 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001124 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001125 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001126 snd_hda_codec_write(codec, 0x14, 0,
1127 AC_VERB_SET_EAPD_BTLENABLE, 2);
1128 snd_hda_codec_write(codec, 0x15, 0,
1129 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001130 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001131 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001132 switch (codec->vendor_id) {
1133 case 0x10ec0260:
1134 snd_hda_codec_write(codec, 0x1a, 0,
1135 AC_VERB_SET_COEF_INDEX, 7);
1136 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1137 AC_VERB_GET_PROC_COEF, 0);
1138 snd_hda_codec_write(codec, 0x1a, 0,
1139 AC_VERB_SET_COEF_INDEX, 7);
1140 snd_hda_codec_write(codec, 0x1a, 0,
1141 AC_VERB_SET_PROC_COEF,
1142 tmp | 0x2010);
1143 break;
1144 case 0x10ec0262:
1145 case 0x10ec0880:
1146 case 0x10ec0882:
1147 case 0x10ec0883:
1148 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001149 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001150 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001151 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001152 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001153 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001154 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001155 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001156 case 0x10ec0267:
1157 case 0x10ec0268:
1158 snd_hda_codec_write(codec, 0x20, 0,
1159 AC_VERB_SET_COEF_INDEX, 7);
1160 tmp = snd_hda_codec_read(codec, 0x20, 0,
1161 AC_VERB_GET_PROC_COEF, 0);
1162 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001163 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001164 snd_hda_codec_write(codec, 0x20, 0,
1165 AC_VERB_SET_PROC_COEF,
1166 tmp | 0x3000);
1167 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001168 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001169 break;
1170 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001171}
Kailang Yangea1fb292008-08-26 12:58:38 +02001172
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001173static void alc_init_auto_hp(struct hda_codec *codec)
1174{
1175 struct alc_spec *spec = codec->spec;
1176
1177 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001178 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001179
Kailang Yangc9b58002007-10-16 14:30:01 +02001180 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001181 if (spec->autocfg.line_out_pins[0] &&
1182 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001183 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001184 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001185 else
1186 return;
1187 }
1188
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001189 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1190 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001191 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1192 AC_VERB_SET_UNSOLICITED_ENABLE,
1193 AC_USRSP_EN | ALC880_HP_EVENT);
1194 spec->unsol_event = alc_sku_unsol_event;
1195}
1196
Takashi Iwai6c819492009-08-10 18:47:44 +02001197static void alc_init_auto_mic(struct hda_codec *codec)
1198{
1199 struct alc_spec *spec = codec->spec;
1200 struct auto_pin_cfg *cfg = &spec->autocfg;
1201 hda_nid_t fixed, ext;
1202 int i;
1203
1204 /* there must be only two mic inputs exclusively */
1205 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1206 if (cfg->input_pins[i])
1207 return;
1208
1209 fixed = ext = 0;
1210 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1211 hda_nid_t nid = cfg->input_pins[i];
1212 unsigned int defcfg;
1213 if (!nid)
1214 return;
1215 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1216 switch (get_defcfg_connect(defcfg)) {
1217 case AC_JACK_PORT_FIXED:
1218 if (fixed)
1219 return; /* already occupied */
1220 fixed = nid;
1221 break;
1222 case AC_JACK_PORT_COMPLEX:
1223 if (ext)
1224 return; /* already occupied */
1225 ext = nid;
1226 break;
1227 default:
1228 return; /* invalid entry */
1229 }
1230 }
1231 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1232 return; /* no unsol support */
1233 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1234 ext, fixed);
1235 spec->ext_mic.pin = ext;
1236 spec->int_mic.pin = fixed;
1237 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1238 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1239 spec->auto_mic = 1;
1240 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1241 AC_VERB_SET_UNSOLICITED_ENABLE,
1242 AC_USRSP_EN | ALC880_MIC_EVENT);
1243 spec->unsol_event = alc_sku_unsol_event;
1244}
1245
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001246/* check subsystem ID and set up device-specific initialization;
1247 * return 1 if initialized, 0 if invalid SSID
1248 */
1249/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1250 * 31 ~ 16 : Manufacture ID
1251 * 15 ~ 8 : SKU ID
1252 * 7 ~ 0 : Assembly ID
1253 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1254 */
1255static int alc_subsystem_id(struct hda_codec *codec,
1256 hda_nid_t porta, hda_nid_t porte,
1257 hda_nid_t portd)
1258{
1259 unsigned int ass, tmp, i;
1260 unsigned nid;
1261 struct alc_spec *spec = codec->spec;
1262
1263 ass = codec->subsystem_id & 0xffff;
1264 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1265 goto do_sku;
1266
1267 /* invalid SSID, check the special NID pin defcfg instead */
1268 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001269 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001270 * 29~21 : reserve
1271 * 20 : PCBEEP input
1272 * 19~16 : Check sum (15:1)
1273 * 15~1 : Custom
1274 * 0 : override
1275 */
1276 nid = 0x1d;
1277 if (codec->vendor_id == 0x10ec0260)
1278 nid = 0x17;
1279 ass = snd_hda_codec_get_pincfg(codec, nid);
1280 snd_printd("realtek: No valid SSID, "
1281 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001282 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001283 if (!(ass & 1) && !(ass & 0x100000))
1284 return 0;
1285 if ((ass >> 30) != 1) /* no physical connection */
1286 return 0;
1287
1288 /* check sum */
1289 tmp = 0;
1290 for (i = 1; i < 16; i++) {
1291 if ((ass >> i) & 1)
1292 tmp++;
1293 }
1294 if (((ass >> 16) & 0xf) != tmp)
1295 return 0;
1296do_sku:
1297 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1298 ass & 0xffff, codec->vendor_id);
1299 /*
1300 * 0 : override
1301 * 1 : Swap Jack
1302 * 2 : 0 --> Desktop, 1 --> Laptop
1303 * 3~5 : External Amplifier control
1304 * 7~6 : Reserved
1305 */
1306 tmp = (ass & 0x38) >> 3; /* external Amp control */
1307 switch (tmp) {
1308 case 1:
1309 spec->init_amp = ALC_INIT_GPIO1;
1310 break;
1311 case 3:
1312 spec->init_amp = ALC_INIT_GPIO2;
1313 break;
1314 case 7:
1315 spec->init_amp = ALC_INIT_GPIO3;
1316 break;
1317 case 5:
1318 spec->init_amp = ALC_INIT_DEFAULT;
1319 break;
1320 }
1321
1322 /* is laptop or Desktop and enable the function "Mute internal speaker
1323 * when the external headphone out jack is plugged"
1324 */
1325 if (!(ass & 0x8000))
1326 return 1;
1327 /*
1328 * 10~8 : Jack location
1329 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1330 * 14~13: Resvered
1331 * 15 : 1 --> enable the function "Mute internal speaker
1332 * when the external headphone out jack is plugged"
1333 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001334 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001335 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001336 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1337 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001338 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001339 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001340 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001341 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001342 nid = portd;
Kailang Yangc9b58002007-10-16 14:30:01 +02001343 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001344 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001345 for (i = 0; i < spec->autocfg.line_outs; i++)
1346 if (spec->autocfg.line_out_pins[i] == nid)
1347 return 1;
1348 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001349 }
1350
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001351 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001352 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001353 return 1;
1354}
Kailang Yangea1fb292008-08-26 12:58:38 +02001355
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001356static void alc_ssid_check(struct hda_codec *codec,
1357 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1358{
1359 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1360 struct alc_spec *spec = codec->spec;
1361 snd_printd("realtek: "
1362 "Enable default setup for auto mode as fallback\n");
1363 spec->init_amp = ALC_INIT_DEFAULT;
1364 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001365 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001366 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001367}
1368
Takashi Iwai41e41f12005-06-08 14:48:49 +02001369/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001370 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001371 */
1372
1373struct alc_pincfg {
1374 hda_nid_t nid;
1375 u32 val;
1376};
1377
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001378struct alc_fixup {
1379 const struct alc_pincfg *pins;
1380 const struct hda_verb *verbs;
1381};
1382
1383static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001384 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001385 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001386{
1387 const struct alc_pincfg *cfg;
1388
1389 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1390 if (!quirk)
1391 return;
1392
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001393 fix += quirk->value;
1394 cfg = fix->pins;
1395 if (cfg) {
1396 for (; cfg->nid; cfg++)
1397 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1398 }
1399 if (fix->verbs)
1400 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001401}
1402
1403/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001404 * ALC888
1405 */
1406
1407/*
1408 * 2ch mode
1409 */
1410static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1411/* Mic-in jack as mic in */
1412 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1413 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1414/* Line-in jack as Line in */
1415 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1416 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1417/* Line-Out as Front */
1418 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1419 { } /* end */
1420};
1421
1422/*
1423 * 4ch mode
1424 */
1425static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1426/* Mic-in jack as mic in */
1427 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1428 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1429/* Line-in jack as Surround */
1430 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1431 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1432/* Line-Out as Front */
1433 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1434 { } /* end */
1435};
1436
1437/*
1438 * 6ch mode
1439 */
1440static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1441/* Mic-in jack as CLFE */
1442 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1443 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1444/* Line-in jack as Surround */
1445 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1446 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1447/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1448 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1449 { } /* end */
1450};
1451
1452/*
1453 * 8ch mode
1454 */
1455static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1456/* Mic-in jack as CLFE */
1457 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1458 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1459/* Line-in jack as Surround */
1460 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1461 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1462/* Line-Out as Side */
1463 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1464 { } /* end */
1465};
1466
1467static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1468 { 2, alc888_4ST_ch2_intel_init },
1469 { 4, alc888_4ST_ch4_intel_init },
1470 { 6, alc888_4ST_ch6_intel_init },
1471 { 8, alc888_4ST_ch8_intel_init },
1472};
1473
1474/*
1475 * ALC888 Fujitsu Siemens Amillo xa3530
1476 */
1477
1478static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1479/* Front Mic: set to PIN_IN (empty by default) */
1480 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1481/* Connect Internal HP to Front */
1482 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1483 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1484 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1485/* Connect Bass HP to Front */
1486 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1487 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1488 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1489/* Connect Line-Out side jack (SPDIF) to Side */
1490 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1491 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1492 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1493/* Connect Mic jack to CLFE */
1494 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1495 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1496 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1497/* Connect Line-in jack to Surround */
1498 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1499 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1501/* Connect HP out jack to Front */
1502 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1503 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1504 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1505/* Enable unsolicited event for HP jack and Line-out jack */
1506 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1507 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1508 {}
1509};
1510
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001511static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001512{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001513 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +02001514 unsigned int val, mute, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001515 hda_nid_t nid;
1516 int i;
1517
1518 spec->jack_present = 0;
1519 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1520 nid = spec->autocfg.hp_pins[i];
1521 if (!nid)
1522 break;
Takashi Iwai261c2402009-06-25 08:13:40 +02001523 pincap = snd_hda_query_pin_caps(codec, nid);
1524 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1525 snd_hda_codec_read(codec, nid, 0,
1526 AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001527 val = snd_hda_codec_read(codec, nid, 0,
1528 AC_VERB_GET_PIN_SENSE, 0);
1529 if (val & AC_PINSENSE_PRESENCE) {
1530 spec->jack_present = 1;
1531 break;
1532 }
1533 }
1534
1535 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001536 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001537 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1538 nid = spec->autocfg.speaker_pins[i];
1539 if (!nid)
1540 break;
1541 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1542 HDA_AMP_MUTE, mute);
1543 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001544}
1545
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001546static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1547 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001548{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001549 if (codec->vendor_id == 0x10ec0880)
1550 res >>= 28;
1551 else
1552 res >>= 26;
1553 if (res == ALC880_HP_EVENT)
1554 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001555}
1556
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001557static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001558{
1559 struct alc_spec *spec = codec->spec;
1560
1561 spec->autocfg.hp_pins[0] = 0x15;
1562 spec->autocfg.speaker_pins[0] = 0x14;
1563 spec->autocfg.speaker_pins[1] = 0x16;
1564 spec->autocfg.speaker_pins[2] = 0x17;
1565 spec->autocfg.speaker_pins[3] = 0x19;
1566 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001567}
1568
1569static void alc889_intel_init_hook(struct hda_codec *codec)
1570{
1571 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001572 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001573}
1574
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001575static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001576{
1577 struct alc_spec *spec = codec->spec;
1578
1579 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1580 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1581 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1582 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001583}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001584
1585/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001586 * ALC888 Acer Aspire 4930G model
1587 */
1588
1589static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1590/* Front Mic: set to PIN_IN (empty by default) */
1591 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1592/* Unselect Front Mic by default in input mixer 3 */
1593 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001594/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001595 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1596/* Connect Internal HP to front */
1597 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1598 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1599 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1600/* Connect HP out to front */
1601 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1602 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1603 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1604 { }
1605};
1606
Hector Martin3b315d72009-06-02 10:54:19 +02001607/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001608 * ALC888 Acer Aspire 6530G model
1609 */
1610
1611static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1612/* Bias voltage on for external mic port */
1613 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001614/* Front Mic: set to PIN_IN (empty by default) */
1615 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1616/* Unselect Front Mic by default in input mixer 3 */
1617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001618/* Enable unsolicited event for HP jack */
1619 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1620/* Enable speaker output */
1621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1622 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1623/* Enable headphone output */
1624 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1625 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1626 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1627 { }
1628};
1629
1630/*
Hector Martin018df412009-06-04 00:13:40 +02001631 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001632 */
1633
Hector Martin018df412009-06-04 00:13:40 +02001634static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001635/* Front Mic: set to PIN_IN (empty by default) */
1636 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1637/* Unselect Front Mic by default in input mixer 3 */
1638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1639/* Enable unsolicited event for HP jack */
1640 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1641/* Connect Internal Front to Front */
1642 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1643 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1644 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1645/* Connect Internal Rear to Rear */
1646 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1647 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1648 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1649/* Connect Internal CLFE to CLFE */
1650 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1651 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1652 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1653/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001654 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001655 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1656 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1657/* Enable all DACs */
1658/* DAC DISABLE/MUTE 1? */
1659/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1660 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1661 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1662/* DAC DISABLE/MUTE 2? */
1663/* some bit here disables the other DACs. Init=0x4900 */
1664 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1665 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1666/* Enable amplifiers */
1667 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1668 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001669/* DMIC fix
1670 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1671 * which makes the stereo useless. However, either the mic or the ALC889
1672 * makes the signal become a difference/sum signal instead of standard
1673 * stereo, which is annoying. So instead we flip this bit which makes the
1674 * codec replicate the sum signal to both channels, turning it into a
1675 * normal mono mic.
1676 */
1677/* DMIC_CONTROL? Init value = 0x0001 */
1678 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1679 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001680 { }
1681};
1682
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001683static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001684 /* Front mic only available on one ADC */
1685 {
1686 .num_items = 4,
1687 .items = {
1688 { "Mic", 0x0 },
1689 { "Line", 0x2 },
1690 { "CD", 0x4 },
1691 { "Front Mic", 0xb },
1692 },
1693 },
1694 {
1695 .num_items = 3,
1696 .items = {
1697 { "Mic", 0x0 },
1698 { "Line", 0x2 },
1699 { "CD", 0x4 },
1700 },
1701 }
1702};
1703
Tony Vroond2fd4b02009-06-21 00:40:10 +01001704static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1705 /* Interal mic only available on one ADC */
1706 {
Tony Vroon684a8842009-06-26 09:27:50 +01001707 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001708 .items = {
1709 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001710 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001711 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001712 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001713 { "Int Mic", 0xb },
1714 },
1715 },
1716 {
Tony Vroon684a8842009-06-26 09:27:50 +01001717 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001718 .items = {
1719 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001720 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001721 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001722 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001723 },
1724 }
1725};
1726
Hector Martin018df412009-06-04 00:13:40 +02001727static struct hda_input_mux alc889_capture_sources[3] = {
1728 /* Digital mic only available on first "ADC" */
1729 {
1730 .num_items = 5,
1731 .items = {
1732 { "Mic", 0x0 },
1733 { "Line", 0x2 },
1734 { "CD", 0x4 },
1735 { "Front Mic", 0xb },
1736 { "Input Mix", 0xa },
1737 },
1738 },
1739 {
1740 .num_items = 4,
1741 .items = {
1742 { "Mic", 0x0 },
1743 { "Line", 0x2 },
1744 { "CD", 0x4 },
1745 { "Input Mix", 0xa },
1746 },
1747 },
1748 {
1749 .num_items = 4,
1750 .items = {
1751 { "Mic", 0x0 },
1752 { "Line", 0x2 },
1753 { "CD", 0x4 },
1754 { "Input Mix", 0xa },
1755 },
1756 }
1757};
1758
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001759static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001760 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1761 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1762 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1763 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1764 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1765 HDA_OUTPUT),
1766 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1767 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1768 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1769 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1770 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1771 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1772 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1773 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1774 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1775 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1776 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001778 { } /* end */
1779};
1780
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001781static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001782{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001783 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001784
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001785 spec->autocfg.hp_pins[0] = 0x15;
1786 spec->autocfg.speaker_pins[0] = 0x14;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001787}
1788
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001789static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001790{
1791 struct alc_spec *spec = codec->spec;
1792
1793 spec->autocfg.hp_pins[0] = 0x15;
1794 spec->autocfg.speaker_pins[0] = 0x14;
1795 spec->autocfg.speaker_pins[1] = 0x16;
1796 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001797}
1798
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001799static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001800{
1801 struct alc_spec *spec = codec->spec;
1802
1803 spec->autocfg.hp_pins[0] = 0x15;
1804 spec->autocfg.speaker_pins[0] = 0x14;
1805 spec->autocfg.speaker_pins[1] = 0x16;
1806 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001807}
1808
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001809/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001810 * ALC880 3-stack model
1811 *
1812 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001813 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1814 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001815 */
1816
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001817static hda_nid_t alc880_dac_nids[4] = {
1818 /* front, rear, clfe, rear_surr */
1819 0x02, 0x05, 0x04, 0x03
1820};
1821
1822static hda_nid_t alc880_adc_nids[3] = {
1823 /* ADC0-2 */
1824 0x07, 0x08, 0x09,
1825};
1826
1827/* The datasheet says the node 0x07 is connected from inputs,
1828 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001829 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001830 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001831static hda_nid_t alc880_adc_nids_alt[2] = {
1832 /* ADC1-2 */
1833 0x08, 0x09,
1834};
1835
1836#define ALC880_DIGOUT_NID 0x06
1837#define ALC880_DIGIN_NID 0x0a
1838
1839static struct hda_input_mux alc880_capture_source = {
1840 .num_items = 4,
1841 .items = {
1842 { "Mic", 0x0 },
1843 { "Front Mic", 0x3 },
1844 { "Line", 0x2 },
1845 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001846 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001847};
1848
1849/* channel source setting (2/6 channel selection for 3-stack) */
1850/* 2ch mode */
1851static struct hda_verb alc880_threestack_ch2_init[] = {
1852 /* set line-in to input, mute it */
1853 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1854 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1855 /* set mic-in to input vref 80%, mute it */
1856 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1857 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001858 { } /* end */
1859};
1860
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001861/* 6ch mode */
1862static struct hda_verb alc880_threestack_ch6_init[] = {
1863 /* set line-in to output, unmute it */
1864 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1865 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1866 /* set mic-in to output, unmute it */
1867 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1868 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1869 { } /* end */
1870};
1871
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001872static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001873 { 2, alc880_threestack_ch2_init },
1874 { 6, alc880_threestack_ch6_init },
1875};
1876
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001877static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001878 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001879 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001880 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001881 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001882 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1883 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001884 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1885 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001886 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1887 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1888 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1889 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1892 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1893 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001894 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001895 {
1896 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1897 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001898 .info = alc_ch_mode_info,
1899 .get = alc_ch_mode_get,
1900 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001901 },
1902 { } /* end */
1903};
1904
1905/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001906static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1907 struct snd_ctl_elem_info *uinfo)
1908{
1909 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1910 struct alc_spec *spec = codec->spec;
1911 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001912
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001913 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001914 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1915 HDA_INPUT);
1916 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001917 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001918 return err;
1919}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001920
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001921static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1922 unsigned int size, unsigned int __user *tlv)
1923{
1924 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1925 struct alc_spec *spec = codec->spec;
1926 int err;
1927
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001928 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001929 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1930 HDA_INPUT);
1931 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001932 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001933 return err;
1934}
1935
1936typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1937 struct snd_ctl_elem_value *ucontrol);
1938
1939static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1940 struct snd_ctl_elem_value *ucontrol,
1941 getput_call_t func)
1942{
1943 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1944 struct alc_spec *spec = codec->spec;
1945 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1946 int err;
1947
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001948 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001949 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1950 3, 0, HDA_INPUT);
1951 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001952 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001953 return err;
1954}
1955
1956static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1957 struct snd_ctl_elem_value *ucontrol)
1958{
1959 return alc_cap_getput_caller(kcontrol, ucontrol,
1960 snd_hda_mixer_amp_volume_get);
1961}
1962
1963static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1964 struct snd_ctl_elem_value *ucontrol)
1965{
1966 return alc_cap_getput_caller(kcontrol, ucontrol,
1967 snd_hda_mixer_amp_volume_put);
1968}
1969
1970/* capture mixer elements */
1971#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1972
1973static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1974 struct snd_ctl_elem_value *ucontrol)
1975{
1976 return alc_cap_getput_caller(kcontrol, ucontrol,
1977 snd_hda_mixer_amp_switch_get);
1978}
1979
1980static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1981 struct snd_ctl_elem_value *ucontrol)
1982{
1983 return alc_cap_getput_caller(kcontrol, ucontrol,
1984 snd_hda_mixer_amp_switch_put);
1985}
1986
Takashi Iwaia23b6882009-03-23 15:21:36 +01001987#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001988 { \
1989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1990 .name = "Capture Switch", \
1991 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1992 .count = num, \
1993 .info = alc_cap_sw_info, \
1994 .get = alc_cap_sw_get, \
1995 .put = alc_cap_sw_put, \
1996 }, \
1997 { \
1998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1999 .name = "Capture Volume", \
2000 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2001 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2002 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2003 .count = num, \
2004 .info = alc_cap_vol_info, \
2005 .get = alc_cap_vol_get, \
2006 .put = alc_cap_vol_put, \
2007 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002008 }
2009
2010#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002011 { \
2012 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2013 /* .name = "Capture Source", */ \
2014 .name = "Input Source", \
2015 .count = num, \
2016 .info = alc_mux_enum_info, \
2017 .get = alc_mux_enum_get, \
2018 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002019 }
2020
2021#define DEFINE_CAPMIX(num) \
2022static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2023 _DEFINE_CAPMIX(num), \
2024 _DEFINE_CAPSRC(num), \
2025 { } /* end */ \
2026}
2027
2028#define DEFINE_CAPMIX_NOSRC(num) \
2029static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2030 _DEFINE_CAPMIX(num), \
2031 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002032}
2033
2034/* up to three ADCs */
2035DEFINE_CAPMIX(1);
2036DEFINE_CAPMIX(2);
2037DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002038DEFINE_CAPMIX_NOSRC(1);
2039DEFINE_CAPMIX_NOSRC(2);
2040DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002041
2042/*
2043 * ALC880 5-stack model
2044 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002045 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2046 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002047 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2048 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2049 */
2050
2051/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002052static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002053 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002054 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055 { } /* end */
2056};
2057
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002058/* channel source setting (6/8 channel selection for 5-stack) */
2059/* 6ch mode */
2060static struct hda_verb alc880_fivestack_ch6_init[] = {
2061 /* set line-in to input, mute it */
2062 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2063 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002064 { } /* end */
2065};
2066
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002067/* 8ch mode */
2068static struct hda_verb alc880_fivestack_ch8_init[] = {
2069 /* set line-in to output, unmute it */
2070 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2071 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2072 { } /* end */
2073};
2074
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002075static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002076 { 6, alc880_fivestack_ch6_init },
2077 { 8, alc880_fivestack_ch8_init },
2078};
2079
2080
2081/*
2082 * ALC880 6-stack model
2083 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002084 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2085 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002086 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2087 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2088 */
2089
2090static hda_nid_t alc880_6st_dac_nids[4] = {
2091 /* front, rear, clfe, rear_surr */
2092 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002093};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002094
2095static struct hda_input_mux alc880_6stack_capture_source = {
2096 .num_items = 4,
2097 .items = {
2098 { "Mic", 0x0 },
2099 { "Front Mic", 0x1 },
2100 { "Line", 0x2 },
2101 { "CD", 0x4 },
2102 },
2103};
2104
2105/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002106static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002107 { 8, NULL },
2108};
2109
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002110static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002111 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002112 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002113 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002114 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002115 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2116 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002117 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2118 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002119 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002120 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002121 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2122 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2123 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2124 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2125 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2126 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2127 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2128 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002129 {
2130 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2131 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002132 .info = alc_ch_mode_info,
2133 .get = alc_ch_mode_get,
2134 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002135 },
2136 { } /* end */
2137};
2138
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002139
2140/*
2141 * ALC880 W810 model
2142 *
2143 * W810 has rear IO for:
2144 * Front (DAC 02)
2145 * Surround (DAC 03)
2146 * Center/LFE (DAC 04)
2147 * Digital out (06)
2148 *
2149 * The system also has a pair of internal speakers, and a headphone jack.
2150 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002151 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002152 * There is a variable resistor to control the speaker or headphone
2153 * volume. This is a hardware-only device without a software API.
2154 *
2155 * Plugging headphones in will disable the internal speakers. This is
2156 * implemented in hardware, not via the driver using jack sense. In
2157 * a similar fashion, plugging into the rear socket marked "front" will
2158 * disable both the speakers and headphones.
2159 *
2160 * For input, there's a microphone jack, and an "audio in" jack.
2161 * These may not do anything useful with this driver yet, because I
2162 * haven't setup any initialization verbs for these yet...
2163 */
2164
2165static hda_nid_t alc880_w810_dac_nids[3] = {
2166 /* front, rear/surround, clfe */
2167 0x02, 0x03, 0x04
2168};
2169
2170/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002171static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002172 { 6, NULL }
2173};
2174
2175/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002176static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002177 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002178 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002179 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002180 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002181 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2182 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002183 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2184 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002185 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2186 { } /* end */
2187};
2188
2189
2190/*
2191 * Z710V model
2192 *
2193 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002194 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2195 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002196 */
2197
2198static hda_nid_t alc880_z71v_dac_nids[1] = {
2199 0x02
2200};
2201#define ALC880_Z71V_HP_DAC 0x03
2202
2203/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002204static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002205 { 2, NULL }
2206};
2207
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002208static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002209 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002210 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002211 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002212 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002213 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2214 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2217 { } /* end */
2218};
2219
2220
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002221/*
2222 * ALC880 F1734 model
2223 *
2224 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2225 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2226 */
2227
2228static hda_nid_t alc880_f1734_dac_nids[1] = {
2229 0x03
2230};
2231#define ALC880_F1734_HP_DAC 0x02
2232
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002233static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002234 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002235 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002236 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2237 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002238 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2239 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002240 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2241 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002242 { } /* end */
2243};
2244
Takashi Iwai937b4162008-02-11 14:52:36 +01002245static struct hda_input_mux alc880_f1734_capture_source = {
2246 .num_items = 2,
2247 .items = {
2248 { "Mic", 0x1 },
2249 { "CD", 0x4 },
2250 },
2251};
2252
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002253
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002254/*
2255 * ALC880 ASUS model
2256 *
2257 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2258 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2259 * Mic = 0x18, Line = 0x1a
2260 */
2261
2262#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2263#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2264
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002265static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002266 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002267 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002268 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002269 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002270 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2271 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002272 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2273 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002274 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2275 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2276 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2277 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2278 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2279 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002280 {
2281 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2282 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002283 .info = alc_ch_mode_info,
2284 .get = alc_ch_mode_get,
2285 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002286 },
2287 { } /* end */
2288};
2289
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002290/*
2291 * ALC880 ASUS W1V model
2292 *
2293 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2294 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2295 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2296 */
2297
2298/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002299static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002300 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2301 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002302 { } /* end */
2303};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002304
Kailang Yangdf694da2005-12-05 19:42:22 +01002305/* TCL S700 */
2306static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2307 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2308 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2309 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2310 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2311 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2312 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2313 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2314 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2315 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002316 { } /* end */
2317};
2318
Kailang Yangccc656c2006-10-17 12:32:26 +02002319/* Uniwill */
2320static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002321 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2322 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2323 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2324 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002325 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2326 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2327 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2328 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2329 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2330 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2331 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2332 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2333 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2334 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2335 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2336 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002337 {
2338 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2339 .name = "Channel Mode",
2340 .info = alc_ch_mode_info,
2341 .get = alc_ch_mode_get,
2342 .put = alc_ch_mode_put,
2343 },
2344 { } /* end */
2345};
2346
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002347static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2348 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2349 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2350 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2351 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2352 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2353 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2354 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2355 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2356 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2357 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2358 { } /* end */
2359};
2360
Kailang Yangccc656c2006-10-17 12:32:26 +02002361static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002362 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2363 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2364 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2365 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2367 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2368 { } /* end */
2369};
2370
Linus Torvalds1da177e2005-04-16 15:20:36 -07002371/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002372 * virtual master controls
2373 */
2374
2375/*
2376 * slave controls for virtual master
2377 */
2378static const char *alc_slave_vols[] = {
2379 "Front Playback Volume",
2380 "Surround Playback Volume",
2381 "Center Playback Volume",
2382 "LFE Playback Volume",
2383 "Side Playback Volume",
2384 "Headphone Playback Volume",
2385 "Speaker Playback Volume",
2386 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002387 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002388 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002389 NULL,
2390};
2391
2392static const char *alc_slave_sws[] = {
2393 "Front Playback Switch",
2394 "Surround Playback Switch",
2395 "Center Playback Switch",
2396 "LFE Playback Switch",
2397 "Side Playback Switch",
2398 "Headphone Playback Switch",
2399 "Speaker Playback Switch",
2400 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002401 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002402 NULL,
2403};
2404
2405/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002406 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002407 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002408
2409static void alc_free_kctls(struct hda_codec *codec);
2410
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002411/* additional beep mixers; the actual parameters are overwritten at build */
2412static struct snd_kcontrol_new alc_beep_mixer[] = {
2413 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2414 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2415 { } /* end */
2416};
2417
Linus Torvalds1da177e2005-04-16 15:20:36 -07002418static int alc_build_controls(struct hda_codec *codec)
2419{
2420 struct alc_spec *spec = codec->spec;
2421 int err;
2422 int i;
2423
2424 for (i = 0; i < spec->num_mixers; i++) {
2425 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2426 if (err < 0)
2427 return err;
2428 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002429 if (spec->cap_mixer) {
2430 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2431 if (err < 0)
2432 return err;
2433 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002434 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002435 err = snd_hda_create_spdif_out_ctls(codec,
2436 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002437 if (err < 0)
2438 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002439 if (!spec->no_analog) {
2440 err = snd_hda_create_spdif_share_sw(codec,
2441 &spec->multiout);
2442 if (err < 0)
2443 return err;
2444 spec->multiout.share_spdif = 1;
2445 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002446 }
2447 if (spec->dig_in_nid) {
2448 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2449 if (err < 0)
2450 return err;
2451 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002452
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002453 /* create beep controls if needed */
2454 if (spec->beep_amp) {
2455 struct snd_kcontrol_new *knew;
2456 for (knew = alc_beep_mixer; knew->name; knew++) {
2457 struct snd_kcontrol *kctl;
2458 kctl = snd_ctl_new1(knew, codec);
2459 if (!kctl)
2460 return -ENOMEM;
2461 kctl->private_value = spec->beep_amp;
2462 err = snd_hda_ctl_add(codec, kctl);
2463 if (err < 0)
2464 return err;
2465 }
2466 }
2467
Takashi Iwai2134ea42008-01-10 16:53:55 +01002468 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002469 if (!spec->no_analog &&
2470 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002471 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002472 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002473 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002474 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002475 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002476 if (err < 0)
2477 return err;
2478 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002479 if (!spec->no_analog &&
2480 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002481 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2482 NULL, alc_slave_sws);
2483 if (err < 0)
2484 return err;
2485 }
2486
Takashi Iwai603c4012008-07-30 15:01:44 +02002487 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002488 return 0;
2489}
2490
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002491
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492/*
2493 * initialize the codec volumes, etc
2494 */
2495
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002496/*
2497 * generic initialization of ADC, input mixers and output mixers
2498 */
2499static struct hda_verb alc880_volume_init_verbs[] = {
2500 /*
2501 * Unmute ADC0-2 and set the default input to mic-in
2502 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002503 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002505 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002506 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002507 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002508 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002509
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002510 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2511 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002512 * Note: PASD motherboards uses the Line In 2 as the input for front
2513 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002515 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002523
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002524 /*
2525 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002526 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002527 /* set vol=0 to output mixers */
2528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2529 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2530 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2531 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2532 /* set up input amps for analog loopback */
2533 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002534 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2535 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002536 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2537 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002538 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002540 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2541 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002542
2543 { }
2544};
2545
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002546/*
2547 * 3-stack pin configuration:
2548 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2549 */
2550static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2551 /*
2552 * preset connection lists of input pins
2553 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2554 */
2555 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2556 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2557 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2558
2559 /*
2560 * Set pin mode and muting
2561 */
2562 /* set front pin widgets 0x14 for output */
2563 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2564 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2565 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2566 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2567 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2568 /* Mic2 (as headphone out) for HP output */
2569 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2570 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2571 /* Line In pin widget for input */
2572 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2573 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2574 /* Line2 (as front mic) pin widget for input and vref at 80% */
2575 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2576 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2577 /* CD pin widget for input */
2578 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2579
2580 { }
2581};
2582
2583/*
2584 * 5-stack pin configuration:
2585 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2586 * line-in/side = 0x1a, f-mic = 0x1b
2587 */
2588static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2589 /*
2590 * preset connection lists of input pins
2591 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2592 */
2593 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2594 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2595
2596 /*
2597 * Set pin mode and muting
2598 */
2599 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2601 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2602 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2603 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002604 /* unmute pins for output (no gain on this amp) */
2605 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2606 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2607 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2608 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2609
Linus Torvalds1da177e2005-04-16 15:20:36 -07002610 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002611 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002612 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2613 /* Mic2 (as headphone out) for HP output */
2614 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002615 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002616 /* Line In pin widget for input */
2617 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2618 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2619 /* Line2 (as front mic) pin widget for input and vref at 80% */
2620 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2621 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2622 /* CD pin widget for input */
2623 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002624
2625 { }
2626};
2627
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002628/*
2629 * W810 pin configuration:
2630 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2631 */
2632static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002633 /* hphone/speaker input selector: front DAC */
2634 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2635
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002636 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2637 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2638 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2640 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2641 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2642
2643 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002644 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002645
Linus Torvalds1da177e2005-04-16 15:20:36 -07002646 { }
2647};
2648
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002649/*
2650 * Z71V pin configuration:
2651 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2652 */
2653static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002655 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002656 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002657 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002658
Takashi Iwai16ded522005-06-10 19:58:24 +02002659 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002660 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002661 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002662 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002663
2664 { }
2665};
2666
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002667/*
2668 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002669 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2670 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002671 */
2672static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2673 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2674
Takashi Iwai16ded522005-06-10 19:58:24 +02002675 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002676 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002677 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002678 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002679 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002680 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002681 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002682 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2683
Takashi Iwai16ded522005-06-10 19:58:24 +02002684 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002685 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002686 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002687 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002688 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002689 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002690 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002691 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002692 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002693
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002694 { }
2695};
Takashi Iwai16ded522005-06-10 19:58:24 +02002696
Kailang Yangccc656c2006-10-17 12:32:26 +02002697/*
2698 * Uniwill pin configuration:
2699 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2700 * line = 0x1a
2701 */
2702static struct hda_verb alc880_uniwill_init_verbs[] = {
2703 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2704
2705 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2706 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2709 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2710 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2711 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2712 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2713 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2714 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2715 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2716 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2717 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2718 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2719
2720 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2721 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2722 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2723 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2724 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2725 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2726 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2727 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2728 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2729
2730 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2731 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2732
2733 { }
2734};
2735
2736/*
2737* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002738* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002739 */
2740static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2741 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2742
2743 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2744 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2745 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2747 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2748 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2749 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2751 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2752 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2753 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2754 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2755
2756 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2757 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2758 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2759 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2760 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2761 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2762
2763 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2764 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2765
2766 { }
2767};
2768
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002769static struct hda_verb alc880_beep_init_verbs[] = {
2770 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2771 { }
2772};
2773
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002774/* auto-toggle front mic */
2775static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2776{
2777 unsigned int present;
2778 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002779
2780 present = snd_hda_codec_read(codec, 0x18, 0,
2781 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002782 bits = present ? HDA_AMP_MUTE : 0;
2783 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002784}
2785
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002786static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002787{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002788 struct alc_spec *spec = codec->spec;
2789
2790 spec->autocfg.hp_pins[0] = 0x14;
2791 spec->autocfg.speaker_pins[0] = 0x15;
2792 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002793}
2794
2795static void alc880_uniwill_init_hook(struct hda_codec *codec)
2796{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002797 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002798 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002799}
2800
2801static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2802 unsigned int res)
2803{
2804 /* Looks like the unsol event is incompatible with the standard
2805 * definition. 4bit tag is placed at 28 bit!
2806 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002807 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002808 case ALC880_MIC_EVENT:
2809 alc880_uniwill_mic_automute(codec);
2810 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002811 default:
2812 alc_automute_amp_unsol_event(codec, res);
2813 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002814 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002815}
2816
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002817static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002818{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002819 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002820
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002821 spec->autocfg.hp_pins[0] = 0x14;
2822 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002823}
2824
2825static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2826{
2827 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002828
Kailang Yangccc656c2006-10-17 12:32:26 +02002829 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002830 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2831 present &= HDA_AMP_VOLMASK;
2832 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2833 HDA_AMP_VOLMASK, present);
2834 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2835 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002836}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002837
Kailang Yangccc656c2006-10-17 12:32:26 +02002838static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2839 unsigned int res)
2840{
2841 /* Looks like the unsol event is incompatible with the standard
2842 * definition. 4bit tag is placed at 28 bit!
2843 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002844 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002845 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002846 else
2847 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002848}
2849
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002850/*
2851 * F1734 pin configuration:
2852 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2853 */
2854static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002855 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002856 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2857 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2858 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2859 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2860
2861 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2862 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2863 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2865
2866 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2867 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002868 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002869 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2870 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2871 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2872 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2873 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2874 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002875
Takashi Iwai937b4162008-02-11 14:52:36 +01002876 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2877 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2878
Takashi Iwai16ded522005-06-10 19:58:24 +02002879 { }
2880};
2881
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002882/*
2883 * ASUS pin configuration:
2884 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2885 */
2886static struct hda_verb alc880_pin_asus_init_verbs[] = {
2887 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2888 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2889 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2890 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2891
2892 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2893 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2894 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2895 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2896 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2897 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2898 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2899 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2900
2901 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2902 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2903 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2904 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2905 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2906 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2907 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2909 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002910
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002911 { }
2912};
2913
2914/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002915#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2916#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002917#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002918
Kailang Yangdf694da2005-12-05 19:42:22 +01002919/* Clevo m520g init */
2920static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2921 /* headphone output */
2922 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2923 /* line-out */
2924 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2925 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2926 /* Line-in */
2927 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2928 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2929 /* CD */
2930 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2931 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2932 /* Mic1 (rear panel) */
2933 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2934 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2935 /* Mic2 (front panel) */
2936 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2937 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2938 /* headphone */
2939 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2940 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2941 /* change to EAPD mode */
2942 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2943 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2944
2945 { }
2946};
2947
2948static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002949 /* change to EAPD mode */
2950 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2951 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2952
Kailang Yangdf694da2005-12-05 19:42:22 +01002953 /* Headphone output */
2954 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2955 /* Front output*/
2956 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2957 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2958
2959 /* Line In pin widget for input */
2960 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2961 /* CD pin widget for input */
2962 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2963 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2964 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2965
2966 /* change to EAPD mode */
2967 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2968 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2969
2970 { }
2971};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002972
2973/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002974 * LG m1 express dual
2975 *
2976 * Pin assignment:
2977 * Rear Line-In/Out (blue): 0x14
2978 * Build-in Mic-In: 0x15
2979 * Speaker-out: 0x17
2980 * HP-Out (green): 0x1b
2981 * Mic-In/Out (red): 0x19
2982 * SPDIF-Out: 0x1e
2983 */
2984
2985/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2986static hda_nid_t alc880_lg_dac_nids[3] = {
2987 0x05, 0x02, 0x03
2988};
2989
2990/* seems analog CD is not working */
2991static struct hda_input_mux alc880_lg_capture_source = {
2992 .num_items = 3,
2993 .items = {
2994 { "Mic", 0x1 },
2995 { "Line", 0x5 },
2996 { "Internal Mic", 0x6 },
2997 },
2998};
2999
3000/* 2,4,6 channel modes */
3001static struct hda_verb alc880_lg_ch2_init[] = {
3002 /* set line-in and mic-in to input */
3003 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3004 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3005 { }
3006};
3007
3008static struct hda_verb alc880_lg_ch4_init[] = {
3009 /* set line-in to out and mic-in to input */
3010 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3011 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3012 { }
3013};
3014
3015static struct hda_verb alc880_lg_ch6_init[] = {
3016 /* set line-in and mic-in to output */
3017 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3018 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3019 { }
3020};
3021
3022static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3023 { 2, alc880_lg_ch2_init },
3024 { 4, alc880_lg_ch4_init },
3025 { 6, alc880_lg_ch6_init },
3026};
3027
3028static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003029 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3030 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003031 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3032 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3033 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3034 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3035 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3036 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3037 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3038 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3039 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3040 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3041 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3042 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3043 {
3044 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3045 .name = "Channel Mode",
3046 .info = alc_ch_mode_info,
3047 .get = alc_ch_mode_get,
3048 .put = alc_ch_mode_put,
3049 },
3050 { } /* end */
3051};
3052
3053static struct hda_verb alc880_lg_init_verbs[] = {
3054 /* set capture source to mic-in */
3055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3056 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3057 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3058 /* mute all amp mixer inputs */
3059 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003060 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003062 /* line-in to input */
3063 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3064 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3065 /* built-in mic */
3066 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3068 /* speaker-out */
3069 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3070 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3071 /* mic-in to input */
3072 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3073 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3074 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3075 /* HP-out */
3076 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3077 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3078 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3079 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003080 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003081 { }
3082};
3083
3084/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003085static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003086{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003087 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003088
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003089 spec->autocfg.hp_pins[0] = 0x1b;
3090 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003091}
3092
3093/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003094 * LG LW20
3095 *
3096 * Pin assignment:
3097 * Speaker-out: 0x14
3098 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003099 * Built-in Mic-In: 0x19
3100 * Line-In: 0x1b
3101 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003102 * SPDIF-Out: 0x1e
3103 */
3104
Takashi Iwaid6815182006-03-23 16:06:23 +01003105static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003106 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003107 .items = {
3108 { "Mic", 0x0 },
3109 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003110 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003111 },
3112};
3113
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003114#define alc880_lg_lw_modes alc880_threestack_modes
3115
Takashi Iwaid6815182006-03-23 16:06:23 +01003116static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003117 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3118 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3119 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3120 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3121 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3122 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3123 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3124 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3125 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3126 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003127 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3128 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3129 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3130 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003131 {
3132 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3133 .name = "Channel Mode",
3134 .info = alc_ch_mode_info,
3135 .get = alc_ch_mode_get,
3136 .put = alc_ch_mode_put,
3137 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003138 { } /* end */
3139};
3140
3141static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003142 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3143 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3144 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3145
Takashi Iwaid6815182006-03-23 16:06:23 +01003146 /* set capture source to mic-in */
3147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3148 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3149 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003151 /* speaker-out */
3152 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3153 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3154 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003155 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3156 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3157 /* mic-in to input */
3158 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3159 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3160 /* built-in mic */
3161 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3162 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3163 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003164 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003165 { }
3166};
3167
3168/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003169static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003170{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003171 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003172
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003173 spec->autocfg.hp_pins[0] = 0x1b;
3174 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003175}
3176
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003177static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3178 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3179 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3181 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3182 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3183 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3184 { } /* end */
3185};
3186
3187static struct hda_input_mux alc880_medion_rim_capture_source = {
3188 .num_items = 2,
3189 .items = {
3190 { "Mic", 0x0 },
3191 { "Internal Mic", 0x1 },
3192 },
3193};
3194
3195static struct hda_verb alc880_medion_rim_init_verbs[] = {
3196 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3197
3198 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3199 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3200
3201 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3202 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3203 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3204 /* Mic2 (as headphone out) for HP output */
3205 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3206 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3207 /* Internal Speaker */
3208 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3209 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3210
3211 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3212 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3213
3214 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3215 { }
3216};
3217
3218/* toggle speaker-output according to the hp-jack state */
3219static void alc880_medion_rim_automute(struct hda_codec *codec)
3220{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003221 struct alc_spec *spec = codec->spec;
3222 alc_automute_amp(codec);
3223 /* toggle EAPD */
3224 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003225 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3226 else
3227 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3228}
3229
3230static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3231 unsigned int res)
3232{
3233 /* Looks like the unsol event is incompatible with the standard
3234 * definition. 4bit tag is placed at 28 bit!
3235 */
3236 if ((res >> 28) == ALC880_HP_EVENT)
3237 alc880_medion_rim_automute(codec);
3238}
3239
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003240static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003241{
3242 struct alc_spec *spec = codec->spec;
3243
3244 spec->autocfg.hp_pins[0] = 0x14;
3245 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003246}
3247
Takashi Iwaicb53c622007-08-10 17:21:45 +02003248#ifdef CONFIG_SND_HDA_POWER_SAVE
3249static struct hda_amp_list alc880_loopbacks[] = {
3250 { 0x0b, HDA_INPUT, 0 },
3251 { 0x0b, HDA_INPUT, 1 },
3252 { 0x0b, HDA_INPUT, 2 },
3253 { 0x0b, HDA_INPUT, 3 },
3254 { 0x0b, HDA_INPUT, 4 },
3255 { } /* end */
3256};
3257
3258static struct hda_amp_list alc880_lg_loopbacks[] = {
3259 { 0x0b, HDA_INPUT, 1 },
3260 { 0x0b, HDA_INPUT, 6 },
3261 { 0x0b, HDA_INPUT, 7 },
3262 { } /* end */
3263};
3264#endif
3265
Takashi Iwaid6815182006-03-23 16:06:23 +01003266/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003267 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003268 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003269
Linus Torvalds1da177e2005-04-16 15:20:36 -07003270static int alc_init(struct hda_codec *codec)
3271{
3272 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003273 unsigned int i;
3274
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003275 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003276 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003277
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003278 for (i = 0; i < spec->num_init_verbs; i++)
3279 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003280
3281 if (spec->init_hook)
3282 spec->init_hook(codec);
3283
Linus Torvalds1da177e2005-04-16 15:20:36 -07003284 return 0;
3285}
3286
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003287static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3288{
3289 struct alc_spec *spec = codec->spec;
3290
3291 if (spec->unsol_event)
3292 spec->unsol_event(codec, res);
3293}
3294
Takashi Iwaicb53c622007-08-10 17:21:45 +02003295#ifdef CONFIG_SND_HDA_POWER_SAVE
3296static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3297{
3298 struct alc_spec *spec = codec->spec;
3299 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3300}
3301#endif
3302
Linus Torvalds1da177e2005-04-16 15:20:36 -07003303/*
3304 * Analog playback callbacks
3305 */
3306static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3307 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003308 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003309{
3310 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003311 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3312 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003313}
3314
3315static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3316 struct hda_codec *codec,
3317 unsigned int stream_tag,
3318 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003319 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003320{
3321 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003322 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3323 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003324}
3325
3326static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3327 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003328 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003329{
3330 struct alc_spec *spec = codec->spec;
3331 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3332}
3333
3334/*
3335 * Digital out
3336 */
3337static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3338 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003339 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003340{
3341 struct alc_spec *spec = codec->spec;
3342 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3343}
3344
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003345static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3346 struct hda_codec *codec,
3347 unsigned int stream_tag,
3348 unsigned int format,
3349 struct snd_pcm_substream *substream)
3350{
3351 struct alc_spec *spec = codec->spec;
3352 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3353 stream_tag, format, substream);
3354}
3355
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003356static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3357 struct hda_codec *codec,
3358 struct snd_pcm_substream *substream)
3359{
3360 struct alc_spec *spec = codec->spec;
3361 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3362}
3363
Linus Torvalds1da177e2005-04-16 15:20:36 -07003364static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3365 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003366 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003367{
3368 struct alc_spec *spec = codec->spec;
3369 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3370}
3371
3372/*
3373 * Analog capture
3374 */
Takashi Iwai63300792008-01-24 15:31:36 +01003375static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003376 struct hda_codec *codec,
3377 unsigned int stream_tag,
3378 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003379 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003380{
3381 struct alc_spec *spec = codec->spec;
3382
Takashi Iwai63300792008-01-24 15:31:36 +01003383 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003384 stream_tag, 0, format);
3385 return 0;
3386}
3387
Takashi Iwai63300792008-01-24 15:31:36 +01003388static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003389 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003390 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003391{
3392 struct alc_spec *spec = codec->spec;
3393
Takashi Iwai888afa12008-03-18 09:57:50 +01003394 snd_hda_codec_cleanup_stream(codec,
3395 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003396 return 0;
3397}
3398
3399
3400/*
3401 */
3402static struct hda_pcm_stream alc880_pcm_analog_playback = {
3403 .substreams = 1,
3404 .channels_min = 2,
3405 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003406 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003407 .ops = {
3408 .open = alc880_playback_pcm_open,
3409 .prepare = alc880_playback_pcm_prepare,
3410 .cleanup = alc880_playback_pcm_cleanup
3411 },
3412};
3413
3414static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003415 .substreams = 1,
3416 .channels_min = 2,
3417 .channels_max = 2,
3418 /* NID is set in alc_build_pcms */
3419};
3420
3421static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3422 .substreams = 1,
3423 .channels_min = 2,
3424 .channels_max = 2,
3425 /* NID is set in alc_build_pcms */
3426};
3427
3428static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3429 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003430 .channels_min = 2,
3431 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003432 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003433 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003434 .prepare = alc880_alt_capture_pcm_prepare,
3435 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003436 },
3437};
3438
3439static struct hda_pcm_stream alc880_pcm_digital_playback = {
3440 .substreams = 1,
3441 .channels_min = 2,
3442 .channels_max = 2,
3443 /* NID is set in alc_build_pcms */
3444 .ops = {
3445 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003446 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003447 .prepare = alc880_dig_playback_pcm_prepare,
3448 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003449 },
3450};
3451
3452static struct hda_pcm_stream alc880_pcm_digital_capture = {
3453 .substreams = 1,
3454 .channels_min = 2,
3455 .channels_max = 2,
3456 /* NID is set in alc_build_pcms */
3457};
3458
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003459/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003460static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003461 .substreams = 0,
3462 .channels_min = 0,
3463 .channels_max = 0,
3464};
3465
Linus Torvalds1da177e2005-04-16 15:20:36 -07003466static int alc_build_pcms(struct hda_codec *codec)
3467{
3468 struct alc_spec *spec = codec->spec;
3469 struct hda_pcm *info = spec->pcm_rec;
3470 int i;
3471
3472 codec->num_pcms = 1;
3473 codec->pcm_info = info;
3474
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003475 if (spec->no_analog)
3476 goto skip_analog;
3477
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003478 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3479 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003480 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003481
Takashi Iwai4a471b72005-12-07 13:56:29 +01003482 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003483 if (snd_BUG_ON(!spec->multiout.dac_nids))
3484 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003485 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3486 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3487 }
3488 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003489 if (snd_BUG_ON(!spec->adc_nids))
3490 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003491 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3492 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3493 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003494
Takashi Iwai4a471b72005-12-07 13:56:29 +01003495 if (spec->channel_mode) {
3496 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3497 for (i = 0; i < spec->num_channel_mode; i++) {
3498 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3499 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3500 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003501 }
3502 }
3503
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003504 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003505 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003506 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003507 snprintf(spec->stream_name_digital,
3508 sizeof(spec->stream_name_digital),
3509 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003510 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003511 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003512 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003513 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003514 if (spec->dig_out_type)
3515 info->pcm_type = spec->dig_out_type;
3516 else
3517 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003518 if (spec->multiout.dig_out_nid &&
3519 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003520 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3521 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3522 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003523 if (spec->dig_in_nid &&
3524 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003525 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3526 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3527 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003528 /* FIXME: do we need this for all Realtek codec models? */
3529 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003530 }
3531
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003532 if (spec->no_analog)
3533 return 0;
3534
Takashi Iwaie08a0072006-09-07 17:52:14 +02003535 /* If the use of more than one ADC is requested for the current
3536 * model, configure a second analog capture-only PCM.
3537 */
3538 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003539 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3540 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003541 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003542 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003543 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003544 if (spec->alt_dac_nid) {
3545 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3546 *spec->stream_analog_alt_playback;
3547 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3548 spec->alt_dac_nid;
3549 } else {
3550 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3551 alc_pcm_null_stream;
3552 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3553 }
3554 if (spec->num_adc_nids > 1) {
3555 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3556 *spec->stream_analog_alt_capture;
3557 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3558 spec->adc_nids[1];
3559 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3560 spec->num_adc_nids - 1;
3561 } else {
3562 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3563 alc_pcm_null_stream;
3564 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003565 }
3566 }
3567
Linus Torvalds1da177e2005-04-16 15:20:36 -07003568 return 0;
3569}
3570
Takashi Iwai603c4012008-07-30 15:01:44 +02003571static void alc_free_kctls(struct hda_codec *codec)
3572{
3573 struct alc_spec *spec = codec->spec;
3574
3575 if (spec->kctls.list) {
3576 struct snd_kcontrol_new *kctl = spec->kctls.list;
3577 int i;
3578 for (i = 0; i < spec->kctls.used; i++)
3579 kfree(kctl[i].name);
3580 }
3581 snd_array_free(&spec->kctls);
3582}
3583
Linus Torvalds1da177e2005-04-16 15:20:36 -07003584static void alc_free(struct hda_codec *codec)
3585{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003586 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003587
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003588 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003589 return;
3590
Takashi Iwai603c4012008-07-30 15:01:44 +02003591 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003592 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003593 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003594}
3595
Takashi Iwaie044c392008-10-27 16:56:24 +01003596#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003597static int alc_resume(struct hda_codec *codec)
3598{
Takashi Iwaie044c392008-10-27 16:56:24 +01003599 codec->patch_ops.init(codec);
3600 snd_hda_codec_resume_amp(codec);
3601 snd_hda_codec_resume_cache(codec);
3602 return 0;
3603}
Takashi Iwaie044c392008-10-27 16:56:24 +01003604#endif
3605
Linus Torvalds1da177e2005-04-16 15:20:36 -07003606/*
3607 */
3608static struct hda_codec_ops alc_patch_ops = {
3609 .build_controls = alc_build_controls,
3610 .build_pcms = alc_build_pcms,
3611 .init = alc_init,
3612 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003613 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003614#ifdef SND_HDA_NEEDS_RESUME
3615 .resume = alc_resume,
3616#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003617#ifdef CONFIG_SND_HDA_POWER_SAVE
3618 .check_power_status = alc_check_power_status,
3619#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003620};
3621
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003622
3623/*
3624 * Test configuration for debugging
3625 *
3626 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3627 * enum controls.
3628 */
3629#ifdef CONFIG_SND_DEBUG
3630static hda_nid_t alc880_test_dac_nids[4] = {
3631 0x02, 0x03, 0x04, 0x05
3632};
3633
3634static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003635 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003636 .items = {
3637 { "In-1", 0x0 },
3638 { "In-2", 0x1 },
3639 { "In-3", 0x2 },
3640 { "In-4", 0x3 },
3641 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003642 { "Front", 0x5 },
3643 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003644 },
3645};
3646
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003647static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003648 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003649 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003650 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003651 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003652};
3653
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003654static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3655 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003656{
3657 static char *texts[] = {
3658 "N/A", "Line Out", "HP Out",
3659 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3660 };
3661 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3662 uinfo->count = 1;
3663 uinfo->value.enumerated.items = 8;
3664 if (uinfo->value.enumerated.item >= 8)
3665 uinfo->value.enumerated.item = 7;
3666 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3667 return 0;
3668}
3669
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003670static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3671 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003672{
3673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3674 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3675 unsigned int pin_ctl, item = 0;
3676
3677 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3678 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3679 if (pin_ctl & AC_PINCTL_OUT_EN) {
3680 if (pin_ctl & AC_PINCTL_HP_EN)
3681 item = 2;
3682 else
3683 item = 1;
3684 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3685 switch (pin_ctl & AC_PINCTL_VREFEN) {
3686 case AC_PINCTL_VREF_HIZ: item = 3; break;
3687 case AC_PINCTL_VREF_50: item = 4; break;
3688 case AC_PINCTL_VREF_GRD: item = 5; break;
3689 case AC_PINCTL_VREF_80: item = 6; break;
3690 case AC_PINCTL_VREF_100: item = 7; break;
3691 }
3692 }
3693 ucontrol->value.enumerated.item[0] = item;
3694 return 0;
3695}
3696
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003697static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3698 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003699{
3700 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3701 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3702 static unsigned int ctls[] = {
3703 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3704 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3705 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3706 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3707 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3708 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3709 };
3710 unsigned int old_ctl, new_ctl;
3711
3712 old_ctl = snd_hda_codec_read(codec, nid, 0,
3713 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3714 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3715 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003716 int val;
3717 snd_hda_codec_write_cache(codec, nid, 0,
3718 AC_VERB_SET_PIN_WIDGET_CONTROL,
3719 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003720 val = ucontrol->value.enumerated.item[0] >= 3 ?
3721 HDA_AMP_MUTE : 0;
3722 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3723 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003724 return 1;
3725 }
3726 return 0;
3727}
3728
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003729static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3730 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003731{
3732 static char *texts[] = {
3733 "Front", "Surround", "CLFE", "Side"
3734 };
3735 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3736 uinfo->count = 1;
3737 uinfo->value.enumerated.items = 4;
3738 if (uinfo->value.enumerated.item >= 4)
3739 uinfo->value.enumerated.item = 3;
3740 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3741 return 0;
3742}
3743
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003744static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3745 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003746{
3747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3748 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3749 unsigned int sel;
3750
3751 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3752 ucontrol->value.enumerated.item[0] = sel & 3;
3753 return 0;
3754}
3755
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003756static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3757 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003758{
3759 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3760 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3761 unsigned int sel;
3762
3763 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3764 if (ucontrol->value.enumerated.item[0] != sel) {
3765 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003766 snd_hda_codec_write_cache(codec, nid, 0,
3767 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003768 return 1;
3769 }
3770 return 0;
3771}
3772
3773#define PIN_CTL_TEST(xname,nid) { \
3774 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3775 .name = xname, \
3776 .info = alc_test_pin_ctl_info, \
3777 .get = alc_test_pin_ctl_get, \
3778 .put = alc_test_pin_ctl_put, \
3779 .private_value = nid \
3780 }
3781
3782#define PIN_SRC_TEST(xname,nid) { \
3783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3784 .name = xname, \
3785 .info = alc_test_pin_src_info, \
3786 .get = alc_test_pin_src_get, \
3787 .put = alc_test_pin_src_put, \
3788 .private_value = nid \
3789 }
3790
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003791static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003792 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3793 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3794 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3795 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003796 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3797 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3798 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3799 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003800 PIN_CTL_TEST("Front Pin Mode", 0x14),
3801 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3802 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3803 PIN_CTL_TEST("Side Pin Mode", 0x17),
3804 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3805 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3806 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3807 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3808 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3809 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3810 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3811 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3812 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3813 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3814 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3815 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3816 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3817 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3818 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3819 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3820 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3821 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003822 {
3823 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3824 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003825 .info = alc_ch_mode_info,
3826 .get = alc_ch_mode_get,
3827 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003828 },
3829 { } /* end */
3830};
3831
3832static struct hda_verb alc880_test_init_verbs[] = {
3833 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003834 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3835 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3836 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3837 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3838 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3839 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3840 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3841 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003842 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003843 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3844 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3845 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3846 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003847 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003848 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3849 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3850 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3851 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003852 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003853 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3854 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3855 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3856 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003857 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003858 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3859 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003860 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3861 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3862 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003863 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003864 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3865 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3866 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3867 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003868 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003869 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003870 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003871 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003872 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003873 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003874 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003875 /* Analog input/passthru */
3876 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3877 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3878 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3879 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3880 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003881 { }
3882};
3883#endif
3884
Linus Torvalds1da177e2005-04-16 15:20:36 -07003885/*
3886 */
3887
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003888static const char *alc880_models[ALC880_MODEL_LAST] = {
3889 [ALC880_3ST] = "3stack",
3890 [ALC880_TCL_S700] = "tcl",
3891 [ALC880_3ST_DIG] = "3stack-digout",
3892 [ALC880_CLEVO] = "clevo",
3893 [ALC880_5ST] = "5stack",
3894 [ALC880_5ST_DIG] = "5stack-digout",
3895 [ALC880_W810] = "w810",
3896 [ALC880_Z71V] = "z71v",
3897 [ALC880_6ST] = "6stack",
3898 [ALC880_6ST_DIG] = "6stack-digout",
3899 [ALC880_ASUS] = "asus",
3900 [ALC880_ASUS_W1V] = "asus-w1v",
3901 [ALC880_ASUS_DIG] = "asus-dig",
3902 [ALC880_ASUS_DIG2] = "asus-dig2",
3903 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003904 [ALC880_UNIWILL_P53] = "uniwill-p53",
3905 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003906 [ALC880_F1734] = "F1734",
3907 [ALC880_LG] = "lg",
3908 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003909 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003910#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003911 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003912#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003913 [ALC880_AUTO] = "auto",
3914};
3915
3916static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003917 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003918 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3919 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3920 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3921 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3922 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3923 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3924 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3925 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003926 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3927 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003928 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3929 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3930 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3931 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3932 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3933 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3934 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3935 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3936 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3937 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003938 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003939 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3940 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3941 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003942 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003943 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003944 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3945 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003946 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3947 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003948 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3949 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3950 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3951 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003952 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3953 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003954 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003955 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003956 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003957 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003958 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3959 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003960 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003961 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003962 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003963 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003964 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003965 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003966 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003967 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003968 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003969 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3970 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003971 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003972 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3973 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3974 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3975 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003976 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3977 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003978 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003979 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003980 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3981 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003982 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3983 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3984 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003985 /* default Intel */
3986 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003987 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3988 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003989 {}
3990};
3991
Takashi Iwai16ded522005-06-10 19:58:24 +02003992/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003993 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003994 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003995static struct alc_config_preset alc880_presets[] = {
3996 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003997 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003998 .init_verbs = { alc880_volume_init_verbs,
3999 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004000 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004001 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004002 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4003 .channel_mode = alc880_threestack_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 },
4007 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004008 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004009 .init_verbs = { alc880_volume_init_verbs,
4010 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004011 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004012 .dac_nids = alc880_dac_nids,
4013 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004014 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4015 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004016 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004017 .input_mux = &alc880_capture_source,
4018 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004019 [ALC880_TCL_S700] = {
4020 .mixers = { alc880_tcl_s700_mixer },
4021 .init_verbs = { alc880_volume_init_verbs,
4022 alc880_pin_tcl_S700_init_verbs,
4023 alc880_gpio2_init_verbs },
4024 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4025 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004026 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4027 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004028 .hp_nid = 0x03,
4029 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4030 .channel_mode = alc880_2_jack_modes,
4031 .input_mux = &alc880_capture_source,
4032 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004033 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004034 .mixers = { alc880_three_stack_mixer,
4035 alc880_five_stack_mixer},
4036 .init_verbs = { alc880_volume_init_verbs,
4037 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004038 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4039 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004040 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4041 .channel_mode = alc880_fivestack_modes,
4042 .input_mux = &alc880_capture_source,
4043 },
4044 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004045 .mixers = { alc880_three_stack_mixer,
4046 alc880_five_stack_mixer },
4047 .init_verbs = { alc880_volume_init_verbs,
4048 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004049 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4050 .dac_nids = alc880_dac_nids,
4051 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004052 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4053 .channel_mode = alc880_fivestack_modes,
4054 .input_mux = &alc880_capture_source,
4055 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004056 [ALC880_6ST] = {
4057 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004058 .init_verbs = { alc880_volume_init_verbs,
4059 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004060 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4061 .dac_nids = alc880_6st_dac_nids,
4062 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4063 .channel_mode = alc880_sixstack_modes,
4064 .input_mux = &alc880_6stack_capture_source,
4065 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004066 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004067 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004068 .init_verbs = { alc880_volume_init_verbs,
4069 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004070 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4071 .dac_nids = alc880_6st_dac_nids,
4072 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004073 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4074 .channel_mode = alc880_sixstack_modes,
4075 .input_mux = &alc880_6stack_capture_source,
4076 },
4077 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004078 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004079 .init_verbs = { alc880_volume_init_verbs,
4080 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004081 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004082 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4083 .dac_nids = alc880_w810_dac_nids,
4084 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004085 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4086 .channel_mode = alc880_w810_modes,
4087 .input_mux = &alc880_capture_source,
4088 },
4089 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004090 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004091 .init_verbs = { alc880_volume_init_verbs,
4092 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004093 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4094 .dac_nids = alc880_z71v_dac_nids,
4095 .dig_out_nid = ALC880_DIGOUT_NID,
4096 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004097 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4098 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004099 .input_mux = &alc880_capture_source,
4100 },
4101 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004102 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004103 .init_verbs = { alc880_volume_init_verbs,
4104 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004105 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4106 .dac_nids = alc880_f1734_dac_nids,
4107 .hp_nid = 0x02,
4108 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4109 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004110 .input_mux = &alc880_f1734_capture_source,
4111 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004112 .setup = alc880_uniwill_p53_setup,
4113 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004114 },
4115 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004116 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004117 .init_verbs = { alc880_volume_init_verbs,
4118 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004119 alc880_gpio1_init_verbs },
4120 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4121 .dac_nids = alc880_asus_dac_nids,
4122 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4123 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004124 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004125 .input_mux = &alc880_capture_source,
4126 },
4127 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004128 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004129 .init_verbs = { alc880_volume_init_verbs,
4130 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004131 alc880_gpio1_init_verbs },
4132 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4133 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004134 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004135 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4136 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004137 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004138 .input_mux = &alc880_capture_source,
4139 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004140 [ALC880_ASUS_DIG2] = {
4141 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004142 .init_verbs = { alc880_volume_init_verbs,
4143 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004144 alc880_gpio2_init_verbs }, /* use GPIO2 */
4145 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4146 .dac_nids = alc880_asus_dac_nids,
4147 .dig_out_nid = ALC880_DIGOUT_NID,
4148 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4149 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004150 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004151 .input_mux = &alc880_capture_source,
4152 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004153 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004154 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004155 .init_verbs = { alc880_volume_init_verbs,
4156 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004157 alc880_gpio1_init_verbs },
4158 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4159 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004160 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004161 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4162 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004163 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004164 .input_mux = &alc880_capture_source,
4165 },
4166 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004167 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004168 .init_verbs = { alc880_volume_init_verbs,
4169 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004170 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4171 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004172 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004173 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4174 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004175 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004176 .input_mux = &alc880_capture_source,
4177 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004178 [ALC880_UNIWILL] = {
4179 .mixers = { alc880_uniwill_mixer },
4180 .init_verbs = { alc880_volume_init_verbs,
4181 alc880_uniwill_init_verbs },
4182 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4183 .dac_nids = alc880_asus_dac_nids,
4184 .dig_out_nid = ALC880_DIGOUT_NID,
4185 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4186 .channel_mode = alc880_threestack_modes,
4187 .need_dac_fix = 1,
4188 .input_mux = &alc880_capture_source,
4189 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004190 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004191 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004192 },
4193 [ALC880_UNIWILL_P53] = {
4194 .mixers = { alc880_uniwill_p53_mixer },
4195 .init_verbs = { alc880_volume_init_verbs,
4196 alc880_uniwill_p53_init_verbs },
4197 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4198 .dac_nids = alc880_asus_dac_nids,
4199 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004200 .channel_mode = alc880_threestack_modes,
4201 .input_mux = &alc880_capture_source,
4202 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004203 .setup = alc880_uniwill_p53_setup,
4204 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004205 },
4206 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004207 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004208 .init_verbs = { alc880_volume_init_verbs,
4209 alc880_uniwill_p53_init_verbs,
4210 alc880_beep_init_verbs },
4211 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4212 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004213 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004214 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4215 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004216 .input_mux = &alc880_capture_source,
4217 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004218 .setup = alc880_uniwill_p53_setup,
4219 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004220 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004221 [ALC880_CLEVO] = {
4222 .mixers = { alc880_three_stack_mixer },
4223 .init_verbs = { alc880_volume_init_verbs,
4224 alc880_pin_clevo_init_verbs },
4225 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4226 .dac_nids = alc880_dac_nids,
4227 .hp_nid = 0x03,
4228 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4229 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004230 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004231 .input_mux = &alc880_capture_source,
4232 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004233 [ALC880_LG] = {
4234 .mixers = { alc880_lg_mixer },
4235 .init_verbs = { alc880_volume_init_verbs,
4236 alc880_lg_init_verbs },
4237 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4238 .dac_nids = alc880_lg_dac_nids,
4239 .dig_out_nid = ALC880_DIGOUT_NID,
4240 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4241 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004242 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004243 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004244 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004245 .setup = alc880_lg_setup,
4246 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004247#ifdef CONFIG_SND_HDA_POWER_SAVE
4248 .loopbacks = alc880_lg_loopbacks,
4249#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004250 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004251 [ALC880_LG_LW] = {
4252 .mixers = { alc880_lg_lw_mixer },
4253 .init_verbs = { alc880_volume_init_verbs,
4254 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004255 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004256 .dac_nids = alc880_dac_nids,
4257 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004258 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4259 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004260 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004261 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004262 .setup = alc880_lg_lw_setup,
4263 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004264 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004265 [ALC880_MEDION_RIM] = {
4266 .mixers = { alc880_medion_rim_mixer },
4267 .init_verbs = { alc880_volume_init_verbs,
4268 alc880_medion_rim_init_verbs,
4269 alc_gpio2_init_verbs },
4270 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4271 .dac_nids = alc880_dac_nids,
4272 .dig_out_nid = ALC880_DIGOUT_NID,
4273 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4274 .channel_mode = alc880_2_jack_modes,
4275 .input_mux = &alc880_medion_rim_capture_source,
4276 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004277 .setup = alc880_medion_rim_setup,
4278 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004279 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004280#ifdef CONFIG_SND_DEBUG
4281 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004282 .mixers = { alc880_test_mixer },
4283 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004284 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4285 .dac_nids = alc880_test_dac_nids,
4286 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004287 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4288 .channel_mode = alc880_test_modes,
4289 .input_mux = &alc880_test_capture_source,
4290 },
4291#endif
4292};
4293
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004294/*
4295 * Automatic parse of I/O pins from the BIOS configuration
4296 */
4297
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004298enum {
4299 ALC_CTL_WIDGET_VOL,
4300 ALC_CTL_WIDGET_MUTE,
4301 ALC_CTL_BIND_MUTE,
4302};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004303static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004304 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4305 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004306 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004307};
4308
4309/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004310static int add_control(struct alc_spec *spec, int type, const char *name,
4311 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004312{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004313 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004314
Takashi Iwai603c4012008-07-30 15:01:44 +02004315 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4316 knew = snd_array_new(&spec->kctls);
4317 if (!knew)
4318 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004319 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004320 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004321 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004322 return -ENOMEM;
4323 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004324 return 0;
4325}
4326
4327#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4328#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4329#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4330#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004331#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4332#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4333#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4334#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4335#define ALC880_PIN_CD_NID 0x1c
4336
4337/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004338static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4339 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004340{
4341 hda_nid_t nid;
4342 int assigned[4];
4343 int i, j;
4344
4345 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004346 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004347
4348 /* check the pins hardwired to audio widget */
4349 for (i = 0; i < cfg->line_outs; i++) {
4350 nid = cfg->line_out_pins[i];
4351 if (alc880_is_fixed_pin(nid)) {
4352 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004353 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004354 assigned[idx] = 1;
4355 }
4356 }
4357 /* left pins can be connect to any audio widget */
4358 for (i = 0; i < cfg->line_outs; i++) {
4359 nid = cfg->line_out_pins[i];
4360 if (alc880_is_fixed_pin(nid))
4361 continue;
4362 /* search for an empty channel */
4363 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004364 if (!assigned[j]) {
4365 spec->multiout.dac_nids[i] =
4366 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004367 assigned[j] = 1;
4368 break;
4369 }
4370 }
4371 }
4372 spec->multiout.num_dacs = cfg->line_outs;
4373 return 0;
4374}
4375
4376/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004377static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4378 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004379{
4380 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004381 static const char *chname[4] = {
4382 "Front", "Surround", NULL /*CLFE*/, "Side"
4383 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004384 hda_nid_t nid;
4385 int i, err;
4386
4387 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004388 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004389 continue;
4390 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4391 if (i == 2) {
4392 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004393 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4394 "Center Playback Volume",
4395 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4396 HDA_OUTPUT));
4397 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004398 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004399 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4400 "LFE Playback Volume",
4401 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4402 HDA_OUTPUT));
4403 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004404 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004405 err = add_control(spec, ALC_CTL_BIND_MUTE,
4406 "Center Playback Switch",
4407 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4408 HDA_INPUT));
4409 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004410 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004411 err = add_control(spec, ALC_CTL_BIND_MUTE,
4412 "LFE Playback Switch",
4413 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4414 HDA_INPUT));
4415 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004416 return err;
4417 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004418 const char *pfx;
4419 if (cfg->line_outs == 1 &&
4420 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4421 pfx = "Speaker";
4422 else
4423 pfx = chname[i];
4424 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004425 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4426 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4427 HDA_OUTPUT));
4428 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004429 return err;
Takashi Iwaicb162b62009-08-25 16:05:03 +02004430 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004431 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4432 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4433 HDA_INPUT));
4434 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004435 return err;
4436 }
4437 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004438 return 0;
4439}
4440
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004441/* add playback controls for speaker and HP outputs */
4442static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4443 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004444{
4445 hda_nid_t nid;
4446 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004447 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004448
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004449 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004450 return 0;
4451
4452 if (alc880_is_fixed_pin(pin)) {
4453 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004454 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004455 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004456 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004457 else
4458 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004459 /* control HP volume/switch on the output mixer amp */
4460 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004461 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004462 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4463 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4464 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004465 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004466 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004467 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4468 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4469 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004470 return err;
4471 } else if (alc880_is_multi_pin(pin)) {
4472 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004473 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004474 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004475 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4476 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4477 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004478 return err;
4479 }
4480 return 0;
4481}
4482
4483/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004484static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4485 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004486 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004487{
4488 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004489 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004490
4491 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004492 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4493 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4494 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004495 return err;
4496 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004497 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4498 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4499 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004500 return err;
4501 return 0;
4502}
4503
Takashi Iwai05f5f472009-08-25 13:10:18 +02004504static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004505{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004506 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4507 return (pincap & AC_PINCAP_IN) != 0;
4508}
4509
4510/* create playback/capture controls for input pins */
4511static int alc_auto_create_input_ctls(struct hda_codec *codec,
4512 const struct auto_pin_cfg *cfg,
4513 hda_nid_t mixer,
4514 hda_nid_t cap1, hda_nid_t cap2)
4515{
4516 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004517 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004518 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004519
4520 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004521 hda_nid_t pin;
4522
4523 pin = cfg->input_pins[i];
4524 if (!alc_is_input_pin(codec, pin))
4525 continue;
4526
4527 if (mixer) {
4528 idx = get_connection_index(codec, mixer, pin);
4529 if (idx >= 0) {
4530 err = new_analog_input(spec, pin,
4531 auto_pin_cfg_labels[i],
4532 idx, mixer);
4533 if (err < 0)
4534 return err;
4535 }
4536 }
4537
4538 if (!cap1)
4539 continue;
4540 idx = get_connection_index(codec, cap1, pin);
4541 if (idx < 0 && cap2)
4542 idx = get_connection_index(codec, cap2, pin);
4543 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004544 imux->items[imux->num_items].label =
4545 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004546 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004547 imux->num_items++;
4548 }
4549 }
4550 return 0;
4551}
4552
Takashi Iwai05f5f472009-08-25 13:10:18 +02004553static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4554 const struct auto_pin_cfg *cfg)
4555{
4556 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4557}
4558
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004559static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4560 unsigned int pin_type)
4561{
4562 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4563 pin_type);
4564 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004565 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4566 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004567}
4568
Kailang Yangdf694da2005-12-05 19:42:22 +01004569static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4570 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004571 int dac_idx)
4572{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004573 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004574 /* need the manual connection? */
4575 if (alc880_is_multi_pin(nid)) {
4576 struct alc_spec *spec = codec->spec;
4577 int idx = alc880_multi_pin_idx(nid);
4578 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4579 AC_VERB_SET_CONNECT_SEL,
4580 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4581 }
4582}
4583
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004584static int get_pin_type(int line_out_type)
4585{
4586 if (line_out_type == AUTO_PIN_HP_OUT)
4587 return PIN_HP;
4588 else
4589 return PIN_OUT;
4590}
4591
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004592static void alc880_auto_init_multi_out(struct hda_codec *codec)
4593{
4594 struct alc_spec *spec = codec->spec;
4595 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004596
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004597 for (i = 0; i < spec->autocfg.line_outs; i++) {
4598 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004599 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4600 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004601 }
4602}
4603
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004604static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004605{
4606 struct alc_spec *spec = codec->spec;
4607 hda_nid_t pin;
4608
Takashi Iwai82bc9552006-03-21 11:24:42 +01004609 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004610 if (pin) /* connect to front */
4611 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004612 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004613 if (pin) /* connect to front */
4614 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4615}
4616
4617static void alc880_auto_init_analog_input(struct hda_codec *codec)
4618{
4619 struct alc_spec *spec = codec->spec;
4620 int i;
4621
4622 for (i = 0; i < AUTO_PIN_LAST; i++) {
4623 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004624 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004625 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004626 if (nid != ALC880_PIN_CD_NID &&
4627 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004628 snd_hda_codec_write(codec, nid, 0,
4629 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004630 AMP_OUT_MUTE);
4631 }
4632 }
4633}
4634
4635/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004636/* return 1 if successful, 0 if the proper config is not found,
4637 * or a negative error code
4638 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004639static int alc880_parse_auto_config(struct hda_codec *codec)
4640{
4641 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004642 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004643 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004644
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004645 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4646 alc880_ignore);
4647 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004648 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004649 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004650 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004651
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004652 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4653 if (err < 0)
4654 return err;
4655 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4656 if (err < 0)
4657 return err;
4658 err = alc880_auto_create_extra_out(spec,
4659 spec->autocfg.speaker_pins[0],
4660 "Speaker");
4661 if (err < 0)
4662 return err;
4663 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4664 "Headphone");
4665 if (err < 0)
4666 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004667 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004668 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004669 return err;
4670
4671 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4672
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004673 /* check multiple SPDIF-out (for recent codecs) */
4674 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4675 hda_nid_t dig_nid;
4676 err = snd_hda_get_connections(codec,
4677 spec->autocfg.dig_out_pins[i],
4678 &dig_nid, 1);
4679 if (err < 0)
4680 continue;
4681 if (!i)
4682 spec->multiout.dig_out_nid = dig_nid;
4683 else {
4684 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4685 spec->slave_dig_outs[i - 1] = dig_nid;
4686 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4687 break;
4688 }
4689 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004690 if (spec->autocfg.dig_in_pin)
4691 spec->dig_in_nid = ALC880_DIGIN_NID;
4692
Takashi Iwai603c4012008-07-30 15:01:44 +02004693 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004694 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004695
Takashi Iwaid88897e2008-10-31 15:01:37 +01004696 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004697
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004698 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004699 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004700
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004701 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4702
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004703 return 1;
4704}
4705
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004706/* additional initialization for auto-configuration model */
4707static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004708{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004709 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004710 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004711 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004712 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004713 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004714 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004715}
4716
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004717/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4718 * one of two digital mic pins, e.g. on ALC272
4719 */
4720static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004721{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004722 struct alc_spec *spec = codec->spec;
4723 int i;
4724
4725 for (i = 0; i < spec->num_adc_nids; i++) {
4726 hda_nid_t cap = spec->capsrc_nids ?
4727 spec->capsrc_nids[i] : spec->adc_nids[i];
4728 int iidx, eidx;
4729
4730 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4731 if (iidx < 0)
4732 continue;
4733 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4734 if (eidx < 0)
4735 continue;
4736 spec->int_mic.mux_idx = iidx;
4737 spec->ext_mic.mux_idx = eidx;
4738 if (spec->capsrc_nids)
4739 spec->capsrc_nids += i;
4740 spec->adc_nids += i;
4741 spec->num_adc_nids = 1;
4742 return;
4743 }
4744 snd_printd(KERN_INFO "hda_codec: %s: "
4745 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4746 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4747 spec->auto_mic = 0; /* disable auto-mic to be sure */
4748}
4749
4750static void set_capture_mixer(struct hda_codec *codec)
4751{
4752 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004753 static struct snd_kcontrol_new *caps[2][3] = {
4754 { alc_capture_mixer_nosrc1,
4755 alc_capture_mixer_nosrc2,
4756 alc_capture_mixer_nosrc3 },
4757 { alc_capture_mixer1,
4758 alc_capture_mixer2,
4759 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004760 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004761 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4762 int mux;
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004763 if (spec->auto_mic) {
4764 mux = 0;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004765 fixup_automic_adc(codec);
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004766 } else if (spec->input_mux && spec->input_mux->num_items > 1)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004767 mux = 1;
4768 else
4769 mux = 0;
4770 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4771 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004772}
4773
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004774#define set_beep_amp(spec, nid, idx, dir) \
4775 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4776
4777/*
4778 * OK, here we have finally the patch for ALC880
4779 */
4780
Linus Torvalds1da177e2005-04-16 15:20:36 -07004781static int patch_alc880(struct hda_codec *codec)
4782{
4783 struct alc_spec *spec;
4784 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004785 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004786
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004787 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004788 if (spec == NULL)
4789 return -ENOMEM;
4790
4791 codec->spec = spec;
4792
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004793 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4794 alc880_models,
4795 alc880_cfg_tbl);
4796 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004797 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4798 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004799 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004800 }
4801
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004802 if (board_config == ALC880_AUTO) {
4803 /* automatic parse from the BIOS config */
4804 err = alc880_parse_auto_config(codec);
4805 if (err < 0) {
4806 alc_free(codec);
4807 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004808 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004809 printk(KERN_INFO
4810 "hda_codec: Cannot set up configuration "
4811 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004812 board_config = ALC880_3ST;
4813 }
4814 }
4815
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004816 err = snd_hda_attach_beep_device(codec, 0x1);
4817 if (err < 0) {
4818 alc_free(codec);
4819 return err;
4820 }
4821
Kailang Yangdf694da2005-12-05 19:42:22 +01004822 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004823 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004824
Linus Torvalds1da177e2005-04-16 15:20:36 -07004825 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4826 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004827 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004828
Linus Torvalds1da177e2005-04-16 15:20:36 -07004829 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4830 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4831
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004832 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004833 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004834 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004835 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004836 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004837 if (wcap != AC_WID_AUD_IN) {
4838 spec->adc_nids = alc880_adc_nids_alt;
4839 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004840 } else {
4841 spec->adc_nids = alc880_adc_nids;
4842 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004843 }
4844 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004845 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004846 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004847
Takashi Iwai2134ea42008-01-10 16:53:55 +01004848 spec->vmaster_nid = 0x0c;
4849
Linus Torvalds1da177e2005-04-16 15:20:36 -07004850 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004851 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004852 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004853#ifdef CONFIG_SND_HDA_POWER_SAVE
4854 if (!spec->loopback.amplist)
4855 spec->loopback.amplist = alc880_loopbacks;
4856#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004857 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004858
4859 return 0;
4860}
4861
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004862
Linus Torvalds1da177e2005-04-16 15:20:36 -07004863/*
4864 * ALC260 support
4865 */
4866
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004867static hda_nid_t alc260_dac_nids[1] = {
4868 /* front */
4869 0x02,
4870};
4871
4872static hda_nid_t alc260_adc_nids[1] = {
4873 /* ADC0 */
4874 0x04,
4875};
4876
Kailang Yangdf694da2005-12-05 19:42:22 +01004877static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004878 /* ADC1 */
4879 0x05,
4880};
4881
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004882/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4883 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4884 */
4885static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004886 /* ADC0, ADC1 */
4887 0x04, 0x05
4888};
4889
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004890#define ALC260_DIGOUT_NID 0x03
4891#define ALC260_DIGIN_NID 0x06
4892
4893static struct hda_input_mux alc260_capture_source = {
4894 .num_items = 4,
4895 .items = {
4896 { "Mic", 0x0 },
4897 { "Front Mic", 0x1 },
4898 { "Line", 0x2 },
4899 { "CD", 0x4 },
4900 },
4901};
4902
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004903/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004904 * headphone jack and the internal CD lines since these are the only pins at
4905 * which audio can appear. For flexibility, also allow the option of
4906 * recording the mixer output on the second ADC (ADC0 doesn't have a
4907 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004908 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004909static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4910 {
4911 .num_items = 3,
4912 .items = {
4913 { "Mic/Line", 0x0 },
4914 { "CD", 0x4 },
4915 { "Headphone", 0x2 },
4916 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004917 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004918 {
4919 .num_items = 4,
4920 .items = {
4921 { "Mic/Line", 0x0 },
4922 { "CD", 0x4 },
4923 { "Headphone", 0x2 },
4924 { "Mixer", 0x5 },
4925 },
4926 },
4927
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004928};
4929
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004930/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4931 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004932 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004933static struct hda_input_mux alc260_acer_capture_sources[2] = {
4934 {
4935 .num_items = 4,
4936 .items = {
4937 { "Mic", 0x0 },
4938 { "Line", 0x2 },
4939 { "CD", 0x4 },
4940 { "Headphone", 0x5 },
4941 },
4942 },
4943 {
4944 .num_items = 5,
4945 .items = {
4946 { "Mic", 0x0 },
4947 { "Line", 0x2 },
4948 { "CD", 0x4 },
4949 { "Headphone", 0x6 },
4950 { "Mixer", 0x5 },
4951 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004952 },
4953};
Michael Schwingencc959482009-02-22 18:58:45 +01004954
4955/* Maxdata Favorit 100XS */
4956static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4957 {
4958 .num_items = 2,
4959 .items = {
4960 { "Line/Mic", 0x0 },
4961 { "CD", 0x4 },
4962 },
4963 },
4964 {
4965 .num_items = 3,
4966 .items = {
4967 { "Line/Mic", 0x0 },
4968 { "CD", 0x4 },
4969 { "Mixer", 0x5 },
4970 },
4971 },
4972};
4973
Linus Torvalds1da177e2005-04-16 15:20:36 -07004974/*
4975 * This is just place-holder, so there's something for alc_build_pcms to look
4976 * at when it calculates the maximum number of channels. ALC260 has no mixer
4977 * element which allows changing the channel mode, so the verb list is
4978 * never used.
4979 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004980static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004981 { 2, NULL },
4982};
4983
Kailang Yangdf694da2005-12-05 19:42:22 +01004984
4985/* Mixer combinations
4986 *
4987 * basic: base_output + input + pc_beep + capture
4988 * HP: base_output + input + capture_alt
4989 * HP_3013: hp_3013 + input + capture
4990 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004991 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004992 */
4993
4994static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004995 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004996 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004997 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4998 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4999 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5000 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5001 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005002};
Kailang Yangdf694da2005-12-05 19:42:22 +01005003
5004static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005005 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5006 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5007 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5008 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5009 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5010 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5011 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5012 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005013 { } /* end */
5014};
5015
Takashi Iwaibec15c32008-01-28 18:16:30 +01005016/* update HP, line and mono out pins according to the master switch */
5017static void alc260_hp_master_update(struct hda_codec *codec,
5018 hda_nid_t hp, hda_nid_t line,
5019 hda_nid_t mono)
5020{
5021 struct alc_spec *spec = codec->spec;
5022 unsigned int val = spec->master_sw ? PIN_HP : 0;
5023 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005024 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005025 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005026 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005027 val);
5028 /* mono (speaker) depending on the HP jack sense */
5029 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005030 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005031 val);
5032}
5033
5034static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5035 struct snd_ctl_elem_value *ucontrol)
5036{
5037 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5038 struct alc_spec *spec = codec->spec;
5039 *ucontrol->value.integer.value = spec->master_sw;
5040 return 0;
5041}
5042
5043static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5044 struct snd_ctl_elem_value *ucontrol)
5045{
5046 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5047 struct alc_spec *spec = codec->spec;
5048 int val = !!*ucontrol->value.integer.value;
5049 hda_nid_t hp, line, mono;
5050
5051 if (val == spec->master_sw)
5052 return 0;
5053 spec->master_sw = val;
5054 hp = (kcontrol->private_value >> 16) & 0xff;
5055 line = (kcontrol->private_value >> 8) & 0xff;
5056 mono = kcontrol->private_value & 0xff;
5057 alc260_hp_master_update(codec, hp, line, mono);
5058 return 1;
5059}
5060
5061static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5062 {
5063 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5064 .name = "Master Playback Switch",
5065 .info = snd_ctl_boolean_mono_info,
5066 .get = alc260_hp_master_sw_get,
5067 .put = alc260_hp_master_sw_put,
5068 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5069 },
5070 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5071 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5072 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5073 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5074 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5075 HDA_OUTPUT),
5076 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5077 { } /* end */
5078};
5079
5080static struct hda_verb alc260_hp_unsol_verbs[] = {
5081 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5082 {},
5083};
5084
5085static void alc260_hp_automute(struct hda_codec *codec)
5086{
5087 struct alc_spec *spec = codec->spec;
5088 unsigned int present;
5089
5090 present = snd_hda_codec_read(codec, 0x10, 0,
5091 AC_VERB_GET_PIN_SENSE, 0);
5092 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5093 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5094}
5095
5096static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5097{
5098 if ((res >> 26) == ALC880_HP_EVENT)
5099 alc260_hp_automute(codec);
5100}
5101
Kailang Yangdf694da2005-12-05 19:42:22 +01005102static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005103 {
5104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5105 .name = "Master Playback Switch",
5106 .info = snd_ctl_boolean_mono_info,
5107 .get = alc260_hp_master_sw_get,
5108 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005109 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005110 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005111 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5112 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5113 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5114 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5115 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5116 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005117 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5118 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005119 { } /* end */
5120};
5121
Kailang Yang3f878302008-08-26 13:02:23 +02005122static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5123 .ops = &snd_hda_bind_vol,
5124 .values = {
5125 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5126 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5127 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5128 0
5129 },
5130};
5131
5132static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5133 .ops = &snd_hda_bind_sw,
5134 .values = {
5135 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5136 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5137 0
5138 },
5139};
5140
5141static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5142 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5143 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5144 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5145 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5146 { } /* end */
5147};
5148
Takashi Iwaibec15c32008-01-28 18:16:30 +01005149static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5150 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5151 {},
5152};
5153
5154static void alc260_hp_3013_automute(struct hda_codec *codec)
5155{
5156 struct alc_spec *spec = codec->spec;
5157 unsigned int present;
5158
5159 present = snd_hda_codec_read(codec, 0x15, 0,
5160 AC_VERB_GET_PIN_SENSE, 0);
5161 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005162 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005163}
5164
5165static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5166 unsigned int res)
5167{
5168 if ((res >> 26) == ALC880_HP_EVENT)
5169 alc260_hp_3013_automute(codec);
5170}
5171
Kailang Yang3f878302008-08-26 13:02:23 +02005172static void alc260_hp_3012_automute(struct hda_codec *codec)
5173{
5174 unsigned int present, bits;
5175
5176 present = snd_hda_codec_read(codec, 0x10, 0,
5177 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
5178
5179 bits = present ? 0 : PIN_OUT;
5180 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5181 bits);
5182 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5183 bits);
5184 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5185 bits);
5186}
5187
5188static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5189 unsigned int res)
5190{
5191 if ((res >> 26) == ALC880_HP_EVENT)
5192 alc260_hp_3012_automute(codec);
5193}
5194
5195/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005196 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5197 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005198static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005199 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005200 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005201 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005202 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5203 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5204 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5205 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005206 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005207 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5208 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005209 { } /* end */
5210};
5211
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005212/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5213 * versions of the ALC260 don't act on requests to enable mic bias from NID
5214 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5215 * datasheet doesn't mention this restriction. At this stage it's not clear
5216 * whether this behaviour is intentional or is a hardware bug in chip
5217 * revisions available in early 2006. Therefore for now allow the
5218 * "Headphone Jack Mode" control to span all choices, but if it turns out
5219 * that the lack of mic bias for this NID is intentional we could change the
5220 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5221 *
5222 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5223 * don't appear to make the mic bias available from the "line" jack, even
5224 * though the NID used for this jack (0x14) can supply it. The theory is
5225 * that perhaps Acer have included blocking capacitors between the ALC260
5226 * and the output jack. If this turns out to be the case for all such
5227 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5228 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005229 *
5230 * The C20x Tablet series have a mono internal speaker which is controlled
5231 * via the chip's Mono sum widget and pin complex, so include the necessary
5232 * controls for such models. On models without a "mono speaker" the control
5233 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005234 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005235static struct snd_kcontrol_new alc260_acer_mixer[] = {
5236 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5237 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005238 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005239 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005240 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005241 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005242 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005243 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5244 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5245 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5246 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5247 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5248 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5249 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5250 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005251 { } /* end */
5252};
5253
Michael Schwingencc959482009-02-22 18:58:45 +01005254/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5255 */
5256static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5257 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5258 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5259 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5260 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5261 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5262 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5263 { } /* end */
5264};
5265
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005266/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5267 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5268 */
5269static struct snd_kcontrol_new alc260_will_mixer[] = {
5270 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5271 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5272 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5273 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5274 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5275 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5276 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5277 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5278 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5279 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005280 { } /* end */
5281};
5282
5283/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5284 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5285 */
5286static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5287 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5288 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5289 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5290 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5291 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5292 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5293 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5294 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5295 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5296 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5297 { } /* end */
5298};
5299
Kailang Yangdf694da2005-12-05 19:42:22 +01005300/*
5301 * initialization verbs
5302 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005303static struct hda_verb alc260_init_verbs[] = {
5304 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005305 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005306 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005307 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005308 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005309 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005310 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005311 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005312 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005313 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005314 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005315 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005316 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005317 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005318 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005319 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005320 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005321 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5322 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005323 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005324 /* set connection select to line in (default select for this ADC) */
5325 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005326 /* mute capture amp left and right */
5327 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5328 /* set connection select to line in (default select for this ADC) */
5329 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005330 /* set vol=0 Line-Out mixer amp left and right */
5331 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5332 /* unmute pin widget amp left and right (no gain on this amp) */
5333 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5334 /* set vol=0 HP mixer amp left and right */
5335 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5336 /* unmute pin widget amp left and right (no gain on this amp) */
5337 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5338 /* set vol=0 Mono mixer amp left and right */
5339 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5340 /* unmute pin widget amp left and right (no gain on this amp) */
5341 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5342 /* unmute LINE-2 out pin */
5343 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005344 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5345 * Line In 2 = 0x03
5346 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005347 /* mute analog inputs */
5348 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5349 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5350 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5351 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5352 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005353 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005354 /* mute Front out path */
5355 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5356 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5357 /* mute Headphone out path */
5358 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5359 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5360 /* mute Mono out path */
5361 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5362 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005363 { }
5364};
5365
Takashi Iwai474167d2006-05-17 17:17:43 +02005366#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005367static struct hda_verb alc260_hp_init_verbs[] = {
5368 /* Headphone and output */
5369 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5370 /* mono output */
5371 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5372 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5373 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5374 /* Mic2 (front panel) pin widget for input and vref at 80% */
5375 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5376 /* Line In pin widget for input */
5377 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5378 /* Line-2 pin widget for output */
5379 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5380 /* CD pin widget for input */
5381 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5382 /* unmute amp left and right */
5383 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5384 /* set connection select to line in (default select for this ADC) */
5385 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5386 /* unmute Line-Out mixer amp left and right (volume = 0) */
5387 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5388 /* mute pin widget amp left and right (no gain on this amp) */
5389 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5390 /* unmute HP mixer amp left and right (volume = 0) */
5391 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5392 /* mute pin widget amp left and right (no gain on this amp) */
5393 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005394 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5395 * Line In 2 = 0x03
5396 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005397 /* mute analog inputs */
5398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5399 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5401 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005403 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5404 /* Unmute Front out path */
5405 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5406 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5407 /* Unmute Headphone out path */
5408 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5409 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5410 /* Unmute Mono out path */
5411 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5412 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5413 { }
5414};
Takashi Iwai474167d2006-05-17 17:17:43 +02005415#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005416
5417static struct hda_verb alc260_hp_3013_init_verbs[] = {
5418 /* Line out and output */
5419 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5420 /* mono output */
5421 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5422 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5423 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5424 /* Mic2 (front panel) pin widget for input and vref at 80% */
5425 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5426 /* Line In pin widget for input */
5427 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5428 /* Headphone pin widget for output */
5429 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5430 /* CD pin widget for input */
5431 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5432 /* unmute amp left and right */
5433 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5434 /* set connection select to line in (default select for this ADC) */
5435 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5436 /* unmute Line-Out mixer amp left and right (volume = 0) */
5437 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5438 /* mute pin widget amp left and right (no gain on this amp) */
5439 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5440 /* unmute HP mixer amp left and right (volume = 0) */
5441 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5442 /* mute pin widget amp left and right (no gain on this amp) */
5443 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005444 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5445 * Line In 2 = 0x03
5446 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005447 /* mute analog inputs */
5448 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5449 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5451 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005453 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5454 /* Unmute Front out path */
5455 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5456 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5457 /* Unmute Headphone out path */
5458 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5459 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5460 /* Unmute Mono out path */
5461 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5462 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5463 { }
5464};
5465
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005466/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005467 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5468 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005469 */
5470static struct hda_verb alc260_fujitsu_init_verbs[] = {
5471 /* Disable all GPIOs */
5472 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5473 /* Internal speaker is connected to headphone pin */
5474 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5475 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5476 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005477 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5478 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5479 /* Ensure all other unused pins are disabled and muted. */
5480 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5481 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005482 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005483 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005484 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005485 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5486 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5487 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005488
Jonathan Woithef7ace402006-02-28 11:46:14 +01005489 /* Disable digital (SPDIF) pins */
5490 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5491 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005492
Kailang Yangea1fb292008-08-26 12:58:38 +02005493 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005494 * when acting as an output.
5495 */
5496 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5497
5498 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005499 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5500 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5501 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5502 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5503 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5504 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5505 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5506 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5507 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005508
Jonathan Woithef7ace402006-02-28 11:46:14 +01005509 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5510 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5511 /* Unmute Line1 pin widget output buffer since it starts as an output.
5512 * If the pin mode is changed by the user the pin mode control will
5513 * take care of enabling the pin's input/output buffers as needed.
5514 * Therefore there's no need to enable the input buffer at this
5515 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005516 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005517 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005518 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005519 * mixer ctrl)
5520 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005521 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005522
Jonathan Woithef7ace402006-02-28 11:46:14 +01005523 /* Mute capture amp left and right */
5524 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005525 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005526 * in (on mic1 pin)
5527 */
5528 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005529
Jonathan Woithef7ace402006-02-28 11:46:14 +01005530 /* Do the same for the second ADC: mute capture input amp and
5531 * set ADC connection to line in (on mic1 pin)
5532 */
5533 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5534 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005535
Jonathan Woithef7ace402006-02-28 11:46:14 +01005536 /* Mute all inputs to mixer widget (even unconnected ones) */
5537 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5538 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5539 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5540 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5541 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005545
5546 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005547};
5548
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005549/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5550 * similar laptops (adapted from Fujitsu init verbs).
5551 */
5552static struct hda_verb alc260_acer_init_verbs[] = {
5553 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5554 * the headphone jack. Turn this on and rely on the standard mute
5555 * methods whenever the user wants to turn these outputs off.
5556 */
5557 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5558 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5559 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5560 /* Internal speaker/Headphone jack is connected to Line-out pin */
5561 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5562 /* Internal microphone/Mic jack is connected to Mic1 pin */
5563 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5564 /* Line In jack is connected to Line1 pin */
5565 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005566 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5567 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005568 /* Ensure all other unused pins are disabled and muted. */
5569 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5570 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005571 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5572 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5573 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5574 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5575 /* Disable digital (SPDIF) pins */
5576 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5577 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5578
Kailang Yangea1fb292008-08-26 12:58:38 +02005579 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005580 * bus when acting as outputs.
5581 */
5582 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5583 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5584
5585 /* Start with output sum widgets muted and their output gains at min */
5586 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5587 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5588 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5589 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5590 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5591 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5592 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5593 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5594 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5595
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005596 /* Unmute Line-out pin widget amp left and right
5597 * (no equiv mixer ctrl)
5598 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005599 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005600 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5601 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005602 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5603 * inputs. If the pin mode is changed by the user the pin mode control
5604 * will take care of enabling the pin's input/output buffers as needed.
5605 * Therefore there's no need to enable the input buffer at this
5606 * stage.
5607 */
5608 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5609 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5610
5611 /* Mute capture amp left and right */
5612 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5613 /* Set ADC connection select to match default mixer setting - mic
5614 * (on mic1 pin)
5615 */
5616 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5617
5618 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005619 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005620 */
5621 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005622 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005623
5624 /* Mute all inputs to mixer widget (even unconnected ones) */
5625 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5626 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5627 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5629 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5630 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5633
5634 { }
5635};
5636
Michael Schwingencc959482009-02-22 18:58:45 +01005637/* Initialisation sequence for Maxdata Favorit 100XS
5638 * (adapted from Acer init verbs).
5639 */
5640static struct hda_verb alc260_favorit100_init_verbs[] = {
5641 /* GPIO 0 enables the output jack.
5642 * Turn this on and rely on the standard mute
5643 * methods whenever the user wants to turn these outputs off.
5644 */
5645 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5646 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5647 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5648 /* Line/Mic input jack is connected to Mic1 pin */
5649 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5650 /* Ensure all other unused pins are disabled and muted. */
5651 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5652 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5653 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5654 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5655 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5656 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5657 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5658 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5659 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5661 /* Disable digital (SPDIF) pins */
5662 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5663 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5664
5665 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5666 * bus when acting as outputs.
5667 */
5668 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5669 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5670
5671 /* Start with output sum widgets muted and their output gains at min */
5672 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5673 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5674 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5675 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5676 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5677 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5678 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5679 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5680 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5681
5682 /* Unmute Line-out pin widget amp left and right
5683 * (no equiv mixer ctrl)
5684 */
5685 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5686 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5687 * inputs. If the pin mode is changed by the user the pin mode control
5688 * will take care of enabling the pin's input/output buffers as needed.
5689 * Therefore there's no need to enable the input buffer at this
5690 * stage.
5691 */
5692 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5693
5694 /* Mute capture amp left and right */
5695 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5696 /* Set ADC connection select to match default mixer setting - mic
5697 * (on mic1 pin)
5698 */
5699 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5700
5701 /* Do similar with the second ADC: mute capture input amp and
5702 * set ADC connection to mic to match ALSA's default state.
5703 */
5704 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5705 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5706
5707 /* Mute all inputs to mixer widget (even unconnected ones) */
5708 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5709 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5711 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5714 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5715 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5716
5717 { }
5718};
5719
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005720static struct hda_verb alc260_will_verbs[] = {
5721 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5722 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5723 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5724 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5725 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5726 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5727 {}
5728};
5729
5730static struct hda_verb alc260_replacer_672v_verbs[] = {
5731 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5732 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5733 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5734
5735 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5736 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5737 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5738
5739 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5740 {}
5741};
5742
5743/* toggle speaker-output according to the hp-jack state */
5744static void alc260_replacer_672v_automute(struct hda_codec *codec)
5745{
5746 unsigned int present;
5747
5748 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5749 present = snd_hda_codec_read(codec, 0x0f, 0,
5750 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5751 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005752 snd_hda_codec_write_cache(codec, 0x01, 0,
5753 AC_VERB_SET_GPIO_DATA, 1);
5754 snd_hda_codec_write_cache(codec, 0x0f, 0,
5755 AC_VERB_SET_PIN_WIDGET_CONTROL,
5756 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005757 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005758 snd_hda_codec_write_cache(codec, 0x01, 0,
5759 AC_VERB_SET_GPIO_DATA, 0);
5760 snd_hda_codec_write_cache(codec, 0x0f, 0,
5761 AC_VERB_SET_PIN_WIDGET_CONTROL,
5762 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005763 }
5764}
5765
5766static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5767 unsigned int res)
5768{
5769 if ((res >> 26) == ALC880_HP_EVENT)
5770 alc260_replacer_672v_automute(codec);
5771}
5772
Kailang Yang3f878302008-08-26 13:02:23 +02005773static struct hda_verb alc260_hp_dc7600_verbs[] = {
5774 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5775 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5776 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5777 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5778 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5779 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5780 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5781 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5782 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5783 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5784 {}
5785};
5786
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005787/* Test configuration for debugging, modelled after the ALC880 test
5788 * configuration.
5789 */
5790#ifdef CONFIG_SND_DEBUG
5791static hda_nid_t alc260_test_dac_nids[1] = {
5792 0x02,
5793};
5794static hda_nid_t alc260_test_adc_nids[2] = {
5795 0x04, 0x05,
5796};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005797/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005798 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005799 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005800 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005801static struct hda_input_mux alc260_test_capture_sources[2] = {
5802 {
5803 .num_items = 7,
5804 .items = {
5805 { "MIC1 pin", 0x0 },
5806 { "MIC2 pin", 0x1 },
5807 { "LINE1 pin", 0x2 },
5808 { "LINE2 pin", 0x3 },
5809 { "CD pin", 0x4 },
5810 { "LINE-OUT pin", 0x5 },
5811 { "HP-OUT pin", 0x6 },
5812 },
5813 },
5814 {
5815 .num_items = 8,
5816 .items = {
5817 { "MIC1 pin", 0x0 },
5818 { "MIC2 pin", 0x1 },
5819 { "LINE1 pin", 0x2 },
5820 { "LINE2 pin", 0x3 },
5821 { "CD pin", 0x4 },
5822 { "Mixer", 0x5 },
5823 { "LINE-OUT pin", 0x6 },
5824 { "HP-OUT pin", 0x7 },
5825 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005826 },
5827};
5828static struct snd_kcontrol_new alc260_test_mixer[] = {
5829 /* Output driver widgets */
5830 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5831 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5832 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5833 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5834 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5835 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5836
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005837 /* Modes for retasking pin widgets
5838 * Note: the ALC260 doesn't seem to act on requests to enable mic
5839 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5840 * mention this restriction. At this stage it's not clear whether
5841 * this behaviour is intentional or is a hardware bug in chip
5842 * revisions available at least up until early 2006. Therefore for
5843 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5844 * choices, but if it turns out that the lack of mic bias for these
5845 * NIDs is intentional we could change their modes from
5846 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5847 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005848 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5849 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5850 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5851 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5852 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5853 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5854
5855 /* Loopback mixer controls */
5856 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5857 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5858 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5859 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5860 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5861 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5862 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5863 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5864 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5865 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005866 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5867 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5868 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5869 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005870
5871 /* Controls for GPIO pins, assuming they are configured as outputs */
5872 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5873 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5874 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5875 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5876
Jonathan Woithe92621f12006-02-28 11:47:47 +01005877 /* Switches to allow the digital IO pins to be enabled. The datasheet
5878 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005879 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005880 */
5881 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5882 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5883
Jonathan Woithef8225f62008-01-08 12:16:54 +01005884 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5885 * this output to turn on an external amplifier.
5886 */
5887 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5888 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5889
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005890 { } /* end */
5891};
5892static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005893 /* Enable all GPIOs as outputs with an initial value of 0 */
5894 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5895 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5896 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5897
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005898 /* Enable retasking pins as output, initially without power amp */
5899 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5900 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5901 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5902 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5903 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5904 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5905
Jonathan Woithe92621f12006-02-28 11:47:47 +01005906 /* Disable digital (SPDIF) pins initially, but users can enable
5907 * them via a mixer switch. In the case of SPDIF-out, this initverb
5908 * payload also sets the generation to 0, output to be in "consumer"
5909 * PCM format, copyright asserted, no pre-emphasis and no validity
5910 * control.
5911 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005912 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5913 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5914
Kailang Yangea1fb292008-08-26 12:58:38 +02005915 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005916 * OUT1 sum bus when acting as an output.
5917 */
5918 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5919 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5920 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5921 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5922
5923 /* Start with output sum widgets muted and their output gains at min */
5924 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5925 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5926 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5927 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5928 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5929 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5930 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5931 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5932 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5933
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005934 /* Unmute retasking pin widget output buffers since the default
5935 * state appears to be output. As the pin mode is changed by the
5936 * user the pin mode control will take care of enabling the pin's
5937 * input/output buffers as needed.
5938 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005939 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5940 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5941 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5942 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5943 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5944 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5945 /* Also unmute the mono-out pin widget */
5946 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5947
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005948 /* Mute capture amp left and right */
5949 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005950 /* Set ADC connection select to match default mixer setting (mic1
5951 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005952 */
5953 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5954
5955 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005956 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005957 */
5958 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5959 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5960
5961 /* Mute all inputs to mixer widget (even unconnected ones) */
5962 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5963 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5964 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5965 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5967 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5969 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5970
5971 { }
5972};
5973#endif
5974
Takashi Iwai63300792008-01-24 15:31:36 +01005975#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5976#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005977
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005978#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5979#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5980
Kailang Yangdf694da2005-12-05 19:42:22 +01005981/*
5982 * for BIOS auto-configuration
5983 */
5984
5985static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005986 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005987{
5988 hda_nid_t nid_vol;
5989 unsigned long vol_val, sw_val;
5990 char name[32];
5991 int err;
5992
5993 if (nid >= 0x0f && nid < 0x11) {
5994 nid_vol = nid - 0x7;
5995 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5996 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5997 } else if (nid == 0x11) {
5998 nid_vol = nid - 0x7;
5999 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6000 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6001 } else if (nid >= 0x12 && nid <= 0x15) {
6002 nid_vol = 0x08;
6003 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6004 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6005 } else
6006 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006007
Takashi Iwai863b4512008-10-21 17:01:47 +02006008 if (!(*vol_bits & (1 << nid_vol))) {
6009 /* first control for the volume widget */
6010 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
6011 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
6012 if (err < 0)
6013 return err;
6014 *vol_bits |= (1 << nid_vol);
6015 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006016 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006017 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
6018 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006019 return err;
6020 return 1;
6021}
6022
6023/* add playback controls from the parsed DAC table */
6024static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6025 const struct auto_pin_cfg *cfg)
6026{
6027 hda_nid_t nid;
6028 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006029 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006030
6031 spec->multiout.num_dacs = 1;
6032 spec->multiout.dac_nids = spec->private_dac_nids;
6033 spec->multiout.dac_nids[0] = 0x02;
6034
6035 nid = cfg->line_out_pins[0];
6036 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006037 const char *pfx;
6038 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6039 pfx = "Master";
6040 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6041 pfx = "Speaker";
6042 else
6043 pfx = "Front";
6044 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006045 if (err < 0)
6046 return err;
6047 }
6048
Takashi Iwai82bc9552006-03-21 11:24:42 +01006049 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006050 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006051 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006052 if (err < 0)
6053 return err;
6054 }
6055
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006056 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006057 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006058 err = alc260_add_playback_controls(spec, nid, "Headphone",
6059 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006060 if (err < 0)
6061 return err;
6062 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006063 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006064}
6065
6066/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006067static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006068 const struct auto_pin_cfg *cfg)
6069{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006070 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006071}
6072
6073static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6074 hda_nid_t nid, int pin_type,
6075 int sel_idx)
6076{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006077 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006078 /* need the manual connection? */
6079 if (nid >= 0x12) {
6080 int idx = nid - 0x12;
6081 snd_hda_codec_write(codec, idx + 0x0b, 0,
6082 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006083 }
6084}
6085
6086static void alc260_auto_init_multi_out(struct hda_codec *codec)
6087{
6088 struct alc_spec *spec = codec->spec;
6089 hda_nid_t nid;
6090
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006091 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006092 if (nid) {
6093 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6094 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6095 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006096
Takashi Iwai82bc9552006-03-21 11:24:42 +01006097 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006098 if (nid)
6099 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6100
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006101 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006102 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006103 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006104}
Kailang Yangdf694da2005-12-05 19:42:22 +01006105
6106#define ALC260_PIN_CD_NID 0x16
6107static void alc260_auto_init_analog_input(struct hda_codec *codec)
6108{
6109 struct alc_spec *spec = codec->spec;
6110 int i;
6111
6112 for (i = 0; i < AUTO_PIN_LAST; i++) {
6113 hda_nid_t nid = spec->autocfg.input_pins[i];
6114 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006115 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006116 if (nid != ALC260_PIN_CD_NID &&
6117 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006118 snd_hda_codec_write(codec, nid, 0,
6119 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006120 AMP_OUT_MUTE);
6121 }
6122 }
6123}
6124
6125/*
6126 * generic initialization of ADC, input mixers and output mixers
6127 */
6128static struct hda_verb alc260_volume_init_verbs[] = {
6129 /*
6130 * Unmute ADC0-1 and set the default input to mic-in
6131 */
6132 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6133 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6134 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6135 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006136
Kailang Yangdf694da2005-12-05 19:42:22 +01006137 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6138 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006139 * Note: PASD motherboards uses the Line In 2 as the input for
6140 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006141 */
6142 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006143 /* mute analog inputs */
6144 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6145 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6146 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006149
6150 /*
6151 * Set up output mixers (0x08 - 0x0a)
6152 */
6153 /* set vol=0 to output mixers */
6154 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6155 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6156 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6157 /* set up input amps for analog loopback */
6158 /* Amp Indices: DAC = 0, mixer = 1 */
6159 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6160 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6161 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6162 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6163 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6164 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006165
Kailang Yangdf694da2005-12-05 19:42:22 +01006166 { }
6167};
6168
6169static int alc260_parse_auto_config(struct hda_codec *codec)
6170{
6171 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006172 int err;
6173 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6174
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006175 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6176 alc260_ignore);
6177 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006178 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006179 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6180 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006181 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006182 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006183 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006184 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006185 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006186 return err;
6187
6188 spec->multiout.max_channels = 2;
6189
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006190 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006191 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006192 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006193 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006194
Takashi Iwaid88897e2008-10-31 15:01:37 +01006195 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006196
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006197 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006198 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006199
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006200 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6201
Kailang Yangdf694da2005-12-05 19:42:22 +01006202 return 1;
6203}
6204
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006205/* additional initialization for auto-configuration model */
6206static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006207{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006208 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006209 alc260_auto_init_multi_out(codec);
6210 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006211 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006212 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006213}
6214
Takashi Iwaicb53c622007-08-10 17:21:45 +02006215#ifdef CONFIG_SND_HDA_POWER_SAVE
6216static struct hda_amp_list alc260_loopbacks[] = {
6217 { 0x07, HDA_INPUT, 0 },
6218 { 0x07, HDA_INPUT, 1 },
6219 { 0x07, HDA_INPUT, 2 },
6220 { 0x07, HDA_INPUT, 3 },
6221 { 0x07, HDA_INPUT, 4 },
6222 { } /* end */
6223};
6224#endif
6225
Kailang Yangdf694da2005-12-05 19:42:22 +01006226/*
6227 * ALC260 configurations
6228 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006229static const char *alc260_models[ALC260_MODEL_LAST] = {
6230 [ALC260_BASIC] = "basic",
6231 [ALC260_HP] = "hp",
6232 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006233 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006234 [ALC260_FUJITSU_S702X] = "fujitsu",
6235 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006236 [ALC260_WILL] = "will",
6237 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006238 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006239#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006240 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006241#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006242 [ALC260_AUTO] = "auto",
6243};
6244
6245static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006246 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006247 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006248 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006249 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006250 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006251 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006252 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006253 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006254 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6255 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6256 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6257 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6258 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6259 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6260 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6261 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6262 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006263 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006264 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006265 {}
6266};
6267
Kailang Yangdf694da2005-12-05 19:42:22 +01006268static struct alc_config_preset alc260_presets[] = {
6269 [ALC260_BASIC] = {
6270 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006271 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006272 .init_verbs = { alc260_init_verbs },
6273 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6274 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006275 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006276 .adc_nids = alc260_adc_nids,
6277 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6278 .channel_mode = alc260_modes,
6279 .input_mux = &alc260_capture_source,
6280 },
6281 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006282 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006283 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006284 .init_verbs = { alc260_init_verbs,
6285 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006286 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6287 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006288 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6289 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006290 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6291 .channel_mode = alc260_modes,
6292 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006293 .unsol_event = alc260_hp_unsol_event,
6294 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006295 },
Kailang Yang3f878302008-08-26 13:02:23 +02006296 [ALC260_HP_DC7600] = {
6297 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006298 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006299 .init_verbs = { alc260_init_verbs,
6300 alc260_hp_dc7600_verbs },
6301 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6302 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006303 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6304 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006305 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6306 .channel_mode = alc260_modes,
6307 .input_mux = &alc260_capture_source,
6308 .unsol_event = alc260_hp_3012_unsol_event,
6309 .init_hook = alc260_hp_3012_automute,
6310 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006311 [ALC260_HP_3013] = {
6312 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006313 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006314 .init_verbs = { alc260_hp_3013_init_verbs,
6315 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006316 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6317 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006318 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6319 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006320 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6321 .channel_mode = alc260_modes,
6322 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006323 .unsol_event = alc260_hp_3013_unsol_event,
6324 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006325 },
6326 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006327 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006328 .init_verbs = { alc260_fujitsu_init_verbs },
6329 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6330 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006331 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6332 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006333 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6334 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006335 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6336 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006337 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006338 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006339 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006340 .init_verbs = { alc260_acer_init_verbs },
6341 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6342 .dac_nids = alc260_dac_nids,
6343 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6344 .adc_nids = alc260_dual_adc_nids,
6345 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6346 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006347 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6348 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006349 },
Michael Schwingencc959482009-02-22 18:58:45 +01006350 [ALC260_FAVORIT100] = {
6351 .mixers = { alc260_favorit100_mixer },
6352 .init_verbs = { alc260_favorit100_init_verbs },
6353 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6354 .dac_nids = alc260_dac_nids,
6355 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6356 .adc_nids = alc260_dual_adc_nids,
6357 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6358 .channel_mode = alc260_modes,
6359 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6360 .input_mux = alc260_favorit100_capture_sources,
6361 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006362 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006363 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006364 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6365 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6366 .dac_nids = alc260_dac_nids,
6367 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6368 .adc_nids = alc260_adc_nids,
6369 .dig_out_nid = ALC260_DIGOUT_NID,
6370 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6371 .channel_mode = alc260_modes,
6372 .input_mux = &alc260_capture_source,
6373 },
6374 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006375 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006376 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6377 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6378 .dac_nids = alc260_dac_nids,
6379 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6380 .adc_nids = alc260_adc_nids,
6381 .dig_out_nid = ALC260_DIGOUT_NID,
6382 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6383 .channel_mode = alc260_modes,
6384 .input_mux = &alc260_capture_source,
6385 .unsol_event = alc260_replacer_672v_unsol_event,
6386 .init_hook = alc260_replacer_672v_automute,
6387 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006388#ifdef CONFIG_SND_DEBUG
6389 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006390 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006391 .init_verbs = { alc260_test_init_verbs },
6392 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6393 .dac_nids = alc260_test_dac_nids,
6394 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6395 .adc_nids = alc260_test_adc_nids,
6396 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6397 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006398 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6399 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006400 },
6401#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006402};
6403
Linus Torvalds1da177e2005-04-16 15:20:36 -07006404static int patch_alc260(struct hda_codec *codec)
6405{
6406 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006407 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006408
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006409 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006410 if (spec == NULL)
6411 return -ENOMEM;
6412
6413 codec->spec = spec;
6414
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006415 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6416 alc260_models,
6417 alc260_cfg_tbl);
6418 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006419 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006420 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006421 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006422 }
6423
Kailang Yangdf694da2005-12-05 19:42:22 +01006424 if (board_config == ALC260_AUTO) {
6425 /* automatic parse from the BIOS config */
6426 err = alc260_parse_auto_config(codec);
6427 if (err < 0) {
6428 alc_free(codec);
6429 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006430 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006431 printk(KERN_INFO
6432 "hda_codec: Cannot set up configuration "
6433 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006434 board_config = ALC260_BASIC;
6435 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006436 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006437
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006438 err = snd_hda_attach_beep_device(codec, 0x1);
6439 if (err < 0) {
6440 alc_free(codec);
6441 return err;
6442 }
6443
Kailang Yangdf694da2005-12-05 19:42:22 +01006444 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006445 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006446
Linus Torvalds1da177e2005-04-16 15:20:36 -07006447 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6448 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6449
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006450 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6451 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6452
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006453 if (!spec->adc_nids && spec->input_mux) {
6454 /* check whether NID 0x04 is valid */
6455 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006456 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006457 /* get type */
6458 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6459 spec->adc_nids = alc260_adc_nids_alt;
6460 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6461 } else {
6462 spec->adc_nids = alc260_adc_nids;
6463 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6464 }
6465 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006466 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006467 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006468
Takashi Iwai2134ea42008-01-10 16:53:55 +01006469 spec->vmaster_nid = 0x08;
6470
Linus Torvalds1da177e2005-04-16 15:20:36 -07006471 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006472 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006473 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006474#ifdef CONFIG_SND_HDA_POWER_SAVE
6475 if (!spec->loopback.amplist)
6476 spec->loopback.amplist = alc260_loopbacks;
6477#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006478 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006479
6480 return 0;
6481}
6482
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006483
Linus Torvalds1da177e2005-04-16 15:20:36 -07006484/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006485 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006486 *
6487 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6488 * configuration. Each pin widget can choose any input DACs and a mixer.
6489 * Each ADC is connected from a mixer of all inputs. This makes possible
6490 * 6-channel independent captures.
6491 *
6492 * In addition, an independent DAC for the multi-playback (not used in this
6493 * driver yet).
6494 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006495#define ALC882_DIGOUT_NID 0x06
6496#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006497#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6498#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6499#define ALC1200_DIGOUT_NID 0x10
6500
Linus Torvalds1da177e2005-04-16 15:20:36 -07006501
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006502static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006503 { 8, NULL }
6504};
6505
Takashi Iwai4953550a2009-06-30 15:28:30 +02006506/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006507static hda_nid_t alc882_dac_nids[4] = {
6508 /* front, rear, clfe, rear_surr */
6509 0x02, 0x03, 0x04, 0x05
6510};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006511#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006512
Takashi Iwai4953550a2009-06-30 15:28:30 +02006513/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006514#define alc882_adc_nids alc880_adc_nids
6515#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006516#define alc883_adc_nids alc882_adc_nids_alt
6517static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6518static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6519#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006520
Takashi Iwaie1406342008-02-11 18:32:32 +01006521static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6522static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006523#define alc883_capsrc_nids alc882_capsrc_nids_alt
6524static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6525#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006526
Linus Torvalds1da177e2005-04-16 15:20:36 -07006527/* input MUX */
6528/* FIXME: should be a matrix-type input source selection */
6529
6530static struct hda_input_mux alc882_capture_source = {
6531 .num_items = 4,
6532 .items = {
6533 { "Mic", 0x0 },
6534 { "Front Mic", 0x1 },
6535 { "Line", 0x2 },
6536 { "CD", 0x4 },
6537 },
6538};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006539
Takashi Iwai4953550a2009-06-30 15:28:30 +02006540#define alc883_capture_source alc882_capture_source
6541
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006542static struct hda_input_mux alc889_capture_source = {
6543 .num_items = 3,
6544 .items = {
6545 { "Front Mic", 0x0 },
6546 { "Mic", 0x3 },
6547 { "Line", 0x2 },
6548 },
6549};
6550
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006551static struct hda_input_mux mb5_capture_source = {
6552 .num_items = 3,
6553 .items = {
6554 { "Mic", 0x1 },
6555 { "Line", 0x2 },
6556 { "CD", 0x4 },
6557 },
6558};
6559
Takashi Iwai4953550a2009-06-30 15:28:30 +02006560static struct hda_input_mux alc883_3stack_6ch_intel = {
6561 .num_items = 4,
6562 .items = {
6563 { "Mic", 0x1 },
6564 { "Front Mic", 0x0 },
6565 { "Line", 0x2 },
6566 { "CD", 0x4 },
6567 },
6568};
6569
6570static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6571 .num_items = 2,
6572 .items = {
6573 { "Mic", 0x1 },
6574 { "Line", 0x2 },
6575 },
6576};
6577
6578static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6579 .num_items = 4,
6580 .items = {
6581 { "Mic", 0x0 },
6582 { "iMic", 0x1 },
6583 { "Line", 0x2 },
6584 { "CD", 0x4 },
6585 },
6586};
6587
6588static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6589 .num_items = 2,
6590 .items = {
6591 { "Mic", 0x0 },
6592 { "Int Mic", 0x1 },
6593 },
6594};
6595
6596static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6597 .num_items = 3,
6598 .items = {
6599 { "Mic", 0x0 },
6600 { "Front Mic", 0x1 },
6601 { "Line", 0x4 },
6602 },
6603};
6604
6605static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6606 .num_items = 2,
6607 .items = {
6608 { "Mic", 0x0 },
6609 { "Line", 0x2 },
6610 },
6611};
6612
6613static struct hda_input_mux alc889A_mb31_capture_source = {
6614 .num_items = 2,
6615 .items = {
6616 { "Mic", 0x0 },
6617 /* Front Mic (0x01) unused */
6618 { "Line", 0x2 },
6619 /* Line 2 (0x03) unused */
6620 /* CD (0x04) unsused? */
6621 },
6622};
6623
6624/*
6625 * 2ch mode
6626 */
6627static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6628 { 2, NULL }
6629};
6630
Kailang Yangdf694da2005-12-05 19:42:22 +01006631/*
Kailang Yang272a5272007-05-14 11:00:38 +02006632 * 2ch mode
6633 */
6634static struct hda_verb alc882_3ST_ch2_init[] = {
6635 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6636 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6637 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6638 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6639 { } /* end */
6640};
6641
6642/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006643 * 4ch mode
6644 */
6645static struct hda_verb alc882_3ST_ch4_init[] = {
6646 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6647 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6648 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6649 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6650 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6651 { } /* end */
6652};
6653
6654/*
Kailang Yang272a5272007-05-14 11:00:38 +02006655 * 6ch mode
6656 */
6657static struct hda_verb alc882_3ST_ch6_init[] = {
6658 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6659 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6660 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6661 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6662 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6663 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6664 { } /* end */
6665};
6666
Takashi Iwai4953550a2009-06-30 15:28:30 +02006667static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006668 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006669 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006670 { 6, alc882_3ST_ch6_init },
6671};
6672
Takashi Iwai4953550a2009-06-30 15:28:30 +02006673#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6674
Kailang Yang272a5272007-05-14 11:00:38 +02006675/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306676 * 2ch mode
6677 */
6678static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6679 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6680 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6681 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6682 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6683 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6684 { } /* end */
6685};
6686
6687/*
6688 * 4ch mode
6689 */
6690static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6691 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6692 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6693 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6694 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6695 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6696 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6697 { } /* end */
6698};
6699
6700/*
6701 * 6ch mode
6702 */
6703static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6704 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6705 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6706 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6707 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6708 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6709 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6710 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6711 { } /* end */
6712};
6713
6714static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6715 { 2, alc883_3ST_ch2_clevo_init },
6716 { 4, alc883_3ST_ch4_clevo_init },
6717 { 6, alc883_3ST_ch6_clevo_init },
6718};
6719
6720
6721/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006722 * 6ch mode
6723 */
6724static struct hda_verb alc882_sixstack_ch6_init[] = {
6725 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6726 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6727 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6728 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6729 { } /* end */
6730};
6731
6732/*
6733 * 8ch mode
6734 */
6735static struct hda_verb alc882_sixstack_ch8_init[] = {
6736 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6737 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6738 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6739 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6740 { } /* end */
6741};
6742
6743static struct hda_channel_mode alc882_sixstack_modes[2] = {
6744 { 6, alc882_sixstack_ch6_init },
6745 { 8, alc882_sixstack_ch8_init },
6746};
6747
Takashi Iwai87350ad2007-08-16 18:19:38 +02006748/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006749 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006750 */
6751
6752/*
6753 * 2ch mode
6754 */
6755static struct hda_verb alc885_mbp_ch2_init[] = {
6756 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6757 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6758 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6759 { } /* end */
6760};
6761
6762/*
Takashi Iwaia3f730a2009-08-31 08:15:26 +02006763 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006764 */
Takashi Iwaia3f730a2009-08-31 08:15:26 +02006765static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006766 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6767 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6768 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6769 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6770 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6771 { } /* end */
6772};
6773
Takashi Iwaia3f730a2009-08-31 08:15:26 +02006774static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006775 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730a2009-08-31 08:15:26 +02006776 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006777};
6778
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006779/*
6780 * 2ch
6781 * Speakers/Woofer/HP = Front
6782 * LineIn = Input
6783 */
6784static struct hda_verb alc885_mb5_ch2_init[] = {
6785 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6786 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6787 { } /* end */
6788};
6789
6790/*
6791 * 6ch mode
6792 * Speakers/HP = Front
6793 * Woofer = LFE
6794 * LineIn = Surround
6795 */
6796static struct hda_verb alc885_mb5_ch6_init[] = {
6797 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6798 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6799 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6800 { } /* end */
6801};
6802
6803static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6804 { 2, alc885_mb5_ch2_init },
6805 { 6, alc885_mb5_ch6_init },
6806};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006807
Takashi Iwai4953550a2009-06-30 15:28:30 +02006808
6809/*
6810 * 2ch mode
6811 */
6812static struct hda_verb alc883_4ST_ch2_init[] = {
6813 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6814 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6815 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6816 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6817 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6818 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6819 { } /* end */
6820};
6821
6822/*
6823 * 4ch mode
6824 */
6825static struct hda_verb alc883_4ST_ch4_init[] = {
6826 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6827 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6828 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6829 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6830 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6831 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6832 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6833 { } /* end */
6834};
6835
6836/*
6837 * 6ch mode
6838 */
6839static struct hda_verb alc883_4ST_ch6_init[] = {
6840 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6841 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6842 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6843 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6844 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6845 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6846 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6847 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6848 { } /* end */
6849};
6850
6851/*
6852 * 8ch mode
6853 */
6854static struct hda_verb alc883_4ST_ch8_init[] = {
6855 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6856 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6857 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6858 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6859 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6860 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6861 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6862 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6863 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6864 { } /* end */
6865};
6866
6867static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6868 { 2, alc883_4ST_ch2_init },
6869 { 4, alc883_4ST_ch4_init },
6870 { 6, alc883_4ST_ch6_init },
6871 { 8, alc883_4ST_ch8_init },
6872};
6873
6874
6875/*
6876 * 2ch mode
6877 */
6878static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6879 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6880 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6881 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6882 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6883 { } /* end */
6884};
6885
6886/*
6887 * 4ch mode
6888 */
6889static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6890 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6891 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6892 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6893 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6894 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6895 { } /* end */
6896};
6897
6898/*
6899 * 6ch mode
6900 */
6901static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6902 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6903 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6904 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6905 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6906 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6907 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6908 { } /* end */
6909};
6910
6911static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6912 { 2, alc883_3ST_ch2_intel_init },
6913 { 4, alc883_3ST_ch4_intel_init },
6914 { 6, alc883_3ST_ch6_intel_init },
6915};
6916
6917/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006918 * 2ch mode
6919 */
6920static struct hda_verb alc889_ch2_intel_init[] = {
6921 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6922 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6923 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6924 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6925 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6926 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6927 { } /* end */
6928};
6929
6930/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006931 * 6ch mode
6932 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006933static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006934 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6935 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6936 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6937 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6938 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006939 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6940 { } /* end */
6941};
6942
6943/*
6944 * 8ch mode
6945 */
6946static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006947 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6948 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6949 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6950 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6951 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006952 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6953 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006954 { } /* end */
6955};
6956
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006957static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6958 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006959 { 6, alc889_ch6_intel_init },
6960 { 8, alc889_ch8_intel_init },
6961};
6962
6963/*
6964 * 6ch mode
6965 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006966static struct hda_verb alc883_sixstack_ch6_init[] = {
6967 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6968 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6969 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6970 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6971 { } /* end */
6972};
6973
6974/*
6975 * 8ch mode
6976 */
6977static struct hda_verb alc883_sixstack_ch8_init[] = {
6978 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6979 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6980 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6981 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6982 { } /* end */
6983};
6984
6985static struct hda_channel_mode alc883_sixstack_modes[2] = {
6986 { 6, alc883_sixstack_ch6_init },
6987 { 8, alc883_sixstack_ch8_init },
6988};
6989
6990
Linus Torvalds1da177e2005-04-16 15:20:36 -07006991/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6992 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6993 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006994static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006995 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006996 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006997 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006998 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006999 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7000 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007001 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7002 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007003 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007004 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7006 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7007 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7008 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7009 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7010 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007011 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7013 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007014 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007015 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007016 { } /* end */
7017};
7018
Takashi Iwai87350ad2007-08-16 18:19:38 +02007019static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007020 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7021 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7022 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7023 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7024 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007025 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7026 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007027 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7028 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007029 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007030 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7031 { } /* end */
7032};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007033
7034static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007035 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7036 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7037 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7038 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7039 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7040 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7041 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7042 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007043 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7044 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7045 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7046 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7047 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7048 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7049 { } /* end */
7050};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007051
Kailang Yangbdd148a2007-05-08 15:19:08 +02007052static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7053 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7054 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7055 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7056 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7057 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7058 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7060 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7061 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007062 { } /* end */
7063};
7064
Kailang Yang272a5272007-05-14 11:00:38 +02007065static struct snd_kcontrol_new alc882_targa_mixer[] = {
7066 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7067 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7068 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7069 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7070 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7071 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7072 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7073 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7074 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007075 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007076 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7077 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007078 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007079 { } /* end */
7080};
7081
7082/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7083 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7084 */
7085static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7086 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7087 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7088 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7089 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7090 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7091 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7092 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7093 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7094 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7095 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7097 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007098 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007099 { } /* end */
7100};
7101
Takashi Iwai914759b2007-09-06 14:52:04 +02007102static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7103 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7104 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7105 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7106 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7107 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7108 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7109 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7111 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007113 { } /* end */
7114};
7115
Kailang Yangdf694da2005-12-05 19:42:22 +01007116static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7117 {
7118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7119 .name = "Channel Mode",
7120 .info = alc_ch_mode_info,
7121 .get = alc_ch_mode_get,
7122 .put = alc_ch_mode_put,
7123 },
7124 { } /* end */
7125};
7126
Takashi Iwai4953550a2009-06-30 15:28:30 +02007127static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007128 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7130 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7131 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007132 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007133 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7134 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7135 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007136 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007137 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7138 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7139 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007140 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007141 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7142 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7143 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007144
Takashi Iwaicb638122009-07-03 10:56:10 +02007145 /* mute analog input loopbacks */
7146 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7147 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7149 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7151
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007152 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007154 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007155 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007156 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007157 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007158 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007159 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007160 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007161 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007162 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007163 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007164 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007165 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007166 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007167 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007168 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007169 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007170 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7171 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007172 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007173 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7174 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007175 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007176 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7177 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7178 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7179 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7180 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007181 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007182 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007183
7184 /* FIXME: use matrix-type input source selection */
7185 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007186 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007187 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7188 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7189 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7190 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007191 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007192 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7193 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7194 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007196 /* ADC2: mute amp left and right */
7197 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007198 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007199 /* ADC3: mute amp left and right */
7200 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007201 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007202
7203 { }
7204};
7205
Takashi Iwai4953550a2009-06-30 15:28:30 +02007206static struct hda_verb alc882_adc1_init_verbs[] = {
7207 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7208 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7212 /* ADC1: mute amp left and right */
7213 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7214 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7215 { }
7216};
7217
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007218static struct hda_verb alc882_eapd_verbs[] = {
7219 /* change to EAPD mode */
7220 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007221 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007222 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007223};
7224
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007225static struct hda_verb alc889_eapd_verbs[] = {
7226 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7227 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7228 { }
7229};
7230
Wu Fengguang6732bd02009-07-30 09:19:14 +02007231static struct hda_verb alc_hp15_unsol_verbs[] = {
7232 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7233 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7234 {}
7235};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007236
7237static struct hda_verb alc885_init_verbs[] = {
7238 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7239 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7240 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7241 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7242 /* Rear mixer */
7243 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7244 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7245 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7246 /* CLFE mixer */
7247 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7248 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7249 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7250 /* Side mixer */
7251 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7252 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7253 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7254
7255 /* mute analog input loopbacks */
7256 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7257 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7258 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7259
7260 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007261 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007262 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7263 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7264 /* Front Pin: output 0 (0x0c) */
7265 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7266 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7267 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7268 /* Rear Pin: output 1 (0x0d) */
7269 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7270 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7271 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7272 /* CLFE Pin: output 2 (0x0e) */
7273 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7274 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7275 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7276 /* Side Pin: output 3 (0x0f) */
7277 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7278 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7279 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7280 /* Mic (rear) pin: input vref at 80% */
7281 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7282 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7283 /* Front Mic pin: input vref at 80% */
7284 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7285 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7286 /* Line In pin: input */
7287 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7288 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7289
7290 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7291 /* Input mixer1 */
7292 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7293 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7294 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7295 /* Input mixer2 */
7296 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7297 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7299 /* Input mixer3 */
7300 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7301 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7303 /* ADC2: mute amp left and right */
7304 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7305 /* ADC3: mute amp left and right */
7306 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7307
7308 { }
7309};
7310
7311static struct hda_verb alc885_init_input_verbs[] = {
7312 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7313 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7314 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7315 { }
7316};
7317
7318
7319/* Unmute Selector 24h and set the default input to front mic */
7320static struct hda_verb alc889_init_input_verbs[] = {
7321 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7322 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7323 { }
7324};
7325
7326
Takashi Iwai4953550a2009-06-30 15:28:30 +02007327#define alc883_init_verbs alc882_base_init_verbs
7328
Tobin Davis9102cd12006-12-15 10:02:12 +01007329/* Mac Pro test */
7330static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7331 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7332 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7333 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7334 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7335 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007336 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01007337 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
7338 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007339 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007340 { } /* end */
7341};
7342
7343static struct hda_verb alc882_macpro_init_verbs[] = {
7344 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7348 /* Front Pin: output 0 (0x0c) */
7349 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7350 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7351 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7352 /* Front Mic pin: input vref at 80% */
7353 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7354 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7355 /* Speaker: output */
7356 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7357 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7358 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7359 /* Headphone output (output 0 - 0x0c) */
7360 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7361 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7362 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7363
7364 /* FIXME: use matrix-type input source selection */
7365 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7366 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7368 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7369 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7370 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7371 /* Input mixer2 */
7372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7376 /* Input mixer3 */
7377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7380 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7381 /* ADC1: mute amp left and right */
7382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7383 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7384 /* ADC2: mute amp left and right */
7385 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7386 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7387 /* ADC3: mute amp left and right */
7388 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7389 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7390
7391 { }
7392};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007393
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007394/* Macbook 5,1 */
7395static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007396 /* DACs */
7397 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7398 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7399 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7400 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007401 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007402 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007405 /* Surround mixer */
7406 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7407 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7408 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7409 /* LFE mixer */
7410 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7411 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7412 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7413 /* HP mixer */
7414 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7415 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7416 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7417 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007418 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7419 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007420 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7421 /* LFE Pin (0x0e) */
7422 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7423 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7424 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7425 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007426 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7427 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007428 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007429 /* Front Mic pin: input vref at 80% */
7430 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7431 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7432 /* Line In pin */
7433 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7434 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7435
7436 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7437 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7440 { }
7441};
7442
Takashi Iwai87350ad2007-08-16 18:19:38 +02007443/* Macbook Pro rev3 */
7444static struct hda_verb alc885_mbp3_init_verbs[] = {
7445 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7446 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7447 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7448 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7449 /* Rear mixer */
7450 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7451 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7452 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007453 /* HP mixer */
7454 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7455 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7456 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007457 /* Front Pin: output 0 (0x0c) */
7458 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7459 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7460 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007461 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007462 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730a2009-08-31 08:15:26 +02007463 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7464 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007465 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7466 /* Mic (rear) pin: input vref at 80% */
7467 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7468 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7469 /* Front Mic pin: input vref at 80% */
7470 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7471 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7472 /* Line In pin: use output 1 when in LineOut mode */
7473 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7474 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7475 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7476
7477 /* FIXME: use matrix-type input source selection */
7478 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7479 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7480 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7481 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7482 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7483 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7484 /* Input mixer2 */
7485 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7487 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7488 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7489 /* Input mixer3 */
7490 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7494 /* ADC1: mute amp left and right */
7495 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7496 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7497 /* ADC2: mute amp left and right */
7498 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7499 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7500 /* ADC3: mute amp left and right */
7501 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7502 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7503
7504 { }
7505};
7506
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007507/* iMac 24 mixer. */
7508static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7509 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7510 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7511 { } /* end */
7512};
7513
7514/* iMac 24 init verbs. */
7515static struct hda_verb alc885_imac24_init_verbs[] = {
7516 /* Internal speakers: output 0 (0x0c) */
7517 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7518 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7519 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7520 /* Internal speakers: output 0 (0x0c) */
7521 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7522 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7523 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7524 /* Headphone: output 0 (0x0c) */
7525 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7526 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7527 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7528 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7529 /* Front Mic: input vref at 80% */
7530 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7531 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7532 { }
7533};
7534
7535/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007536static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007537{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007538 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007539
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007540 spec->autocfg.hp_pins[0] = 0x14;
7541 spec->autocfg.speaker_pins[0] = 0x18;
7542 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007543}
7544
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007545static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007546{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007547 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007548
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007549 spec->autocfg.hp_pins[0] = 0x15;
7550 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007551}
7552
7553
Kailang Yang272a5272007-05-14 11:00:38 +02007554static struct hda_verb alc882_targa_verbs[] = {
7555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7556 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7557
7558 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7559 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007560
Kailang Yang272a5272007-05-14 11:00:38 +02007561 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7562 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7563 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7564
7565 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007566 { } /* end */
7567};
7568
7569/* toggle speaker-output according to the hp-jack state */
7570static void alc882_targa_automute(struct hda_codec *codec)
7571{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007572 struct alc_spec *spec = codec->spec;
7573 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007574 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007575 spec->jack_present ? 1 : 3);
7576}
7577
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007578static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007579{
7580 struct alc_spec *spec = codec->spec;
7581
7582 spec->autocfg.hp_pins[0] = 0x14;
7583 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007584}
7585
7586static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7587{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007588 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007589 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007590}
7591
7592static struct hda_verb alc882_asus_a7j_verbs[] = {
7593 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7595
7596 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7597 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7598 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007599
Kailang Yang272a5272007-05-14 11:00:38 +02007600 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7601 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7602 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7603
7604 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7605 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7606 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7607 { } /* end */
7608};
7609
Takashi Iwai914759b2007-09-06 14:52:04 +02007610static struct hda_verb alc882_asus_a7m_verbs[] = {
7611 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7612 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7613
7614 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7615 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7616 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007617
Takashi Iwai914759b2007-09-06 14:52:04 +02007618 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7619 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7620 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7621
7622 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7623 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7624 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7625 { } /* end */
7626};
7627
Tobin Davis9102cd12006-12-15 10:02:12 +01007628static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7629{
7630 unsigned int gpiostate, gpiomask, gpiodir;
7631
7632 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7633 AC_VERB_GET_GPIO_DATA, 0);
7634
7635 if (!muted)
7636 gpiostate |= (1 << pin);
7637 else
7638 gpiostate &= ~(1 << pin);
7639
7640 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7641 AC_VERB_GET_GPIO_MASK, 0);
7642 gpiomask |= (1 << pin);
7643
7644 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7645 AC_VERB_GET_GPIO_DIRECTION, 0);
7646 gpiodir |= (1 << pin);
7647
7648
7649 snd_hda_codec_write(codec, codec->afg, 0,
7650 AC_VERB_SET_GPIO_MASK, gpiomask);
7651 snd_hda_codec_write(codec, codec->afg, 0,
7652 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7653
7654 msleep(1);
7655
7656 snd_hda_codec_write(codec, codec->afg, 0,
7657 AC_VERB_SET_GPIO_DATA, gpiostate);
7658}
7659
Takashi Iwai7debbe52007-08-16 15:01:03 +02007660/* set up GPIO at initialization */
7661static void alc885_macpro_init_hook(struct hda_codec *codec)
7662{
7663 alc882_gpio_mute(codec, 0, 0);
7664 alc882_gpio_mute(codec, 1, 0);
7665}
7666
7667/* set up GPIO and update auto-muting at initialization */
7668static void alc885_imac24_init_hook(struct hda_codec *codec)
7669{
7670 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007671 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007672}
7673
Kailang Yangdf694da2005-12-05 19:42:22 +01007674/*
7675 * generic initialization of ADC, input mixers and output mixers
7676 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007677static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007678 /*
7679 * Unmute ADC0-2 and set the default input to mic-in
7680 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007681 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7682 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7683 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7684 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7685
Takashi Iwaicb53c622007-08-10 17:21:45 +02007686 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007687 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007688 * Note: PASD motherboards uses the Line In 2 as the input for
7689 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007690 */
7691 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007692 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7693 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007697
7698 /*
7699 * Set up output mixers (0x0c - 0x0f)
7700 */
7701 /* set vol=0 to output mixers */
7702 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7703 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7704 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7705 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7706 /* set up input amps for analog loopback */
7707 /* Amp Indices: DAC = 0, mixer = 1 */
7708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7709 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7710 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7711 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7712 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7713 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7714 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7715 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7716 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7717 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7718
7719 /* FIXME: use matrix-type input source selection */
7720 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007721 /* Input mixer2 */
7722 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7725 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7726 /* Input mixer3 */
7727 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7731
7732 { }
7733};
7734
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007735/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7736static struct hda_verb alc889A_mb31_ch2_init[] = {
7737 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7738 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7739 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7740 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7741 { } /* end */
7742};
7743
7744/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7745static struct hda_verb alc889A_mb31_ch4_init[] = {
7746 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7747 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7748 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7749 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7750 { } /* end */
7751};
7752
7753/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7754static struct hda_verb alc889A_mb31_ch5_init[] = {
7755 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7756 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7757 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7758 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7759 { } /* end */
7760};
7761
7762/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7763static struct hda_verb alc889A_mb31_ch6_init[] = {
7764 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7765 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7766 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7767 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7768 { } /* end */
7769};
7770
7771static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7772 { 2, alc889A_mb31_ch2_init },
7773 { 4, alc889A_mb31_ch4_init },
7774 { 5, alc889A_mb31_ch5_init },
7775 { 6, alc889A_mb31_ch6_init },
7776};
7777
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007778static struct hda_verb alc883_medion_eapd_verbs[] = {
7779 /* eanable EAPD on medion laptop */
7780 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7781 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7782 { }
7783};
7784
Takashi Iwai4953550a2009-06-30 15:28:30 +02007785#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007786
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007787static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7788 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7789 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7790 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7791 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7792 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7793 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7794 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7795 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7796 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7798 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7799 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7800 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007801 { } /* end */
7802};
7803
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007804static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007805 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7806 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7807 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7808 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7810 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7811 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7812 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7813 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7814 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007815 { } /* end */
7816};
7817
Jiang zhefb97dc62008-03-06 11:07:11 +01007818static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7819 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7820 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7821 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7822 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7823 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7824 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7825 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7826 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7827 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7828 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007829 { } /* end */
7830};
7831
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007832static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7833 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7834 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7835 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7836 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7837 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7838 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7839 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7840 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007841 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007842 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7843 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007844 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007845 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007846 { } /* end */
7847};
7848
7849static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7850 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7851 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7852 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7853 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7854 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7855 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7856 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7857 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7858 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7859 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7860 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7861 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7862 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7863 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007864 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007865 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7866 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007867 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007868 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007869 { } /* end */
7870};
7871
Jiang zhe17bba1b2008-06-04 12:11:07 +02007872static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7873 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7874 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7875 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7876 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7877 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7878 HDA_OUTPUT),
7879 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7880 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7881 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7883 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7884 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7885 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7886 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7887 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7888 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7889 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7890 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7891 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7892 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007893 { } /* end */
7894};
7895
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007896static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7897 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7898 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7899 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7900 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7901 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7902 HDA_OUTPUT),
7903 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7904 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7905 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7906 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7907 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7908 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7909 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7910 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7911 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7912 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7914 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7915 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7916 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7917 { } /* end */
7918};
7919
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007920static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007921 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007922 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007923 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007924 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007925 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7926 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007927 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7928 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007929 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7930 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7931 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7932 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7933 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7934 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007935 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7937 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007938 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007939 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007940 { } /* end */
7941};
7942
Sasha Alexandrc2592492009-06-16 14:52:54 -04007943static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007944 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007945 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007946 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007947 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007948 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7949 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7950 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7951 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7952 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7953 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7954 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7955 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7956 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7957 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7958 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007959 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007961 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007962};
Kailang Yangccc656c2006-10-17 12:32:26 +02007963
Sasha Alexandrc2592492009-06-16 14:52:54 -04007964static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007965 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007966 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007967 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007968 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007969 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7970 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007972 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007974 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7975 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7976 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007977 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007978};
Kailang Yangccc656c2006-10-17 12:32:26 +02007979
Takashi Iwaib99dba32009-09-17 18:23:00 +02007980static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
7981 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7982 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7983 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7984 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7985 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7986 { } /* end */
7987};
7988
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007989static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7990 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7991 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007992 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7993 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7996 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007998 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007999};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008000
Kailang Yang272a5272007-05-14 11:00:38 +02008001static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8002 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8003 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8005 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8006 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8009 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8010 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008011 { } /* end */
8012};
8013
8014static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8015 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8016 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8017 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8018 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8019 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008024 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008025};
Kailang Yang272a5272007-05-14 11:00:38 +02008026
Tobin Davis2880a8672007-08-07 11:50:26 +02008027static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008028 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8029 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02008030 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02008031 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8032 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008033 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8034 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8035 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a8672007-08-07 11:50:26 +02008036 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008037};
Tobin Davis2880a8672007-08-07 11:50:26 +02008038
Tony Vroond2fd4b02009-06-21 00:40:10 +01008039static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8040 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8041 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8042 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8043 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008044 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8045 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008046 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8047 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8048 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8049 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8050 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8051 { } /* end */
8052};
8053
Kailang Yange2757d52008-08-26 13:17:46 +02008054static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8055 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8056 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8057 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8058 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8059 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8060 0x0d, 1, 0x0, HDA_OUTPUT),
8061 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8062 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8063 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8064 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8065 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008066 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8067 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8068 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8069 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8070 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8071 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8072 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8073 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8074 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8075 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008076 { } /* end */
8077};
8078
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008079static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8080 /* Output mixers */
8081 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8082 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8083 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8084 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8085 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8086 HDA_OUTPUT),
8087 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8088 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8089 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8090 /* Output switches */
8091 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8092 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8093 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8094 /* Boost mixers */
8095 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8096 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8097 /* Input mixers */
8098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8100 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8101 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8102 { } /* end */
8103};
8104
Guido Günther3e1647c2009-06-05 00:47:26 +02008105static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8106 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8107 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8108 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8109 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8110 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8111 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8112 { } /* end */
8113};
8114
Kailang Yange2757d52008-08-26 13:17:46 +02008115static struct hda_bind_ctls alc883_bind_cap_vol = {
8116 .ops = &snd_hda_bind_vol,
8117 .values = {
8118 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8119 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8120 0
8121 },
8122};
8123
8124static struct hda_bind_ctls alc883_bind_cap_switch = {
8125 .ops = &snd_hda_bind_sw,
8126 .values = {
8127 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8128 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8129 0
8130 },
8131};
8132
8133static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8134 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8135 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8137 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8138 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8139 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8140 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8141 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008142 { } /* end */
8143};
8144
8145static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008146 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8147 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8148 {
8149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8150 /* .name = "Capture Source", */
8151 .name = "Input Source",
8152 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008153 .info = alc_mux_enum_info,
8154 .get = alc_mux_enum_get,
8155 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008156 },
8157 { } /* end */
8158};
8159
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008160static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8161 {
8162 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8163 .name = "Channel Mode",
8164 .info = alc_ch_mode_info,
8165 .get = alc_ch_mode_get,
8166 .put = alc_ch_mode_put,
8167 },
8168 { } /* end */
8169};
8170
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008171/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008172static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008173{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008174 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008175
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008176 spec->autocfg.hp_pins[0] = 0x15;
8177 spec->autocfg.speaker_pins[0] = 0x14;
8178 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008179}
8180
8181/* auto-toggle front mic */
8182/*
8183static void alc883_mitac_mic_automute(struct hda_codec *codec)
8184{
8185 unsigned int present;
8186 unsigned char bits;
8187
8188 present = snd_hda_codec_read(codec, 0x18, 0,
8189 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8190 bits = present ? HDA_AMP_MUTE : 0;
8191 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8192}
8193*/
8194
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008195static struct hda_verb alc883_mitac_verbs[] = {
8196 /* HP */
8197 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8199 /* Subwoofer */
8200 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8201 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8202
8203 /* enable unsolicited event */
8204 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8205 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8206
8207 { } /* end */
8208};
8209
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308210static struct hda_verb alc883_clevo_m540r_verbs[] = {
8211 /* HP */
8212 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8213 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8214 /* Int speaker */
8215 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8216
8217 /* enable unsolicited event */
8218 /*
8219 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8220 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8221 */
8222
8223 { } /* end */
8224};
8225
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008226static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008227 /* HP */
8228 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8229 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8230 /* Int speaker */
8231 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8232 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8233
8234 /* enable unsolicited event */
8235 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008236 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008237
8238 { } /* end */
8239};
8240
Jiang zhefb97dc62008-03-06 11:07:11 +01008241static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8242 /* HP */
8243 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8244 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8245 /* Subwoofer */
8246 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8248
8249 /* enable unsolicited event */
8250 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8251
8252 { } /* end */
8253};
8254
Sasha Alexandrc2592492009-06-16 14:52:54 -04008255static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008256 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8258
8259 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8260 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008261
David Heidelberger64a8be72009-06-08 16:15:18 +02008262/* Connect Line-Out side jack (SPDIF) to Side */
8263 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8264 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8265 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8266/* Connect Mic jack to CLFE */
8267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8269 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8270/* Connect Line-in jack to Surround */
8271 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8272 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8273 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8274/* Connect HP out jack to Front */
8275 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8276 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8277 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008278
8279 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008280
8281 { } /* end */
8282};
8283
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008284static struct hda_verb alc883_lenovo_101e_verbs[] = {
8285 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8286 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8287 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8288 { } /* end */
8289};
8290
Kailang Yang272a5272007-05-14 11:00:38 +02008291static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8292 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8293 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8294 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8295 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8296 { } /* end */
8297};
8298
8299static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8300 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8301 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8302 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8303 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8304 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8305 { } /* end */
8306};
8307
Kailang Yang189609a2007-08-20 11:31:23 +02008308static struct hda_verb alc883_haier_w66_verbs[] = {
8309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8311
8312 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8313
8314 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8315 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8316 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8317 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8318 { } /* end */
8319};
8320
Kailang Yange2757d52008-08-26 13:17:46 +02008321static struct hda_verb alc888_lenovo_sky_verbs[] = {
8322 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8324 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8326 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8327 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8328 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8329 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8330 { } /* end */
8331};
8332
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008333static struct hda_verb alc888_6st_dell_verbs[] = {
8334 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8335 { }
8336};
8337
Guido Günther3e1647c2009-06-05 00:47:26 +02008338static struct hda_verb alc883_vaiott_verbs[] = {
8339 /* HP */
8340 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8341 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8342
8343 /* enable unsolicited event */
8344 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8345
8346 { } /* end */
8347};
8348
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008349static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008350{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008351 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008352
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008353 spec->autocfg.hp_pins[0] = 0x1b;
8354 spec->autocfg.speaker_pins[0] = 0x14;
8355 spec->autocfg.speaker_pins[1] = 0x16;
8356 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008357}
8358
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008359static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008360 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008361 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8362 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008363 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008364 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008365};
8366
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008367/*
8368 * 2ch mode
8369 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008370static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008371 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8372 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8373 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8374 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008375 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008376};
8377
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008378/*
8379 * 4ch mode
8380 */
8381static struct hda_verb alc888_3st_hp_4ch_init[] = {
8382 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8383 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8384 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8385 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8386 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8387 { } /* end */
8388};
8389
8390/*
8391 * 6ch mode
8392 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008393static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008394 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8395 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008396 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008397 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8398 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008399 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8400 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008401};
8402
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008403static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008404 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008405 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008406 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008407};
8408
Kailang Yang272a5272007-05-14 11:00:38 +02008409/* toggle front-jack and RCA according to the hp-jack state */
8410static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8411{
8412 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008413
Kailang Yang272a5272007-05-14 11:00:38 +02008414 present = snd_hda_codec_read(codec, 0x1b, 0,
8415 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008416 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8417 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8418 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8419 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008420}
8421
8422/* toggle RCA according to the front-jack state */
8423static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8424{
8425 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008426
Kailang Yang272a5272007-05-14 11:00:38 +02008427 present = snd_hda_codec_read(codec, 0x14, 0,
8428 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008429 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8430 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008431}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008432
Kailang Yang272a5272007-05-14 11:00:38 +02008433static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8434 unsigned int res)
8435{
8436 if ((res >> 26) == ALC880_HP_EVENT)
8437 alc888_lenovo_ms7195_front_automute(codec);
8438 if ((res >> 26) == ALC880_FRONT_EVENT)
8439 alc888_lenovo_ms7195_rca_automute(codec);
8440}
8441
8442static struct hda_verb alc883_medion_md2_verbs[] = {
8443 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8444 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8445
8446 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8447
8448 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8449 { } /* end */
8450};
8451
8452/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008453static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008454{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008455 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008456
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008457 spec->autocfg.hp_pins[0] = 0x14;
8458 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008459}
8460
Kailang Yangccc656c2006-10-17 12:32:26 +02008461/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008462#define alc883_targa_init_hook alc882_targa_init_hook
8463#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008464
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008465static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8466{
8467 unsigned int present;
8468
8469 present = snd_hda_codec_read(codec, 0x18, 0,
8470 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8471 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8472 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8473}
8474
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008475static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008476{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008477 struct alc_spec *spec = codec->spec;
8478
8479 spec->autocfg.hp_pins[0] = 0x15;
8480 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008481}
8482
8483static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8484{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008485 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008486 alc883_clevo_m720_mic_automute(codec);
8487}
8488
8489static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008490 unsigned int res)
8491{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008492 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008493 case ALC880_MIC_EVENT:
8494 alc883_clevo_m720_mic_automute(codec);
8495 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008496 default:
8497 alc_automute_amp_unsol_event(codec, res);
8498 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008499 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008500}
8501
Jiang zhefb97dc62008-03-06 11:07:11 +01008502/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008503static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008504{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008505 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008506
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008507 spec->autocfg.hp_pins[0] = 0x14;
8508 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008509}
8510
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008511static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008512{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008513 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008514
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008515 spec->autocfg.hp_pins[0] = 0x1b;
8516 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008517}
8518
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008519static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8520{
8521 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008522 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008523
David Heidelberger64a8be72009-06-08 16:15:18 +02008524 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8525 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008526 bits = present ? HDA_AMP_MUTE : 0;
8527 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8528 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008529}
8530
8531static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8532{
8533 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008534 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008535
8536 present = snd_hda_codec_read(codec, 0x1b, 0,
8537 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008538 bits = present ? HDA_AMP_MUTE : 0;
8539 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8540 HDA_AMP_MUTE, bits);
8541 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8542 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008543}
8544
8545static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8546 unsigned int res)
8547{
8548 if ((res >> 26) == ALC880_HP_EVENT)
8549 alc883_lenovo_101e_all_automute(codec);
8550 if ((res >> 26) == ALC880_FRONT_EVENT)
8551 alc883_lenovo_101e_ispeaker_automute(codec);
8552}
8553
Takashi Iwai676a9b52007-08-16 15:23:35 +02008554/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008555static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008556{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008557 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008558
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008559 spec->autocfg.hp_pins[0] = 0x14;
8560 spec->autocfg.speaker_pins[0] = 0x15;
8561 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008562}
8563
Kailang Yangd1a991a2007-08-15 16:21:59 +02008564static struct hda_verb alc883_acer_eapd_verbs[] = {
8565 /* HP Pin: output 0 (0x0c) */
8566 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8567 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8568 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8569 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008570 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8571 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008572 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008573 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8574 /* eanable EAPD on medion laptop */
8575 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8576 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008577 /* enable unsolicited event */
8578 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008579 { }
8580};
8581
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008582static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8583 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8584 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8585 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8586 { } /* end */
8587};
8588
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008589static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008590{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008591 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008592
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008593 spec->autocfg.hp_pins[0] = 0x1b;
8594 spec->autocfg.speaker_pins[0] = 0x14;
8595 spec->autocfg.speaker_pins[1] = 0x15;
8596 spec->autocfg.speaker_pins[2] = 0x16;
8597 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008598}
8599
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008600static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008601{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008602 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008603
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008604 spec->autocfg.hp_pins[0] = 0x1b;
8605 spec->autocfg.speaker_pins[0] = 0x14;
8606 spec->autocfg.speaker_pins[1] = 0x15;
8607 spec->autocfg.speaker_pins[2] = 0x16;
8608 spec->autocfg.speaker_pins[3] = 0x17;
8609 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008610}
8611
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008612static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008613{
8614 struct alc_spec *spec = codec->spec;
8615
8616 spec->autocfg.hp_pins[0] = 0x15;
8617 spec->autocfg.speaker_pins[0] = 0x14;
8618 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008619}
8620
Kailang Yange2757d52008-08-26 13:17:46 +02008621static struct hda_verb alc888_asus_m90v_verbs[] = {
8622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8623 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8624 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8625 /* enable unsolicited event */
8626 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8627 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8628 { } /* end */
8629};
8630
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008631static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008632{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008633 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008634
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008635 spec->autocfg.hp_pins[0] = 0x1b;
8636 spec->autocfg.speaker_pins[0] = 0x14;
8637 spec->autocfg.speaker_pins[1] = 0x15;
8638 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008639 spec->ext_mic.pin = 0x18;
8640 spec->int_mic.pin = 0x19;
8641 spec->ext_mic.mux_idx = 0;
8642 spec->int_mic.mux_idx = 1;
8643 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008644}
8645
8646static struct hda_verb alc888_asus_eee1601_verbs[] = {
8647 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8649 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8650 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8651 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8652 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8653 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8654 /* enable unsolicited event */
8655 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8656 { } /* end */
8657};
8658
Kailang Yange2757d52008-08-26 13:17:46 +02008659static void alc883_eee1601_inithook(struct hda_codec *codec)
8660{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008661 struct alc_spec *spec = codec->spec;
8662
8663 spec->autocfg.hp_pins[0] = 0x14;
8664 spec->autocfg.speaker_pins[0] = 0x1b;
8665 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008666}
8667
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008668static struct hda_verb alc889A_mb31_verbs[] = {
8669 /* Init rear pin (used as headphone output) */
8670 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8671 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8672 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8673 /* Init line pin (used as output in 4ch and 6ch mode) */
8674 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8675 /* Init line 2 pin (used as headphone out by default) */
8676 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8677 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8678 { } /* end */
8679};
8680
8681/* Mute speakers according to the headphone jack state */
8682static void alc889A_mb31_automute(struct hda_codec *codec)
8683{
8684 unsigned int present;
8685
8686 /* Mute only in 2ch or 4ch mode */
8687 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8688 == 0x00) {
8689 present = snd_hda_codec_read(codec, 0x15, 0,
8690 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8691 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8692 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8693 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8694 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8695 }
8696}
8697
8698static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8699{
8700 if ((res >> 26) == ALC880_HP_EVENT)
8701 alc889A_mb31_automute(codec);
8702}
8703
Takashi Iwai4953550a2009-06-30 15:28:30 +02008704
Takashi Iwaicb53c622007-08-10 17:21:45 +02008705#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008706#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008707#endif
8708
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008709/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008710#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8711#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8712#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8713#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8714
8715static hda_nid_t alc883_slave_dig_outs[] = {
8716 ALC1200_DIGOUT_NID, 0,
8717};
8718
8719static hda_nid_t alc1200_slave_dig_outs[] = {
8720 ALC883_DIGOUT_NID, 0,
8721};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008722
8723/*
8724 * configuration and preset
8725 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008726static const char *alc882_models[ALC882_MODEL_LAST] = {
8727 [ALC882_3ST_DIG] = "3stack-dig",
8728 [ALC882_6ST_DIG] = "6stack-dig",
8729 [ALC882_ARIMA] = "arima",
8730 [ALC882_W2JC] = "w2jc",
8731 [ALC882_TARGA] = "targa",
8732 [ALC882_ASUS_A7J] = "asus-a7j",
8733 [ALC882_ASUS_A7M] = "asus-a7m",
8734 [ALC885_MACPRO] = "macpro",
8735 [ALC885_MB5] = "mb5",
8736 [ALC885_MBP3] = "mbp3",
8737 [ALC885_IMAC24] = "imac24",
8738 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008739 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8740 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008741 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008742 [ALC883_TARGA_DIG] = "targa-dig",
8743 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008744 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008745 [ALC883_ACER] = "acer",
Tobin Davis2880a8672007-08-07 11:50:26 +02008746 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008747 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008748 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008749 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008750 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008751 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008752 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008753 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008754 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008755 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8756 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008757 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008758 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008759 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008760 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008761 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308762 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008763 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008764 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008765 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008766 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008767 [ALC889A_INTEL] = "intel-alc889a",
8768 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008769 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008770 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008771 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008772 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008773};
8774
Takashi Iwai4953550a2009-06-30 15:28:30 +02008775static struct snd_pci_quirk alc882_cfg_tbl[] = {
8776 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8777
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008778 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008779 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008780 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008781 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8782 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008783 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008784 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8785 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008786 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8787 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008788 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8789 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008790 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8791 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008792 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8793 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008794 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008795 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008796 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008797 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008798 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8799 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008800 /* default Acer -- disabled as it causes more problems.
8801 * model=auto should work fine now
8802 */
8803 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008804
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008805 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008806
Tobin Davisfebe3372007-06-12 11:27:46 +02008807 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008808 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8809 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008810 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008811 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008812 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008813
8814 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8815 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8816 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008817 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008818 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8819 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8820 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008821 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008822 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008823 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008824 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008825
8826 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008827 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008828 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008829 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008830 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8831 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008832 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008833 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008834 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8835
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008836 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8837 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8838 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008839 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Jiang zhe4383fae2008-04-14 12:58:57 +02008840 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008841 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008842 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008843 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008844 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8845 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8846 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8847 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8848 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8849 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008850 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008851 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8852 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8853 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008854 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008855 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8856 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008857 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008858 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008859 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008860 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008861 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008862 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008863 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008864 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008865
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008866 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008867 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8868 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308869 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008870 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008871 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008872 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008873 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008874 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008875 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008876 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008877 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008878 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008879 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008880 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8881 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008882 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008883 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008884 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008885 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008886 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008887
Jiang zhe17bba1b2008-06-04 12:11:07 +02008888 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8889 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008890 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008891 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8892 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8893 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008894 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008895
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008896 {}
8897};
8898
Takashi Iwai4953550a2009-06-30 15:28:30 +02008899/* codec SSID table for Intel Mac */
8900static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8901 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8902 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8903 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8904 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8905 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8906 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8907 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8908 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8909 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8910 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8911 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8912 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8913 * no perfect solution yet
8914 */
8915 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8916 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008917};
8918
Takashi Iwai4953550a2009-06-30 15:28:30 +02008919static struct alc_config_preset alc882_presets[] = {
8920 [ALC882_3ST_DIG] = {
8921 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008922 .init_verbs = { alc882_base_init_verbs,
8923 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008924 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8925 .dac_nids = alc882_dac_nids,
8926 .dig_out_nid = ALC882_DIGOUT_NID,
8927 .dig_in_nid = ALC882_DIGIN_NID,
8928 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8929 .channel_mode = alc882_ch_modes,
8930 .need_dac_fix = 1,
8931 .input_mux = &alc882_capture_source,
8932 },
8933 [ALC882_6ST_DIG] = {
8934 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008935 .init_verbs = { alc882_base_init_verbs,
8936 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008937 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8938 .dac_nids = alc882_dac_nids,
8939 .dig_out_nid = ALC882_DIGOUT_NID,
8940 .dig_in_nid = ALC882_DIGIN_NID,
8941 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8942 .channel_mode = alc882_sixstack_modes,
8943 .input_mux = &alc882_capture_source,
8944 },
8945 [ALC882_ARIMA] = {
8946 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008947 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8948 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008949 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8950 .dac_nids = alc882_dac_nids,
8951 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8952 .channel_mode = alc882_sixstack_modes,
8953 .input_mux = &alc882_capture_source,
8954 },
8955 [ALC882_W2JC] = {
8956 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008957 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8958 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008959 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8960 .dac_nids = alc882_dac_nids,
8961 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8962 .channel_mode = alc880_threestack_modes,
8963 .need_dac_fix = 1,
8964 .input_mux = &alc882_capture_source,
8965 .dig_out_nid = ALC882_DIGOUT_NID,
8966 },
8967 [ALC885_MBP3] = {
8968 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8969 .init_verbs = { alc885_mbp3_init_verbs,
8970 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02008971 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008972 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02008973 .hp_nid = 0x04,
8974 .channel_mode = alc885_mbp_4ch_modes,
8975 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008976 .input_mux = &alc882_capture_source,
8977 .dig_out_nid = ALC882_DIGOUT_NID,
8978 .dig_in_nid = ALC882_DIGIN_NID,
8979 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008980 .setup = alc885_mbp3_setup,
8981 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008982 },
8983 [ALC885_MB5] = {
8984 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8985 .init_verbs = { alc885_mb5_init_verbs,
8986 alc880_gpio1_init_verbs },
8987 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8988 .dac_nids = alc882_dac_nids,
8989 .channel_mode = alc885_mb5_6ch_modes,
8990 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8991 .input_mux = &mb5_capture_source,
8992 .dig_out_nid = ALC882_DIGOUT_NID,
8993 .dig_in_nid = ALC882_DIGIN_NID,
8994 },
8995 [ALC885_MACPRO] = {
8996 .mixers = { alc882_macpro_mixer },
8997 .init_verbs = { alc882_macpro_init_verbs },
8998 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8999 .dac_nids = alc882_dac_nids,
9000 .dig_out_nid = ALC882_DIGOUT_NID,
9001 .dig_in_nid = ALC882_DIGIN_NID,
9002 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9003 .channel_mode = alc882_ch_modes,
9004 .input_mux = &alc882_capture_source,
9005 .init_hook = alc885_macpro_init_hook,
9006 },
9007 [ALC885_IMAC24] = {
9008 .mixers = { alc885_imac24_mixer },
9009 .init_verbs = { alc885_imac24_init_verbs },
9010 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9011 .dac_nids = alc882_dac_nids,
9012 .dig_out_nid = ALC882_DIGOUT_NID,
9013 .dig_in_nid = ALC882_DIGIN_NID,
9014 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9015 .channel_mode = alc882_ch_modes,
9016 .input_mux = &alc882_capture_source,
9017 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009018 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009019 .init_hook = alc885_imac24_init_hook,
9020 },
9021 [ALC882_TARGA] = {
9022 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009023 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009024 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009025 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9026 .dac_nids = alc882_dac_nids,
9027 .dig_out_nid = ALC882_DIGOUT_NID,
9028 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9029 .adc_nids = alc882_adc_nids,
9030 .capsrc_nids = alc882_capsrc_nids,
9031 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9032 .channel_mode = alc882_3ST_6ch_modes,
9033 .need_dac_fix = 1,
9034 .input_mux = &alc882_capture_source,
9035 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009036 .setup = alc882_targa_setup,
9037 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009038 },
9039 [ALC882_ASUS_A7J] = {
9040 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009041 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9042 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009043 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9044 .dac_nids = alc882_dac_nids,
9045 .dig_out_nid = ALC882_DIGOUT_NID,
9046 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9047 .adc_nids = alc882_adc_nids,
9048 .capsrc_nids = alc882_capsrc_nids,
9049 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9050 .channel_mode = alc882_3ST_6ch_modes,
9051 .need_dac_fix = 1,
9052 .input_mux = &alc882_capture_source,
9053 },
9054 [ALC882_ASUS_A7M] = {
9055 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009056 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9057 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009058 alc882_asus_a7m_verbs },
9059 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9060 .dac_nids = alc882_dac_nids,
9061 .dig_out_nid = ALC882_DIGOUT_NID,
9062 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9063 .channel_mode = alc880_threestack_modes,
9064 .need_dac_fix = 1,
9065 .input_mux = &alc882_capture_source,
9066 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009067 [ALC883_3ST_2ch_DIG] = {
9068 .mixers = { alc883_3ST_2ch_mixer },
9069 .init_verbs = { alc883_init_verbs },
9070 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9071 .dac_nids = alc883_dac_nids,
9072 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009073 .dig_in_nid = ALC883_DIGIN_NID,
9074 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9075 .channel_mode = alc883_3ST_2ch_modes,
9076 .input_mux = &alc883_capture_source,
9077 },
9078 [ALC883_3ST_6ch_DIG] = {
9079 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9080 .init_verbs = { alc883_init_verbs },
9081 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9082 .dac_nids = alc883_dac_nids,
9083 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009084 .dig_in_nid = ALC883_DIGIN_NID,
9085 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9086 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009087 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009088 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009089 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009090 [ALC883_3ST_6ch] = {
9091 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9092 .init_verbs = { alc883_init_verbs },
9093 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9094 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009095 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9096 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009097 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009098 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009099 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009100 [ALC883_3ST_6ch_INTEL] = {
9101 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9102 .init_verbs = { alc883_init_verbs },
9103 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9104 .dac_nids = alc883_dac_nids,
9105 .dig_out_nid = ALC883_DIGOUT_NID,
9106 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009107 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009108 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9109 .channel_mode = alc883_3ST_6ch_intel_modes,
9110 .need_dac_fix = 1,
9111 .input_mux = &alc883_3stack_6ch_intel,
9112 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009113 [ALC889A_INTEL] = {
9114 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009115 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9116 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009117 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9118 .dac_nids = alc883_dac_nids,
9119 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9120 .adc_nids = alc889_adc_nids,
9121 .dig_out_nid = ALC883_DIGOUT_NID,
9122 .dig_in_nid = ALC883_DIGIN_NID,
9123 .slave_dig_outs = alc883_slave_dig_outs,
9124 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9125 .channel_mode = alc889_8ch_intel_modes,
9126 .capsrc_nids = alc889_capsrc_nids,
9127 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009128 .setup = alc889_automute_setup,
9129 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009130 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009131 .need_dac_fix = 1,
9132 },
9133 [ALC889_INTEL] = {
9134 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9135 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009136 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009137 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9138 .dac_nids = alc883_dac_nids,
9139 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9140 .adc_nids = alc889_adc_nids,
9141 .dig_out_nid = ALC883_DIGOUT_NID,
9142 .dig_in_nid = ALC883_DIGIN_NID,
9143 .slave_dig_outs = alc883_slave_dig_outs,
9144 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9145 .channel_mode = alc889_8ch_intel_modes,
9146 .capsrc_nids = alc889_capsrc_nids,
9147 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009148 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009149 .init_hook = alc889_intel_init_hook,
9150 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009151 .need_dac_fix = 1,
9152 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009153 [ALC883_6ST_DIG] = {
9154 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9155 .init_verbs = { alc883_init_verbs },
9156 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9157 .dac_nids = alc883_dac_nids,
9158 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009159 .dig_in_nid = ALC883_DIGIN_NID,
9160 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9161 .channel_mode = alc883_sixstack_modes,
9162 .input_mux = &alc883_capture_source,
9163 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009164 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009165 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009166 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9167 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009168 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9169 .dac_nids = alc883_dac_nids,
9170 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009171 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9172 .channel_mode = alc883_3ST_6ch_modes,
9173 .need_dac_fix = 1,
9174 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009175 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009176 .setup = alc882_targa_setup,
9177 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009178 },
9179 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009180 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009181 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9182 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009183 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9184 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009185 .adc_nids = alc883_adc_nids_alt,
9186 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009187 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009188 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9189 .channel_mode = alc883_3ST_2ch_modes,
9190 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009191 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009192 .setup = alc882_targa_setup,
9193 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009194 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009195 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009196 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9197 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009198 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009199 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009200 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9201 .dac_nids = alc883_dac_nids,
9202 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9203 .adc_nids = alc883_adc_nids_rev,
9204 .capsrc_nids = alc883_capsrc_nids_rev,
9205 .dig_out_nid = ALC883_DIGOUT_NID,
9206 .dig_in_nid = ALC883_DIGIN_NID,
9207 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9208 .channel_mode = alc883_4ST_8ch_modes,
9209 .need_dac_fix = 1,
9210 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009211 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009212 .setup = alc882_targa_setup,
9213 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009214 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009215 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009216 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009217 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9218 * and the headphone jack. Turn this on and rely on the
9219 * standard mute methods whenever the user wants to turn
9220 * these outputs off.
9221 */
9222 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9223 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9224 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009225 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9226 .channel_mode = alc883_3ST_2ch_modes,
9227 .input_mux = &alc883_capture_source,
9228 },
Tobin Davis2880a8672007-08-07 11:50:26 +02009229 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009230 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009231 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a8672007-08-07 11:50:26 +02009232 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9233 .dac_nids = alc883_dac_nids,
9234 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a8672007-08-07 11:50:26 +02009235 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9236 .channel_mode = alc883_3ST_2ch_modes,
9237 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009238 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009239 .setup = alc883_acer_aspire_setup,
9240 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009241 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009242 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009243 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009244 alc883_chmode_mixer },
9245 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9246 alc888_acer_aspire_4930g_verbs },
9247 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9248 .dac_nids = alc883_dac_nids,
9249 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9250 .adc_nids = alc883_adc_nids_rev,
9251 .capsrc_nids = alc883_capsrc_nids_rev,
9252 .dig_out_nid = ALC883_DIGOUT_NID,
9253 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9254 .channel_mode = alc883_3ST_6ch_modes,
9255 .need_dac_fix = 1,
9256 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009257 ARRAY_SIZE(alc888_2_capture_sources),
9258 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009259 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009260 .setup = alc888_acer_aspire_4930g_setup,
9261 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009262 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009263 [ALC888_ACER_ASPIRE_6530G] = {
9264 .mixers = { alc888_acer_aspire_6530_mixer },
9265 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9266 alc888_acer_aspire_6530g_verbs },
9267 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9268 .dac_nids = alc883_dac_nids,
9269 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9270 .adc_nids = alc883_adc_nids_rev,
9271 .capsrc_nids = alc883_capsrc_nids_rev,
9272 .dig_out_nid = ALC883_DIGOUT_NID,
9273 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9274 .channel_mode = alc883_3ST_2ch_modes,
9275 .num_mux_defs =
9276 ARRAY_SIZE(alc888_2_capture_sources),
9277 .input_mux = alc888_acer_aspire_6530_sources,
9278 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009279 .setup = alc888_acer_aspire_6530g_setup,
9280 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009281 },
Hector Martin3b315d72009-06-02 10:54:19 +02009282 [ALC888_ACER_ASPIRE_8930G] = {
9283 .mixers = { alc888_base_mixer,
9284 alc883_chmode_mixer },
9285 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009286 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009287 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9288 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009289 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9290 .adc_nids = alc889_adc_nids,
9291 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009292 .dig_out_nid = ALC883_DIGOUT_NID,
9293 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9294 .channel_mode = alc883_3ST_6ch_modes,
9295 .need_dac_fix = 1,
9296 .const_channel_count = 6,
9297 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009298 ARRAY_SIZE(alc889_capture_sources),
9299 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009300 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009301 .setup = alc889_acer_aspire_8930g_setup,
9302 .init_hook = alc_automute_amp,
Hector Martin3b315d72009-06-02 10:54:19 +02009303 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009304 [ALC888_ACER_ASPIRE_7730G] = {
9305 .mixers = { alc883_3ST_6ch_mixer,
9306 alc883_chmode_mixer },
9307 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9308 alc888_acer_aspire_7730G_verbs },
9309 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9310 .dac_nids = alc883_dac_nids,
9311 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9312 .adc_nids = alc883_adc_nids_rev,
9313 .capsrc_nids = alc883_capsrc_nids_rev,
9314 .dig_out_nid = ALC883_DIGOUT_NID,
9315 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9316 .channel_mode = alc883_3ST_6ch_modes,
9317 .need_dac_fix = 1,
9318 .const_channel_count = 6,
9319 .input_mux = &alc883_capture_source,
9320 .unsol_event = alc_automute_amp_unsol_event,
9321 .setup = alc888_acer_aspire_6530g_setup,
9322 .init_hook = alc_automute_amp,
9323 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009324 [ALC883_MEDION] = {
9325 .mixers = { alc883_fivestack_mixer,
9326 alc883_chmode_mixer },
9327 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009328 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009329 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9330 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009331 .adc_nids = alc883_adc_nids_alt,
9332 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009333 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9334 .channel_mode = alc883_sixstack_modes,
9335 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009336 },
Kailang Yang272a5272007-05-14 11:00:38 +02009337 [ALC883_MEDION_MD2] = {
9338 .mixers = { alc883_medion_md2_mixer},
9339 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9340 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9341 .dac_nids = alc883_dac_nids,
9342 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009343 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9344 .channel_mode = alc883_3ST_2ch_modes,
9345 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009346 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009347 .setup = alc883_medion_md2_setup,
9348 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009349 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009350 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009351 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009352 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9353 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9354 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009355 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9356 .channel_mode = alc883_3ST_2ch_modes,
9357 .input_mux = &alc883_capture_source,
9358 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309359 [ALC883_CLEVO_M540R] = {
9360 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9361 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9362 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9363 .dac_nids = alc883_dac_nids,
9364 .dig_out_nid = ALC883_DIGOUT_NID,
9365 .dig_in_nid = ALC883_DIGIN_NID,
9366 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9367 .channel_mode = alc883_3ST_6ch_clevo_modes,
9368 .need_dac_fix = 1,
9369 .input_mux = &alc883_capture_source,
9370 /* This machine has the hardware HP auto-muting, thus
9371 * we need no software mute via unsol event
9372 */
9373 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009374 [ALC883_CLEVO_M720] = {
9375 .mixers = { alc883_clevo_m720_mixer },
9376 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009377 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9378 .dac_nids = alc883_dac_nids,
9379 .dig_out_nid = ALC883_DIGOUT_NID,
9380 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9381 .channel_mode = alc883_3ST_2ch_modes,
9382 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009383 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009384 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009385 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009386 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009387 [ALC883_LENOVO_101E_2ch] = {
9388 .mixers = { alc883_lenovo_101e_2ch_mixer},
9389 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9390 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9391 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009392 .adc_nids = alc883_adc_nids_alt,
9393 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009394 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9395 .channel_mode = alc883_3ST_2ch_modes,
9396 .input_mux = &alc883_lenovo_101e_capture_source,
9397 .unsol_event = alc883_lenovo_101e_unsol_event,
9398 .init_hook = alc883_lenovo_101e_all_automute,
9399 },
Kailang Yang272a5272007-05-14 11:00:38 +02009400 [ALC883_LENOVO_NB0763] = {
9401 .mixers = { alc883_lenovo_nb0763_mixer },
9402 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9403 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9404 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009405 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9406 .channel_mode = alc883_3ST_2ch_modes,
9407 .need_dac_fix = 1,
9408 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009409 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009410 .setup = alc883_medion_md2_setup,
9411 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009412 },
9413 [ALC888_LENOVO_MS7195_DIG] = {
9414 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9415 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9416 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9417 .dac_nids = alc883_dac_nids,
9418 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009419 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9420 .channel_mode = alc883_3ST_6ch_modes,
9421 .need_dac_fix = 1,
9422 .input_mux = &alc883_capture_source,
9423 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9424 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009425 },
9426 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009427 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009428 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9429 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9430 .dac_nids = alc883_dac_nids,
9431 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009432 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9433 .channel_mode = alc883_3ST_2ch_modes,
9434 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009435 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009436 .setup = alc883_haier_w66_setup,
9437 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009438 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009439 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009440 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009441 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009442 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9443 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009444 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9445 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009446 .need_dac_fix = 1,
9447 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009448 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009449 .setup = alc888_3st_hp_setup,
9450 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009451 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009452 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009453 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009454 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9455 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9456 .dac_nids = alc883_dac_nids,
9457 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009458 .dig_in_nid = ALC883_DIGIN_NID,
9459 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9460 .channel_mode = alc883_sixstack_modes,
9461 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009462 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009463 .setup = alc888_6st_dell_setup,
9464 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009465 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009466 [ALC883_MITAC] = {
9467 .mixers = { alc883_mitac_mixer },
9468 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9469 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9470 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009471 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9472 .channel_mode = alc883_3ST_2ch_modes,
9473 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009474 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009475 .setup = alc883_mitac_setup,
9476 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009477 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009478 [ALC883_FUJITSU_PI2515] = {
9479 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9480 .init_verbs = { alc883_init_verbs,
9481 alc883_2ch_fujitsu_pi2515_verbs},
9482 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9483 .dac_nids = alc883_dac_nids,
9484 .dig_out_nid = ALC883_DIGOUT_NID,
9485 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9486 .channel_mode = alc883_3ST_2ch_modes,
9487 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009488 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009489 .setup = alc883_2ch_fujitsu_pi2515_setup,
9490 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009491 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009492 [ALC888_FUJITSU_XA3530] = {
9493 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9494 .init_verbs = { alc883_init_verbs,
9495 alc888_fujitsu_xa3530_verbs },
9496 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9497 .dac_nids = alc883_dac_nids,
9498 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9499 .adc_nids = alc883_adc_nids_rev,
9500 .capsrc_nids = alc883_capsrc_nids_rev,
9501 .dig_out_nid = ALC883_DIGOUT_NID,
9502 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9503 .channel_mode = alc888_4ST_8ch_intel_modes,
9504 .num_mux_defs =
9505 ARRAY_SIZE(alc888_2_capture_sources),
9506 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009507 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009508 .setup = alc888_fujitsu_xa3530_setup,
9509 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009510 },
Kailang Yange2757d52008-08-26 13:17:46 +02009511 [ALC888_LENOVO_SKY] = {
9512 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9513 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9514 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9515 .dac_nids = alc883_dac_nids,
9516 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009517 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9518 .channel_mode = alc883_sixstack_modes,
9519 .need_dac_fix = 1,
9520 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009521 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009522 .setup = alc888_lenovo_sky_setup,
9523 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009524 },
9525 [ALC888_ASUS_M90V] = {
9526 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9527 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9528 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9529 .dac_nids = alc883_dac_nids,
9530 .dig_out_nid = ALC883_DIGOUT_NID,
9531 .dig_in_nid = ALC883_DIGIN_NID,
9532 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9533 .channel_mode = alc883_3ST_6ch_modes,
9534 .need_dac_fix = 1,
9535 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009536 .unsol_event = alc_sku_unsol_event,
9537 .setup = alc883_mode2_setup,
9538 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009539 },
9540 [ALC888_ASUS_EEE1601] = {
9541 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009542 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009543 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9544 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9545 .dac_nids = alc883_dac_nids,
9546 .dig_out_nid = ALC883_DIGOUT_NID,
9547 .dig_in_nid = ALC883_DIGIN_NID,
9548 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9549 .channel_mode = alc883_3ST_2ch_modes,
9550 .need_dac_fix = 1,
9551 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009552 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009553 .init_hook = alc883_eee1601_inithook,
9554 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009555 [ALC1200_ASUS_P5Q] = {
9556 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9557 .init_verbs = { alc883_init_verbs },
9558 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9559 .dac_nids = alc883_dac_nids,
9560 .dig_out_nid = ALC1200_DIGOUT_NID,
9561 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009562 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009563 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9564 .channel_mode = alc883_sixstack_modes,
9565 .input_mux = &alc883_capture_source,
9566 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009567 [ALC889A_MB31] = {
9568 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9569 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9570 alc880_gpio1_init_verbs },
9571 .adc_nids = alc883_adc_nids,
9572 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9573 .dac_nids = alc883_dac_nids,
9574 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9575 .channel_mode = alc889A_mb31_6ch_modes,
9576 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9577 .input_mux = &alc889A_mb31_capture_source,
9578 .dig_out_nid = ALC883_DIGOUT_NID,
9579 .unsol_event = alc889A_mb31_unsol_event,
9580 .init_hook = alc889A_mb31_automute,
9581 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009582 [ALC883_SONY_VAIO_TT] = {
9583 .mixers = { alc883_vaiott_mixer },
9584 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9585 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9586 .dac_nids = alc883_dac_nids,
9587 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9588 .channel_mode = alc883_3ST_2ch_modes,
9589 .input_mux = &alc883_capture_source,
9590 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009591 .setup = alc883_vaiott_setup,
9592 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009593 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009594};
9595
9596
9597/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009598 * Pin config fixes
9599 */
9600enum {
9601 PINFIX_ABIT_AW9D_MAX
9602};
9603
9604static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9605 { 0x15, 0x01080104 }, /* side */
9606 { 0x16, 0x01011012 }, /* rear */
9607 { 0x17, 0x01016011 }, /* clfe */
9608 { }
9609};
9610
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009611static const struct alc_fixup alc882_fixups[] = {
9612 [PINFIX_ABIT_AW9D_MAX] = {
9613 .pins = alc882_abit_aw9d_pinfix
9614 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009615};
9616
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009617static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009618 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9619 {}
9620};
9621
9622/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009623 * BIOS auto configuration
9624 */
Takashi Iwai05f5f472009-08-25 13:10:18 +02009625static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9626 const struct auto_pin_cfg *cfg)
9627{
9628 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9629}
9630
Takashi Iwai4953550a2009-06-30 15:28:30 +02009631static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009632 hda_nid_t nid, int pin_type,
9633 int dac_idx)
9634{
9635 /* set as output */
9636 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009637 int idx;
9638
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009639 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009640 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9641 idx = 4;
9642 else
9643 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009644 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9645
9646}
9647
Takashi Iwai4953550a2009-06-30 15:28:30 +02009648static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009649{
9650 struct alc_spec *spec = codec->spec;
9651 int i;
9652
9653 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009654 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009655 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009656 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009657 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009658 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009659 }
9660}
9661
Takashi Iwai4953550a2009-06-30 15:28:30 +02009662static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009663{
9664 struct alc_spec *spec = codec->spec;
9665 hda_nid_t pin;
9666
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009667 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009668 if (pin) /* connect to front */
9669 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009670 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009671 pin = spec->autocfg.speaker_pins[0];
9672 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009673 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009674}
9675
Takashi Iwai4953550a2009-06-30 15:28:30 +02009676static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009677{
9678 struct alc_spec *spec = codec->spec;
9679 int i;
9680
9681 for (i = 0; i < AUTO_PIN_LAST; i++) {
9682 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009683 if (!nid)
9684 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009685 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009686 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9687 snd_hda_codec_write(codec, nid, 0,
9688 AC_VERB_SET_AMP_GAIN_MUTE,
9689 AMP_OUT_MUTE);
9690 }
9691}
9692
9693static void alc882_auto_init_input_src(struct hda_codec *codec)
9694{
9695 struct alc_spec *spec = codec->spec;
9696 int c;
9697
9698 for (c = 0; c < spec->num_adc_nids; c++) {
9699 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9700 hda_nid_t nid = spec->capsrc_nids[c];
9701 unsigned int mux_idx;
9702 const struct hda_input_mux *imux;
9703 int conns, mute, idx, item;
9704
9705 conns = snd_hda_get_connections(codec, nid, conn_list,
9706 ARRAY_SIZE(conn_list));
9707 if (conns < 0)
9708 continue;
9709 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9710 imux = &spec->input_mux[mux_idx];
9711 for (idx = 0; idx < conns; idx++) {
9712 /* if the current connection is the selected one,
9713 * unmute it as default - otherwise mute it
9714 */
9715 mute = AMP_IN_MUTE(idx);
9716 for (item = 0; item < imux->num_items; item++) {
9717 if (imux->items[item].index == idx) {
9718 if (spec->cur_mux[c] == item)
9719 mute = AMP_IN_UNMUTE(idx);
9720 break;
9721 }
9722 }
9723 /* check if we have a selector or mixer
9724 * we could check for the widget type instead, but
9725 * just check for Amp-In presence (in case of mixer
9726 * without amp-in there is something wrong, this
9727 * function shouldn't be used or capsrc nid is wrong)
9728 */
9729 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009730 snd_hda_codec_write(codec, nid, 0,
9731 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009732 mute);
9733 else if (mute != AMP_IN_MUTE(idx))
9734 snd_hda_codec_write(codec, nid, 0,
9735 AC_VERB_SET_CONNECT_SEL,
9736 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009737 }
9738 }
9739}
9740
Takashi Iwai4953550a2009-06-30 15:28:30 +02009741/* add mic boosts if needed */
9742static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009743{
9744 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009745 int err;
9746 hda_nid_t nid;
9747
9748 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9749 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9750 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9751 "Mic Boost",
9752 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9753 if (err < 0)
9754 return err;
9755 }
9756 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9757 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9758 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9759 "Front Mic Boost",
9760 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9761 if (err < 0)
9762 return err;
9763 }
9764 return 0;
9765}
9766
9767/* almost identical with ALC880 parser... */
9768static int alc882_parse_auto_config(struct hda_codec *codec)
9769{
9770 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009771 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9772 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009773
Takashi Iwai05f5f472009-08-25 13:10:18 +02009774 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9775 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009776 if (err < 0)
9777 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009778 if (!spec->autocfg.line_outs)
9779 return 0; /* can't find valid BIOS pin config */
9780
9781 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9782 if (err < 0)
9783 return err;
9784 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9785 if (err < 0)
9786 return err;
9787 err = alc880_auto_create_extra_out(spec,
9788 spec->autocfg.speaker_pins[0],
9789 "Speaker");
9790 if (err < 0)
9791 return err;
9792 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9793 "Headphone");
9794 if (err < 0)
9795 return err;
9796 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9797 if (err < 0)
9798 return err;
9799
9800 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9801
9802 /* check multiple SPDIF-out (for recent codecs) */
9803 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9804 hda_nid_t dig_nid;
9805 err = snd_hda_get_connections(codec,
9806 spec->autocfg.dig_out_pins[i],
9807 &dig_nid, 1);
9808 if (err < 0)
9809 continue;
9810 if (!i)
9811 spec->multiout.dig_out_nid = dig_nid;
9812 else {
9813 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
9814 spec->slave_dig_outs[i - 1] = dig_nid;
9815 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
9816 break;
9817 }
9818 }
9819 if (spec->autocfg.dig_in_pin)
9820 spec->dig_in_nid = ALC880_DIGIN_NID;
9821
9822 if (spec->kctls.list)
9823 add_mixer(spec, spec->kctls.list);
9824
9825 add_verb(spec, alc883_auto_init_verbs);
9826 /* if ADC 0x07 is available, initialize it, too */
9827 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9828 add_verb(spec, alc882_adc1_init_verbs);
9829
9830 spec->num_mux_defs = 1;
9831 spec->input_mux = &spec->private_imux[0];
9832
9833 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +02009834
9835 err = alc_auto_add_mic_boost(codec);
9836 if (err < 0)
9837 return err;
9838
Takashi Iwai776e1842007-08-29 15:07:11 +02009839 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009840}
9841
9842/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009843static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009844{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009845 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009846 alc882_auto_init_multi_out(codec);
9847 alc882_auto_init_hp_out(codec);
9848 alc882_auto_init_analog_input(codec);
9849 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009850 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009851 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009852}
9853
Takashi Iwai4953550a2009-06-30 15:28:30 +02009854static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009855{
9856 struct alc_spec *spec;
9857 int err, board_config;
9858
9859 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9860 if (spec == NULL)
9861 return -ENOMEM;
9862
9863 codec->spec = spec;
9864
Takashi Iwai4953550a2009-06-30 15:28:30 +02009865 switch (codec->vendor_id) {
9866 case 0x10ec0882:
9867 case 0x10ec0885:
9868 break;
9869 default:
9870 /* ALC883 and variants */
9871 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9872 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009873 }
9874
Takashi Iwai4953550a2009-06-30 15:28:30 +02009875 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9876 alc882_models,
9877 alc882_cfg_tbl);
9878
9879 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9880 board_config = snd_hda_check_board_codec_sid_config(codec,
9881 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9882
9883 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009884 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009885 codec->chip_name);
9886 board_config = ALC882_AUTO;
9887 }
9888
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009889 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009890
9891 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009892 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009893 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009894 if (err < 0) {
9895 alc_free(codec);
9896 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009897 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009898 printk(KERN_INFO
9899 "hda_codec: Cannot set up configuration "
9900 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +02009901 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009902 }
9903 }
9904
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009905 err = snd_hda_attach_beep_device(codec, 0x1);
9906 if (err < 0) {
9907 alc_free(codec);
9908 return err;
9909 }
9910
Takashi Iwai4953550a2009-06-30 15:28:30 +02009911 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02009912 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009913
Takashi Iwai4953550a2009-06-30 15:28:30 +02009914 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9915 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9916 /* FIXME: setup DAC5 */
9917 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9918 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9919
9920 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9921 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9922
9923 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009924 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009925
9926 if (!spec->adc_nids && spec->input_mux) {
9927 int i;
9928 spec->num_adc_nids = 0;
9929 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9930 hda_nid_t cap;
9931 hda_nid_t nid = alc882_adc_nids[i];
9932 unsigned int wcap = get_wcaps(codec, nid);
9933 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02009934 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009935 if (wcap != AC_WID_AUD_IN)
9936 continue;
9937 spec->private_adc_nids[spec->num_adc_nids] = nid;
9938 err = snd_hda_get_connections(codec, nid, &cap, 1);
9939 if (err < 0)
9940 continue;
9941 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9942 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009943 }
Takashi Iwai4953550a2009-06-30 15:28:30 +02009944 spec->adc_nids = spec->private_adc_nids;
9945 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009946 }
9947
Takashi Iwaib59bdf32009-08-11 09:47:30 +02009948 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009949 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009950
Takashi Iwai2134ea42008-01-10 16:53:55 +01009951 spec->vmaster_nid = 0x0c;
9952
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009953 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009954 if (board_config == ALC882_AUTO)
9955 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009956#ifdef CONFIG_SND_HDA_POWER_SAVE
9957 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009958 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009959#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009960 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009961
9962 return 0;
9963}
9964
Takashi Iwai4953550a2009-06-30 15:28:30 +02009965
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009966/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009967 * ALC262 support
9968 */
9969
9970#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9971#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9972
9973#define alc262_dac_nids alc260_dac_nids
9974#define alc262_adc_nids alc882_adc_nids
9975#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009976#define alc262_capsrc_nids alc882_capsrc_nids
9977#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009978
9979#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009980#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009981
Kailang Yang4e555fe2008-08-26 13:05:55 +02009982static hda_nid_t alc262_dmic_adc_nids[1] = {
9983 /* ADC0 */
9984 0x09
9985};
9986
9987static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9988
Kailang Yangdf694da2005-12-05 19:42:22 +01009989static struct snd_kcontrol_new alc262_base_mixer[] = {
9990 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9991 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9992 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9993 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9994 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9995 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009998 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009999 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10000 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010001 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010002 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10003 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10004 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10005 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010006 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010007};
10008
Takashi Iwaice875f02008-01-28 18:17:43 +010010009/* update HP, line and mono-out pins according to the master switch */
10010static void alc262_hp_master_update(struct hda_codec *codec)
10011{
10012 struct alc_spec *spec = codec->spec;
10013 int val = spec->master_sw;
10014
10015 /* HP & line-out */
10016 snd_hda_codec_write_cache(codec, 0x1b, 0,
10017 AC_VERB_SET_PIN_WIDGET_CONTROL,
10018 val ? PIN_HP : 0);
10019 snd_hda_codec_write_cache(codec, 0x15, 0,
10020 AC_VERB_SET_PIN_WIDGET_CONTROL,
10021 val ? PIN_HP : 0);
10022 /* mono (speaker) depending on the HP jack sense */
10023 val = val && !spec->jack_present;
10024 snd_hda_codec_write_cache(codec, 0x16, 0,
10025 AC_VERB_SET_PIN_WIDGET_CONTROL,
10026 val ? PIN_OUT : 0);
10027}
10028
10029static void alc262_hp_bpc_automute(struct hda_codec *codec)
10030{
10031 struct alc_spec *spec = codec->spec;
10032 unsigned int presence;
10033 presence = snd_hda_codec_read(codec, 0x1b, 0,
10034 AC_VERB_GET_PIN_SENSE, 0);
10035 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
10036 alc262_hp_master_update(codec);
10037}
10038
10039static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10040{
10041 if ((res >> 26) != ALC880_HP_EVENT)
10042 return;
10043 alc262_hp_bpc_automute(codec);
10044}
10045
10046static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10047{
10048 struct alc_spec *spec = codec->spec;
10049 unsigned int presence;
10050 presence = snd_hda_codec_read(codec, 0x15, 0,
10051 AC_VERB_GET_PIN_SENSE, 0);
10052 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
10053 alc262_hp_master_update(codec);
10054}
10055
10056static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10057 unsigned int res)
10058{
10059 if ((res >> 26) != ALC880_HP_EVENT)
10060 return;
10061 alc262_hp_wildwest_automute(codec);
10062}
10063
Takashi Iwaib72519b2009-05-08 14:31:55 +020010064#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010065
10066static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10067 struct snd_ctl_elem_value *ucontrol)
10068{
10069 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10070 struct alc_spec *spec = codec->spec;
10071 int val = !!*ucontrol->value.integer.value;
10072
10073 if (val == spec->master_sw)
10074 return 0;
10075 spec->master_sw = val;
10076 alc262_hp_master_update(codec);
10077 return 1;
10078}
10079
Takashi Iwaib72519b2009-05-08 14:31:55 +020010080#define ALC262_HP_MASTER_SWITCH \
10081 { \
10082 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10083 .name = "Master Playback Switch", \
10084 .info = snd_ctl_boolean_mono_info, \
10085 .get = alc262_hp_master_sw_get, \
10086 .put = alc262_hp_master_sw_put, \
10087 }
10088
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010089static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010090 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010091 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10092 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10093 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010094 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10095 HDA_OUTPUT),
10096 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10097 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010100 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010101 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10102 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010103 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010104 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10105 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10106 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10107 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010108 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10109 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10110 { } /* end */
10111};
10112
Kailang Yangcd7509a2007-01-26 18:33:17 +010010113static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010114 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010115 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10116 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10117 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10118 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010119 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10120 HDA_OUTPUT),
10121 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10122 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010123 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10124 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010125 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010126 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10127 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10128 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10129 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010130 { } /* end */
10131};
10132
10133static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10134 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10135 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010136 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010137 { } /* end */
10138};
10139
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010140/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010141static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010142{
10143 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010144
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010145 spec->autocfg.hp_pins[0] = 0x15;
10146 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010147}
10148
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010149static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010150 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10151 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010152 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10153 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10155 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10156 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10157 { } /* end */
10158};
10159
10160static struct hda_verb alc262_hp_t5735_verbs[] = {
10161 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10162 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10163
10164 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10165 { }
10166};
10167
Kailang Yang8c427222008-01-10 13:03:59 +010010168static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010169 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10170 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010171 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10172 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010173 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10174 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10175 { } /* end */
10176};
10177
10178static struct hda_verb alc262_hp_rp5700_verbs[] = {
10179 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10180 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10181 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10182 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10183 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10184 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10185 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10186 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10187 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10188 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10189 {}
10190};
10191
10192static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10193 .num_items = 1,
10194 .items = {
10195 { "Line", 0x1 },
10196 },
10197};
10198
Takashi Iwai42171c12009-05-08 14:11:43 +020010199/* bind hp and internal speaker mute (with plug check) as master switch */
10200static void alc262_hippo_master_update(struct hda_codec *codec)
10201{
10202 struct alc_spec *spec = codec->spec;
10203 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10204 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10205 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10206 unsigned int mute;
10207
10208 /* HP */
10209 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10210 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10211 HDA_AMP_MUTE, mute);
10212 /* mute internal speaker per jack sense */
10213 if (spec->jack_present)
10214 mute = HDA_AMP_MUTE;
10215 if (line_nid)
10216 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10217 HDA_AMP_MUTE, mute);
10218 if (speaker_nid && speaker_nid != line_nid)
10219 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10220 HDA_AMP_MUTE, mute);
10221}
10222
10223#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10224
10225static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10226 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010227{
10228 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010229 struct alc_spec *spec = codec->spec;
10230 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010231
Takashi Iwai42171c12009-05-08 14:11:43 +020010232 if (val == spec->master_sw)
10233 return 0;
10234 spec->master_sw = val;
10235 alc262_hippo_master_update(codec);
10236 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010237}
Takashi Iwai5b319542007-07-26 11:49:22 +020010238
Takashi Iwai42171c12009-05-08 14:11:43 +020010239#define ALC262_HIPPO_MASTER_SWITCH \
10240 { \
10241 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10242 .name = "Master Playback Switch", \
10243 .info = snd_ctl_boolean_mono_info, \
10244 .get = alc262_hippo_master_sw_get, \
10245 .put = alc262_hippo_master_sw_put, \
10246 }
10247
10248static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10249 ALC262_HIPPO_MASTER_SWITCH,
10250 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10251 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10252 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10253 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10254 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10255 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10256 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10257 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10258 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10259 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10260 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10261 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10262 { } /* end */
10263};
10264
10265static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10266 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10267 ALC262_HIPPO_MASTER_SWITCH,
10268 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10269 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10270 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10271 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10272 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10273 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10274 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10275 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10276 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10277 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10278 { } /* end */
10279};
10280
10281/* mute/unmute internal speaker according to the hp jack and mute state */
10282static void alc262_hippo_automute(struct hda_codec *codec)
10283{
10284 struct alc_spec *spec = codec->spec;
10285 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10286 unsigned int present;
10287
10288 /* need to execute and sync at first */
10289 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10290 present = snd_hda_codec_read(codec, hp_nid, 0,
10291 AC_VERB_GET_PIN_SENSE, 0);
10292 spec->jack_present = (present & 0x80000000) != 0;
10293 alc262_hippo_master_update(codec);
10294}
10295
10296static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10297{
10298 if ((res >> 26) != ALC880_HP_EVENT)
10299 return;
10300 alc262_hippo_automute(codec);
10301}
10302
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010303static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010304{
10305 struct alc_spec *spec = codec->spec;
10306
10307 spec->autocfg.hp_pins[0] = 0x15;
10308 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010309}
10310
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010311static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010312{
10313 struct alc_spec *spec = codec->spec;
10314
10315 spec->autocfg.hp_pins[0] = 0x1b;
10316 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010317}
10318
10319
Kailang Yang272a5272007-05-14 11:00:38 +020010320static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010321 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010322 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010323 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10324 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10325 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10326 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10327 { } /* end */
10328};
10329
Kailang Yang83c34212007-07-05 11:43:05 +020010330static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010331 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10332 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010333 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10336 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10337 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10338 { } /* end */
10339};
Kailang Yang272a5272007-05-14 11:00:38 +020010340
Tony Vroonba340e82009-02-02 19:01:30 +000010341static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10342 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10343 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10344 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10345 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10346 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10347 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10348 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10349 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10350 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10351 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10352 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10353 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10354 { } /* end */
10355};
10356
10357static struct hda_verb alc262_tyan_verbs[] = {
10358 /* Headphone automute */
10359 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10360 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10361 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10362
10363 /* P11 AUX_IN, white 4-pin connector */
10364 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10365 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10366 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10367 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10368
10369 {}
10370};
10371
10372/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010373static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010374{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010375 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010376
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010377 spec->autocfg.hp_pins[0] = 0x1b;
10378 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010379}
10380
Tony Vroonba340e82009-02-02 19:01:30 +000010381
Kailang Yangdf694da2005-12-05 19:42:22 +010010382#define alc262_capture_mixer alc882_capture_mixer
10383#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10384
10385/*
10386 * generic initialization of ADC, input mixers and output mixers
10387 */
10388static struct hda_verb alc262_init_verbs[] = {
10389 /*
10390 * Unmute ADC0-2 and set the default input to mic-in
10391 */
10392 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10393 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10394 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10395 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10396 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10397 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10398
Takashi Iwaicb53c622007-08-10 17:21:45 +020010399 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010400 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010401 * Note: PASD motherboards uses the Line In 2 as the input for
10402 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010403 */
10404 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010405 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10406 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10407 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10408 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10409 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010410
10411 /*
10412 * Set up output mixers (0x0c - 0x0e)
10413 */
10414 /* set vol=0 to output mixers */
10415 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10416 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10417 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10418 /* set up input amps for analog loopback */
10419 /* Amp Indices: DAC = 0, mixer = 1 */
10420 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10421 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10422 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10423 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10424 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10425 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10426
10427 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10428 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10429 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10430 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10431 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10432 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10433
10434 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10435 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10436 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10437 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10438 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010439
Kailang Yangdf694da2005-12-05 19:42:22 +010010440 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10441 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010442
Kailang Yangdf694da2005-12-05 19:42:22 +010010443 /* FIXME: use matrix-type input source selection */
10444 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10445 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10446 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10447 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10450 /* Input mixer2 */
10451 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10452 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10455 /* Input mixer3 */
10456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010460
10461 { }
10462};
10463
Kailang Yang4e555fe2008-08-26 13:05:55 +020010464static struct hda_verb alc262_eapd_verbs[] = {
10465 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10466 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10467 { }
10468};
10469
Kailang Yangccc656c2006-10-17 12:32:26 +020010470static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10471 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10472 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10473 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10474
10475 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10476 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10477 {}
10478};
10479
Kailang Yang272a5272007-05-14 11:00:38 +020010480static struct hda_verb alc262_sony_unsol_verbs[] = {
10481 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10482 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10483 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10484
10485 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10486 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010487 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010488};
10489
Kailang Yang4e555fe2008-08-26 13:05:55 +020010490static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10491 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10492 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10493 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10494 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10495 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010496 { } /* end */
10497};
10498
10499static struct hda_verb alc262_toshiba_s06_verbs[] = {
10500 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10501 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10502 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10503 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10504 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10505 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10506 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10507 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10508 {}
10509};
10510
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010511static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010512{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010513 struct alc_spec *spec = codec->spec;
10514
10515 spec->autocfg.hp_pins[0] = 0x15;
10516 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010517 spec->ext_mic.pin = 0x18;
10518 spec->ext_mic.mux_idx = 0;
10519 spec->int_mic.pin = 0x12;
10520 spec->int_mic.mux_idx = 9;
10521 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010522}
10523
Takashi Iwai834be882006-03-01 14:16:17 +010010524/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010525 * nec model
10526 * 0x15 = headphone
10527 * 0x16 = internal speaker
10528 * 0x18 = external mic
10529 */
10530
10531static struct snd_kcontrol_new alc262_nec_mixer[] = {
10532 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10533 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10534
10535 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10536 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10537 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10538
10539 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10540 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10541 { } /* end */
10542};
10543
10544static struct hda_verb alc262_nec_verbs[] = {
10545 /* Unmute Speaker */
10546 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10547
10548 /* Headphone */
10549 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10550 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10551
10552 /* External mic to headphone */
10553 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10554 /* External mic to speaker */
10555 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10556 {}
10557};
10558
10559/*
Takashi Iwai834be882006-03-01 14:16:17 +010010560 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010561 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10562 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010563 */
10564
10565#define ALC_HP_EVENT 0x37
10566
10567static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10568 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10569 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010570 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10571 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010572 {}
10573};
10574
Jiang zhe0e31daf2008-03-20 12:12:39 +010010575static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10576 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10577 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10578 {}
10579};
10580
Takashi Iwai834be882006-03-01 14:16:17 +010010581static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010582 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010583 .items = {
10584 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010585 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010586 { "CD", 0x4 },
10587 },
10588};
10589
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010590static struct hda_input_mux alc262_HP_capture_source = {
10591 .num_items = 5,
10592 .items = {
10593 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010594 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010595 { "Line", 0x2 },
10596 { "CD", 0x4 },
10597 { "AUX IN", 0x6 },
10598 },
10599};
10600
zhejiangaccbe492007-08-31 12:36:05 +020010601static struct hda_input_mux alc262_HP_D7000_capture_source = {
10602 .num_items = 4,
10603 .items = {
10604 { "Mic", 0x0 },
10605 { "Front Mic", 0x2 },
10606 { "Line", 0x1 },
10607 { "CD", 0x4 },
10608 },
10609};
10610
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010611/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010612static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10613{
10614 struct alc_spec *spec = codec->spec;
10615 unsigned int mute;
10616
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010617 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010618 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010619 /* need to execute and sync at first */
10620 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010621 /* check laptop HP jack */
10622 present = snd_hda_codec_read(codec, 0x14, 0,
10623 AC_VERB_GET_PIN_SENSE, 0);
10624 /* need to execute and sync at first */
10625 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10626 /* check docking HP jack */
10627 present |= snd_hda_codec_read(codec, 0x1b, 0,
10628 AC_VERB_GET_PIN_SENSE, 0);
10629 if (present & AC_PINSENSE_PRESENCE)
10630 spec->jack_present = 1;
10631 else
10632 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010633 spec->sense_updated = 1;
10634 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010635 /* unmute internal speaker only if both HPs are unplugged and
10636 * master switch is on
10637 */
10638 if (spec->jack_present)
10639 mute = HDA_AMP_MUTE;
10640 else
Takashi Iwai834be882006-03-01 14:16:17 +010010641 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010642 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10643 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010644}
10645
10646/* unsolicited event for HP jack sensing */
10647static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10648 unsigned int res)
10649{
10650 if ((res >> 26) != ALC_HP_EVENT)
10651 return;
10652 alc262_fujitsu_automute(codec, 1);
10653}
10654
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010655static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10656{
10657 alc262_fujitsu_automute(codec, 1);
10658}
10659
Takashi Iwai834be882006-03-01 14:16:17 +010010660/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010661static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10662 .ops = &snd_hda_bind_vol,
10663 .values = {
10664 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10665 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10666 0
10667 },
10668};
Takashi Iwai834be882006-03-01 14:16:17 +010010669
Jiang zhe0e31daf2008-03-20 12:12:39 +010010670/* mute/unmute internal speaker according to the hp jack and mute state */
10671static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10672{
10673 struct alc_spec *spec = codec->spec;
10674 unsigned int mute;
10675
10676 if (force || !spec->sense_updated) {
10677 unsigned int present_int_hp;
10678 /* need to execute and sync at first */
10679 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10680 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10681 AC_VERB_GET_PIN_SENSE, 0);
10682 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10683 spec->sense_updated = 1;
10684 }
10685 if (spec->jack_present) {
10686 /* mute internal speaker */
10687 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10688 HDA_AMP_MUTE, HDA_AMP_MUTE);
10689 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10690 HDA_AMP_MUTE, HDA_AMP_MUTE);
10691 } else {
10692 /* unmute internal speaker if necessary */
10693 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10694 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10695 HDA_AMP_MUTE, mute);
10696 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10697 HDA_AMP_MUTE, mute);
10698 }
10699}
10700
10701/* unsolicited event for HP jack sensing */
10702static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10703 unsigned int res)
10704{
10705 if ((res >> 26) != ALC_HP_EVENT)
10706 return;
10707 alc262_lenovo_3000_automute(codec, 1);
10708}
10709
Takashi Iwai8de56b72009-07-24 16:51:47 +020010710static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10711 int dir, int idx, long *valp)
10712{
10713 int i, change = 0;
10714
10715 for (i = 0; i < 2; i++, valp++)
10716 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10717 HDA_AMP_MUTE,
10718 *valp ? 0 : HDA_AMP_MUTE);
10719 return change;
10720}
10721
Takashi Iwai834be882006-03-01 14:16:17 +010010722/* bind hp and internal speaker mute (with plug check) */
10723static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10724 struct snd_ctl_elem_value *ucontrol)
10725{
10726 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10727 long *valp = ucontrol->value.integer.value;
10728 int change;
10729
Takashi Iwai8de56b72009-07-24 16:51:47 +020010730 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10731 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010732 if (change)
10733 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010734 return change;
10735}
10736
10737static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010738 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010739 {
10740 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10741 .name = "Master Playback Switch",
10742 .info = snd_hda_mixer_amp_switch_info,
10743 .get = snd_hda_mixer_amp_switch_get,
10744 .put = alc262_fujitsu_master_sw_put,
10745 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10746 },
10747 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10748 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10749 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10750 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10751 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010752 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10753 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10754 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010755 { } /* end */
10756};
10757
Jiang zhe0e31daf2008-03-20 12:12:39 +010010758/* bind hp and internal speaker mute (with plug check) */
10759static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10760 struct snd_ctl_elem_value *ucontrol)
10761{
10762 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10763 long *valp = ucontrol->value.integer.value;
10764 int change;
10765
Takashi Iwai8de56b72009-07-24 16:51:47 +020010766 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010767 if (change)
10768 alc262_lenovo_3000_automute(codec, 0);
10769 return change;
10770}
10771
10772static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10773 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10774 {
10775 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10776 .name = "Master Playback Switch",
10777 .info = snd_hda_mixer_amp_switch_info,
10778 .get = snd_hda_mixer_amp_switch_get,
10779 .put = alc262_lenovo_3000_master_sw_put,
10780 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10781 },
10782 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10783 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10784 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10785 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10786 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10787 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10788 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10789 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10790 { } /* end */
10791};
10792
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010793static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10794 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010795 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10798 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10799 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10800 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10801 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10802 { } /* end */
10803};
10804
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010805/* additional init verbs for Benq laptops */
10806static struct hda_verb alc262_EAPD_verbs[] = {
10807 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10808 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10809 {}
10810};
10811
Kailang Yang83c34212007-07-05 11:43:05 +020010812static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10813 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10814 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10815
10816 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10817 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10818 {}
10819};
10820
Tobin Davisf651b502007-10-26 12:40:47 +020010821/* Samsung Q1 Ultra Vista model setup */
10822static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010823 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10824 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10826 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10827 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010828 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010829 { } /* end */
10830};
10831
10832static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010833 /* output mixer */
10834 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10835 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10836 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10837 /* speaker */
10838 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10839 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10840 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10841 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10842 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010843 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010844 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10846 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10847 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10848 /* internal mic */
10849 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10850 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10851 /* ADC, choose mic */
10852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10853 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10854 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10855 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10856 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10857 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10858 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010862 {}
10863};
10864
Tobin Davisf651b502007-10-26 12:40:47 +020010865/* mute/unmute internal speaker according to the hp jack and mute state */
10866static void alc262_ultra_automute(struct hda_codec *codec)
10867{
10868 struct alc_spec *spec = codec->spec;
10869 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010870
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010871 mute = 0;
10872 /* auto-mute only when HP is used as HP */
10873 if (!spec->cur_mux[0]) {
10874 unsigned int present;
10875 /* need to execute and sync at first */
10876 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10877 present = snd_hda_codec_read(codec, 0x15, 0,
10878 AC_VERB_GET_PIN_SENSE, 0);
10879 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10880 if (spec->jack_present)
10881 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010882 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010883 /* mute/unmute internal speaker */
10884 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10885 HDA_AMP_MUTE, mute);
10886 /* mute/unmute HP */
10887 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10888 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010889}
10890
10891/* unsolicited event for HP jack sensing */
10892static void alc262_ultra_unsol_event(struct hda_codec *codec,
10893 unsigned int res)
10894{
10895 if ((res >> 26) != ALC880_HP_EVENT)
10896 return;
10897 alc262_ultra_automute(codec);
10898}
10899
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010900static struct hda_input_mux alc262_ultra_capture_source = {
10901 .num_items = 2,
10902 .items = {
10903 { "Mic", 0x1 },
10904 { "Headphone", 0x7 },
10905 },
10906};
10907
10908static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10909 struct snd_ctl_elem_value *ucontrol)
10910{
10911 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10912 struct alc_spec *spec = codec->spec;
10913 int ret;
10914
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010915 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010916 if (!ret)
10917 return 0;
10918 /* reprogram the HP pin as mic or HP according to the input source */
10919 snd_hda_codec_write_cache(codec, 0x15, 0,
10920 AC_VERB_SET_PIN_WIDGET_CONTROL,
10921 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10922 alc262_ultra_automute(codec); /* mute/unmute HP */
10923 return ret;
10924}
10925
10926static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10927 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10928 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10929 {
10930 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10931 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010932 .info = alc_mux_enum_info,
10933 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010934 .put = alc262_ultra_mux_enum_put,
10935 },
10936 { } /* end */
10937};
10938
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010939/* We use two mixers depending on the output pin; 0x16 is a mono output
10940 * and thus it's bound with a different mixer.
10941 * This function returns which mixer amp should be used.
10942 */
10943static int alc262_check_volbit(hda_nid_t nid)
10944{
10945 if (!nid)
10946 return 0;
10947 else if (nid == 0x16)
10948 return 2;
10949 else
10950 return 1;
10951}
10952
10953static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
10954 const char *pfx, int *vbits)
10955{
10956 char name[32];
10957 unsigned long val;
10958 int vbit;
10959
10960 vbit = alc262_check_volbit(nid);
10961 if (!vbit)
10962 return 0;
10963 if (*vbits & vbit) /* a volume control for this mixer already there */
10964 return 0;
10965 *vbits |= vbit;
10966 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
10967 if (vbit == 2)
10968 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
10969 else
10970 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
10971 return add_control(spec, ALC_CTL_WIDGET_VOL, name, val);
10972}
10973
10974static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
10975 const char *pfx)
10976{
10977 char name[32];
10978 unsigned long val;
10979
10980 if (!nid)
10981 return 0;
10982 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
10983 if (nid == 0x16)
10984 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
10985 else
10986 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
10987 return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val);
10988}
10989
Kailang Yangdf694da2005-12-05 19:42:22 +010010990/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010991static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10992 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010993{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010994 const char *pfx;
10995 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010010996 int err;
10997
10998 spec->multiout.num_dacs = 1; /* only use one dac */
10999 spec->multiout.dac_nids = spec->private_dac_nids;
11000 spec->multiout.dac_nids[0] = 2;
11001
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011002 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11003 pfx = "Master";
11004 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11005 pfx = "Speaker";
11006 else
11007 pfx = "Front";
11008 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11009 if (err < 0)
11010 return err;
11011 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11012 if (err < 0)
11013 return err;
11014 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11015 if (err < 0)
11016 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011017
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011018 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11019 alc262_check_volbit(cfg->speaker_pins[0]) |
11020 alc262_check_volbit(cfg->hp_pins[0]);
11021 if (vbits == 1 || vbits == 2)
11022 pfx = "Master"; /* only one mixer is used */
11023 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11024 pfx = "Speaker";
11025 else
11026 pfx = "Front";
11027 vbits = 0;
11028 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11029 if (err < 0)
11030 return err;
11031 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11032 &vbits);
11033 if (err < 0)
11034 return err;
11035 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11036 &vbits);
11037 if (err < 0)
11038 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011039 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011040}
11041
Takashi Iwai05f5f472009-08-25 13:10:18 +020011042#define alc262_auto_create_input_ctls \
11043 alc880_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011044
11045/*
11046 * generic initialization of ADC, input mixers and output mixers
11047 */
11048static struct hda_verb alc262_volume_init_verbs[] = {
11049 /*
11050 * Unmute ADC0-2 and set the default input to mic-in
11051 */
11052 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11053 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11054 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11055 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11056 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11057 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11058
Takashi Iwaicb53c622007-08-10 17:21:45 +020011059 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011060 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011061 * Note: PASD motherboards uses the Line In 2 as the input for
11062 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011063 */
11064 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11067 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011070
11071 /*
11072 * Set up output mixers (0x0c - 0x0f)
11073 */
11074 /* set vol=0 to output mixers */
11075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11076 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11077 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011078
Kailang Yangdf694da2005-12-05 19:42:22 +010011079 /* set up input amps for analog loopback */
11080 /* Amp Indices: DAC = 0, mixer = 1 */
11081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11082 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11083 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11084 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11085 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11086 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11087
11088 /* FIXME: use matrix-type input source selection */
11089 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11090 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11091 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11092 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11093 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11094 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11095 /* Input mixer2 */
11096 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11097 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11098 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11099 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11100 /* Input mixer3 */
11101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11102 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11103 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11105
11106 { }
11107};
11108
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011109static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11110 /*
11111 * Unmute ADC0-2 and set the default input to mic-in
11112 */
11113 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11114 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11115 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11116 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11117 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11118 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11119
Takashi Iwaicb53c622007-08-10 17:21:45 +020011120 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011121 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011122 * Note: PASD motherboards uses the Line In 2 as the input for
11123 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011124 */
11125 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011126 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011133
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011134 /*
11135 * Set up output mixers (0x0c - 0x0e)
11136 */
11137 /* set vol=0 to output mixers */
11138 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11139 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11140 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11141
11142 /* set up input amps for analog loopback */
11143 /* Amp Indices: DAC = 0, mixer = 1 */
11144 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11146 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11147 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11148 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11149 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11150
Takashi Iwaice875f02008-01-28 18:17:43 +010011151 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011152 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11153 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11154
11155 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11156 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11157
11158 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11159 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11160
11161 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11162 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11163 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11164 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11165 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11166
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011167 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011168 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11169 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011170 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011171 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11172 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11173
11174
11175 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011176 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11177 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011178 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011179 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11180 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11181 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11182 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11183 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11184 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11185 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11186 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011187 /* Input mixer2 */
11188 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011189 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11190 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11191 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11192 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11193 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11194 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11195 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11196 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011197 /* Input mixer3 */
11198 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011199 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11200 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11201 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11202 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11203 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11204 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11205 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11206 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011207
Takashi Iwaice875f02008-01-28 18:17:43 +010011208 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11209
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011210 { }
11211};
11212
Kailang Yangcd7509a2007-01-26 18:33:17 +010011213static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11214 /*
11215 * Unmute ADC0-2 and set the default input to mic-in
11216 */
11217 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11218 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11219 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11220 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11221 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11222 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11223
Takashi Iwaicb53c622007-08-10 17:21:45 +020011224 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011225 * mixer widget
11226 * Note: PASD motherboards uses the Line In 2 as the input for front
11227 * panel mic (mic 2)
11228 */
11229 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011230 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11231 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11232 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011238 /*
11239 * Set up output mixers (0x0c - 0x0e)
11240 */
11241 /* set vol=0 to output mixers */
11242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11243 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11244 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11245
11246 /* set up input amps for analog loopback */
11247 /* Amp Indices: DAC = 0, mixer = 1 */
11248 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11250 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11251 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11252 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11253 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11254
11255
11256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11257 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11258 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11259 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11260 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11261 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11262 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11263
11264 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11265 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11266
11267 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11268 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11269
11270 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11271 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11272 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11273 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11274 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11275 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11276
11277 /* FIXME: use matrix-type input source selection */
11278 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11279 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11280 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11281 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11282 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11283 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11284 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11285 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11287 /* Input mixer2 */
11288 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11289 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11290 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11291 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11292 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11293 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11294 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11295 /* Input mixer3 */
11296 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11297 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11298 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11300 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11301 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11303
Takashi Iwaice875f02008-01-28 18:17:43 +010011304 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11305
Kailang Yangcd7509a2007-01-26 18:33:17 +010011306 { }
11307};
11308
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011309static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11310
11311 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11312 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11313 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11314
11315 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11316 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11317 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11318 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11319
11320 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11321 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11322 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11323 {}
11324};
11325
11326
Takashi Iwaicb53c622007-08-10 17:21:45 +020011327#ifdef CONFIG_SND_HDA_POWER_SAVE
11328#define alc262_loopbacks alc880_loopbacks
11329#endif
11330
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011331/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011332#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11333#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11334#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11335#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11336
11337/*
11338 * BIOS auto configuration
11339 */
11340static int alc262_parse_auto_config(struct hda_codec *codec)
11341{
11342 struct alc_spec *spec = codec->spec;
11343 int err;
11344 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11345
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011346 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11347 alc262_ignore);
11348 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011349 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011350 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011351 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011352 spec->multiout.max_channels = 2;
11353 spec->no_analog = 1;
11354 goto dig_only;
11355 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011356 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011357 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011358 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11359 if (err < 0)
11360 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011361 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011362 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011363 return err;
11364
11365 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11366
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011367 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011368 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011369 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011370 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011371 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011372 if (spec->autocfg.dig_in_pin)
11373 spec->dig_in_nid = ALC262_DIGIN_NID;
11374
Takashi Iwai603c4012008-07-30 15:01:44 +020011375 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011376 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011377
Takashi Iwaid88897e2008-10-31 15:01:37 +010011378 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011379 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011380 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011381
Takashi Iwai776e1842007-08-29 15:07:11 +020011382 err = alc_auto_add_mic_boost(codec);
11383 if (err < 0)
11384 return err;
11385
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011386 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11387
Kailang Yangdf694da2005-12-05 19:42:22 +010011388 return 1;
11389}
11390
11391#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11392#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11393#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011394#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011395
11396
11397/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011398static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011399{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011400 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011401 alc262_auto_init_multi_out(codec);
11402 alc262_auto_init_hp_out(codec);
11403 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011404 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011405 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011406 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011407}
11408
11409/*
11410 * configuration and preset
11411 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011412static const char *alc262_models[ALC262_MODEL_LAST] = {
11413 [ALC262_BASIC] = "basic",
11414 [ALC262_HIPPO] = "hippo",
11415 [ALC262_HIPPO_1] = "hippo_1",
11416 [ALC262_FUJITSU] = "fujitsu",
11417 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011418 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011419 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011420 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011421 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011422 [ALC262_BENQ_T31] = "benq-t31",
11423 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011424 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011425 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011426 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011427 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011428 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011429 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011430 [ALC262_AUTO] = "auto",
11431};
11432
11433static struct snd_pci_quirk alc262_cfg_tbl[] = {
11434 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011435 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011436 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11437 ALC262_HP_BPC),
11438 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11439 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011440 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11441 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011442 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011443 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011444 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011445 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011446 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011447 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011448 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011449 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011450 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11451 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11452 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011453 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11454 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011455 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011456 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011457 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011458 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011459 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011460 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011461 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11462 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011463 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011464 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011465 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011466 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011467 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011468 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011469 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11470 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011471 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011472 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011473 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011474 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011475 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011476 {}
11477};
11478
11479static struct alc_config_preset alc262_presets[] = {
11480 [ALC262_BASIC] = {
11481 .mixers = { alc262_base_mixer },
11482 .init_verbs = { alc262_init_verbs },
11483 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11484 .dac_nids = alc262_dac_nids,
11485 .hp_nid = 0x03,
11486 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11487 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011488 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011489 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011490 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011491 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011492 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011493 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11494 .dac_nids = alc262_dac_nids,
11495 .hp_nid = 0x03,
11496 .dig_out_nid = ALC262_DIGOUT_NID,
11497 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11498 .channel_mode = alc262_modes,
11499 .input_mux = &alc262_capture_source,
11500 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011501 .setup = alc262_hippo_setup,
11502 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011503 },
11504 [ALC262_HIPPO_1] = {
11505 .mixers = { alc262_hippo1_mixer },
11506 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11507 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11508 .dac_nids = alc262_dac_nids,
11509 .hp_nid = 0x02,
11510 .dig_out_nid = ALC262_DIGOUT_NID,
11511 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11512 .channel_mode = alc262_modes,
11513 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011514 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011515 .setup = alc262_hippo1_setup,
11516 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011517 },
Takashi Iwai834be882006-03-01 14:16:17 +010011518 [ALC262_FUJITSU] = {
11519 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011520 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11521 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011522 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11523 .dac_nids = alc262_dac_nids,
11524 .hp_nid = 0x03,
11525 .dig_out_nid = ALC262_DIGOUT_NID,
11526 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11527 .channel_mode = alc262_modes,
11528 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011529 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011530 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011531 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011532 [ALC262_HP_BPC] = {
11533 .mixers = { alc262_HP_BPC_mixer },
11534 .init_verbs = { alc262_HP_BPC_init_verbs },
11535 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11536 .dac_nids = alc262_dac_nids,
11537 .hp_nid = 0x03,
11538 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11539 .channel_mode = alc262_modes,
11540 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011541 .unsol_event = alc262_hp_bpc_unsol_event,
11542 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011543 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011544 [ALC262_HP_BPC_D7000_WF] = {
11545 .mixers = { alc262_HP_BPC_WildWest_mixer },
11546 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11547 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11548 .dac_nids = alc262_dac_nids,
11549 .hp_nid = 0x03,
11550 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11551 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011552 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011553 .unsol_event = alc262_hp_wildwest_unsol_event,
11554 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011555 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011556 [ALC262_HP_BPC_D7000_WL] = {
11557 .mixers = { alc262_HP_BPC_WildWest_mixer,
11558 alc262_HP_BPC_WildWest_option_mixer },
11559 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11560 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11561 .dac_nids = alc262_dac_nids,
11562 .hp_nid = 0x03,
11563 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11564 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011565 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011566 .unsol_event = alc262_hp_wildwest_unsol_event,
11567 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011568 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011569 [ALC262_HP_TC_T5735] = {
11570 .mixers = { alc262_hp_t5735_mixer },
11571 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11572 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11573 .dac_nids = alc262_dac_nids,
11574 .hp_nid = 0x03,
11575 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11576 .channel_mode = alc262_modes,
11577 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011578 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011579 .setup = alc262_hp_t5735_setup,
11580 .init_hook = alc_automute_amp,
Kailang Yang8c427222008-01-10 13:03:59 +010011581 },
11582 [ALC262_HP_RP5700] = {
11583 .mixers = { alc262_hp_rp5700_mixer },
11584 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11585 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11586 .dac_nids = alc262_dac_nids,
11587 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11588 .channel_mode = alc262_modes,
11589 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011590 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011591 [ALC262_BENQ_ED8] = {
11592 .mixers = { alc262_base_mixer },
11593 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11594 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11595 .dac_nids = alc262_dac_nids,
11596 .hp_nid = 0x03,
11597 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11598 .channel_mode = alc262_modes,
11599 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011600 },
Kailang Yang272a5272007-05-14 11:00:38 +020011601 [ALC262_SONY_ASSAMD] = {
11602 .mixers = { alc262_sony_mixer },
11603 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11604 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11605 .dac_nids = alc262_dac_nids,
11606 .hp_nid = 0x02,
11607 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11608 .channel_mode = alc262_modes,
11609 .input_mux = &alc262_capture_source,
11610 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011611 .setup = alc262_hippo_setup,
11612 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011613 },
11614 [ALC262_BENQ_T31] = {
11615 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011616 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11617 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011618 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11619 .dac_nids = alc262_dac_nids,
11620 .hp_nid = 0x03,
11621 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11622 .channel_mode = alc262_modes,
11623 .input_mux = &alc262_capture_source,
11624 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011625 .setup = alc262_hippo_setup,
11626 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011627 },
Tobin Davisf651b502007-10-26 12:40:47 +020011628 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011629 .mixers = { alc262_ultra_mixer },
11630 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011631 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011632 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11633 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011634 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11635 .channel_mode = alc262_modes,
11636 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011637 .adc_nids = alc262_adc_nids, /* ADC0 */
11638 .capsrc_nids = alc262_capsrc_nids,
11639 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011640 .unsol_event = alc262_ultra_unsol_event,
11641 .init_hook = alc262_ultra_automute,
11642 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011643 [ALC262_LENOVO_3000] = {
11644 .mixers = { alc262_lenovo_3000_mixer },
11645 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11646 alc262_lenovo_3000_unsol_verbs },
11647 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11648 .dac_nids = alc262_dac_nids,
11649 .hp_nid = 0x03,
11650 .dig_out_nid = ALC262_DIGOUT_NID,
11651 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11652 .channel_mode = alc262_modes,
11653 .input_mux = &alc262_fujitsu_capture_source,
11654 .unsol_event = alc262_lenovo_3000_unsol_event,
11655 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011656 [ALC262_NEC] = {
11657 .mixers = { alc262_nec_mixer },
11658 .init_verbs = { alc262_nec_verbs },
11659 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11660 .dac_nids = alc262_dac_nids,
11661 .hp_nid = 0x03,
11662 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11663 .channel_mode = alc262_modes,
11664 .input_mux = &alc262_capture_source,
11665 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011666 [ALC262_TOSHIBA_S06] = {
11667 .mixers = { alc262_toshiba_s06_mixer },
11668 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11669 alc262_eapd_verbs },
11670 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11671 .capsrc_nids = alc262_dmic_capsrc_nids,
11672 .dac_nids = alc262_dac_nids,
11673 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011674 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011675 .dig_out_nid = ALC262_DIGOUT_NID,
11676 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11677 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011678 .unsol_event = alc_sku_unsol_event,
11679 .setup = alc262_toshiba_s06_setup,
11680 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011681 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011682 [ALC262_TOSHIBA_RX1] = {
11683 .mixers = { alc262_toshiba_rx1_mixer },
11684 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11685 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11686 .dac_nids = alc262_dac_nids,
11687 .hp_nid = 0x03,
11688 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11689 .channel_mode = alc262_modes,
11690 .input_mux = &alc262_capture_source,
11691 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011692 .setup = alc262_hippo_setup,
11693 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011694 },
Tony Vroonba340e82009-02-02 19:01:30 +000011695 [ALC262_TYAN] = {
11696 .mixers = { alc262_tyan_mixer },
11697 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11698 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11699 .dac_nids = alc262_dac_nids,
11700 .hp_nid = 0x02,
11701 .dig_out_nid = ALC262_DIGOUT_NID,
11702 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11703 .channel_mode = alc262_modes,
11704 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011705 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011706 .setup = alc262_tyan_setup,
11707 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011708 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011709};
11710
11711static int patch_alc262(struct hda_codec *codec)
11712{
11713 struct alc_spec *spec;
11714 int board_config;
11715 int err;
11716
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011717 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011718 if (spec == NULL)
11719 return -ENOMEM;
11720
11721 codec->spec = spec;
11722#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011723 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11724 * under-run
11725 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011726 {
11727 int tmp;
11728 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11729 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11730 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11731 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11732 }
11733#endif
11734
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011735 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11736
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011737 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11738 alc262_models,
11739 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011740
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011741 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011742 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11743 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011744 board_config = ALC262_AUTO;
11745 }
11746
11747 if (board_config == ALC262_AUTO) {
11748 /* automatic parse from the BIOS config */
11749 err = alc262_parse_auto_config(codec);
11750 if (err < 0) {
11751 alc_free(codec);
11752 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011753 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011754 printk(KERN_INFO
11755 "hda_codec: Cannot set up configuration "
11756 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011757 board_config = ALC262_BASIC;
11758 }
11759 }
11760
Takashi Iwai07eba612009-02-19 08:06:35 +010011761 if (!spec->no_analog) {
11762 err = snd_hda_attach_beep_device(codec, 0x1);
11763 if (err < 0) {
11764 alc_free(codec);
11765 return err;
11766 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011767 }
11768
Kailang Yangdf694da2005-12-05 19:42:22 +010011769 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011770 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011771
Kailang Yangdf694da2005-12-05 19:42:22 +010011772 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11773 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011774
Kailang Yangdf694da2005-12-05 19:42:22 +010011775 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11776 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11777
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011778 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011779 int i;
11780 /* check whether the digital-mic has to be supported */
11781 for (i = 0; i < spec->input_mux->num_items; i++) {
11782 if (spec->input_mux->items[i].index >= 9)
11783 break;
11784 }
11785 if (i < spec->input_mux->num_items) {
11786 /* use only ADC0 */
11787 spec->adc_nids = alc262_dmic_adc_nids;
11788 spec->num_adc_nids = 1;
11789 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011790 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011791 /* all analog inputs */
11792 /* check whether NID 0x07 is valid */
11793 unsigned int wcap = get_wcaps(codec, 0x07);
11794
11795 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011796 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011797 if (wcap != AC_WID_AUD_IN) {
11798 spec->adc_nids = alc262_adc_nids_alt;
11799 spec->num_adc_nids =
11800 ARRAY_SIZE(alc262_adc_nids_alt);
11801 spec->capsrc_nids = alc262_capsrc_nids_alt;
11802 } else {
11803 spec->adc_nids = alc262_adc_nids;
11804 spec->num_adc_nids =
11805 ARRAY_SIZE(alc262_adc_nids);
11806 spec->capsrc_nids = alc262_capsrc_nids;
11807 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011808 }
11809 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011810 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011811 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011812 if (!spec->no_analog)
11813 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011814
Takashi Iwai2134ea42008-01-10 16:53:55 +010011815 spec->vmaster_nid = 0x0c;
11816
Kailang Yangdf694da2005-12-05 19:42:22 +010011817 codec->patch_ops = alc_patch_ops;
11818 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011819 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011820#ifdef CONFIG_SND_HDA_POWER_SAVE
11821 if (!spec->loopback.amplist)
11822 spec->loopback.amplist = alc262_loopbacks;
11823#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011824 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011825
Kailang Yangdf694da2005-12-05 19:42:22 +010011826 return 0;
11827}
11828
Kailang Yangdf694da2005-12-05 19:42:22 +010011829/*
Kailang Yanga361d842007-06-05 12:30:55 +020011830 * ALC268 channel source setting (2 channel)
11831 */
11832#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11833#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011834
Kailang Yanga361d842007-06-05 12:30:55 +020011835static hda_nid_t alc268_dac_nids[2] = {
11836 /* front, hp */
11837 0x02, 0x03
11838};
11839
11840static hda_nid_t alc268_adc_nids[2] = {
11841 /* ADC0-1 */
11842 0x08, 0x07
11843};
11844
11845static hda_nid_t alc268_adc_nids_alt[1] = {
11846 /* ADC0 */
11847 0x08
11848};
11849
Takashi Iwaie1406342008-02-11 18:32:32 +010011850static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11851
Kailang Yanga361d842007-06-05 12:30:55 +020011852static struct snd_kcontrol_new alc268_base_mixer[] = {
11853 /* output mixer control */
11854 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11855 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11856 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11857 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011858 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11859 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11860 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011861 { }
11862};
11863
Takashi Iwai42171c12009-05-08 14:11:43 +020011864static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11865 /* output mixer control */
11866 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11867 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11868 ALC262_HIPPO_MASTER_SWITCH,
11869 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11870 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11871 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11872 { }
11873};
11874
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011875/* bind Beep switches of both NID 0x0f and 0x10 */
11876static struct hda_bind_ctls alc268_bind_beep_sw = {
11877 .ops = &snd_hda_bind_sw,
11878 .values = {
11879 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11880 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11881 0
11882 },
11883};
11884
11885static struct snd_kcontrol_new alc268_beep_mixer[] = {
11886 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11887 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11888 { }
11889};
11890
Kailang Yangd1a991a2007-08-15 16:21:59 +020011891static struct hda_verb alc268_eapd_verbs[] = {
11892 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11893 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11894 { }
11895};
11896
Takashi Iwaid2738092007-08-16 14:59:45 +020011897/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011898static struct hda_verb alc268_toshiba_verbs[] = {
11899 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11900 { } /* end */
11901};
11902
11903/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011904/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011905static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11906 .ops = &snd_hda_bind_vol,
11907 .values = {
11908 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11909 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11910 0
11911 },
11912};
11913
Takashi Iwai889c4392007-08-23 18:56:52 +020011914/* mute/unmute internal speaker according to the hp jack and mute state */
11915static void alc268_acer_automute(struct hda_codec *codec, int force)
11916{
11917 struct alc_spec *spec = codec->spec;
11918 unsigned int mute;
11919
11920 if (force || !spec->sense_updated) {
11921 unsigned int present;
11922 present = snd_hda_codec_read(codec, 0x14, 0,
11923 AC_VERB_GET_PIN_SENSE, 0);
11924 spec->jack_present = (present & 0x80000000) != 0;
11925 spec->sense_updated = 1;
11926 }
11927 if (spec->jack_present)
11928 mute = HDA_AMP_MUTE; /* mute internal speaker */
11929 else /* unmute internal speaker if necessary */
11930 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11931 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11932 HDA_AMP_MUTE, mute);
11933}
11934
11935
11936/* bind hp and internal speaker mute (with plug check) */
11937static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11938 struct snd_ctl_elem_value *ucontrol)
11939{
11940 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11941 long *valp = ucontrol->value.integer.value;
11942 int change;
11943
Takashi Iwai8de56b72009-07-24 16:51:47 +020011944 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020011945 if (change)
11946 alc268_acer_automute(codec, 0);
11947 return change;
11948}
Takashi Iwaid2738092007-08-16 14:59:45 +020011949
Kailang Yang8ef355d2008-08-26 13:10:22 +020011950static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11951 /* output mixer control */
11952 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11953 {
11954 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11955 .name = "Master Playback Switch",
11956 .info = snd_hda_mixer_amp_switch_info,
11957 .get = snd_hda_mixer_amp_switch_get,
11958 .put = alc268_acer_master_sw_put,
11959 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11960 },
11961 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11962 { }
11963};
11964
Takashi Iwaid2738092007-08-16 14:59:45 +020011965static struct snd_kcontrol_new alc268_acer_mixer[] = {
11966 /* output mixer control */
11967 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11968 {
11969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11970 .name = "Master Playback Switch",
11971 .info = snd_hda_mixer_amp_switch_info,
11972 .get = snd_hda_mixer_amp_switch_get,
11973 .put = alc268_acer_master_sw_put,
11974 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11975 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011976 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11977 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11978 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011979 { }
11980};
11981
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011982static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11983 /* output mixer control */
11984 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11985 {
11986 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11987 .name = "Master Playback Switch",
11988 .info = snd_hda_mixer_amp_switch_info,
11989 .get = snd_hda_mixer_amp_switch_get,
11990 .put = alc268_acer_master_sw_put,
11991 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11992 },
11993 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11994 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11995 { }
11996};
11997
Kailang Yang8ef355d2008-08-26 13:10:22 +020011998static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11999 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12000 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12001 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12002 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12003 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12004 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12005 { }
12006};
12007
Takashi Iwaid2738092007-08-16 14:59:45 +020012008static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012009 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12010 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012011 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012013 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12014 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012015 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12016 { }
12017};
12018
12019/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012020#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012021#define alc268_toshiba_setup alc262_hippo_setup
12022#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012023
12024static void alc268_acer_unsol_event(struct hda_codec *codec,
12025 unsigned int res)
12026{
Takashi Iwai889c4392007-08-23 18:56:52 +020012027 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012028 return;
12029 alc268_acer_automute(codec, 1);
12030}
12031
Takashi Iwai889c4392007-08-23 18:56:52 +020012032static void alc268_acer_init_hook(struct hda_codec *codec)
12033{
12034 alc268_acer_automute(codec, 1);
12035}
12036
Kailang Yang8ef355d2008-08-26 13:10:22 +020012037/* toggle speaker-output according to the hp-jack state */
12038static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12039{
12040 unsigned int present;
12041 unsigned char bits;
12042
12043 present = snd_hda_codec_read(codec, 0x15, 0,
12044 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12045 bits = present ? AMP_IN_MUTE(0) : 0;
12046 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12047 AMP_IN_MUTE(0), bits);
12048 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12049 AMP_IN_MUTE(0), bits);
12050}
12051
Kailang Yang8ef355d2008-08-26 13:10:22 +020012052static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12053 unsigned int res)
12054{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012055 switch (res >> 26) {
12056 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012057 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012058 break;
12059 case ALC880_MIC_EVENT:
12060 alc_mic_automute(codec);
12061 break;
12062 }
12063}
12064
12065static void alc268_acer_lc_setup(struct hda_codec *codec)
12066{
12067 struct alc_spec *spec = codec->spec;
12068 spec->ext_mic.pin = 0x18;
12069 spec->ext_mic.mux_idx = 0;
12070 spec->int_mic.pin = 0x12;
12071 spec->int_mic.mux_idx = 6;
12072 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012073}
12074
12075static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12076{
12077 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012078 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012079}
12080
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012081static struct snd_kcontrol_new alc268_dell_mixer[] = {
12082 /* output mixer control */
12083 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12084 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12085 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12086 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12087 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12088 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12089 { }
12090};
12091
12092static struct hda_verb alc268_dell_verbs[] = {
12093 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12094 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12095 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012096 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012097 { }
12098};
12099
12100/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012101static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012102{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012103 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012104
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012105 spec->autocfg.hp_pins[0] = 0x15;
12106 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012107 spec->ext_mic.pin = 0x18;
12108 spec->ext_mic.mux_idx = 0;
12109 spec->int_mic.pin = 0x19;
12110 spec->int_mic.mux_idx = 1;
12111 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012112}
12113
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012114static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12115 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12116 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12117 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12118 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12119 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12120 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12121 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12122 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12123 { }
12124};
12125
12126static struct hda_verb alc267_quanta_il1_verbs[] = {
12127 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12128 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12129 { }
12130};
12131
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012132static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012133{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012134 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012135 spec->autocfg.hp_pins[0] = 0x15;
12136 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012137 spec->ext_mic.pin = 0x18;
12138 spec->ext_mic.mux_idx = 0;
12139 spec->int_mic.pin = 0x19;
12140 spec->int_mic.mux_idx = 1;
12141 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012142}
12143
Kailang Yanga361d842007-06-05 12:30:55 +020012144/*
12145 * generic initialization of ADC, input mixers and output mixers
12146 */
12147static struct hda_verb alc268_base_init_verbs[] = {
12148 /* Unmute DAC0-1 and set vol = 0 */
12149 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012150 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012151
12152 /*
12153 * Set up output mixers (0x0c - 0x0e)
12154 */
12155 /* set vol=0 to output mixers */
12156 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012157 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12158
12159 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12160 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12161
12162 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12163 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12164 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12165 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12166 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12167 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12168 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12169 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12170
12171 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12172 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12173 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12174 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012175 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012176
12177 /* set PCBEEP vol = 0, mute connections */
12178 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12179 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12180 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012181
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012182 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012183
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012184 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12185 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12186 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12187 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012188
Kailang Yanga361d842007-06-05 12:30:55 +020012189 { }
12190};
12191
12192/*
12193 * generic initialization of ADC, input mixers and output mixers
12194 */
12195static struct hda_verb alc268_volume_init_verbs[] = {
12196 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012197 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12198 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012199
12200 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12201 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12202 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12203 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12204 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12205
Kailang Yanga361d842007-06-05 12:30:55 +020012206 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012207 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12208 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12209
12210 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012211 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012212
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012213 /* set PCBEEP vol = 0, mute connections */
12214 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12215 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12216 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012217
12218 { }
12219};
12220
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012221static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12222 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12223 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12224 { } /* end */
12225};
12226
Kailang Yanga361d842007-06-05 12:30:55 +020012227static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12228 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12229 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012230 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012231 { } /* end */
12232};
12233
12234static struct snd_kcontrol_new alc268_capture_mixer[] = {
12235 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12236 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12237 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12238 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012239 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012240 { } /* end */
12241};
12242
12243static struct hda_input_mux alc268_capture_source = {
12244 .num_items = 4,
12245 .items = {
12246 { "Mic", 0x0 },
12247 { "Front Mic", 0x1 },
12248 { "Line", 0x2 },
12249 { "CD", 0x3 },
12250 },
12251};
12252
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012253static struct hda_input_mux alc268_acer_capture_source = {
12254 .num_items = 3,
12255 .items = {
12256 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012257 { "Internal Mic", 0x1 },
12258 { "Line", 0x2 },
12259 },
12260};
12261
12262static struct hda_input_mux alc268_acer_dmic_capture_source = {
12263 .num_items = 3,
12264 .items = {
12265 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012266 { "Internal Mic", 0x6 },
12267 { "Line", 0x2 },
12268 },
12269};
12270
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012271#ifdef CONFIG_SND_DEBUG
12272static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012273 /* Volume widgets */
12274 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12275 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12276 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12277 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12278 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12279 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12280 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12281 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12282 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12283 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12284 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12285 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12286 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012287 /* The below appears problematic on some hardwares */
12288 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012289 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12290 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12291 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12292 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12293
12294 /* Modes for retasking pin widgets */
12295 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12296 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12297 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12298 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12299
12300 /* Controls for GPIO pins, assuming they are configured as outputs */
12301 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12302 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12303 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12304 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12305
12306 /* Switches to allow the digital SPDIF output pin to be enabled.
12307 * The ALC268 does not have an SPDIF input.
12308 */
12309 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12310
12311 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12312 * this output to turn on an external amplifier.
12313 */
12314 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12315 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12316
12317 { } /* end */
12318};
12319#endif
12320
Kailang Yanga361d842007-06-05 12:30:55 +020012321/* create input playback/capture controls for the given pin */
12322static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12323 const char *ctlname, int idx)
12324{
12325 char name[32];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012326 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012327 int err;
12328
12329 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012330 switch (nid) {
12331 case 0x14:
12332 case 0x16:
12333 dac = 0x02;
12334 break;
12335 case 0x15:
12336 dac = 0x03;
12337 break;
12338 default:
12339 return 0;
12340 }
12341 if (spec->multiout.dac_nids[0] != dac &&
12342 spec->multiout.dac_nids[1] != dac) {
Kailang Yanga361d842007-06-05 12:30:55 +020012343 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012344 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012345 HDA_OUTPUT));
12346 if (err < 0)
12347 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012348 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12349 }
12350
Kailang Yanga361d842007-06-05 12:30:55 +020012351 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012352 if (nid != 0x16)
12353 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yanga361d842007-06-05 12:30:55 +020012354 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012355 else /* mono */
12356 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12357 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012358 if (err < 0)
12359 return err;
12360 return 0;
12361}
12362
12363/* add playback controls from the parsed DAC table */
12364static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12365 const struct auto_pin_cfg *cfg)
12366{
12367 hda_nid_t nid;
12368 int err;
12369
Kailang Yanga361d842007-06-05 12:30:55 +020012370 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012371
12372 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012373 if (nid) {
12374 const char *name;
12375 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12376 name = "Speaker";
12377 else
12378 name = "Front";
12379 err = alc268_new_analog_output(spec, nid, name, 0);
12380 if (err < 0)
12381 return err;
12382 }
Kailang Yanga361d842007-06-05 12:30:55 +020012383
12384 nid = cfg->speaker_pins[0];
12385 if (nid == 0x1d) {
12386 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12387 "Speaker Playback Volume",
12388 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12389 if (err < 0)
12390 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012391 } else {
12392 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12393 if (err < 0)
12394 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012395 }
12396 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012397 if (nid) {
12398 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12399 if (err < 0)
12400 return err;
12401 }
Kailang Yanga361d842007-06-05 12:30:55 +020012402
12403 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12404 if (nid == 0x16) {
12405 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12406 "Mono Playback Switch",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012407 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012408 if (err < 0)
12409 return err;
12410 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012411 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012412}
12413
12414/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012415static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012416 const struct auto_pin_cfg *cfg)
12417{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012418 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012419}
12420
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012421static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12422 hda_nid_t nid, int pin_type)
12423{
12424 int idx;
12425
12426 alc_set_pin_output(codec, nid, pin_type);
12427 if (nid == 0x14 || nid == 0x16)
12428 idx = 0;
12429 else
12430 idx = 1;
12431 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12432}
12433
12434static void alc268_auto_init_multi_out(struct hda_codec *codec)
12435{
12436 struct alc_spec *spec = codec->spec;
12437 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12438 if (nid) {
12439 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12440 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12441 }
12442}
12443
12444static void alc268_auto_init_hp_out(struct hda_codec *codec)
12445{
12446 struct alc_spec *spec = codec->spec;
12447 hda_nid_t pin;
12448
12449 pin = spec->autocfg.hp_pins[0];
12450 if (pin)
12451 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12452 pin = spec->autocfg.speaker_pins[0];
12453 if (pin)
12454 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12455}
12456
Kailang Yanga361d842007-06-05 12:30:55 +020012457static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12458{
12459 struct alc_spec *spec = codec->spec;
12460 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12461 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12462 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12463 unsigned int dac_vol1, dac_vol2;
12464
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012465 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012466 snd_hda_codec_write(codec, speaker_nid, 0,
12467 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012468 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012469 snd_hda_codec_write(codec, 0x0f, 0,
12470 AC_VERB_SET_AMP_GAIN_MUTE,
12471 AMP_IN_UNMUTE(1));
12472 snd_hda_codec_write(codec, 0x10, 0,
12473 AC_VERB_SET_AMP_GAIN_MUTE,
12474 AMP_IN_UNMUTE(1));
12475 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012476 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012477 snd_hda_codec_write(codec, 0x0f, 0,
12478 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12479 snd_hda_codec_write(codec, 0x10, 0,
12480 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12481 }
12482
12483 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012484 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012485 dac_vol2 = AMP_OUT_ZERO;
12486 else if (line_nid == 0x15)
12487 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012488 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012489 dac_vol2 = AMP_OUT_ZERO;
12490 else if (hp_nid == 0x15)
12491 dac_vol1 = AMP_OUT_ZERO;
12492 if (line_nid != 0x16 || hp_nid != 0x16 ||
12493 spec->autocfg.line_out_pins[1] != 0x16 ||
12494 spec->autocfg.line_out_pins[2] != 0x16)
12495 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12496
12497 snd_hda_codec_write(codec, 0x02, 0,
12498 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12499 snd_hda_codec_write(codec, 0x03, 0,
12500 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12501}
12502
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012503/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012504#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12505#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012506#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012507#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12508
12509/*
12510 * BIOS auto configuration
12511 */
12512static int alc268_parse_auto_config(struct hda_codec *codec)
12513{
12514 struct alc_spec *spec = codec->spec;
12515 int err;
12516 static hda_nid_t alc268_ignore[] = { 0 };
12517
12518 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12519 alc268_ignore);
12520 if (err < 0)
12521 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012522 if (!spec->autocfg.line_outs) {
12523 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12524 spec->multiout.max_channels = 2;
12525 spec->no_analog = 1;
12526 goto dig_only;
12527 }
Kailang Yanga361d842007-06-05 12:30:55 +020012528 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012529 }
Kailang Yanga361d842007-06-05 12:30:55 +020012530 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12531 if (err < 0)
12532 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012533 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012534 if (err < 0)
12535 return err;
12536
12537 spec->multiout.max_channels = 2;
12538
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012539 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012540 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012541 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012542 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012543 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12544 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012545 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012546 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012547
Takashi Iwai892981f2009-03-02 08:04:35 +010012548 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012549 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012550
Takashi Iwaid88897e2008-10-31 15:01:37 +010012551 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012552 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012553 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012554
Takashi Iwai776e1842007-08-29 15:07:11 +020012555 err = alc_auto_add_mic_boost(codec);
12556 if (err < 0)
12557 return err;
12558
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012559 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12560
Kailang Yanga361d842007-06-05 12:30:55 +020012561 return 1;
12562}
12563
Kailang Yanga361d842007-06-05 12:30:55 +020012564#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12565
12566/* init callback for auto-configuration model -- overriding the default init */
12567static void alc268_auto_init(struct hda_codec *codec)
12568{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012569 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012570 alc268_auto_init_multi_out(codec);
12571 alc268_auto_init_hp_out(codec);
12572 alc268_auto_init_mono_speaker_out(codec);
12573 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012574 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012575 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012576}
12577
12578/*
12579 * configuration and preset
12580 */
12581static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012582 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012583 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012584 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012585 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012586 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012587 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012588 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012589 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012590#ifdef CONFIG_SND_DEBUG
12591 [ALC268_TEST] = "test",
12592#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012593 [ALC268_AUTO] = "auto",
12594};
12595
12596static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012597 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012598 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012599 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012600 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012601 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012602 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12603 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012604 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012605 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020012606 /* almost compatible with toshiba but with optional digital outs;
12607 * auto-probing seems working fine
12608 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012609 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020012610 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012611 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012612 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012613 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012614 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012615 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012616 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012617 {}
12618};
12619
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012620/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12621static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12622 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12623 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12624 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12625 ALC268_TOSHIBA),
12626 {}
12627};
12628
Kailang Yanga361d842007-06-05 12:30:55 +020012629static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012630 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012631 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12632 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012633 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12634 alc267_quanta_il1_verbs },
12635 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12636 .dac_nids = alc268_dac_nids,
12637 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12638 .adc_nids = alc268_adc_nids_alt,
12639 .hp_nid = 0x03,
12640 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12641 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012642 .unsol_event = alc_sku_unsol_event,
12643 .setup = alc267_quanta_il1_setup,
12644 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012645 },
Kailang Yanga361d842007-06-05 12:30:55 +020012646 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012647 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12648 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012649 .init_verbs = { alc268_base_init_verbs },
12650 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12651 .dac_nids = alc268_dac_nids,
12652 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12653 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012654 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012655 .hp_nid = 0x03,
12656 .dig_out_nid = ALC268_DIGOUT_NID,
12657 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12658 .channel_mode = alc268_modes,
12659 .input_mux = &alc268_capture_source,
12660 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012661 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012662 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012663 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012664 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12665 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012666 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12667 .dac_nids = alc268_dac_nids,
12668 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12669 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012670 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012671 .hp_nid = 0x03,
12672 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12673 .channel_mode = alc268_modes,
12674 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012675 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012676 .setup = alc268_toshiba_setup,
12677 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012678 },
12679 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020012680 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012681 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012682 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12683 alc268_acer_verbs },
12684 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12685 .dac_nids = alc268_dac_nids,
12686 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12687 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012688 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012689 .hp_nid = 0x02,
12690 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12691 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012692 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012693 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012694 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012695 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012696 [ALC268_ACER_DMIC] = {
12697 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12698 alc268_beep_mixer },
12699 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12700 alc268_acer_verbs },
12701 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12702 .dac_nids = alc268_dac_nids,
12703 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12704 .adc_nids = alc268_adc_nids_alt,
12705 .capsrc_nids = alc268_capsrc_nids,
12706 .hp_nid = 0x02,
12707 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12708 .channel_mode = alc268_modes,
12709 .input_mux = &alc268_acer_dmic_capture_source,
12710 .unsol_event = alc268_acer_unsol_event,
12711 .init_hook = alc268_acer_init_hook,
12712 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012713 [ALC268_ACER_ASPIRE_ONE] = {
12714 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012715 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012716 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012717 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12718 alc268_acer_aspire_one_verbs },
12719 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12720 .dac_nids = alc268_dac_nids,
12721 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12722 .adc_nids = alc268_adc_nids_alt,
12723 .capsrc_nids = alc268_capsrc_nids,
12724 .hp_nid = 0x03,
12725 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12726 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012727 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012728 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012729 .init_hook = alc268_acer_lc_init_hook,
12730 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012731 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012732 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12733 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012734 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12735 alc268_dell_verbs },
12736 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12737 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012738 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12739 .adc_nids = alc268_adc_nids_alt,
12740 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012741 .hp_nid = 0x02,
12742 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12743 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012744 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012745 .setup = alc268_dell_setup,
12746 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012747 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012748 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012749 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12750 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012751 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12752 alc268_toshiba_verbs },
12753 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12754 .dac_nids = alc268_dac_nids,
12755 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12756 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012757 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012758 .hp_nid = 0x03,
12759 .dig_out_nid = ALC268_DIGOUT_NID,
12760 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12761 .channel_mode = alc268_modes,
12762 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012763 .setup = alc268_toshiba_setup,
12764 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012765 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012766#ifdef CONFIG_SND_DEBUG
12767 [ALC268_TEST] = {
12768 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12769 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12770 alc268_volume_init_verbs },
12771 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12772 .dac_nids = alc268_dac_nids,
12773 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12774 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012775 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012776 .hp_nid = 0x03,
12777 .dig_out_nid = ALC268_DIGOUT_NID,
12778 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12779 .channel_mode = alc268_modes,
12780 .input_mux = &alc268_capture_source,
12781 },
12782#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012783};
12784
12785static int patch_alc268(struct hda_codec *codec)
12786{
12787 struct alc_spec *spec;
12788 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012789 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012790
12791 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12792 if (spec == NULL)
12793 return -ENOMEM;
12794
12795 codec->spec = spec;
12796
12797 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12798 alc268_models,
12799 alc268_cfg_tbl);
12800
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012801 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12802 board_config = snd_hda_check_board_codec_sid_config(codec,
12803 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12804
Kailang Yanga361d842007-06-05 12:30:55 +020012805 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012806 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12807 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012808 board_config = ALC268_AUTO;
12809 }
12810
12811 if (board_config == ALC268_AUTO) {
12812 /* automatic parse from the BIOS config */
12813 err = alc268_parse_auto_config(codec);
12814 if (err < 0) {
12815 alc_free(codec);
12816 return err;
12817 } else if (!err) {
12818 printk(KERN_INFO
12819 "hda_codec: Cannot set up configuration "
12820 "from BIOS. Using base mode...\n");
12821 board_config = ALC268_3ST;
12822 }
12823 }
12824
12825 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012826 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020012827
Kailang Yanga361d842007-06-05 12:30:55 +020012828 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12829 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012830 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012831
Kailang Yanga361d842007-06-05 12:30:55 +020012832 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12833
Takashi Iwai22971e32009-02-10 11:56:44 +010012834 has_beep = 0;
12835 for (i = 0; i < spec->num_mixers; i++) {
12836 if (spec->mixers[i] == alc268_beep_mixer) {
12837 has_beep = 1;
12838 break;
12839 }
12840 }
12841
12842 if (has_beep) {
12843 err = snd_hda_attach_beep_device(codec, 0x1);
12844 if (err < 0) {
12845 alc_free(codec);
12846 return err;
12847 }
12848 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12849 /* override the amp caps for beep generator */
12850 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012851 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12852 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12853 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12854 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012855 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012856
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012857 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012858 /* check whether NID 0x07 is valid */
12859 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012860 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012861
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012862 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012863 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012864 if (spec->auto_mic ||
12865 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012866 spec->adc_nids = alc268_adc_nids_alt;
12867 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012868 if (spec->auto_mic || spec->input_mux->num_items == 1)
12869 add_mixer(spec, alc268_capture_nosrc_mixer);
12870 else
12871 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012872 } else {
12873 spec->adc_nids = alc268_adc_nids;
12874 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012875 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012876 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012877 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012878 /* set default input source */
12879 for (i = 0; i < spec->num_adc_nids; i++)
12880 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12881 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012882 i < spec->num_mux_defs ?
12883 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010012884 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012885 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012886
12887 spec->vmaster_nid = 0x02;
12888
Kailang Yanga361d842007-06-05 12:30:55 +020012889 codec->patch_ops = alc_patch_ops;
12890 if (board_config == ALC268_AUTO)
12891 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012892
Takashi Iwaidaead532008-11-28 12:55:36 +010012893 codec->proc_widget_hook = print_realtek_coef;
12894
Kailang Yanga361d842007-06-05 12:30:55 +020012895 return 0;
12896}
12897
12898/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012899 * ALC269 channel source setting (2 channel)
12900 */
12901#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12902
12903#define alc269_dac_nids alc260_dac_nids
12904
12905static hda_nid_t alc269_adc_nids[1] = {
12906 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012907 0x08,
12908};
12909
Takashi Iwaie01bf502008-08-21 16:25:07 +020012910static hda_nid_t alc269_capsrc_nids[1] = {
12911 0x23,
12912};
12913
12914/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12915 * not a mux!
12916 */
12917
Kailang Yangf6a92242007-12-13 16:52:54 +010012918#define alc269_modes alc260_modes
12919#define alc269_capture_source alc880_lg_lw_capture_source
12920
12921static struct snd_kcontrol_new alc269_base_mixer[] = {
12922 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12923 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12924 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12925 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12926 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12927 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12928 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12929 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12930 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12931 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12932 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12933 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12934 { } /* end */
12935};
12936
Kailang Yang60db6b52008-08-26 13:13:00 +020012937static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12938 /* output mixer control */
12939 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12940 {
12941 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12942 .name = "Master Playback Switch",
12943 .info = snd_hda_mixer_amp_switch_info,
12944 .get = snd_hda_mixer_amp_switch_get,
12945 .put = alc268_acer_master_sw_put,
12946 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12947 },
12948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12950 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12951 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12952 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12953 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012954 { }
12955};
12956
Tony Vroon64154832008-11-06 15:08:49 +000012957static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12958 /* output mixer control */
12959 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12960 {
12961 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12962 .name = "Master Playback Switch",
12963 .info = snd_hda_mixer_amp_switch_info,
12964 .get = snd_hda_mixer_amp_switch_get,
12965 .put = alc268_acer_master_sw_put,
12966 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12967 },
12968 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12969 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12970 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12971 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12972 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12973 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12974 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12975 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12976 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012977 { }
12978};
12979
Kailang Yangf53281e2008-07-18 12:36:43 +020012980static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012981 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012982 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012983 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012984 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012985 { } /* end */
12986};
12987
Kailang Yangf6a92242007-12-13 16:52:54 +010012988/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012989static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12990 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12991 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012992 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12993 { } /* end */
12994};
12995
12996/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012997#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012998
Kailang Yang60db6b52008-08-26 13:13:00 +020012999static struct hda_verb alc269_quanta_fl1_verbs[] = {
13000 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13001 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13002 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13003 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13004 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13005 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13006 { }
13007};
13008
Tony Vroon64154832008-11-06 15:08:49 +000013009static struct hda_verb alc269_lifebook_verbs[] = {
13010 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13011 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13012 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13013 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13014 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13015 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13016 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13017 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13018 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13019 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13020 { }
13021};
13022
Kailang Yang60db6b52008-08-26 13:13:00 +020013023/* toggle speaker-output according to the hp-jack state */
13024static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13025{
13026 unsigned int present;
13027 unsigned char bits;
13028
13029 present = snd_hda_codec_read(codec, 0x15, 0,
13030 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13031 bits = present ? AMP_IN_MUTE(0) : 0;
13032 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13033 AMP_IN_MUTE(0), bits);
13034 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13035 AMP_IN_MUTE(0), bits);
13036
13037 snd_hda_codec_write(codec, 0x20, 0,
13038 AC_VERB_SET_COEF_INDEX, 0x0c);
13039 snd_hda_codec_write(codec, 0x20, 0,
13040 AC_VERB_SET_PROC_COEF, 0x680);
13041
13042 snd_hda_codec_write(codec, 0x20, 0,
13043 AC_VERB_SET_COEF_INDEX, 0x0c);
13044 snd_hda_codec_write(codec, 0x20, 0,
13045 AC_VERB_SET_PROC_COEF, 0x480);
13046}
13047
Tony Vroon64154832008-11-06 15:08:49 +000013048/* toggle speaker-output according to the hp-jacks state */
13049static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13050{
13051 unsigned int present;
13052 unsigned char bits;
13053
13054 /* Check laptop headphone socket */
13055 present = snd_hda_codec_read(codec, 0x15, 0,
13056 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13057
13058 /* Check port replicator headphone socket */
13059 present |= snd_hda_codec_read(codec, 0x1a, 0,
13060 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13061
13062 bits = present ? AMP_IN_MUTE(0) : 0;
13063 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13064 AMP_IN_MUTE(0), bits);
13065 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13066 AMP_IN_MUTE(0), bits);
13067
13068 snd_hda_codec_write(codec, 0x20, 0,
13069 AC_VERB_SET_COEF_INDEX, 0x0c);
13070 snd_hda_codec_write(codec, 0x20, 0,
13071 AC_VERB_SET_PROC_COEF, 0x680);
13072
13073 snd_hda_codec_write(codec, 0x20, 0,
13074 AC_VERB_SET_COEF_INDEX, 0x0c);
13075 snd_hda_codec_write(codec, 0x20, 0,
13076 AC_VERB_SET_PROC_COEF, 0x480);
13077}
13078
Tony Vroon64154832008-11-06 15:08:49 +000013079static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13080{
13081 unsigned int present_laptop;
13082 unsigned int present_dock;
13083
13084 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
13085 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13086
13087 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
13088 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13089
13090 /* Laptop mic port overrides dock mic port, design decision */
13091 if (present_dock)
13092 snd_hda_codec_write(codec, 0x23, 0,
13093 AC_VERB_SET_CONNECT_SEL, 0x3);
13094 if (present_laptop)
13095 snd_hda_codec_write(codec, 0x23, 0,
13096 AC_VERB_SET_CONNECT_SEL, 0x0);
13097 if (!present_dock && !present_laptop)
13098 snd_hda_codec_write(codec, 0x23, 0,
13099 AC_VERB_SET_CONNECT_SEL, 0x1);
13100}
13101
Kailang Yang60db6b52008-08-26 13:13:00 +020013102static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13103 unsigned int res)
13104{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013105 switch (res >> 26) {
13106 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013107 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013108 break;
13109 case ALC880_MIC_EVENT:
13110 alc_mic_automute(codec);
13111 break;
13112 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013113}
13114
Tony Vroon64154832008-11-06 15:08:49 +000013115static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13116 unsigned int res)
13117{
13118 if ((res >> 26) == ALC880_HP_EVENT)
13119 alc269_lifebook_speaker_automute(codec);
13120 if ((res >> 26) == ALC880_MIC_EVENT)
13121 alc269_lifebook_mic_autoswitch(codec);
13122}
13123
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013124static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13125{
13126 struct alc_spec *spec = codec->spec;
13127 spec->ext_mic.pin = 0x18;
13128 spec->ext_mic.mux_idx = 0;
13129 spec->int_mic.pin = 0x19;
13130 spec->int_mic.mux_idx = 1;
13131 spec->auto_mic = 1;
13132}
13133
Kailang Yang60db6b52008-08-26 13:13:00 +020013134static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13135{
13136 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013137 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013138}
13139
Tony Vroon64154832008-11-06 15:08:49 +000013140static void alc269_lifebook_init_hook(struct hda_codec *codec)
13141{
13142 alc269_lifebook_speaker_automute(codec);
13143 alc269_lifebook_mic_autoswitch(codec);
13144}
13145
Kailang Yang60db6b52008-08-26 13:13:00 +020013146static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13147 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13148 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13149 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13150 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13151 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13152 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13153 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13154 {}
13155};
13156
13157static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13158 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13159 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13160 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13161 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13162 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13163 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13164 {}
13165};
13166
13167/* toggle speaker-output according to the hp-jack state */
13168static void alc269_speaker_automute(struct hda_codec *codec)
13169{
13170 unsigned int present;
13171 unsigned char bits;
13172
13173 present = snd_hda_codec_read(codec, 0x15, 0,
13174 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13175 bits = present ? AMP_IN_MUTE(0) : 0;
13176 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13177 AMP_IN_MUTE(0), bits);
13178 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13179 AMP_IN_MUTE(0), bits);
13180}
13181
Kailang Yang60db6b52008-08-26 13:13:00 +020013182/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013183static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013184 unsigned int res)
13185{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013186 switch (res >> 26) {
13187 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013188 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013189 break;
13190 case ALC880_MIC_EVENT:
13191 alc_mic_automute(codec);
13192 break;
13193 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013194}
13195
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013196static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13197{
13198 struct alc_spec *spec = codec->spec;
13199 spec->ext_mic.pin = 0x18;
13200 spec->ext_mic.mux_idx = 0;
13201 spec->int_mic.pin = 0x12;
13202 spec->int_mic.mux_idx = 5;
13203 spec->auto_mic = 1;
13204}
13205
13206static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13207{
13208 struct alc_spec *spec = codec->spec;
13209 spec->ext_mic.pin = 0x18;
13210 spec->ext_mic.mux_idx = 0;
13211 spec->int_mic.pin = 0x19;
13212 spec->int_mic.mux_idx = 1;
13213 spec->auto_mic = 1;
13214}
13215
13216static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013217{
13218 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013219 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013220}
13221
Kailang Yangf6a92242007-12-13 16:52:54 +010013222/*
13223 * generic initialization of ADC, input mixers and output mixers
13224 */
13225static struct hda_verb alc269_init_verbs[] = {
13226 /*
13227 * Unmute ADC0 and set the default input to mic-in
13228 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013229 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013230
13231 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13232 * analog-loopback mixer widget
13233 * Note: PASD motherboards uses the Line In 2 as the input for
13234 * front panel mic (mic 2)
13235 */
13236 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13238 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13239 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13240 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13241 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13242
13243 /*
13244 * Set up output mixers (0x0c - 0x0e)
13245 */
13246 /* set vol=0 to output mixers */
13247 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13248 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13249
13250 /* set up input amps for analog loopback */
13251 /* Amp Indices: DAC = 0, mixer = 1 */
13252 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13253 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13254 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13255 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13256 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13257 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13258
13259 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13260 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13261 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13262 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13263 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13264 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13265 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13266
13267 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13268 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13269 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13270 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13271 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13272 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13273 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13274
13275 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13276 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13277
13278 /* FIXME: use matrix-type input source selection */
13279 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13280 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013281 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13282 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013283 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13284 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13285
13286 /* set EAPD */
13287 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13288 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13289 { }
13290};
13291
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013292#define alc269_auto_create_multi_out_ctls \
13293 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013294#define alc269_auto_create_input_ctls \
13295 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013296
13297#ifdef CONFIG_SND_HDA_POWER_SAVE
13298#define alc269_loopbacks alc880_loopbacks
13299#endif
13300
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013301/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013302#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13303#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13304#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13305#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13306
Takashi Iwaif03d3112009-03-05 14:18:16 +010013307static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13308 .substreams = 1,
13309 .channels_min = 2,
13310 .channels_max = 8,
13311 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13312 /* NID is set in alc_build_pcms */
13313 .ops = {
13314 .open = alc880_playback_pcm_open,
13315 .prepare = alc880_playback_pcm_prepare,
13316 .cleanup = alc880_playback_pcm_cleanup
13317 },
13318};
13319
13320static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13321 .substreams = 1,
13322 .channels_min = 2,
13323 .channels_max = 2,
13324 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13325 /* NID is set in alc_build_pcms */
13326};
13327
Kailang Yangf6a92242007-12-13 16:52:54 +010013328/*
13329 * BIOS auto configuration
13330 */
13331static int alc269_parse_auto_config(struct hda_codec *codec)
13332{
13333 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013334 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013335 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13336
13337 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13338 alc269_ignore);
13339 if (err < 0)
13340 return err;
13341
13342 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13343 if (err < 0)
13344 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013345 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013346 if (err < 0)
13347 return err;
13348
13349 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13350
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013351 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013352 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13353
Takashi Iwai603c4012008-07-30 15:01:44 +020013354 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013355 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013356
Takashi Iwaid88897e2008-10-31 15:01:37 +010013357 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013358 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013359 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013360 /* set default input source */
13361 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13362 0, AC_VERB_SET_CONNECT_SEL,
13363 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013364
13365 err = alc_auto_add_mic_boost(codec);
13366 if (err < 0)
13367 return err;
13368
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013369 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013370 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013371
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013372 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13373
Kailang Yangf6a92242007-12-13 16:52:54 +010013374 return 1;
13375}
13376
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013377#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13378#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013379#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13380
13381
13382/* init callback for auto-configuration model -- overriding the default init */
13383static void alc269_auto_init(struct hda_codec *codec)
13384{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013385 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013386 alc269_auto_init_multi_out(codec);
13387 alc269_auto_init_hp_out(codec);
13388 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013389 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013390 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013391}
13392
13393/*
13394 * configuration and preset
13395 */
13396static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013397 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013398 [ALC269_QUANTA_FL1] = "quanta",
13399 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013400 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013401 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013402 [ALC269_LIFEBOOK] = "lifebook",
13403 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013404};
13405
13406static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013407 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013408 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13409 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013410 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13411 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13412 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13413 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13414 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13415 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013416 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13417 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013418 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13419 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013420 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013421 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013422 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013423 {}
13424};
13425
13426static struct alc_config_preset alc269_presets[] = {
13427 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013428 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013429 .init_verbs = { alc269_init_verbs },
13430 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13431 .dac_nids = alc269_dac_nids,
13432 .hp_nid = 0x03,
13433 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13434 .channel_mode = alc269_modes,
13435 .input_mux = &alc269_capture_source,
13436 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013437 [ALC269_QUANTA_FL1] = {
13438 .mixers = { alc269_quanta_fl1_mixer },
13439 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13440 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13441 .dac_nids = alc269_dac_nids,
13442 .hp_nid = 0x03,
13443 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13444 .channel_mode = alc269_modes,
13445 .input_mux = &alc269_capture_source,
13446 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013447 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013448 .init_hook = alc269_quanta_fl1_init_hook,
13449 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013450 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013451 .mixers = { alc269_eeepc_mixer },
13452 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013453 .init_verbs = { alc269_init_verbs,
13454 alc269_eeepc_amic_init_verbs },
13455 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13456 .dac_nids = alc269_dac_nids,
13457 .hp_nid = 0x03,
13458 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13459 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013460 .unsol_event = alc269_eeepc_unsol_event,
13461 .setup = alc269_eeepc_amic_setup,
13462 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013463 },
13464 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013465 .mixers = { alc269_eeepc_mixer },
13466 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013467 .init_verbs = { alc269_init_verbs,
13468 alc269_eeepc_dmic_init_verbs },
13469 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13470 .dac_nids = alc269_dac_nids,
13471 .hp_nid = 0x03,
13472 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13473 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013474 .unsol_event = alc269_eeepc_unsol_event,
13475 .setup = alc269_eeepc_dmic_setup,
13476 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013477 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013478 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013479 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013480 .cap_mixer = alc269_epc_capture_mixer,
13481 .init_verbs = { alc269_init_verbs,
13482 alc269_eeepc_dmic_init_verbs },
13483 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13484 .dac_nids = alc269_dac_nids,
13485 .hp_nid = 0x03,
13486 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13487 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013488 .unsol_event = alc269_eeepc_unsol_event,
13489 .setup = alc269_eeepc_dmic_setup,
13490 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013491 },
Tony Vroon64154832008-11-06 15:08:49 +000013492 [ALC269_LIFEBOOK] = {
13493 .mixers = { alc269_lifebook_mixer },
13494 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13495 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13496 .dac_nids = alc269_dac_nids,
13497 .hp_nid = 0x03,
13498 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13499 .channel_mode = alc269_modes,
13500 .input_mux = &alc269_capture_source,
13501 .unsol_event = alc269_lifebook_unsol_event,
13502 .init_hook = alc269_lifebook_init_hook,
13503 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013504};
13505
13506static int patch_alc269(struct hda_codec *codec)
13507{
13508 struct alc_spec *spec;
13509 int board_config;
13510 int err;
13511
13512 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13513 if (spec == NULL)
13514 return -ENOMEM;
13515
13516 codec->spec = spec;
13517
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013518 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13519
Kailang Yangf6a92242007-12-13 16:52:54 +010013520 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13521 alc269_models,
13522 alc269_cfg_tbl);
13523
13524 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013525 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13526 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013527 board_config = ALC269_AUTO;
13528 }
13529
13530 if (board_config == ALC269_AUTO) {
13531 /* automatic parse from the BIOS config */
13532 err = alc269_parse_auto_config(codec);
13533 if (err < 0) {
13534 alc_free(codec);
13535 return err;
13536 } else if (!err) {
13537 printk(KERN_INFO
13538 "hda_codec: Cannot set up configuration "
13539 "from BIOS. Using base mode...\n");
13540 board_config = ALC269_BASIC;
13541 }
13542 }
13543
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013544 err = snd_hda_attach_beep_device(codec, 0x1);
13545 if (err < 0) {
13546 alc_free(codec);
13547 return err;
13548 }
13549
Kailang Yangf6a92242007-12-13 16:52:54 +010013550 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013551 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013552
Takashi Iwaif03d3112009-03-05 14:18:16 +010013553 if (codec->subsystem_id == 0x17aa3bf8) {
13554 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13555 * fix the sample rate of analog I/O to 44.1kHz
13556 */
13557 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13558 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13559 } else {
13560 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13561 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13562 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013563 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13564 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13565
13566 spec->adc_nids = alc269_adc_nids;
13567 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013568 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013569 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013570 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013571 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013572
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013573 spec->vmaster_nid = 0x02;
13574
Kailang Yangf6a92242007-12-13 16:52:54 +010013575 codec->patch_ops = alc_patch_ops;
13576 if (board_config == ALC269_AUTO)
13577 spec->init_hook = alc269_auto_init;
13578#ifdef CONFIG_SND_HDA_POWER_SAVE
13579 if (!spec->loopback.amplist)
13580 spec->loopback.amplist = alc269_loopbacks;
13581#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013582 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013583
13584 return 0;
13585}
13586
13587/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013588 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13589 */
13590
13591/*
13592 * set the path ways for 2 channel output
13593 * need to set the codec line out and mic 1 pin widgets to inputs
13594 */
13595static struct hda_verb alc861_threestack_ch2_init[] = {
13596 /* set pin widget 1Ah (line in) for input */
13597 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013598 /* set pin widget 18h (mic1/2) for input, for mic also enable
13599 * the vref
13600 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013601 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13602
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013603 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13604#if 0
13605 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13606 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13607#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013608 { } /* end */
13609};
13610/*
13611 * 6ch mode
13612 * need to set the codec line out and mic 1 pin widgets to outputs
13613 */
13614static struct hda_verb alc861_threestack_ch6_init[] = {
13615 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13616 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13617 /* set pin widget 18h (mic1) for output (CLFE)*/
13618 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13619
13620 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013621 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013622
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013623 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13624#if 0
13625 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13626 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13627#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013628 { } /* end */
13629};
13630
13631static struct hda_channel_mode alc861_threestack_modes[2] = {
13632 { 2, alc861_threestack_ch2_init },
13633 { 6, alc861_threestack_ch6_init },
13634};
Takashi Iwai22309c32006-08-09 16:57:28 +020013635/* Set mic1 as input and unmute the mixer */
13636static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13637 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13638 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13639 { } /* end */
13640};
13641/* Set mic1 as output and mute mixer */
13642static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13643 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13644 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13645 { } /* end */
13646};
13647
13648static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13649 { 2, alc861_uniwill_m31_ch2_init },
13650 { 4, alc861_uniwill_m31_ch4_init },
13651};
Kailang Yangdf694da2005-12-05 19:42:22 +010013652
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013653/* Set mic1 and line-in as input and unmute the mixer */
13654static struct hda_verb alc861_asus_ch2_init[] = {
13655 /* set pin widget 1Ah (line in) for input */
13656 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013657 /* set pin widget 18h (mic1/2) for input, for mic also enable
13658 * the vref
13659 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013660 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13661
13662 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13663#if 0
13664 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13665 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13666#endif
13667 { } /* end */
13668};
13669/* Set mic1 nad line-in as output and mute mixer */
13670static struct hda_verb alc861_asus_ch6_init[] = {
13671 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13672 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13673 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13674 /* set pin widget 18h (mic1) for output (CLFE)*/
13675 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13676 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13677 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13678 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13679
13680 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13681#if 0
13682 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13683 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13684#endif
13685 { } /* end */
13686};
13687
13688static struct hda_channel_mode alc861_asus_modes[2] = {
13689 { 2, alc861_asus_ch2_init },
13690 { 6, alc861_asus_ch6_init },
13691};
13692
Kailang Yangdf694da2005-12-05 19:42:22 +010013693/* patch-ALC861 */
13694
13695static struct snd_kcontrol_new alc861_base_mixer[] = {
13696 /* output mixer control */
13697 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13698 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13699 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13700 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13701 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13702
13703 /*Input mixer control */
13704 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13705 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13706 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13707 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13708 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13709 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13710 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13711 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13712 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13713 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013714
Kailang Yangdf694da2005-12-05 19:42:22 +010013715 { } /* end */
13716};
13717
13718static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13719 /* output mixer control */
13720 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13721 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13722 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13723 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13724 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13725
13726 /* Input mixer control */
13727 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13728 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13729 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13730 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13731 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13732 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13733 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13734 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13735 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13736 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013737
Kailang Yangdf694da2005-12-05 19:42:22 +010013738 {
13739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13740 .name = "Channel Mode",
13741 .info = alc_ch_mode_info,
13742 .get = alc_ch_mode_get,
13743 .put = alc_ch_mode_put,
13744 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13745 },
13746 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013747};
13748
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013749static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013750 /* output mixer control */
13751 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13752 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13753 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013754
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013755 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013756};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013757
Takashi Iwai22309c32006-08-09 16:57:28 +020013758static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13759 /* output mixer control */
13760 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13761 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13762 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13763 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13764 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13765
13766 /* Input mixer control */
13767 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13768 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13769 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13770 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13771 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13772 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13773 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13774 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13775 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13776 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013777
Takashi Iwai22309c32006-08-09 16:57:28 +020013778 {
13779 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13780 .name = "Channel Mode",
13781 .info = alc_ch_mode_info,
13782 .get = alc_ch_mode_get,
13783 .put = alc_ch_mode_put,
13784 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13785 },
13786 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013787};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013788
13789static struct snd_kcontrol_new alc861_asus_mixer[] = {
13790 /* output mixer control */
13791 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13792 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13793 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13794 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13795 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13796
13797 /* Input mixer control */
13798 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13799 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13800 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13801 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13802 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13803 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13804 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13805 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13806 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013807 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13808
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013809 {
13810 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13811 .name = "Channel Mode",
13812 .info = alc_ch_mode_info,
13813 .get = alc_ch_mode_get,
13814 .put = alc_ch_mode_put,
13815 .private_value = ARRAY_SIZE(alc861_asus_modes),
13816 },
13817 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013818};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013819
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013820/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013821static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013822 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13823 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013824 { }
13825};
13826
Kailang Yangdf694da2005-12-05 19:42:22 +010013827/*
13828 * generic initialization of ADC, input mixers and output mixers
13829 */
13830static struct hda_verb alc861_base_init_verbs[] = {
13831 /*
13832 * Unmute ADC0 and set the default input to mic-in
13833 */
13834 /* port-A for surround (rear panel) */
13835 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13836 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13837 /* port-B for mic-in (rear panel) with vref */
13838 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13839 /* port-C for line-in (rear panel) */
13840 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13841 /* port-D for Front */
13842 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13843 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13844 /* port-E for HP out (front panel) */
13845 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13846 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013847 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013848 /* port-F for mic-in (front panel) with vref */
13849 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13850 /* port-G for CLFE (rear panel) */
13851 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13852 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13853 /* port-H for side (rear panel) */
13854 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13855 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13856 /* CD-in */
13857 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13858 /* route front mic to ADC1*/
13859 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13860 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013861
Kailang Yangdf694da2005-12-05 19:42:22 +010013862 /* Unmute DAC0~3 & spdif out*/
13863 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13864 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13865 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13866 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13867 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013868
Kailang Yangdf694da2005-12-05 19:42:22 +010013869 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13870 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13871 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13872 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13873 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013874
Kailang Yangdf694da2005-12-05 19:42:22 +010013875 /* Unmute Stereo Mixer 15 */
13876 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13877 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13878 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013880
13881 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13882 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13883 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13884 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13885 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13886 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13887 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13888 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013889 /* hp used DAC 3 (Front) */
13890 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013891 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13892
13893 { }
13894};
13895
13896static struct hda_verb alc861_threestack_init_verbs[] = {
13897 /*
13898 * Unmute ADC0 and set the default input to mic-in
13899 */
13900 /* port-A for surround (rear panel) */
13901 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13902 /* port-B for mic-in (rear panel) with vref */
13903 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13904 /* port-C for line-in (rear panel) */
13905 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13906 /* port-D for Front */
13907 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13908 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13909 /* port-E for HP out (front panel) */
13910 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13911 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013912 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013913 /* port-F for mic-in (front panel) with vref */
13914 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13915 /* port-G for CLFE (rear panel) */
13916 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13917 /* port-H for side (rear panel) */
13918 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13919 /* CD-in */
13920 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13921 /* route front mic to ADC1*/
13922 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13923 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13924 /* Unmute DAC0~3 & spdif out*/
13925 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13926 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13927 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13928 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13929 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013930
Kailang Yangdf694da2005-12-05 19:42:22 +010013931 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13932 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13933 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13934 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13935 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013936
Kailang Yangdf694da2005-12-05 19:42:22 +010013937 /* Unmute Stereo Mixer 15 */
13938 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13939 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13940 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013941 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013942
13943 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13944 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13945 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13946 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13947 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13948 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13949 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13950 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013951 /* hp used DAC 3 (Front) */
13952 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013953 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13954 { }
13955};
Takashi Iwai22309c32006-08-09 16:57:28 +020013956
13957static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13958 /*
13959 * Unmute ADC0 and set the default input to mic-in
13960 */
13961 /* port-A for surround (rear panel) */
13962 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13963 /* port-B for mic-in (rear panel) with vref */
13964 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13965 /* port-C for line-in (rear panel) */
13966 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13967 /* port-D for Front */
13968 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13969 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13970 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013971 /* this has to be set to VREF80 */
13972 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013973 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013974 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013975 /* port-F for mic-in (front panel) with vref */
13976 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13977 /* port-G for CLFE (rear panel) */
13978 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13979 /* port-H for side (rear panel) */
13980 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13981 /* CD-in */
13982 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13983 /* route front mic to ADC1*/
13984 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13985 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13986 /* Unmute DAC0~3 & spdif out*/
13987 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13988 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13989 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13990 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13991 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013992
Takashi Iwai22309c32006-08-09 16:57:28 +020013993 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13994 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13995 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13996 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13997 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013998
Takashi Iwai22309c32006-08-09 16:57:28 +020013999 /* Unmute Stereo Mixer 15 */
14000 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14001 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14002 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014003 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014004
14005 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14006 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14007 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14008 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14009 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14010 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14011 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14012 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014013 /* hp used DAC 3 (Front) */
14014 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014015 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14016 { }
14017};
14018
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014019static struct hda_verb alc861_asus_init_verbs[] = {
14020 /*
14021 * Unmute ADC0 and set the default input to mic-in
14022 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014023 /* port-A for surround (rear panel)
14024 * according to codec#0 this is the HP jack
14025 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014026 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14027 /* route front PCM to HP */
14028 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14029 /* port-B for mic-in (rear panel) with vref */
14030 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14031 /* port-C for line-in (rear panel) */
14032 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14033 /* port-D for Front */
14034 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14035 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14036 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014037 /* this has to be set to VREF80 */
14038 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014039 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014040 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014041 /* port-F for mic-in (front panel) with vref */
14042 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14043 /* port-G for CLFE (rear panel) */
14044 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14045 /* port-H for side (rear panel) */
14046 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14047 /* CD-in */
14048 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14049 /* route front mic to ADC1*/
14050 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14051 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14052 /* Unmute DAC0~3 & spdif out*/
14053 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14054 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14055 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14056 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14057 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14058 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14059 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14060 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14061 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14062 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014063
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014064 /* Unmute Stereo Mixer 15 */
14065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014068 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014069
14070 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14071 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14072 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14073 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14074 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14075 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14077 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014078 /* hp used DAC 3 (Front) */
14079 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014080 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14081 { }
14082};
14083
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014084/* additional init verbs for ASUS laptops */
14085static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14086 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14087 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14088 { }
14089};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014090
Kailang Yangdf694da2005-12-05 19:42:22 +010014091/*
14092 * generic initialization of ADC, input mixers and output mixers
14093 */
14094static struct hda_verb alc861_auto_init_verbs[] = {
14095 /*
14096 * Unmute ADC0 and set the default input to mic-in
14097 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014098 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014099 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014100
Kailang Yangdf694da2005-12-05 19:42:22 +010014101 /* Unmute DAC0~3 & spdif out*/
14102 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14103 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14104 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14105 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14106 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014107
Kailang Yangdf694da2005-12-05 19:42:22 +010014108 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14109 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14110 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14111 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14112 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014113
Kailang Yangdf694da2005-12-05 19:42:22 +010014114 /* Unmute Stereo Mixer 15 */
14115 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14116 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14117 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14118 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14119
Takashi Iwai1c209302009-07-22 15:17:45 +020014120 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14121 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14122 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14123 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14124 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14125 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14126 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14127 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014128
14129 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14130 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014131 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14132 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014133 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14134 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014135 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14136 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014137
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014138 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014139
14140 { }
14141};
14142
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014143static struct hda_verb alc861_toshiba_init_verbs[] = {
14144 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014145
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014146 { }
14147};
14148
14149/* toggle speaker-output according to the hp-jack state */
14150static void alc861_toshiba_automute(struct hda_codec *codec)
14151{
14152 unsigned int present;
14153
14154 present = snd_hda_codec_read(codec, 0x0f, 0,
14155 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014156 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14157 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14158 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14159 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014160}
14161
14162static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14163 unsigned int res)
14164{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014165 if ((res >> 26) == ALC880_HP_EVENT)
14166 alc861_toshiba_automute(codec);
14167}
14168
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014169/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014170#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14171#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14172#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14173#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14174
14175
14176#define ALC861_DIGOUT_NID 0x07
14177
14178static struct hda_channel_mode alc861_8ch_modes[1] = {
14179 { 8, NULL }
14180};
14181
14182static hda_nid_t alc861_dac_nids[4] = {
14183 /* front, surround, clfe, side */
14184 0x03, 0x06, 0x05, 0x04
14185};
14186
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014187static hda_nid_t alc660_dac_nids[3] = {
14188 /* front, clfe, surround */
14189 0x03, 0x05, 0x06
14190};
14191
Kailang Yangdf694da2005-12-05 19:42:22 +010014192static hda_nid_t alc861_adc_nids[1] = {
14193 /* ADC0-2 */
14194 0x08,
14195};
14196
14197static struct hda_input_mux alc861_capture_source = {
14198 .num_items = 5,
14199 .items = {
14200 { "Mic", 0x0 },
14201 { "Front Mic", 0x3 },
14202 { "Line", 0x1 },
14203 { "CD", 0x4 },
14204 { "Mixer", 0x5 },
14205 },
14206};
14207
Takashi Iwai1c209302009-07-22 15:17:45 +020014208static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14209{
14210 struct alc_spec *spec = codec->spec;
14211 hda_nid_t mix, srcs[5];
14212 int i, j, num;
14213
14214 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14215 return 0;
14216 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14217 if (num < 0)
14218 return 0;
14219 for (i = 0; i < num; i++) {
14220 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014221 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014222 if (type != AC_WID_AUD_OUT)
14223 continue;
14224 for (j = 0; j < spec->multiout.num_dacs; j++)
14225 if (spec->multiout.dac_nids[j] == srcs[i])
14226 break;
14227 if (j >= spec->multiout.num_dacs)
14228 return srcs[i];
14229 }
14230 return 0;
14231}
14232
Kailang Yangdf694da2005-12-05 19:42:22 +010014233/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014234static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014235 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014236{
Takashi Iwai1c209302009-07-22 15:17:45 +020014237 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014238 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014239 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014240
14241 spec->multiout.dac_nids = spec->private_dac_nids;
14242 for (i = 0; i < cfg->line_outs; i++) {
14243 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014244 dac = alc861_look_for_dac(codec, nid);
14245 if (!dac)
14246 continue;
14247 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014248 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014249 return 0;
14250}
14251
Takashi Iwai1c209302009-07-22 15:17:45 +020014252static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14253 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014254{
14255 char name[32];
Takashi Iwai1c209302009-07-22 15:17:45 +020014256 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14257 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14258 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14259}
14260
14261/* add playback controls from the parsed DAC table */
14262static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14263 const struct auto_pin_cfg *cfg)
14264{
14265 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014266 static const char *chname[4] = {
14267 "Front", "Surround", NULL /*CLFE*/, "Side"
14268 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014269 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014270 int i, err;
14271
14272 if (cfg->line_outs == 1) {
14273 const char *pfx = NULL;
14274 if (!cfg->hp_outs)
14275 pfx = "Master";
14276 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14277 pfx = "Speaker";
14278 if (pfx) {
14279 nid = spec->multiout.dac_nids[0];
14280 return alc861_create_out_sw(codec, pfx, nid, 3);
14281 }
14282 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014283
14284 for (i = 0; i < cfg->line_outs; i++) {
14285 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014286 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014287 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014288 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014289 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014290 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014291 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014292 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014293 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014294 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014295 return err;
14296 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014297 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014298 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014299 return err;
14300 }
14301 }
14302 return 0;
14303}
14304
Takashi Iwai1c209302009-07-22 15:17:45 +020014305static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014306{
Takashi Iwai1c209302009-07-22 15:17:45 +020014307 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014308 int err;
14309 hda_nid_t nid;
14310
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014311 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014312 return 0;
14313
14314 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014315 nid = alc861_look_for_dac(codec, pin);
14316 if (nid) {
14317 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14318 if (err < 0)
14319 return err;
14320 spec->multiout.hp_nid = nid;
14321 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014322 }
14323 return 0;
14324}
14325
14326/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014327static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014328 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014329{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014330 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014331}
14332
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014333static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14334 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014335 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014336{
Takashi Iwai1c209302009-07-22 15:17:45 +020014337 hda_nid_t mix, srcs[5];
14338 int i, num;
14339
Jacek Luczak564c5be2008-05-03 18:41:23 +020014340 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14341 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014342 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014343 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014344 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14345 return;
14346 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14347 if (num < 0)
14348 return;
14349 for (i = 0; i < num; i++) {
14350 unsigned int mute;
14351 if (srcs[i] == dac || srcs[i] == 0x15)
14352 mute = AMP_IN_UNMUTE(i);
14353 else
14354 mute = AMP_IN_MUTE(i);
14355 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14356 mute);
14357 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014358}
14359
14360static void alc861_auto_init_multi_out(struct hda_codec *codec)
14361{
14362 struct alc_spec *spec = codec->spec;
14363 int i;
14364
14365 for (i = 0; i < spec->autocfg.line_outs; i++) {
14366 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014367 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014368 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014369 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014370 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014371 }
14372}
14373
14374static void alc861_auto_init_hp_out(struct hda_codec *codec)
14375{
14376 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014377
Takashi Iwai15870f02009-10-05 08:25:13 +020014378 if (spec->autocfg.hp_outs)
14379 alc861_auto_set_output_and_unmute(codec,
14380 spec->autocfg.hp_pins[0],
14381 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014382 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014383 if (spec->autocfg.speaker_outs)
14384 alc861_auto_set_output_and_unmute(codec,
14385 spec->autocfg.speaker_pins[0],
14386 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014387 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014388}
14389
14390static void alc861_auto_init_analog_input(struct hda_codec *codec)
14391{
14392 struct alc_spec *spec = codec->spec;
14393 int i;
14394
14395 for (i = 0; i < AUTO_PIN_LAST; i++) {
14396 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014397 if (nid >= 0x0c && nid <= 0x11)
14398 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014399 }
14400}
14401
14402/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014403/* return 1 if successful, 0 if the proper config is not found,
14404 * or a negative error code
14405 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014406static int alc861_parse_auto_config(struct hda_codec *codec)
14407{
14408 struct alc_spec *spec = codec->spec;
14409 int err;
14410 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14411
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014412 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14413 alc861_ignore);
14414 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014415 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014416 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014417 return 0; /* can't find valid BIOS pin config */
14418
Takashi Iwai1c209302009-07-22 15:17:45 +020014419 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014420 if (err < 0)
14421 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014422 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014423 if (err < 0)
14424 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014425 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014426 if (err < 0)
14427 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014428 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014429 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014430 return err;
14431
14432 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14433
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014434 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014435 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14436
Takashi Iwai603c4012008-07-30 15:01:44 +020014437 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014438 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014439
Takashi Iwaid88897e2008-10-31 15:01:37 +010014440 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014441
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014442 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014443 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014444
14445 spec->adc_nids = alc861_adc_nids;
14446 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014447 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014448
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014449 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14450
Kailang Yangdf694da2005-12-05 19:42:22 +010014451 return 1;
14452}
14453
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014454/* additional initialization for auto-configuration model */
14455static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014456{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014457 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014458 alc861_auto_init_multi_out(codec);
14459 alc861_auto_init_hp_out(codec);
14460 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014461 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014462 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014463}
14464
Takashi Iwaicb53c622007-08-10 17:21:45 +020014465#ifdef CONFIG_SND_HDA_POWER_SAVE
14466static struct hda_amp_list alc861_loopbacks[] = {
14467 { 0x15, HDA_INPUT, 0 },
14468 { 0x15, HDA_INPUT, 1 },
14469 { 0x15, HDA_INPUT, 2 },
14470 { 0x15, HDA_INPUT, 3 },
14471 { } /* end */
14472};
14473#endif
14474
Kailang Yangdf694da2005-12-05 19:42:22 +010014475
14476/*
14477 * configuration and preset
14478 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014479static const char *alc861_models[ALC861_MODEL_LAST] = {
14480 [ALC861_3ST] = "3stack",
14481 [ALC660_3ST] = "3stack-660",
14482 [ALC861_3ST_DIG] = "3stack-dig",
14483 [ALC861_6ST_DIG] = "6stack-dig",
14484 [ALC861_UNIWILL_M31] = "uniwill-m31",
14485 [ALC861_TOSHIBA] = "toshiba",
14486 [ALC861_ASUS] = "asus",
14487 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14488 [ALC861_AUTO] = "auto",
14489};
14490
14491static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014492 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014493 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14494 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14495 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014496 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014497 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014498 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014499 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14500 * Any other models that need this preset?
14501 */
14502 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014503 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14504 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014505 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14506 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14507 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14508 /* FIXME: the below seems conflict */
14509 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14510 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14511 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014512 {}
14513};
14514
14515static struct alc_config_preset alc861_presets[] = {
14516 [ALC861_3ST] = {
14517 .mixers = { alc861_3ST_mixer },
14518 .init_verbs = { alc861_threestack_init_verbs },
14519 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14520 .dac_nids = alc861_dac_nids,
14521 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14522 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014523 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014524 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14525 .adc_nids = alc861_adc_nids,
14526 .input_mux = &alc861_capture_source,
14527 },
14528 [ALC861_3ST_DIG] = {
14529 .mixers = { alc861_base_mixer },
14530 .init_verbs = { alc861_threestack_init_verbs },
14531 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14532 .dac_nids = alc861_dac_nids,
14533 .dig_out_nid = ALC861_DIGOUT_NID,
14534 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14535 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014536 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014537 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14538 .adc_nids = alc861_adc_nids,
14539 .input_mux = &alc861_capture_source,
14540 },
14541 [ALC861_6ST_DIG] = {
14542 .mixers = { alc861_base_mixer },
14543 .init_verbs = { alc861_base_init_verbs },
14544 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14545 .dac_nids = alc861_dac_nids,
14546 .dig_out_nid = ALC861_DIGOUT_NID,
14547 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14548 .channel_mode = alc861_8ch_modes,
14549 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14550 .adc_nids = alc861_adc_nids,
14551 .input_mux = &alc861_capture_source,
14552 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014553 [ALC660_3ST] = {
14554 .mixers = { alc861_3ST_mixer },
14555 .init_verbs = { alc861_threestack_init_verbs },
14556 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14557 .dac_nids = alc660_dac_nids,
14558 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14559 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014560 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014561 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14562 .adc_nids = alc861_adc_nids,
14563 .input_mux = &alc861_capture_source,
14564 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014565 [ALC861_UNIWILL_M31] = {
14566 .mixers = { alc861_uniwill_m31_mixer },
14567 .init_verbs = { alc861_uniwill_m31_init_verbs },
14568 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14569 .dac_nids = alc861_dac_nids,
14570 .dig_out_nid = ALC861_DIGOUT_NID,
14571 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14572 .channel_mode = alc861_uniwill_m31_modes,
14573 .need_dac_fix = 1,
14574 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14575 .adc_nids = alc861_adc_nids,
14576 .input_mux = &alc861_capture_source,
14577 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014578 [ALC861_TOSHIBA] = {
14579 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014580 .init_verbs = { alc861_base_init_verbs,
14581 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014582 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14583 .dac_nids = alc861_dac_nids,
14584 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14585 .channel_mode = alc883_3ST_2ch_modes,
14586 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14587 .adc_nids = alc861_adc_nids,
14588 .input_mux = &alc861_capture_source,
14589 .unsol_event = alc861_toshiba_unsol_event,
14590 .init_hook = alc861_toshiba_automute,
14591 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014592 [ALC861_ASUS] = {
14593 .mixers = { alc861_asus_mixer },
14594 .init_verbs = { alc861_asus_init_verbs },
14595 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14596 .dac_nids = alc861_dac_nids,
14597 .dig_out_nid = ALC861_DIGOUT_NID,
14598 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14599 .channel_mode = alc861_asus_modes,
14600 .need_dac_fix = 1,
14601 .hp_nid = 0x06,
14602 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14603 .adc_nids = alc861_adc_nids,
14604 .input_mux = &alc861_capture_source,
14605 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014606 [ALC861_ASUS_LAPTOP] = {
14607 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14608 .init_verbs = { alc861_asus_init_verbs,
14609 alc861_asus_laptop_init_verbs },
14610 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14611 .dac_nids = alc861_dac_nids,
14612 .dig_out_nid = ALC861_DIGOUT_NID,
14613 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14614 .channel_mode = alc883_3ST_2ch_modes,
14615 .need_dac_fix = 1,
14616 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14617 .adc_nids = alc861_adc_nids,
14618 .input_mux = &alc861_capture_source,
14619 },
14620};
Kailang Yangdf694da2005-12-05 19:42:22 +010014621
14622
14623static int patch_alc861(struct hda_codec *codec)
14624{
14625 struct alc_spec *spec;
14626 int board_config;
14627 int err;
14628
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014629 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014630 if (spec == NULL)
14631 return -ENOMEM;
14632
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014633 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014634
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014635 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14636 alc861_models,
14637 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014638
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014639 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014640 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14641 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014642 board_config = ALC861_AUTO;
14643 }
14644
14645 if (board_config == ALC861_AUTO) {
14646 /* automatic parse from the BIOS config */
14647 err = alc861_parse_auto_config(codec);
14648 if (err < 0) {
14649 alc_free(codec);
14650 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014651 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014652 printk(KERN_INFO
14653 "hda_codec: Cannot set up configuration "
14654 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014655 board_config = ALC861_3ST_DIG;
14656 }
14657 }
14658
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014659 err = snd_hda_attach_beep_device(codec, 0x23);
14660 if (err < 0) {
14661 alc_free(codec);
14662 return err;
14663 }
14664
Kailang Yangdf694da2005-12-05 19:42:22 +010014665 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014666 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014667
Kailang Yangdf694da2005-12-05 19:42:22 +010014668 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14669 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14670
Kailang Yangdf694da2005-12-05 19:42:22 +010014671 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14672 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14673
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014674 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14675
Takashi Iwai2134ea42008-01-10 16:53:55 +010014676 spec->vmaster_nid = 0x03;
14677
Kailang Yangdf694da2005-12-05 19:42:22 +010014678 codec->patch_ops = alc_patch_ops;
14679 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014680 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014681#ifdef CONFIG_SND_HDA_POWER_SAVE
14682 if (!spec->loopback.amplist)
14683 spec->loopback.amplist = alc861_loopbacks;
14684#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014685 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014686
Kailang Yangdf694da2005-12-05 19:42:22 +010014687 return 0;
14688}
14689
14690/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014691 * ALC861-VD support
14692 *
14693 * Based on ALC882
14694 *
14695 * In addition, an independent DAC
14696 */
14697#define ALC861VD_DIGOUT_NID 0x06
14698
14699static hda_nid_t alc861vd_dac_nids[4] = {
14700 /* front, surr, clfe, side surr */
14701 0x02, 0x03, 0x04, 0x05
14702};
14703
14704/* dac_nids for ALC660vd are in a different order - according to
14705 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014706 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014707 * of ALC660vd codecs, but for now there is only 3stack mixer
14708 * - and it is the same as in 861vd.
14709 * adc_nids in ALC660vd are (is) the same as in 861vd
14710 */
14711static hda_nid_t alc660vd_dac_nids[3] = {
14712 /* front, rear, clfe, rear_surr */
14713 0x02, 0x04, 0x03
14714};
14715
14716static hda_nid_t alc861vd_adc_nids[1] = {
14717 /* ADC0 */
14718 0x09,
14719};
14720
Takashi Iwaie1406342008-02-11 18:32:32 +010014721static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14722
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014723/* input MUX */
14724/* FIXME: should be a matrix-type input source selection */
14725static struct hda_input_mux alc861vd_capture_source = {
14726 .num_items = 4,
14727 .items = {
14728 { "Mic", 0x0 },
14729 { "Front Mic", 0x1 },
14730 { "Line", 0x2 },
14731 { "CD", 0x4 },
14732 },
14733};
14734
Kailang Yang272a5272007-05-14 11:00:38 +020014735static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014736 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014737 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014738 { "Ext Mic", 0x0 },
14739 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014740 },
14741};
14742
Kailang Yangd1a991a2007-08-15 16:21:59 +020014743static struct hda_input_mux alc861vd_hp_capture_source = {
14744 .num_items = 2,
14745 .items = {
14746 { "Front Mic", 0x0 },
14747 { "ATAPI Mic", 0x1 },
14748 },
14749};
14750
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014751/*
14752 * 2ch mode
14753 */
14754static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14755 { 2, NULL }
14756};
14757
14758/*
14759 * 6ch mode
14760 */
14761static struct hda_verb alc861vd_6stack_ch6_init[] = {
14762 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14763 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14764 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14765 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14766 { } /* end */
14767};
14768
14769/*
14770 * 8ch mode
14771 */
14772static struct hda_verb alc861vd_6stack_ch8_init[] = {
14773 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14774 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14775 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14776 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14777 { } /* end */
14778};
14779
14780static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14781 { 6, alc861vd_6stack_ch6_init },
14782 { 8, alc861vd_6stack_ch8_init },
14783};
14784
14785static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14786 {
14787 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14788 .name = "Channel Mode",
14789 .info = alc_ch_mode_info,
14790 .get = alc_ch_mode_get,
14791 .put = alc_ch_mode_put,
14792 },
14793 { } /* end */
14794};
14795
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014796/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14797 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14798 */
14799static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14800 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14801 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14802
14803 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14804 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14805
14806 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14807 HDA_OUTPUT),
14808 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14809 HDA_OUTPUT),
14810 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14811 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14812
14813 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14814 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14815
14816 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14817
14818 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14821
14822 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14823 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14824 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14825
14826 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14827 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14828
14829 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14830 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14831
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014832 { } /* end */
14833};
14834
14835static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14836 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14837 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14838
14839 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14840
14841 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14842 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14843 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14844
14845 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14846 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14847 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14848
14849 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14850 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14851
14852 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14853 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14854
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014855 { } /* end */
14856};
14857
Kailang Yangbdd148a2007-05-08 15:19:08 +020014858static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14859 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14860 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14861 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14862
14863 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14864
14865 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14866 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14867 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14868
14869 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14870 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14871 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14872
14873 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14874 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14875
14876 { } /* end */
14877};
14878
Tobin Davisb419f342008-03-07 11:57:51 +010014879/* Pin assignment: Speaker=0x14, HP = 0x15,
14880 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014881 */
14882static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014883 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14884 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014885 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14886 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014887 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14888 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14889 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14890 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14891 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14892 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014893 { } /* end */
14894};
14895
Kailang Yangd1a991a2007-08-15 16:21:59 +020014896/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14897 * Front Mic=0x18, ATAPI Mic = 0x19,
14898 */
14899static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14900 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14901 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14902 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14903 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14904 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14905 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14906 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14907 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014908
Kailang Yangd1a991a2007-08-15 16:21:59 +020014909 { } /* end */
14910};
14911
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014912/*
14913 * generic initialization of ADC, input mixers and output mixers
14914 */
14915static struct hda_verb alc861vd_volume_init_verbs[] = {
14916 /*
14917 * Unmute ADC0 and set the default input to mic-in
14918 */
14919 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14920 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14921
14922 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14923 * the analog-loopback mixer widget
14924 */
14925 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14927 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14928 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14929 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14930 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014931
14932 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014933 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14934 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014936 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014937
14938 /*
14939 * Set up output mixers (0x02 - 0x05)
14940 */
14941 /* set vol=0 to output mixers */
14942 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14943 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14944 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14945 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14946
14947 /* set up input amps for analog loopback */
14948 /* Amp Indices: DAC = 0, mixer = 1 */
14949 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14950 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14951 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14952 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14953 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14954 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14955 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14956 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14957
14958 { }
14959};
14960
14961/*
14962 * 3-stack pin configuration:
14963 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14964 */
14965static struct hda_verb alc861vd_3stack_init_verbs[] = {
14966 /*
14967 * Set pin mode and muting
14968 */
14969 /* set front pin widgets 0x14 for output */
14970 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14971 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14972 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14973
14974 /* Mic (rear) pin: input vref at 80% */
14975 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14976 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14977 /* Front Mic pin: input vref at 80% */
14978 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14979 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14980 /* Line In pin: input */
14981 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14982 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14983 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14984 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14985 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14986 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14987 /* CD pin widget for input */
14988 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14989
14990 { }
14991};
14992
14993/*
14994 * 6-stack pin configuration:
14995 */
14996static struct hda_verb alc861vd_6stack_init_verbs[] = {
14997 /*
14998 * Set pin mode and muting
14999 */
15000 /* set front pin widgets 0x14 for output */
15001 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15002 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15003 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15004
15005 /* Rear Pin: output 1 (0x0d) */
15006 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15007 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15008 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15009 /* CLFE Pin: output 2 (0x0e) */
15010 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15011 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15012 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15013 /* Side Pin: output 3 (0x0f) */
15014 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15015 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15016 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15017
15018 /* Mic (rear) pin: input vref at 80% */
15019 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15020 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15021 /* Front Mic pin: input vref at 80% */
15022 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15023 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15024 /* Line In pin: input */
15025 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15026 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15027 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15028 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15029 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15030 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15031 /* CD pin widget for input */
15032 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15033
15034 { }
15035};
15036
Kailang Yangbdd148a2007-05-08 15:19:08 +020015037static struct hda_verb alc861vd_eapd_verbs[] = {
15038 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15039 { }
15040};
15041
Kailang Yangf9423e72008-05-27 12:32:25 +020015042static struct hda_verb alc660vd_eapd_verbs[] = {
15043 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15044 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15045 { }
15046};
15047
Kailang Yangbdd148a2007-05-08 15:19:08 +020015048static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15049 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15050 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15051 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15052 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015053 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015054 {}
15055};
15056
Kailang Yangbdd148a2007-05-08 15:19:08 +020015057static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15058{
15059 unsigned int present;
15060 unsigned char bits;
15061
15062 present = snd_hda_codec_read(codec, 0x18, 0,
15063 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015064 bits = present ? HDA_AMP_MUTE : 0;
15065 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15066 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015067}
15068
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015069static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015070{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015071 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015072 spec->autocfg.hp_pins[0] = 0x1b;
15073 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015074}
15075
15076static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15077{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015078 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015079 alc861vd_lenovo_mic_automute(codec);
15080}
15081
15082static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15083 unsigned int res)
15084{
15085 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015086 case ALC880_MIC_EVENT:
15087 alc861vd_lenovo_mic_automute(codec);
15088 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015089 default:
15090 alc_automute_amp_unsol_event(codec, res);
15091 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015092 }
15093}
15094
Kailang Yang272a5272007-05-14 11:00:38 +020015095static struct hda_verb alc861vd_dallas_verbs[] = {
15096 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15097 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15098 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15099 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15100
15101 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15102 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15103 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15104 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15105 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15106 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15107 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15108 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015109
Kailang Yang272a5272007-05-14 11:00:38 +020015110 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15111 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15112 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15113 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15114 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15115 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15116 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15117 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15118
15119 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15120 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15121 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15122 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15123 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15124 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15125 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15126 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15127
15128 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15129 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15130 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15132
15133 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015134 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015135 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15136
15137 { } /* end */
15138};
15139
15140/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015141static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015142{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015143 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015144
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015145 spec->autocfg.hp_pins[0] = 0x15;
15146 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015147}
15148
Takashi Iwaicb53c622007-08-10 17:21:45 +020015149#ifdef CONFIG_SND_HDA_POWER_SAVE
15150#define alc861vd_loopbacks alc880_loopbacks
15151#endif
15152
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015153/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015154#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15155#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15156#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15157#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15158
15159/*
15160 * configuration and preset
15161 */
15162static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15163 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015164 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015165 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015166 [ALC861VD_3ST] = "3stack",
15167 [ALC861VD_3ST_DIG] = "3stack-digout",
15168 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015169 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015170 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015171 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015172 [ALC861VD_AUTO] = "auto",
15173};
15174
15175static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015176 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15177 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015178 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015179 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015180 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015181 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015182 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015183 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015184 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015185 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015186 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015187 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015188 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015189 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015190 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015191 {}
15192};
15193
15194static struct alc_config_preset alc861vd_presets[] = {
15195 [ALC660VD_3ST] = {
15196 .mixers = { alc861vd_3st_mixer },
15197 .init_verbs = { alc861vd_volume_init_verbs,
15198 alc861vd_3stack_init_verbs },
15199 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15200 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015201 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15202 .channel_mode = alc861vd_3stack_2ch_modes,
15203 .input_mux = &alc861vd_capture_source,
15204 },
Mike Crash6963f842007-06-25 12:12:51 +020015205 [ALC660VD_3ST_DIG] = {
15206 .mixers = { alc861vd_3st_mixer },
15207 .init_verbs = { alc861vd_volume_init_verbs,
15208 alc861vd_3stack_init_verbs },
15209 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15210 .dac_nids = alc660vd_dac_nids,
15211 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015212 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15213 .channel_mode = alc861vd_3stack_2ch_modes,
15214 .input_mux = &alc861vd_capture_source,
15215 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015216 [ALC861VD_3ST] = {
15217 .mixers = { alc861vd_3st_mixer },
15218 .init_verbs = { alc861vd_volume_init_verbs,
15219 alc861vd_3stack_init_verbs },
15220 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15221 .dac_nids = alc861vd_dac_nids,
15222 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15223 .channel_mode = alc861vd_3stack_2ch_modes,
15224 .input_mux = &alc861vd_capture_source,
15225 },
15226 [ALC861VD_3ST_DIG] = {
15227 .mixers = { alc861vd_3st_mixer },
15228 .init_verbs = { alc861vd_volume_init_verbs,
15229 alc861vd_3stack_init_verbs },
15230 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15231 .dac_nids = alc861vd_dac_nids,
15232 .dig_out_nid = ALC861VD_DIGOUT_NID,
15233 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15234 .channel_mode = alc861vd_3stack_2ch_modes,
15235 .input_mux = &alc861vd_capture_source,
15236 },
15237 [ALC861VD_6ST_DIG] = {
15238 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15239 .init_verbs = { alc861vd_volume_init_verbs,
15240 alc861vd_6stack_init_verbs },
15241 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15242 .dac_nids = alc861vd_dac_nids,
15243 .dig_out_nid = ALC861VD_DIGOUT_NID,
15244 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15245 .channel_mode = alc861vd_6stack_modes,
15246 .input_mux = &alc861vd_capture_source,
15247 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015248 [ALC861VD_LENOVO] = {
15249 .mixers = { alc861vd_lenovo_mixer },
15250 .init_verbs = { alc861vd_volume_init_verbs,
15251 alc861vd_3stack_init_verbs,
15252 alc861vd_eapd_verbs,
15253 alc861vd_lenovo_unsol_verbs },
15254 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15255 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015256 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15257 .channel_mode = alc861vd_3stack_2ch_modes,
15258 .input_mux = &alc861vd_capture_source,
15259 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015260 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015261 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015262 },
Kailang Yang272a5272007-05-14 11:00:38 +020015263 [ALC861VD_DALLAS] = {
15264 .mixers = { alc861vd_dallas_mixer },
15265 .init_verbs = { alc861vd_dallas_verbs },
15266 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15267 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015268 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15269 .channel_mode = alc861vd_3stack_2ch_modes,
15270 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015271 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015272 .setup = alc861vd_dallas_setup,
15273 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015274 },
15275 [ALC861VD_HP] = {
15276 .mixers = { alc861vd_hp_mixer },
15277 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15278 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15279 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015280 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015281 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15282 .channel_mode = alc861vd_3stack_2ch_modes,
15283 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015284 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015285 .setup = alc861vd_dallas_setup,
15286 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015287 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015288 [ALC660VD_ASUS_V1S] = {
15289 .mixers = { alc861vd_lenovo_mixer },
15290 .init_verbs = { alc861vd_volume_init_verbs,
15291 alc861vd_3stack_init_verbs,
15292 alc861vd_eapd_verbs,
15293 alc861vd_lenovo_unsol_verbs },
15294 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15295 .dac_nids = alc660vd_dac_nids,
15296 .dig_out_nid = ALC861VD_DIGOUT_NID,
15297 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15298 .channel_mode = alc861vd_3stack_2ch_modes,
15299 .input_mux = &alc861vd_capture_source,
15300 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015301 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015302 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015303 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015304};
15305
15306/*
15307 * BIOS auto configuration
15308 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015309static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15310 const struct auto_pin_cfg *cfg)
15311{
15312 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15313}
15314
15315
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015316static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15317 hda_nid_t nid, int pin_type, int dac_idx)
15318{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015319 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015320}
15321
15322static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15323{
15324 struct alc_spec *spec = codec->spec;
15325 int i;
15326
15327 for (i = 0; i <= HDA_SIDE; i++) {
15328 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015329 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015330 if (nid)
15331 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015332 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015333 }
15334}
15335
15336
15337static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15338{
15339 struct alc_spec *spec = codec->spec;
15340 hda_nid_t pin;
15341
15342 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015343 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015344 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015345 pin = spec->autocfg.speaker_pins[0];
15346 if (pin)
15347 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015348}
15349
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015350#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15351
15352static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15353{
15354 struct alc_spec *spec = codec->spec;
15355 int i;
15356
15357 for (i = 0; i < AUTO_PIN_LAST; i++) {
15358 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015359 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015360 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015361 if (nid != ALC861VD_PIN_CD_NID &&
15362 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015363 snd_hda_codec_write(codec, nid, 0,
15364 AC_VERB_SET_AMP_GAIN_MUTE,
15365 AMP_OUT_MUTE);
15366 }
15367 }
15368}
15369
Takashi Iwaif511b012008-08-15 16:46:42 +020015370#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15371
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015372#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15373#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15374
15375/* add playback controls from the parsed DAC table */
15376/* Based on ALC880 version. But ALC861VD has separate,
15377 * different NIDs for mute/unmute switch and volume control */
15378static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15379 const struct auto_pin_cfg *cfg)
15380{
15381 char name[32];
15382 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15383 hda_nid_t nid_v, nid_s;
15384 int i, err;
15385
15386 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015387 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015388 continue;
15389 nid_v = alc861vd_idx_to_mixer_vol(
15390 alc880_dac_to_idx(
15391 spec->multiout.dac_nids[i]));
15392 nid_s = alc861vd_idx_to_mixer_switch(
15393 alc880_dac_to_idx(
15394 spec->multiout.dac_nids[i]));
15395
15396 if (i == 2) {
15397 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015398 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15399 "Center Playback Volume",
15400 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15401 HDA_OUTPUT));
15402 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015403 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015404 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15405 "LFE Playback Volume",
15406 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15407 HDA_OUTPUT));
15408 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015409 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015410 err = add_control(spec, ALC_CTL_BIND_MUTE,
15411 "Center Playback Switch",
15412 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15413 HDA_INPUT));
15414 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015415 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015416 err = add_control(spec, ALC_CTL_BIND_MUTE,
15417 "LFE Playback Switch",
15418 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15419 HDA_INPUT));
15420 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015421 return err;
15422 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015423 const char *pfx;
15424 if (cfg->line_outs == 1 &&
15425 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15426 if (!cfg->hp_pins)
15427 pfx = "Speaker";
15428 else
15429 pfx = "PCM";
15430 } else
15431 pfx = chname[i];
15432 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015433 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15434 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15435 HDA_OUTPUT));
15436 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015437 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015438 if (cfg->line_outs == 1 &&
15439 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15440 pfx = "Speaker";
15441 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015442 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015443 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015444 HDA_INPUT));
15445 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015446 return err;
15447 }
15448 }
15449 return 0;
15450}
15451
15452/* add playback controls for speaker and HP outputs */
15453/* Based on ALC880 version. But ALC861VD has separate,
15454 * different NIDs for mute/unmute switch and volume control */
15455static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15456 hda_nid_t pin, const char *pfx)
15457{
15458 hda_nid_t nid_v, nid_s;
15459 int err;
15460 char name[32];
15461
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015462 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015463 return 0;
15464
15465 if (alc880_is_fixed_pin(pin)) {
15466 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15467 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015468 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015469 spec->multiout.hp_nid = nid_v;
15470 else
15471 spec->multiout.extra_out_nid[0] = nid_v;
15472 /* control HP volume/switch on the output mixer amp */
15473 nid_v = alc861vd_idx_to_mixer_vol(
15474 alc880_fixed_pin_idx(pin));
15475 nid_s = alc861vd_idx_to_mixer_switch(
15476 alc880_fixed_pin_idx(pin));
15477
15478 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015479 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15480 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15481 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015482 return err;
15483 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015484 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15485 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15486 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015487 return err;
15488 } else if (alc880_is_multi_pin(pin)) {
15489 /* set manual connection */
15490 /* we have only a switch on HP-out PIN */
15491 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015492 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15493 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15494 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015495 return err;
15496 }
15497 return 0;
15498}
15499
15500/* parse the BIOS configuration and set up the alc_spec
15501 * return 1 if successful, 0 if the proper config is not found,
15502 * or a negative error code
15503 * Based on ALC880 version - had to change it to override
15504 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15505static int alc861vd_parse_auto_config(struct hda_codec *codec)
15506{
15507 struct alc_spec *spec = codec->spec;
15508 int err;
15509 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15510
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015511 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15512 alc861vd_ignore);
15513 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015514 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015515 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015516 return 0; /* can't find valid BIOS pin config */
15517
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015518 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15519 if (err < 0)
15520 return err;
15521 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15522 if (err < 0)
15523 return err;
15524 err = alc861vd_auto_create_extra_out(spec,
15525 spec->autocfg.speaker_pins[0],
15526 "Speaker");
15527 if (err < 0)
15528 return err;
15529 err = alc861vd_auto_create_extra_out(spec,
15530 spec->autocfg.hp_pins[0],
15531 "Headphone");
15532 if (err < 0)
15533 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015534 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015535 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015536 return err;
15537
15538 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15539
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015540 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015541 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15542
Takashi Iwai603c4012008-07-30 15:01:44 +020015543 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015544 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015545
Takashi Iwaid88897e2008-10-31 15:01:37 +010015546 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015547
15548 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015549 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015550
Takashi Iwai776e1842007-08-29 15:07:11 +020015551 err = alc_auto_add_mic_boost(codec);
15552 if (err < 0)
15553 return err;
15554
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015555 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15556
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015557 return 1;
15558}
15559
15560/* additional initialization for auto-configuration model */
15561static void alc861vd_auto_init(struct hda_codec *codec)
15562{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015563 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015564 alc861vd_auto_init_multi_out(codec);
15565 alc861vd_auto_init_hp_out(codec);
15566 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015567 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015568 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015569 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015570}
15571
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015572enum {
15573 ALC660VD_FIX_ASUS_GPIO1
15574};
15575
15576/* reset GPIO1 */
15577static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
15578 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
15579 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
15580 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
15581 { }
15582};
15583
15584static const struct alc_fixup alc861vd_fixups[] = {
15585 [ALC660VD_FIX_ASUS_GPIO1] = {
15586 .verbs = alc660vd_fix_asus_gpio1_verbs,
15587 },
15588};
15589
15590static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
15591 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
15592 {}
15593};
15594
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015595static int patch_alc861vd(struct hda_codec *codec)
15596{
15597 struct alc_spec *spec;
15598 int err, board_config;
15599
15600 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15601 if (spec == NULL)
15602 return -ENOMEM;
15603
15604 codec->spec = spec;
15605
15606 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15607 alc861vd_models,
15608 alc861vd_cfg_tbl);
15609
15610 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015611 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15612 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015613 board_config = ALC861VD_AUTO;
15614 }
15615
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015616 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
15617
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015618 if (board_config == ALC861VD_AUTO) {
15619 /* automatic parse from the BIOS config */
15620 err = alc861vd_parse_auto_config(codec);
15621 if (err < 0) {
15622 alc_free(codec);
15623 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015624 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015625 printk(KERN_INFO
15626 "hda_codec: Cannot set up configuration "
15627 "from BIOS. Using base mode...\n");
15628 board_config = ALC861VD_3ST;
15629 }
15630 }
15631
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015632 err = snd_hda_attach_beep_device(codec, 0x23);
15633 if (err < 0) {
15634 alc_free(codec);
15635 return err;
15636 }
15637
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015638 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015639 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015640
Kailang Yang2f893282008-05-27 12:14:47 +020015641 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015642 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015643 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015644 }
15645
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015646 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15647 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15648
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015649 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15650 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15651
Takashi Iwaidd704692009-08-11 08:45:11 +020015652 if (!spec->adc_nids) {
15653 spec->adc_nids = alc861vd_adc_nids;
15654 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15655 }
15656 if (!spec->capsrc_nids)
15657 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015658
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015659 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015660 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015661
Takashi Iwai2134ea42008-01-10 16:53:55 +010015662 spec->vmaster_nid = 0x02;
15663
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015664 codec->patch_ops = alc_patch_ops;
15665
15666 if (board_config == ALC861VD_AUTO)
15667 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015668#ifdef CONFIG_SND_HDA_POWER_SAVE
15669 if (!spec->loopback.amplist)
15670 spec->loopback.amplist = alc861vd_loopbacks;
15671#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015672 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015673
15674 return 0;
15675}
15676
15677/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015678 * ALC662 support
15679 *
15680 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15681 * configuration. Each pin widget can choose any input DACs and a mixer.
15682 * Each ADC is connected from a mixer of all inputs. This makes possible
15683 * 6-channel independent captures.
15684 *
15685 * In addition, an independent DAC for the multi-playback (not used in this
15686 * driver yet).
15687 */
15688#define ALC662_DIGOUT_NID 0x06
15689#define ALC662_DIGIN_NID 0x0a
15690
15691static hda_nid_t alc662_dac_nids[4] = {
15692 /* front, rear, clfe, rear_surr */
15693 0x02, 0x03, 0x04
15694};
15695
Kailang Yang622e84c2009-04-21 07:39:04 +020015696static hda_nid_t alc272_dac_nids[2] = {
15697 0x02, 0x03
15698};
15699
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015700static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015701 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015702 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015703};
Takashi Iwaie1406342008-02-11 18:32:32 +010015704
Kailang Yang622e84c2009-04-21 07:39:04 +020015705static hda_nid_t alc272_adc_nids[1] = {
15706 /* ADC1-2 */
15707 0x08,
15708};
15709
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015710static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015711static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15712
Takashi Iwaie1406342008-02-11 18:32:32 +010015713
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015714/* input MUX */
15715/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015716static struct hda_input_mux alc662_capture_source = {
15717 .num_items = 4,
15718 .items = {
15719 { "Mic", 0x0 },
15720 { "Front Mic", 0x1 },
15721 { "Line", 0x2 },
15722 { "CD", 0x4 },
15723 },
15724};
15725
15726static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15727 .num_items = 2,
15728 .items = {
15729 { "Mic", 0x1 },
15730 { "Line", 0x2 },
15731 },
15732};
Kailang Yang291702f2007-10-16 14:28:03 +020015733
Kailang Yang6dda9f42008-05-27 12:05:31 +020015734static struct hda_input_mux alc663_capture_source = {
15735 .num_items = 3,
15736 .items = {
15737 { "Mic", 0x0 },
15738 { "Front Mic", 0x1 },
15739 { "Line", 0x2 },
15740 },
15741};
15742
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015743#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015744static struct hda_input_mux alc272_nc10_capture_source = {
15745 .num_items = 16,
15746 .items = {
15747 { "Autoselect Mic", 0x0 },
15748 { "Internal Mic", 0x1 },
15749 { "In-0x02", 0x2 },
15750 { "In-0x03", 0x3 },
15751 { "In-0x04", 0x4 },
15752 { "In-0x05", 0x5 },
15753 { "In-0x06", 0x6 },
15754 { "In-0x07", 0x7 },
15755 { "In-0x08", 0x8 },
15756 { "In-0x09", 0x9 },
15757 { "In-0x0a", 0x0a },
15758 { "In-0x0b", 0x0b },
15759 { "In-0x0c", 0x0c },
15760 { "In-0x0d", 0x0d },
15761 { "In-0x0e", 0x0e },
15762 { "In-0x0f", 0x0f },
15763 },
15764};
15765#endif
15766
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015767/*
15768 * 2ch mode
15769 */
15770static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15771 { 2, NULL }
15772};
15773
15774/*
15775 * 2ch mode
15776 */
15777static struct hda_verb alc662_3ST_ch2_init[] = {
15778 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15779 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15780 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15781 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15782 { } /* end */
15783};
15784
15785/*
15786 * 6ch mode
15787 */
15788static struct hda_verb alc662_3ST_ch6_init[] = {
15789 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15790 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15791 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15792 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15793 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15794 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15795 { } /* end */
15796};
15797
15798static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15799 { 2, alc662_3ST_ch2_init },
15800 { 6, alc662_3ST_ch6_init },
15801};
15802
15803/*
15804 * 2ch mode
15805 */
15806static struct hda_verb alc662_sixstack_ch6_init[] = {
15807 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15808 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15809 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15810 { } /* end */
15811};
15812
15813/*
15814 * 6ch mode
15815 */
15816static struct hda_verb alc662_sixstack_ch8_init[] = {
15817 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15818 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15819 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15820 { } /* end */
15821};
15822
15823static struct hda_channel_mode alc662_5stack_modes[2] = {
15824 { 2, alc662_sixstack_ch6_init },
15825 { 6, alc662_sixstack_ch8_init },
15826};
15827
15828/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15829 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15830 */
15831
15832static struct snd_kcontrol_new alc662_base_mixer[] = {
15833 /* output mixer control */
15834 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015835 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015836 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015837 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015838 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15839 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015840 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15841 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15843
15844 /*Input mixer control */
15845 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15846 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15847 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15848 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15849 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15850 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15851 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15852 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015853 { } /* end */
15854};
15855
15856static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15857 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015858 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15860 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15861 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15862 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15863 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15865 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15866 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15867 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015868 { } /* end */
15869};
15870
15871static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15872 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015873 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015874 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015875 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015876 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15877 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015878 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15879 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015880 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15881 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15882 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15883 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15884 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15885 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15886 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15887 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15888 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015889 { } /* end */
15890};
15891
15892static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15893 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15894 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015895 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15896 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15898 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15899 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15900 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15901 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015902 { } /* end */
15903};
15904
Kailang Yang291702f2007-10-16 14:28:03 +020015905static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015906 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15907 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015908
15909 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15910 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15911 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15912
15913 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15914 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15915 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15916 { } /* end */
15917};
15918
Kailang Yang8c427222008-01-10 13:03:59 +010015919static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015920 ALC262_HIPPO_MASTER_SWITCH,
15921 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015922 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015923 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15924 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015925 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15926 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15927 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15928 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15929 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15930 { } /* end */
15931};
15932
Kailang Yangf1d4e282008-08-26 14:03:29 +020015933static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15934 .ops = &snd_hda_bind_vol,
15935 .values = {
15936 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15937 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15938 0
15939 },
15940};
15941
15942static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15943 .ops = &snd_hda_bind_sw,
15944 .values = {
15945 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15946 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15947 0
15948 },
15949};
15950
Kailang Yang6dda9f42008-05-27 12:05:31 +020015951static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015952 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15953 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15956 { } /* end */
15957};
15958
15959static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15960 .ops = &snd_hda_bind_sw,
15961 .values = {
15962 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15963 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15964 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15965 0
15966 },
15967};
15968
15969static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15970 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15971 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15974 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15975 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15976
15977 { } /* end */
15978};
15979
15980static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15981 .ops = &snd_hda_bind_sw,
15982 .values = {
15983 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15984 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15985 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15986 0
15987 },
15988};
15989
15990static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15991 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15992 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15995 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15996 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15997 { } /* end */
15998};
15999
16000static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016001 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16002 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016003 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16004 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16005 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16006 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16007 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16008 { } /* end */
16009};
16010
16011static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16012 .ops = &snd_hda_bind_vol,
16013 .values = {
16014 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16015 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16016 0
16017 },
16018};
16019
16020static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16021 .ops = &snd_hda_bind_sw,
16022 .values = {
16023 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16024 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16025 0
16026 },
16027};
16028
16029static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16030 HDA_BIND_VOL("Master Playback Volume",
16031 &alc663_asus_two_bind_master_vol),
16032 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16033 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016034 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16035 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16036 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016037 { } /* end */
16038};
16039
16040static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16041 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16042 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16043 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16044 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16045 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16046 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016047 { } /* end */
16048};
16049
16050static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16051 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16052 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16053 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16054 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16055 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16056
16057 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16058 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16059 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16060 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16061 { } /* end */
16062};
16063
16064static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16065 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16066 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16067 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16068
16069 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16070 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16071 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16072 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16073 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16074 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16075 { } /* end */
16076};
16077
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016078static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16079 {
16080 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16081 .name = "Channel Mode",
16082 .info = alc_ch_mode_info,
16083 .get = alc_ch_mode_get,
16084 .put = alc_ch_mode_put,
16085 },
16086 { } /* end */
16087};
16088
16089static struct hda_verb alc662_init_verbs[] = {
16090 /* ADC: mute amp left and right */
16091 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16092 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16093 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16094
Takashi Iwaicb53c622007-08-10 17:21:45 +020016095 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16096 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016100
Kailang Yangb60dd392007-09-20 12:50:29 +020016101 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16102 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16103 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16104 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16105 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16106 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016107
16108 /* Front Pin: output 0 (0x0c) */
16109 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16110 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16111
16112 /* Rear Pin: output 1 (0x0d) */
16113 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16114 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16115
16116 /* CLFE Pin: output 2 (0x0e) */
16117 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16118 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16119
16120 /* Mic (rear) pin: input vref at 80% */
16121 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16122 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16123 /* Front Mic pin: input vref at 80% */
16124 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16125 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16126 /* Line In pin: input */
16127 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16128 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16129 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16130 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16131 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16132 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16133 /* CD pin widget for input */
16134 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16135
16136 /* FIXME: use matrix-type input source selection */
16137 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16138 /* Input mixer */
16139 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016140 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016141
16142 /* always trun on EAPD */
16143 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16144 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16145
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016146 { }
16147};
16148
16149static struct hda_verb alc662_sue_init_verbs[] = {
16150 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16151 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016152 {}
16153};
16154
16155static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16156 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16157 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16158 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016159};
16160
Kailang Yang8c427222008-01-10 13:03:59 +010016161/* Set Unsolicited Event*/
16162static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16163 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16164 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16165 {}
16166};
16167
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016168/*
16169 * generic initialization of ADC, input mixers and output mixers
16170 */
16171static struct hda_verb alc662_auto_init_verbs[] = {
16172 /*
16173 * Unmute ADC and set the default input to mic-in
16174 */
16175 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16176 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16177
16178 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16179 * mixer widget
16180 * Note: PASD motherboards uses the Line In 2 as the input for front
16181 * panel mic (mic 2)
16182 */
16183 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016184 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16185 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16186 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16187 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16188 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016189
16190 /*
16191 * Set up output mixers (0x0c - 0x0f)
16192 */
16193 /* set vol=0 to output mixers */
16194 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16195 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16196 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16197
16198 /* set up input amps for analog loopback */
16199 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016200 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16201 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16202 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16203 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16204 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16205 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016206
16207
16208 /* FIXME: use matrix-type input source selection */
16209 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16210 /* Input mixer */
16211 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016212 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016213 { }
16214};
16215
Takashi Iwai24fb9172008-09-02 14:48:20 +020016216/* additional verbs for ALC663 */
16217static struct hda_verb alc663_auto_init_verbs[] = {
16218 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16219 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16220 { }
16221};
16222
Kailang Yang6dda9f42008-05-27 12:05:31 +020016223static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016224 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16225 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016226 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16227 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016228 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16229 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16230 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016231 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16232 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16233 {}
16234};
16235
Kailang Yangf1d4e282008-08-26 14:03:29 +020016236static struct hda_verb alc663_21jd_amic_init_verbs[] = {
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, 0x01}, /* Headphone */
16240 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16241 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16242 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16243 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16244 {}
16245};
16246
16247static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16248 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16249 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16250 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16251 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16252 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16253 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16254 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16255 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16256 {}
16257};
16258
16259static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16260 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16261 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16262 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16263 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16265 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16266 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16267 {}
16268};
16269
16270static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16271 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
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, 0x0}, /* Headphone */
16275 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16276 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16277 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16278 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16279 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16280 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16281 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16282 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16283 {}
16284};
16285
16286static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16287 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16288 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16289 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16290 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16291 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16292 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16293 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16294 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16295 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16296 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16297 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16298 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16299 {}
16300};
16301
Kailang Yang6dda9f42008-05-27 12:05:31 +020016302static struct hda_verb alc663_g71v_init_verbs[] = {
16303 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16304 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16305 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16306
16307 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16308 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16309 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16310
16311 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16312 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16313 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16314 {}
16315};
16316
16317static struct hda_verb alc663_g50v_init_verbs[] = {
16318 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16319 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16320 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16321
16322 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16323 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16324 {}
16325};
16326
Kailang Yangf1d4e282008-08-26 14:03:29 +020016327static struct hda_verb alc662_ecs_init_verbs[] = {
16328 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16329 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16330 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16331 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16332 {}
16333};
16334
Kailang Yang622e84c2009-04-21 07:39:04 +020016335static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16336 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16337 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16338 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16339 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16340 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16341 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16342 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16343 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16344 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16345 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16346 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16347 {}
16348};
16349
16350static struct hda_verb alc272_dell_init_verbs[] = {
16351 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16352 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16354 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16355 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16356 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16357 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16359 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16360 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16361 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16362 {}
16363};
16364
Kailang Yangf1d4e282008-08-26 14:03:29 +020016365static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16366 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16367 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16368 { } /* end */
16369};
16370
Kailang Yang622e84c2009-04-21 07:39:04 +020016371static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16372 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16373 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16374 { } /* end */
16375};
16376
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016377static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16378{
16379 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016380 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016381
16382 present = snd_hda_codec_read(codec, 0x14, 0,
16383 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016384 bits = present ? HDA_AMP_MUTE : 0;
16385 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16386 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016387}
16388
16389static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16390{
16391 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016392 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016393
16394 present = snd_hda_codec_read(codec, 0x1b, 0,
16395 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016396 bits = present ? HDA_AMP_MUTE : 0;
16397 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16398 HDA_AMP_MUTE, bits);
16399 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16400 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016401}
16402
16403static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16404 unsigned int res)
16405{
16406 if ((res >> 26) == ALC880_HP_EVENT)
16407 alc662_lenovo_101e_all_automute(codec);
16408 if ((res >> 26) == ALC880_FRONT_EVENT)
16409 alc662_lenovo_101e_ispeaker_automute(codec);
16410}
16411
Kailang Yang291702f2007-10-16 14:28:03 +020016412/* unsolicited event for HP jack sensing */
16413static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16414 unsigned int res)
16415{
Kailang Yang291702f2007-10-16 14:28:03 +020016416 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016417 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016418 else
16419 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016420}
16421
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016422static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016423{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016424 struct alc_spec *spec = codec->spec;
16425
16426 alc262_hippo1_setup(codec);
16427 spec->ext_mic.pin = 0x18;
16428 spec->ext_mic.mux_idx = 0;
16429 spec->int_mic.pin = 0x19;
16430 spec->int_mic.mux_idx = 1;
16431 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016432}
16433
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016434static void alc662_eeepc_inithook(struct hda_codec *codec)
16435{
16436 alc262_hippo_automute(codec);
16437 alc_mic_automute(codec);
16438}
16439
16440static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016441{
Takashi Iwai42171c12009-05-08 14:11:43 +020016442 struct alc_spec *spec = codec->spec;
16443
16444 spec->autocfg.hp_pins[0] = 0x14;
16445 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016446}
16447
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016448#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16449
Kailang Yang6dda9f42008-05-27 12:05:31 +020016450static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16451{
16452 unsigned int present;
16453 unsigned char bits;
16454
16455 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016456 AC_VERB_GET_PIN_SENSE, 0)
16457 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016458 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016459 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16460 AMP_IN_MUTE(0), bits);
16461 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16462 AMP_IN_MUTE(0), bits);
16463}
16464
16465static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16466{
16467 unsigned int present;
16468 unsigned char bits;
16469
16470 present = snd_hda_codec_read(codec, 0x21, 0,
16471 AC_VERB_GET_PIN_SENSE, 0)
16472 & AC_PINSENSE_PRESENCE;
16473 bits = present ? HDA_AMP_MUTE : 0;
16474 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16475 AMP_IN_MUTE(0), bits);
16476 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16477 AMP_IN_MUTE(0), bits);
16478 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16479 AMP_IN_MUTE(0), bits);
16480 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16481 AMP_IN_MUTE(0), bits);
16482}
16483
16484static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16485{
16486 unsigned int present;
16487 unsigned char bits;
16488
16489 present = snd_hda_codec_read(codec, 0x15, 0,
16490 AC_VERB_GET_PIN_SENSE, 0)
16491 & AC_PINSENSE_PRESENCE;
16492 bits = present ? HDA_AMP_MUTE : 0;
16493 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16494 AMP_IN_MUTE(0), bits);
16495 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16496 AMP_IN_MUTE(0), bits);
16497 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16498 AMP_IN_MUTE(0), bits);
16499 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16500 AMP_IN_MUTE(0), bits);
16501}
16502
16503static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16504{
16505 unsigned int present;
16506 unsigned char bits;
16507
16508 present = snd_hda_codec_read(codec, 0x1b, 0,
16509 AC_VERB_GET_PIN_SENSE, 0)
16510 & AC_PINSENSE_PRESENCE;
16511 bits = present ? 0 : PIN_OUT;
16512 snd_hda_codec_write(codec, 0x14, 0,
16513 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16514}
16515
16516static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16517{
16518 unsigned int present1, present2;
16519
16520 present1 = snd_hda_codec_read(codec, 0x21, 0,
16521 AC_VERB_GET_PIN_SENSE, 0)
16522 & AC_PINSENSE_PRESENCE;
16523 present2 = snd_hda_codec_read(codec, 0x15, 0,
16524 AC_VERB_GET_PIN_SENSE, 0)
16525 & AC_PINSENSE_PRESENCE;
16526
16527 if (present1 || present2) {
16528 snd_hda_codec_write_cache(codec, 0x14, 0,
16529 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16530 } else {
16531 snd_hda_codec_write_cache(codec, 0x14, 0,
16532 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16533 }
16534}
16535
16536static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16537{
16538 unsigned int present1, present2;
16539
16540 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16541 AC_VERB_GET_PIN_SENSE, 0)
16542 & AC_PINSENSE_PRESENCE;
16543 present2 = snd_hda_codec_read(codec, 0x15, 0,
16544 AC_VERB_GET_PIN_SENSE, 0)
16545 & AC_PINSENSE_PRESENCE;
16546
16547 if (present1 || present2) {
16548 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16549 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16550 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16551 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16552 } else {
16553 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16554 AMP_IN_MUTE(0), 0);
16555 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16556 AMP_IN_MUTE(0), 0);
16557 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016558}
16559
Kailang Yang6dda9f42008-05-27 12:05:31 +020016560static void alc663_m51va_unsol_event(struct hda_codec *codec,
16561 unsigned int res)
16562{
16563 switch (res >> 26) {
16564 case ALC880_HP_EVENT:
16565 alc663_m51va_speaker_automute(codec);
16566 break;
16567 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016568 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016569 break;
16570 }
16571}
16572
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016573static void alc663_m51va_setup(struct hda_codec *codec)
16574{
16575 struct alc_spec *spec = codec->spec;
16576 spec->ext_mic.pin = 0x18;
16577 spec->ext_mic.mux_idx = 0;
16578 spec->int_mic.pin = 0x12;
16579 spec->int_mic.mux_idx = 1;
16580 spec->auto_mic = 1;
16581}
16582
Kailang Yang6dda9f42008-05-27 12:05:31 +020016583static void alc663_m51va_inithook(struct hda_codec *codec)
16584{
16585 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016586 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016587}
16588
Kailang Yangf1d4e282008-08-26 14:03:29 +020016589/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016590#define alc663_mode1_unsol_event alc663_m51va_unsol_event
16591#define alc663_mode1_setup alc663_m51va_setup
16592#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016593
Kailang Yangf1d4e282008-08-26 14:03:29 +020016594/* ***************** Mode2 ******************************/
16595static void alc662_mode2_unsol_event(struct hda_codec *codec,
16596 unsigned int res)
16597{
16598 switch (res >> 26) {
16599 case ALC880_HP_EVENT:
16600 alc662_f5z_speaker_automute(codec);
16601 break;
16602 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016603 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016604 break;
16605 }
16606}
16607
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016608#define alc662_mode2_setup alc663_m51va_setup
16609
Kailang Yangf1d4e282008-08-26 14:03:29 +020016610static void alc662_mode2_inithook(struct hda_codec *codec)
16611{
16612 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016613 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016614}
16615/* ***************** Mode3 ******************************/
16616static void alc663_mode3_unsol_event(struct hda_codec *codec,
16617 unsigned int res)
16618{
16619 switch (res >> 26) {
16620 case ALC880_HP_EVENT:
16621 alc663_two_hp_m1_speaker_automute(codec);
16622 break;
16623 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016624 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016625 break;
16626 }
16627}
16628
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016629#define alc663_mode3_setup alc663_m51va_setup
16630
Kailang Yangf1d4e282008-08-26 14:03:29 +020016631static void alc663_mode3_inithook(struct hda_codec *codec)
16632{
16633 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016634 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016635}
16636/* ***************** Mode4 ******************************/
16637static void alc663_mode4_unsol_event(struct hda_codec *codec,
16638 unsigned int res)
16639{
16640 switch (res >> 26) {
16641 case ALC880_HP_EVENT:
16642 alc663_21jd_two_speaker_automute(codec);
16643 break;
16644 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016645 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016646 break;
16647 }
16648}
16649
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016650#define alc663_mode4_setup alc663_m51va_setup
16651
Kailang Yangf1d4e282008-08-26 14:03:29 +020016652static void alc663_mode4_inithook(struct hda_codec *codec)
16653{
16654 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016655 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016656}
16657/* ***************** Mode5 ******************************/
16658static void alc663_mode5_unsol_event(struct hda_codec *codec,
16659 unsigned int res)
16660{
16661 switch (res >> 26) {
16662 case ALC880_HP_EVENT:
16663 alc663_15jd_two_speaker_automute(codec);
16664 break;
16665 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016666 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016667 break;
16668 }
16669}
16670
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016671#define alc663_mode5_setup alc663_m51va_setup
16672
Kailang Yangf1d4e282008-08-26 14:03:29 +020016673static void alc663_mode5_inithook(struct hda_codec *codec)
16674{
16675 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016676 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016677}
16678/* ***************** Mode6 ******************************/
16679static void alc663_mode6_unsol_event(struct hda_codec *codec,
16680 unsigned int res)
16681{
16682 switch (res >> 26) {
16683 case ALC880_HP_EVENT:
16684 alc663_two_hp_m2_speaker_automute(codec);
16685 break;
16686 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016687 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016688 break;
16689 }
16690}
16691
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016692#define alc663_mode6_setup alc663_m51va_setup
16693
Kailang Yangf1d4e282008-08-26 14:03:29 +020016694static void alc663_mode6_inithook(struct hda_codec *codec)
16695{
16696 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016697 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016698}
16699
Kailang Yang6dda9f42008-05-27 12:05:31 +020016700static void alc663_g71v_hp_automute(struct hda_codec *codec)
16701{
16702 unsigned int present;
16703 unsigned char bits;
16704
16705 present = snd_hda_codec_read(codec, 0x21, 0,
16706 AC_VERB_GET_PIN_SENSE, 0)
16707 & AC_PINSENSE_PRESENCE;
16708 bits = present ? HDA_AMP_MUTE : 0;
16709 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16710 HDA_AMP_MUTE, bits);
16711 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16712 HDA_AMP_MUTE, bits);
16713}
16714
16715static void alc663_g71v_front_automute(struct hda_codec *codec)
16716{
16717 unsigned int present;
16718 unsigned char bits;
16719
16720 present = snd_hda_codec_read(codec, 0x15, 0,
16721 AC_VERB_GET_PIN_SENSE, 0)
16722 & AC_PINSENSE_PRESENCE;
16723 bits = present ? HDA_AMP_MUTE : 0;
16724 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16725 HDA_AMP_MUTE, bits);
16726}
16727
16728static void alc663_g71v_unsol_event(struct hda_codec *codec,
16729 unsigned int res)
16730{
16731 switch (res >> 26) {
16732 case ALC880_HP_EVENT:
16733 alc663_g71v_hp_automute(codec);
16734 break;
16735 case ALC880_FRONT_EVENT:
16736 alc663_g71v_front_automute(codec);
16737 break;
16738 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016739 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016740 break;
16741 }
16742}
16743
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016744#define alc663_g71v_setup alc663_m51va_setup
16745
Kailang Yang6dda9f42008-05-27 12:05:31 +020016746static void alc663_g71v_inithook(struct hda_codec *codec)
16747{
16748 alc663_g71v_front_automute(codec);
16749 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016750 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016751}
16752
16753static void alc663_g50v_unsol_event(struct hda_codec *codec,
16754 unsigned int res)
16755{
16756 switch (res >> 26) {
16757 case ALC880_HP_EVENT:
16758 alc663_m51va_speaker_automute(codec);
16759 break;
16760 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016761 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016762 break;
16763 }
16764}
16765
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016766#define alc663_g50v_setup alc663_m51va_setup
16767
Kailang Yang6dda9f42008-05-27 12:05:31 +020016768static void alc663_g50v_inithook(struct hda_codec *codec)
16769{
16770 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016771 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016772}
16773
Kailang Yangf1d4e282008-08-26 14:03:29 +020016774static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16775 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016776 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016777
16778 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16779 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16780 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16781
16782 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16783 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16784 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16785 { } /* end */
16786};
16787
Chris Pockelé9541ba12009-05-12 08:08:53 +020016788static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16789 /* Master Playback automatically created from Speaker and Headphone */
16790 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16791 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16792 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16793 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16794
16795 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16796 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16797 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16798
16799 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16800 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16801 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16802 { } /* end */
16803};
16804
Takashi Iwaicb53c622007-08-10 17:21:45 +020016805#ifdef CONFIG_SND_HDA_POWER_SAVE
16806#define alc662_loopbacks alc880_loopbacks
16807#endif
16808
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016809
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016810/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016811#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16812#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16813#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16814#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16815
16816/*
16817 * configuration and preset
16818 */
16819static const char *alc662_models[ALC662_MODEL_LAST] = {
16820 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16821 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16822 [ALC662_3ST_6ch] = "3stack-6ch",
16823 [ALC662_5ST_DIG] = "6stack-dig",
16824 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016825 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016826 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016827 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016828 [ALC663_ASUS_M51VA] = "m51va",
16829 [ALC663_ASUS_G71V] = "g71v",
16830 [ALC663_ASUS_H13] = "h13",
16831 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016832 [ALC663_ASUS_MODE1] = "asus-mode1",
16833 [ALC662_ASUS_MODE2] = "asus-mode2",
16834 [ALC663_ASUS_MODE3] = "asus-mode3",
16835 [ALC663_ASUS_MODE4] = "asus-mode4",
16836 [ALC663_ASUS_MODE5] = "asus-mode5",
16837 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016838 [ALC272_DELL] = "dell",
16839 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016840 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016841 [ALC662_AUTO] = "auto",
16842};
16843
16844static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016845 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016846 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16847 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016848 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16849 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16850 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16851 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16852 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16853 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16854 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16855 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16856 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16857 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16858 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16859 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016860 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16861 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16862 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016863 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16864 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16865 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16866 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016867 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016868 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16869 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016870 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016871 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16872 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16873 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016874 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16875 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16876 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016877 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16878 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16879 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016880 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016881 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16882 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016883 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016884 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016885 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016886 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16887 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16888 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016889 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016890 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16891 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016892 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016893 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016894 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016895 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016896 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16897 ALC662_3ST_6ch_DIG),
Manoj Iyer3db6c032009-09-22 18:33:29 -050016898 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB200", ALC663_ASUS_MODE4),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016899 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016900 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16901 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016902 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016903 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016904 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016905 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016906 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016907 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16908 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016909 {}
16910};
16911
16912static struct alc_config_preset alc662_presets[] = {
16913 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016914 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016915 .init_verbs = { alc662_init_verbs },
16916 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16917 .dac_nids = alc662_dac_nids,
16918 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016919 .dig_in_nid = ALC662_DIGIN_NID,
16920 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16921 .channel_mode = alc662_3ST_2ch_modes,
16922 .input_mux = &alc662_capture_source,
16923 },
16924 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016925 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016926 .init_verbs = { alc662_init_verbs },
16927 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16928 .dac_nids = alc662_dac_nids,
16929 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016930 .dig_in_nid = ALC662_DIGIN_NID,
16931 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16932 .channel_mode = alc662_3ST_6ch_modes,
16933 .need_dac_fix = 1,
16934 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016935 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016936 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016937 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016938 .init_verbs = { alc662_init_verbs },
16939 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16940 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016941 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16942 .channel_mode = alc662_3ST_6ch_modes,
16943 .need_dac_fix = 1,
16944 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016945 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016946 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016947 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016948 .init_verbs = { alc662_init_verbs },
16949 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16950 .dac_nids = alc662_dac_nids,
16951 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016952 .dig_in_nid = ALC662_DIGIN_NID,
16953 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16954 .channel_mode = alc662_5stack_modes,
16955 .input_mux = &alc662_capture_source,
16956 },
16957 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016958 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016959 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16960 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16961 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016962 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16963 .channel_mode = alc662_3ST_2ch_modes,
16964 .input_mux = &alc662_lenovo_101e_capture_source,
16965 .unsol_event = alc662_lenovo_101e_unsol_event,
16966 .init_hook = alc662_lenovo_101e_all_automute,
16967 },
Kailang Yang291702f2007-10-16 14:28:03 +020016968 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016969 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016970 .init_verbs = { alc662_init_verbs,
16971 alc662_eeepc_sue_init_verbs },
16972 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16973 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016974 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16975 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020016976 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016977 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020016978 .init_hook = alc662_eeepc_inithook,
16979 },
Kailang Yang8c427222008-01-10 13:03:59 +010016980 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016981 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016982 alc662_chmode_mixer },
16983 .init_verbs = { alc662_init_verbs,
16984 alc662_eeepc_ep20_sue_init_verbs },
16985 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16986 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016987 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16988 .channel_mode = alc662_3ST_6ch_modes,
16989 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016990 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016991 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010016992 .init_hook = alc662_eeepc_ep20_inithook,
16993 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016994 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016995 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016996 .init_verbs = { alc662_init_verbs,
16997 alc662_ecs_init_verbs },
16998 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16999 .dac_nids = alc662_dac_nids,
17000 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17001 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017002 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017003 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017004 .init_hook = alc662_eeepc_inithook,
17005 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017006 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017007 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017008 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17009 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17010 .dac_nids = alc662_dac_nids,
17011 .dig_out_nid = ALC662_DIGOUT_NID,
17012 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17013 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017014 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017015 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017016 .init_hook = alc663_m51va_inithook,
17017 },
17018 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017019 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017020 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17021 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17022 .dac_nids = alc662_dac_nids,
17023 .dig_out_nid = ALC662_DIGOUT_NID,
17024 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17025 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017026 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017027 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017028 .init_hook = alc663_g71v_inithook,
17029 },
17030 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017031 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017032 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17033 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17034 .dac_nids = alc662_dac_nids,
17035 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17036 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017037 .unsol_event = alc663_m51va_unsol_event,
17038 .init_hook = alc663_m51va_inithook,
17039 },
17040 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017041 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017042 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17043 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17044 .dac_nids = alc662_dac_nids,
17045 .dig_out_nid = ALC662_DIGOUT_NID,
17046 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17047 .channel_mode = alc662_3ST_6ch_modes,
17048 .input_mux = &alc663_capture_source,
17049 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017050 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017051 .init_hook = alc663_g50v_inithook,
17052 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017053 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017054 .mixers = { alc663_m51va_mixer },
17055 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017056 .init_verbs = { alc662_init_verbs,
17057 alc663_21jd_amic_init_verbs },
17058 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17059 .hp_nid = 0x03,
17060 .dac_nids = alc662_dac_nids,
17061 .dig_out_nid = ALC662_DIGOUT_NID,
17062 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17063 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017064 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017065 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017066 .init_hook = alc663_mode1_inithook,
17067 },
17068 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017069 .mixers = { alc662_1bjd_mixer },
17070 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017071 .init_verbs = { alc662_init_verbs,
17072 alc662_1bjd_amic_init_verbs },
17073 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17074 .dac_nids = alc662_dac_nids,
17075 .dig_out_nid = ALC662_DIGOUT_NID,
17076 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17077 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017078 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017079 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017080 .init_hook = alc662_mode2_inithook,
17081 },
17082 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017083 .mixers = { alc663_two_hp_m1_mixer },
17084 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017085 .init_verbs = { alc662_init_verbs,
17086 alc663_two_hp_amic_m1_init_verbs },
17087 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17088 .hp_nid = 0x03,
17089 .dac_nids = alc662_dac_nids,
17090 .dig_out_nid = ALC662_DIGOUT_NID,
17091 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17092 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017093 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017094 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017095 .init_hook = alc663_mode3_inithook,
17096 },
17097 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017098 .mixers = { alc663_asus_21jd_clfe_mixer },
17099 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017100 .init_verbs = { alc662_init_verbs,
17101 alc663_21jd_amic_init_verbs},
17102 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17103 .hp_nid = 0x03,
17104 .dac_nids = alc662_dac_nids,
17105 .dig_out_nid = ALC662_DIGOUT_NID,
17106 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17107 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017108 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017109 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017110 .init_hook = alc663_mode4_inithook,
17111 },
17112 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017113 .mixers = { alc663_asus_15jd_clfe_mixer },
17114 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017115 .init_verbs = { alc662_init_verbs,
17116 alc663_15jd_amic_init_verbs },
17117 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17118 .hp_nid = 0x03,
17119 .dac_nids = alc662_dac_nids,
17120 .dig_out_nid = ALC662_DIGOUT_NID,
17121 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17122 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017123 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017124 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017125 .init_hook = alc663_mode5_inithook,
17126 },
17127 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017128 .mixers = { alc663_two_hp_m2_mixer },
17129 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017130 .init_verbs = { alc662_init_verbs,
17131 alc663_two_hp_amic_m2_init_verbs },
17132 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17133 .hp_nid = 0x03,
17134 .dac_nids = alc662_dac_nids,
17135 .dig_out_nid = ALC662_DIGOUT_NID,
17136 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17137 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017138 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017139 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017140 .init_hook = alc663_mode6_inithook,
17141 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017142 [ALC272_DELL] = {
17143 .mixers = { alc663_m51va_mixer },
17144 .cap_mixer = alc272_auto_capture_mixer,
17145 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17146 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17147 .dac_nids = alc662_dac_nids,
17148 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17149 .adc_nids = alc272_adc_nids,
17150 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17151 .capsrc_nids = alc272_capsrc_nids,
17152 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017153 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017154 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017155 .init_hook = alc663_m51va_inithook,
17156 },
17157 [ALC272_DELL_ZM1] = {
17158 .mixers = { alc663_m51va_mixer },
17159 .cap_mixer = alc662_auto_capture_mixer,
17160 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17161 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17162 .dac_nids = alc662_dac_nids,
17163 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17164 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017165 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017166 .capsrc_nids = alc662_capsrc_nids,
17167 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017168 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017169 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017170 .init_hook = alc663_m51va_inithook,
17171 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017172 [ALC272_SAMSUNG_NC10] = {
17173 .mixers = { alc272_nc10_mixer },
17174 .init_verbs = { alc662_init_verbs,
17175 alc663_21jd_amic_init_verbs },
17176 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17177 .dac_nids = alc272_dac_nids,
17178 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17179 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017180 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017181 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017182 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017183 .init_hook = alc663_mode4_inithook,
17184 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017185};
17186
17187
17188/*
17189 * BIOS auto configuration
17190 */
17191
Takashi Iwai7085ec12009-10-02 09:03:58 +020017192/* convert from MIX nid to DAC */
17193static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17194{
17195 if (nid == 0x0f)
17196 return 0x02;
17197 else if (nid >= 0x0c && nid <= 0x0e)
17198 return nid - 0x0c + 0x02;
17199 else
17200 return 0;
17201}
17202
17203/* get MIX nid connected to the given pin targeted to DAC */
17204static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17205 hda_nid_t dac)
17206{
17207 hda_nid_t mix[4];
17208 int i, num;
17209
17210 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17211 for (i = 0; i < num; i++) {
17212 if (alc662_mix_to_dac(mix[i]) == dac)
17213 return mix[i];
17214 }
17215 return 0;
17216}
17217
17218/* look for an empty DAC slot */
17219static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17220{
17221 struct alc_spec *spec = codec->spec;
17222 hda_nid_t srcs[5];
17223 int i, j, num;
17224
17225 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17226 if (num < 0)
17227 return 0;
17228 for (i = 0; i < num; i++) {
17229 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17230 if (!nid)
17231 continue;
17232 for (j = 0; j < spec->multiout.num_dacs; j++)
17233 if (spec->multiout.dac_nids[j] == nid)
17234 break;
17235 if (j >= spec->multiout.num_dacs)
17236 return nid;
17237 }
17238 return 0;
17239}
17240
17241/* fill in the dac_nids table from the parsed pin configuration */
17242static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
17243 const struct auto_pin_cfg *cfg)
17244{
17245 struct alc_spec *spec = codec->spec;
17246 int i;
17247 hda_nid_t dac;
17248
17249 spec->multiout.dac_nids = spec->private_dac_nids;
17250 for (i = 0; i < cfg->line_outs; i++) {
17251 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
17252 if (!dac)
17253 continue;
17254 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
17255 }
17256 return 0;
17257}
17258
17259static int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
17260 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017261{
17262 char name[32];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017263 sprintf(name, "%s Playback Volume", pfx);
17264 return add_control(spec, ALC_CTL_WIDGET_VOL, name,
17265 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
17266}
17267
17268static int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
17269 hda_nid_t nid, unsigned int chs)
17270{
17271 char name[32];
17272 sprintf(name, "%s Playback Switch", pfx);
17273 return add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17274 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
17275}
17276
17277#define alc662_add_stereo_vol(spec, pfx, nid) \
17278 alc662_add_vol_ctl(spec, pfx, nid, 3)
17279#define alc662_add_stereo_sw(spec, pfx, nid) \
17280 alc662_add_sw_ctl(spec, pfx, nid, 3)
17281
17282/* add playback controls from the parsed DAC table */
17283static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
17284 const struct auto_pin_cfg *cfg)
17285{
17286 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017287 static const char *chname[4] = {
17288 "Front", "Surround", NULL /*CLFE*/, "Side"
17289 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020017290 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017291 int i, err;
17292
17293 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017294 nid = spec->multiout.dac_nids[i];
17295 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017296 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017297 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
17298 if (!mix)
17299 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017300 if (i == 2) {
17301 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017302 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017303 if (err < 0)
17304 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017305 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017306 if (err < 0)
17307 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017308 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017309 if (err < 0)
17310 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017311 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017312 if (err < 0)
17313 return err;
17314 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017315 const char *pfx;
17316 if (cfg->line_outs == 1 &&
17317 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017318 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017319 pfx = "Speaker";
17320 else
17321 pfx = "PCM";
17322 } else
17323 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017324 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017325 if (err < 0)
17326 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017327 if (cfg->line_outs == 1 &&
17328 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17329 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020017330 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017331 if (err < 0)
17332 return err;
17333 }
17334 }
17335 return 0;
17336}
17337
17338/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017339/* return DAC nid if any new DAC is assigned */
17340static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017341 const char *pfx)
17342{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017343 struct alc_spec *spec = codec->spec;
17344 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017345 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017346
17347 if (!pin)
17348 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017349 nid = alc662_look_for_dac(codec, pin);
17350 if (!nid) {
17351 char name[32];
17352 /* the corresponding DAC is already occupied */
17353 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
17354 return 0; /* no way */
17355 /* create a switch only */
Takashi Iwai24fb9172008-09-02 14:48:20 +020017356 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai7085ec12009-10-02 09:03:58 +020017357 return add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17358 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17359 }
17360
17361 mix = alc662_dac_to_mix(codec, pin, nid);
17362 if (!mix)
17363 return 0;
17364 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17365 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020017366 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017367 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17368 if (err < 0)
17369 return err;
17370 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017371}
17372
17373/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017374#define alc662_auto_create_input_ctls \
17375 alc880_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017376
17377static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17378 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017379 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017380{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017381 int i, num;
17382 hda_nid_t srcs[4];
17383
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017384 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017385 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017386 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
17387 if (num <= 1)
17388 return;
17389 for (i = 0; i < num; i++) {
17390 if (alc662_mix_to_dac(srcs[i]) != dac)
17391 continue;
17392 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
17393 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017394 }
17395}
17396
17397static void alc662_auto_init_multi_out(struct hda_codec *codec)
17398{
17399 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017400 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017401 int i;
17402
17403 for (i = 0; i <= HDA_SIDE; i++) {
17404 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17405 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017406 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017407 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017408 }
17409}
17410
17411static void alc662_auto_init_hp_out(struct hda_codec *codec)
17412{
17413 struct alc_spec *spec = codec->spec;
17414 hda_nid_t pin;
17415
17416 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017417 if (pin)
17418 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
17419 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017420 pin = spec->autocfg.speaker_pins[0];
17421 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020017422 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
17423 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017424}
17425
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017426#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17427
17428static void alc662_auto_init_analog_input(struct hda_codec *codec)
17429{
17430 struct alc_spec *spec = codec->spec;
17431 int i;
17432
17433 for (i = 0; i < AUTO_PIN_LAST; i++) {
17434 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020017435 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017436 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017437 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017438 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017439 snd_hda_codec_write(codec, nid, 0,
17440 AC_VERB_SET_AMP_GAIN_MUTE,
17441 AMP_OUT_MUTE);
17442 }
17443 }
17444}
17445
Takashi Iwaif511b012008-08-15 16:46:42 +020017446#define alc662_auto_init_input_src alc882_auto_init_input_src
17447
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017448static int alc662_parse_auto_config(struct hda_codec *codec)
17449{
17450 struct alc_spec *spec = codec->spec;
17451 int err;
17452 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17453
17454 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17455 alc662_ignore);
17456 if (err < 0)
17457 return err;
17458 if (!spec->autocfg.line_outs)
17459 return 0; /* can't find valid BIOS pin config */
17460
Takashi Iwai7085ec12009-10-02 09:03:58 +020017461 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017462 if (err < 0)
17463 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017464 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017465 if (err < 0)
17466 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017467 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017468 spec->autocfg.speaker_pins[0],
17469 "Speaker");
17470 if (err < 0)
17471 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017472 if (err)
17473 spec->multiout.extra_out_nid[0] = err;
17474 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017475 "Headphone");
17476 if (err < 0)
17477 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017478 if (err)
17479 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017480 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017481 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017482 return err;
17483
17484 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17485
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017486 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017487 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17488
Takashi Iwai603c4012008-07-30 15:01:44 +020017489 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017490 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017491
17492 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017493 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017494
Takashi Iwaid88897e2008-10-31 15:01:37 +010017495 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017496 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017497 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017498
17499 err = alc_auto_add_mic_boost(codec);
17500 if (err < 0)
17501 return err;
17502
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017503 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17504
Takashi Iwai8c872862007-06-19 12:11:16 +020017505 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017506}
17507
17508/* additional initialization for auto-configuration model */
17509static void alc662_auto_init(struct hda_codec *codec)
17510{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017511 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017512 alc662_auto_init_multi_out(codec);
17513 alc662_auto_init_hp_out(codec);
17514 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017515 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017516 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017517 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017518}
17519
17520static int patch_alc662(struct hda_codec *codec)
17521{
17522 struct alc_spec *spec;
17523 int err, board_config;
17524
17525 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17526 if (!spec)
17527 return -ENOMEM;
17528
17529 codec->spec = spec;
17530
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017531 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17532
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017533 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17534 alc662_models,
17535 alc662_cfg_tbl);
17536 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017537 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17538 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017539 board_config = ALC662_AUTO;
17540 }
17541
17542 if (board_config == ALC662_AUTO) {
17543 /* automatic parse from the BIOS config */
17544 err = alc662_parse_auto_config(codec);
17545 if (err < 0) {
17546 alc_free(codec);
17547 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020017548 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017549 printk(KERN_INFO
17550 "hda_codec: Cannot set up configuration "
17551 "from BIOS. Using base mode...\n");
17552 board_config = ALC662_3ST_2ch_DIG;
17553 }
17554 }
17555
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017556 err = snd_hda_attach_beep_device(codec, 0x1);
17557 if (err < 0) {
17558 alc_free(codec);
17559 return err;
17560 }
17561
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017562 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017563 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017564
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017565 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17566 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17567
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017568 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17569 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17570
Takashi Iwaidd704692009-08-11 08:45:11 +020017571 if (!spec->adc_nids) {
17572 spec->adc_nids = alc662_adc_nids;
17573 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17574 }
17575 if (!spec->capsrc_nids)
17576 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017577
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017578 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017579 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017580 if (codec->vendor_id == 0x10ec0662)
17581 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17582 else
17583 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017584
Takashi Iwai2134ea42008-01-10 16:53:55 +010017585 spec->vmaster_nid = 0x02;
17586
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017587 codec->patch_ops = alc_patch_ops;
17588 if (board_config == ALC662_AUTO)
17589 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017590#ifdef CONFIG_SND_HDA_POWER_SAVE
17591 if (!spec->loopback.amplist)
17592 spec->loopback.amplist = alc662_loopbacks;
17593#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017594 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017595
17596 return 0;
17597}
17598
17599/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017600 * patch entries
17601 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017602static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017603 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017604 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017605 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017606 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017607 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017608 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017609 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017610 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017611 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17612 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17613 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017614 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017615 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017616 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17617 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017618 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017619 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017620 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017621 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017622 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017623 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017624 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017625 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017626 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017627 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017628 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017629 .patch = patch_alc882 },
17630 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17631 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017632 {} /* terminator */
17633};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017634
17635MODULE_ALIAS("snd-hda-codec-id:10ec*");
17636
17637MODULE_LICENSE("GPL");
17638MODULE_DESCRIPTION("Realtek HD-audio codec");
17639
17640static struct hda_codec_preset_list realtek_list = {
17641 .preset = snd_hda_preset_realtek,
17642 .owner = THIS_MODULE,
17643};
17644
17645static int __init patch_realtek_init(void)
17646{
17647 return snd_hda_add_codec_preset(&realtek_list);
17648}
17649
17650static void __exit patch_realtek_exit(void)
17651{
17652 snd_hda_delete_codec_preset(&realtek_list);
17653}
17654
17655module_init(patch_realtek_init)
17656module_exit(patch_realtek_exit)