blob: 84a52efdb2d678fc40c3aae5ea74192a0933421c [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 Avdoninbab282b92006-08-22 13:31:58 +0200218 ALC883_ACER,
Tobin Davis2880a862007-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
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200278 const struct hda_verb *init_verbs[10]; /* 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 Iwaiad87c642009-11-02 14:23:15 +0100968 if (!nid)
969 return;
Takashi Iwai261c2402009-06-25 08:13:40 +0200970 pincap = snd_hda_query_pin_caps(codec, nid);
971 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
972 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200973 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200974 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200975 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
976 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
977 nid = spec->autocfg.speaker_pins[i];
978 if (!nid)
979 break;
980 snd_hda_codec_write(codec, nid, 0,
981 AC_VERB_SET_PIN_WIDGET_CONTROL,
982 spec->jack_present ? 0 : PIN_OUT);
983 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200984}
985
Takashi Iwai6c819492009-08-10 18:47:44 +0200986static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
987 hda_nid_t nid)
988{
989 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
990 int i, nums;
991
992 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
993 for (i = 0; i < nums; i++)
994 if (conn[i] == nid)
995 return i;
996 return -1;
997}
998
Kailang Yang7fb0d782008-10-15 11:12:35 +0200999static void alc_mic_automute(struct hda_codec *codec)
1000{
1001 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001002 struct alc_mic_route *dead, *alive;
1003 unsigned int present, type;
1004 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001005
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001006 if (!spec->auto_mic)
1007 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001008 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1009 return;
1010 if (snd_BUG_ON(!spec->adc_nids))
1011 return;
1012
1013 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1014
1015 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
1016 AC_VERB_GET_PIN_SENSE, 0);
1017 present &= AC_PINSENSE_PRESENCE;
1018 if (present) {
1019 alive = &spec->ext_mic;
1020 dead = &spec->int_mic;
1021 } else {
1022 alive = &spec->int_mic;
1023 dead = &spec->ext_mic;
1024 }
1025
Takashi Iwai6c819492009-08-10 18:47:44 +02001026 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1027 if (type == AC_WID_AUD_MIX) {
1028 /* Matrix-mixer style (e.g. ALC882) */
1029 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1030 alive->mux_idx,
1031 HDA_AMP_MUTE, 0);
1032 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1033 dead->mux_idx,
1034 HDA_AMP_MUTE, HDA_AMP_MUTE);
1035 } else {
1036 /* MUX style (e.g. ALC880) */
1037 snd_hda_codec_write_cache(codec, cap_nid, 0,
1038 AC_VERB_SET_CONNECT_SEL,
1039 alive->mux_idx);
1040 }
1041
1042 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001043}
1044
Kailang Yangc9b58002007-10-16 14:30:01 +02001045/* unsolicited event for HP jack sensing */
1046static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1047{
1048 if (codec->vendor_id == 0x10ec0880)
1049 res >>= 28;
1050 else
1051 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001052 switch (res) {
1053 case ALC880_HP_EVENT:
1054 alc_automute_pin(codec);
1055 break;
1056 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001057 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001058 break;
1059 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001060}
1061
1062static void alc_inithook(struct hda_codec *codec)
1063{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001064 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001065 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001066}
1067
Kailang Yangf9423e72008-05-27 12:32:25 +02001068/* additional initialization for ALC888 variants */
1069static void alc888_coef_init(struct hda_codec *codec)
1070{
1071 unsigned int tmp;
1072
1073 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1074 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1075 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001076 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001077 /* alc888S-VC */
1078 snd_hda_codec_read(codec, 0x20, 0,
1079 AC_VERB_SET_PROC_COEF, 0x830);
1080 else
1081 /* alc888-VB */
1082 snd_hda_codec_read(codec, 0x20, 0,
1083 AC_VERB_SET_PROC_COEF, 0x3030);
1084}
1085
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001086static void alc889_coef_init(struct hda_codec *codec)
1087{
1088 unsigned int tmp;
1089
1090 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1091 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1092 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1093 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1094}
1095
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001096static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001097{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001098 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001099
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001100 switch (type) {
1101 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001102 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1103 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001104 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001105 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1106 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001107 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001108 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1109 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001110 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001111 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001112 case 0x10ec0260:
1113 snd_hda_codec_write(codec, 0x0f, 0,
1114 AC_VERB_SET_EAPD_BTLENABLE, 2);
1115 snd_hda_codec_write(codec, 0x10, 0,
1116 AC_VERB_SET_EAPD_BTLENABLE, 2);
1117 break;
1118 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001119 case 0x10ec0267:
1120 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001121 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001122 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001123 case 0x10ec0660:
1124 case 0x10ec0662:
1125 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001126 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001127 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001128 snd_hda_codec_write(codec, 0x14, 0,
1129 AC_VERB_SET_EAPD_BTLENABLE, 2);
1130 snd_hda_codec_write(codec, 0x15, 0,
1131 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001132 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001133 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001134 switch (codec->vendor_id) {
1135 case 0x10ec0260:
1136 snd_hda_codec_write(codec, 0x1a, 0,
1137 AC_VERB_SET_COEF_INDEX, 7);
1138 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1139 AC_VERB_GET_PROC_COEF, 0);
1140 snd_hda_codec_write(codec, 0x1a, 0,
1141 AC_VERB_SET_COEF_INDEX, 7);
1142 snd_hda_codec_write(codec, 0x1a, 0,
1143 AC_VERB_SET_PROC_COEF,
1144 tmp | 0x2010);
1145 break;
1146 case 0x10ec0262:
1147 case 0x10ec0880:
1148 case 0x10ec0882:
1149 case 0x10ec0883:
1150 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001151 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001152 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001153 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001154 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001155 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001156 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001157 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001158 case 0x10ec0267:
1159 case 0x10ec0268:
1160 snd_hda_codec_write(codec, 0x20, 0,
1161 AC_VERB_SET_COEF_INDEX, 7);
1162 tmp = snd_hda_codec_read(codec, 0x20, 0,
1163 AC_VERB_GET_PROC_COEF, 0);
1164 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001165 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001166 snd_hda_codec_write(codec, 0x20, 0,
1167 AC_VERB_SET_PROC_COEF,
1168 tmp | 0x3000);
1169 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001170 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001171 break;
1172 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001173}
Kailang Yangea1fb292008-08-26 12:58:38 +02001174
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001175static void alc_init_auto_hp(struct hda_codec *codec)
1176{
1177 struct alc_spec *spec = codec->spec;
1178
1179 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001180 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001181
Kailang Yangc9b58002007-10-16 14:30:01 +02001182 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001183 if (spec->autocfg.line_out_pins[0] &&
1184 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001185 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001186 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001187 else
1188 return;
1189 }
1190
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001191 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1192 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001193 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1194 AC_VERB_SET_UNSOLICITED_ENABLE,
1195 AC_USRSP_EN | ALC880_HP_EVENT);
1196 spec->unsol_event = alc_sku_unsol_event;
1197}
1198
Takashi Iwai6c819492009-08-10 18:47:44 +02001199static void alc_init_auto_mic(struct hda_codec *codec)
1200{
1201 struct alc_spec *spec = codec->spec;
1202 struct auto_pin_cfg *cfg = &spec->autocfg;
1203 hda_nid_t fixed, ext;
1204 int i;
1205
1206 /* there must be only two mic inputs exclusively */
1207 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1208 if (cfg->input_pins[i])
1209 return;
1210
1211 fixed = ext = 0;
1212 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1213 hda_nid_t nid = cfg->input_pins[i];
1214 unsigned int defcfg;
1215 if (!nid)
1216 return;
1217 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1218 switch (get_defcfg_connect(defcfg)) {
1219 case AC_JACK_PORT_FIXED:
1220 if (fixed)
1221 return; /* already occupied */
1222 fixed = nid;
1223 break;
1224 case AC_JACK_PORT_COMPLEX:
1225 if (ext)
1226 return; /* already occupied */
1227 ext = nid;
1228 break;
1229 default:
1230 return; /* invalid entry */
1231 }
1232 }
1233 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1234 return; /* no unsol support */
1235 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1236 ext, fixed);
1237 spec->ext_mic.pin = ext;
1238 spec->int_mic.pin = fixed;
1239 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1240 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1241 spec->auto_mic = 1;
1242 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1243 AC_VERB_SET_UNSOLICITED_ENABLE,
1244 AC_USRSP_EN | ALC880_MIC_EVENT);
1245 spec->unsol_event = alc_sku_unsol_event;
1246}
1247
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001248/* check subsystem ID and set up device-specific initialization;
1249 * return 1 if initialized, 0 if invalid SSID
1250 */
1251/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1252 * 31 ~ 16 : Manufacture ID
1253 * 15 ~ 8 : SKU ID
1254 * 7 ~ 0 : Assembly ID
1255 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1256 */
1257static int alc_subsystem_id(struct hda_codec *codec,
1258 hda_nid_t porta, hda_nid_t porte,
1259 hda_nid_t portd)
1260{
1261 unsigned int ass, tmp, i;
1262 unsigned nid;
1263 struct alc_spec *spec = codec->spec;
1264
1265 ass = codec->subsystem_id & 0xffff;
1266 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1267 goto do_sku;
1268
1269 /* invalid SSID, check the special NID pin defcfg instead */
1270 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001271 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001272 * 29~21 : reserve
1273 * 20 : PCBEEP input
1274 * 19~16 : Check sum (15:1)
1275 * 15~1 : Custom
1276 * 0 : override
1277 */
1278 nid = 0x1d;
1279 if (codec->vendor_id == 0x10ec0260)
1280 nid = 0x17;
1281 ass = snd_hda_codec_get_pincfg(codec, nid);
1282 snd_printd("realtek: No valid SSID, "
1283 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001284 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001285 if (!(ass & 1) && !(ass & 0x100000))
1286 return 0;
1287 if ((ass >> 30) != 1) /* no physical connection */
1288 return 0;
1289
1290 /* check sum */
1291 tmp = 0;
1292 for (i = 1; i < 16; i++) {
1293 if ((ass >> i) & 1)
1294 tmp++;
1295 }
1296 if (((ass >> 16) & 0xf) != tmp)
1297 return 0;
1298do_sku:
1299 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1300 ass & 0xffff, codec->vendor_id);
1301 /*
1302 * 0 : override
1303 * 1 : Swap Jack
1304 * 2 : 0 --> Desktop, 1 --> Laptop
1305 * 3~5 : External Amplifier control
1306 * 7~6 : Reserved
1307 */
1308 tmp = (ass & 0x38) >> 3; /* external Amp control */
1309 switch (tmp) {
1310 case 1:
1311 spec->init_amp = ALC_INIT_GPIO1;
1312 break;
1313 case 3:
1314 spec->init_amp = ALC_INIT_GPIO2;
1315 break;
1316 case 7:
1317 spec->init_amp = ALC_INIT_GPIO3;
1318 break;
1319 case 5:
1320 spec->init_amp = ALC_INIT_DEFAULT;
1321 break;
1322 }
1323
1324 /* is laptop or Desktop and enable the function "Mute internal speaker
1325 * when the external headphone out jack is plugged"
1326 */
1327 if (!(ass & 0x8000))
1328 return 1;
1329 /*
1330 * 10~8 : Jack location
1331 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1332 * 14~13: Resvered
1333 * 15 : 1 --> enable the function "Mute internal speaker
1334 * when the external headphone out jack is plugged"
1335 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001336 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001337 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1339 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001340 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001341 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001342 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001343 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001344 nid = portd;
Kailang Yangc9b58002007-10-16 14:30:01 +02001345 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001346 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001347 for (i = 0; i < spec->autocfg.line_outs; i++)
1348 if (spec->autocfg.line_out_pins[i] == nid)
1349 return 1;
1350 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001351 }
1352
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001353 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001354 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001355 return 1;
1356}
Kailang Yangea1fb292008-08-26 12:58:38 +02001357
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001358static void alc_ssid_check(struct hda_codec *codec,
1359 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1360{
1361 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1362 struct alc_spec *spec = codec->spec;
1363 snd_printd("realtek: "
1364 "Enable default setup for auto mode as fallback\n");
1365 spec->init_amp = ALC_INIT_DEFAULT;
1366 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001367 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001368 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001369}
1370
Takashi Iwai41e41f12005-06-08 14:48:49 +02001371/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001372 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001373 */
1374
1375struct alc_pincfg {
1376 hda_nid_t nid;
1377 u32 val;
1378};
1379
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001380struct alc_fixup {
1381 const struct alc_pincfg *pins;
1382 const struct hda_verb *verbs;
1383};
1384
1385static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001386 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001387 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001388{
1389 const struct alc_pincfg *cfg;
1390
1391 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1392 if (!quirk)
1393 return;
1394
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001395 fix += quirk->value;
1396 cfg = fix->pins;
1397 if (cfg) {
1398 for (; cfg->nid; cfg++)
1399 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1400 }
1401 if (fix->verbs)
1402 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001403}
1404
1405/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001406 * ALC888
1407 */
1408
1409/*
1410 * 2ch mode
1411 */
1412static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1413/* Mic-in jack as mic in */
1414 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1415 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1416/* Line-in jack as Line in */
1417 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1418 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1419/* Line-Out as Front */
1420 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1421 { } /* end */
1422};
1423
1424/*
1425 * 4ch mode
1426 */
1427static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1428/* Mic-in jack as mic in */
1429 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1430 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1431/* Line-in jack as Surround */
1432 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1433 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1434/* Line-Out as Front */
1435 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1436 { } /* end */
1437};
1438
1439/*
1440 * 6ch mode
1441 */
1442static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1443/* Mic-in jack as CLFE */
1444 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1445 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1446/* Line-in jack as Surround */
1447 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1448 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1449/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1450 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1451 { } /* end */
1452};
1453
1454/*
1455 * 8ch mode
1456 */
1457static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1458/* Mic-in jack as CLFE */
1459 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1460 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1461/* Line-in jack as Surround */
1462 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1463 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1464/* Line-Out as Side */
1465 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1466 { } /* end */
1467};
1468
1469static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1470 { 2, alc888_4ST_ch2_intel_init },
1471 { 4, alc888_4ST_ch4_intel_init },
1472 { 6, alc888_4ST_ch6_intel_init },
1473 { 8, alc888_4ST_ch8_intel_init },
1474};
1475
1476/*
1477 * ALC888 Fujitsu Siemens Amillo xa3530
1478 */
1479
1480static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1481/* Front Mic: set to PIN_IN (empty by default) */
1482 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1483/* Connect Internal HP to Front */
1484 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1485 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1486 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1487/* Connect Bass HP to Front */
1488 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1489 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1490 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1491/* Connect Line-Out side jack (SPDIF) to Side */
1492 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1493 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1494 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1495/* Connect Mic jack to CLFE */
1496 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1497 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1499/* Connect Line-in jack to Surround */
1500 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1501 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1502 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1503/* Connect HP out jack to Front */
1504 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1505 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1506 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1507/* Enable unsolicited event for HP jack and Line-out jack */
1508 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1509 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1510 {}
1511};
1512
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001513static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001514{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001515 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +02001516 unsigned int val, mute, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001517 hda_nid_t nid;
1518 int i;
1519
1520 spec->jack_present = 0;
1521 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1522 nid = spec->autocfg.hp_pins[i];
1523 if (!nid)
1524 break;
Takashi Iwai261c2402009-06-25 08:13:40 +02001525 pincap = snd_hda_query_pin_caps(codec, nid);
1526 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1527 snd_hda_codec_read(codec, nid, 0,
1528 AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001529 val = snd_hda_codec_read(codec, nid, 0,
1530 AC_VERB_GET_PIN_SENSE, 0);
1531 if (val & AC_PINSENSE_PRESENCE) {
1532 spec->jack_present = 1;
1533 break;
1534 }
1535 }
1536
1537 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001538 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001539 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1540 nid = spec->autocfg.speaker_pins[i];
1541 if (!nid)
1542 break;
1543 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1544 HDA_AMP_MUTE, mute);
1545 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001546}
1547
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001548static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1549 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001550{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001551 if (codec->vendor_id == 0x10ec0880)
1552 res >>= 28;
1553 else
1554 res >>= 26;
1555 if (res == ALC880_HP_EVENT)
1556 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001557}
1558
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001559static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001560{
1561 struct alc_spec *spec = codec->spec;
1562
1563 spec->autocfg.hp_pins[0] = 0x15;
1564 spec->autocfg.speaker_pins[0] = 0x14;
1565 spec->autocfg.speaker_pins[1] = 0x16;
1566 spec->autocfg.speaker_pins[2] = 0x17;
1567 spec->autocfg.speaker_pins[3] = 0x19;
1568 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001569}
1570
1571static void alc889_intel_init_hook(struct hda_codec *codec)
1572{
1573 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001574 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001575}
1576
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001577static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001578{
1579 struct alc_spec *spec = codec->spec;
1580
1581 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1582 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1583 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1584 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001585}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001586
1587/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001588 * ALC888 Acer Aspire 4930G model
1589 */
1590
1591static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1592/* Front Mic: set to PIN_IN (empty by default) */
1593 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1594/* Unselect Front Mic by default in input mixer 3 */
1595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001596/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001597 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1598/* Connect Internal HP to front */
1599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1600 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1601 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1602/* Connect HP out to front */
1603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1605 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1606 { }
1607};
1608
Hector Martin3b315d72009-06-02 10:54:19 +02001609/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001610 * ALC888 Acer Aspire 6530G model
1611 */
1612
1613static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1614/* Bias voltage on for external mic port */
1615 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001616/* Front Mic: set to PIN_IN (empty by default) */
1617 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1618/* Unselect Front Mic by default in input mixer 3 */
1619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001620/* Enable unsolicited event for HP jack */
1621 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1622/* Enable speaker output */
1623 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1624 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1625/* Enable headphone output */
1626 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1627 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1628 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1629 { }
1630};
1631
1632/*
Hector Martin018df412009-06-04 00:13:40 +02001633 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001634 */
1635
Hector Martin018df412009-06-04 00:13:40 +02001636static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001637/* Front Mic: set to PIN_IN (empty by default) */
1638 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1639/* Unselect Front Mic by default in input mixer 3 */
1640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1641/* Enable unsolicited event for HP jack */
1642 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1643/* Connect Internal Front to Front */
1644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1646 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1647/* Connect Internal Rear to Rear */
1648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1649 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1650 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1651/* Connect Internal CLFE to CLFE */
1652 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1654 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1655/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001656 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001657 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1658 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1659/* Enable all DACs */
1660/* DAC DISABLE/MUTE 1? */
1661/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1662 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1663 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1664/* DAC DISABLE/MUTE 2? */
1665/* some bit here disables the other DACs. Init=0x4900 */
1666 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1667 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1668/* Enable amplifiers */
1669 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1670 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001671/* DMIC fix
1672 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1673 * which makes the stereo useless. However, either the mic or the ALC889
1674 * makes the signal become a difference/sum signal instead of standard
1675 * stereo, which is annoying. So instead we flip this bit which makes the
1676 * codec replicate the sum signal to both channels, turning it into a
1677 * normal mono mic.
1678 */
1679/* DMIC_CONTROL? Init value = 0x0001 */
1680 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1681 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001682 { }
1683};
1684
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001685static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001686 /* Front mic only available on one ADC */
1687 {
1688 .num_items = 4,
1689 .items = {
1690 { "Mic", 0x0 },
1691 { "Line", 0x2 },
1692 { "CD", 0x4 },
1693 { "Front Mic", 0xb },
1694 },
1695 },
1696 {
1697 .num_items = 3,
1698 .items = {
1699 { "Mic", 0x0 },
1700 { "Line", 0x2 },
1701 { "CD", 0x4 },
1702 },
1703 }
1704};
1705
Tony Vroond2fd4b02009-06-21 00:40:10 +01001706static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1707 /* Interal mic only available on one ADC */
1708 {
Tony Vroon684a8842009-06-26 09:27:50 +01001709 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001710 .items = {
1711 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001712 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001713 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001714 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001715 { "Int Mic", 0xb },
1716 },
1717 },
1718 {
Tony Vroon684a8842009-06-26 09:27:50 +01001719 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001720 .items = {
1721 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001722 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001723 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001724 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001725 },
1726 }
1727};
1728
Hector Martin018df412009-06-04 00:13:40 +02001729static struct hda_input_mux alc889_capture_sources[3] = {
1730 /* Digital mic only available on first "ADC" */
1731 {
1732 .num_items = 5,
1733 .items = {
1734 { "Mic", 0x0 },
1735 { "Line", 0x2 },
1736 { "CD", 0x4 },
1737 { "Front Mic", 0xb },
1738 { "Input Mix", 0xa },
1739 },
1740 },
1741 {
1742 .num_items = 4,
1743 .items = {
1744 { "Mic", 0x0 },
1745 { "Line", 0x2 },
1746 { "CD", 0x4 },
1747 { "Input Mix", 0xa },
1748 },
1749 },
1750 {
1751 .num_items = 4,
1752 .items = {
1753 { "Mic", 0x0 },
1754 { "Line", 0x2 },
1755 { "CD", 0x4 },
1756 { "Input Mix", 0xa },
1757 },
1758 }
1759};
1760
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001761static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001762 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1763 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1764 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1765 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1766 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1767 HDA_OUTPUT),
1768 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1769 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1770 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1771 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1772 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1773 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1774 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1775 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1776 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1777 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1778 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001780 { } /* end */
1781};
1782
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001783static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001784{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001785 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001786
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001787 spec->autocfg.hp_pins[0] = 0x15;
1788 spec->autocfg.speaker_pins[0] = 0x14;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001789}
1790
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001791static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001792{
1793 struct alc_spec *spec = codec->spec;
1794
1795 spec->autocfg.hp_pins[0] = 0x15;
1796 spec->autocfg.speaker_pins[0] = 0x14;
1797 spec->autocfg.speaker_pins[1] = 0x16;
1798 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001799}
1800
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001801static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001802{
1803 struct alc_spec *spec = codec->spec;
1804
1805 spec->autocfg.hp_pins[0] = 0x15;
1806 spec->autocfg.speaker_pins[0] = 0x14;
1807 spec->autocfg.speaker_pins[1] = 0x16;
1808 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001809}
1810
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001811/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001812 * ALC880 3-stack model
1813 *
1814 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001815 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1816 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001817 */
1818
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001819static hda_nid_t alc880_dac_nids[4] = {
1820 /* front, rear, clfe, rear_surr */
1821 0x02, 0x05, 0x04, 0x03
1822};
1823
1824static hda_nid_t alc880_adc_nids[3] = {
1825 /* ADC0-2 */
1826 0x07, 0x08, 0x09,
1827};
1828
1829/* The datasheet says the node 0x07 is connected from inputs,
1830 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001831 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001832 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001833static hda_nid_t alc880_adc_nids_alt[2] = {
1834 /* ADC1-2 */
1835 0x08, 0x09,
1836};
1837
1838#define ALC880_DIGOUT_NID 0x06
1839#define ALC880_DIGIN_NID 0x0a
1840
1841static struct hda_input_mux alc880_capture_source = {
1842 .num_items = 4,
1843 .items = {
1844 { "Mic", 0x0 },
1845 { "Front Mic", 0x3 },
1846 { "Line", 0x2 },
1847 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001848 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001849};
1850
1851/* channel source setting (2/6 channel selection for 3-stack) */
1852/* 2ch mode */
1853static struct hda_verb alc880_threestack_ch2_init[] = {
1854 /* set line-in to input, mute it */
1855 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1856 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1857 /* set mic-in to input vref 80%, mute it */
1858 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1859 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001860 { } /* end */
1861};
1862
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001863/* 6ch mode */
1864static struct hda_verb alc880_threestack_ch6_init[] = {
1865 /* set line-in to output, unmute it */
1866 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1867 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1868 /* set mic-in to output, unmute it */
1869 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1870 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1871 { } /* end */
1872};
1873
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001874static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001875 { 2, alc880_threestack_ch2_init },
1876 { 6, alc880_threestack_ch6_init },
1877};
1878
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001879static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001880 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001881 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001882 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001883 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001884 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1885 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001886 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1887 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1889 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1890 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1891 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1892 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1894 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1895 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001896 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001897 {
1898 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1899 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001900 .info = alc_ch_mode_info,
1901 .get = alc_ch_mode_get,
1902 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001903 },
1904 { } /* end */
1905};
1906
1907/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001908static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1909 struct snd_ctl_elem_info *uinfo)
1910{
1911 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1912 struct alc_spec *spec = codec->spec;
1913 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001914
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001915 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001916 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1917 HDA_INPUT);
1918 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001919 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001920 return err;
1921}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001922
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001923static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1924 unsigned int size, unsigned int __user *tlv)
1925{
1926 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1927 struct alc_spec *spec = codec->spec;
1928 int err;
1929
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001930 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001931 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1932 HDA_INPUT);
1933 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001934 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001935 return err;
1936}
1937
1938typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1939 struct snd_ctl_elem_value *ucontrol);
1940
1941static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1942 struct snd_ctl_elem_value *ucontrol,
1943 getput_call_t func)
1944{
1945 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1946 struct alc_spec *spec = codec->spec;
1947 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1948 int err;
1949
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001950 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001951 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1952 3, 0, HDA_INPUT);
1953 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001954 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001955 return err;
1956}
1957
1958static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1959 struct snd_ctl_elem_value *ucontrol)
1960{
1961 return alc_cap_getput_caller(kcontrol, ucontrol,
1962 snd_hda_mixer_amp_volume_get);
1963}
1964
1965static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1966 struct snd_ctl_elem_value *ucontrol)
1967{
1968 return alc_cap_getput_caller(kcontrol, ucontrol,
1969 snd_hda_mixer_amp_volume_put);
1970}
1971
1972/* capture mixer elements */
1973#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1974
1975static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1976 struct snd_ctl_elem_value *ucontrol)
1977{
1978 return alc_cap_getput_caller(kcontrol, ucontrol,
1979 snd_hda_mixer_amp_switch_get);
1980}
1981
1982static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1983 struct snd_ctl_elem_value *ucontrol)
1984{
1985 return alc_cap_getput_caller(kcontrol, ucontrol,
1986 snd_hda_mixer_amp_switch_put);
1987}
1988
Takashi Iwaia23b6882009-03-23 15:21:36 +01001989#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001990 { \
1991 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1992 .name = "Capture Switch", \
1993 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1994 .count = num, \
1995 .info = alc_cap_sw_info, \
1996 .get = alc_cap_sw_get, \
1997 .put = alc_cap_sw_put, \
1998 }, \
1999 { \
2000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2001 .name = "Capture Volume", \
2002 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2003 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2004 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2005 .count = num, \
2006 .info = alc_cap_vol_info, \
2007 .get = alc_cap_vol_get, \
2008 .put = alc_cap_vol_put, \
2009 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002010 }
2011
2012#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002013 { \
2014 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2015 /* .name = "Capture Source", */ \
2016 .name = "Input Source", \
2017 .count = num, \
2018 .info = alc_mux_enum_info, \
2019 .get = alc_mux_enum_get, \
2020 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002021 }
2022
2023#define DEFINE_CAPMIX(num) \
2024static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2025 _DEFINE_CAPMIX(num), \
2026 _DEFINE_CAPSRC(num), \
2027 { } /* end */ \
2028}
2029
2030#define DEFINE_CAPMIX_NOSRC(num) \
2031static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2032 _DEFINE_CAPMIX(num), \
2033 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002034}
2035
2036/* up to three ADCs */
2037DEFINE_CAPMIX(1);
2038DEFINE_CAPMIX(2);
2039DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002040DEFINE_CAPMIX_NOSRC(1);
2041DEFINE_CAPMIX_NOSRC(2);
2042DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002043
2044/*
2045 * ALC880 5-stack model
2046 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002047 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2048 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002049 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2050 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2051 */
2052
2053/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002054static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002055 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002056 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002057 { } /* end */
2058};
2059
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002060/* channel source setting (6/8 channel selection for 5-stack) */
2061/* 6ch mode */
2062static struct hda_verb alc880_fivestack_ch6_init[] = {
2063 /* set line-in to input, mute it */
2064 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2065 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002066 { } /* end */
2067};
2068
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002069/* 8ch mode */
2070static struct hda_verb alc880_fivestack_ch8_init[] = {
2071 /* set line-in to output, unmute it */
2072 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2073 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2074 { } /* end */
2075};
2076
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002077static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002078 { 6, alc880_fivestack_ch6_init },
2079 { 8, alc880_fivestack_ch8_init },
2080};
2081
2082
2083/*
2084 * ALC880 6-stack model
2085 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002086 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2087 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002088 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2089 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2090 */
2091
2092static hda_nid_t alc880_6st_dac_nids[4] = {
2093 /* front, rear, clfe, rear_surr */
2094 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002095};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002096
2097static struct hda_input_mux alc880_6stack_capture_source = {
2098 .num_items = 4,
2099 .items = {
2100 { "Mic", 0x0 },
2101 { "Front Mic", 0x1 },
2102 { "Line", 0x2 },
2103 { "CD", 0x4 },
2104 },
2105};
2106
2107/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002108static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002109 { 8, NULL },
2110};
2111
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002112static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002113 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002114 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002115 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002116 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002117 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2118 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002119 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2120 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002121 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002122 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002123 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2124 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2125 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2126 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2127 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2128 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2129 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2130 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002131 {
2132 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2133 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002134 .info = alc_ch_mode_info,
2135 .get = alc_ch_mode_get,
2136 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002137 },
2138 { } /* end */
2139};
2140
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002141
2142/*
2143 * ALC880 W810 model
2144 *
2145 * W810 has rear IO for:
2146 * Front (DAC 02)
2147 * Surround (DAC 03)
2148 * Center/LFE (DAC 04)
2149 * Digital out (06)
2150 *
2151 * The system also has a pair of internal speakers, and a headphone jack.
2152 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002153 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002154 * There is a variable resistor to control the speaker or headphone
2155 * volume. This is a hardware-only device without a software API.
2156 *
2157 * Plugging headphones in will disable the internal speakers. This is
2158 * implemented in hardware, not via the driver using jack sense. In
2159 * a similar fashion, plugging into the rear socket marked "front" will
2160 * disable both the speakers and headphones.
2161 *
2162 * For input, there's a microphone jack, and an "audio in" jack.
2163 * These may not do anything useful with this driver yet, because I
2164 * haven't setup any initialization verbs for these yet...
2165 */
2166
2167static hda_nid_t alc880_w810_dac_nids[3] = {
2168 /* front, rear/surround, clfe */
2169 0x02, 0x03, 0x04
2170};
2171
2172/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002173static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002174 { 6, NULL }
2175};
2176
2177/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002178static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002179 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002180 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002181 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002182 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002183 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2184 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002185 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2186 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2188 { } /* end */
2189};
2190
2191
2192/*
2193 * Z710V model
2194 *
2195 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002196 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2197 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002198 */
2199
2200static hda_nid_t alc880_z71v_dac_nids[1] = {
2201 0x02
2202};
2203#define ALC880_Z71V_HP_DAC 0x03
2204
2205/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002206static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002207 { 2, NULL }
2208};
2209
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002210static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002211 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002212 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002213 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002214 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002215 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2216 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2217 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2218 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2219 { } /* end */
2220};
2221
2222
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002223/*
2224 * ALC880 F1734 model
2225 *
2226 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2227 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2228 */
2229
2230static hda_nid_t alc880_f1734_dac_nids[1] = {
2231 0x03
2232};
2233#define ALC880_F1734_HP_DAC 0x02
2234
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002235static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002236 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002237 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002238 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2239 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002240 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2241 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2243 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002244 { } /* end */
2245};
2246
Takashi Iwai937b4162008-02-11 14:52:36 +01002247static struct hda_input_mux alc880_f1734_capture_source = {
2248 .num_items = 2,
2249 .items = {
2250 { "Mic", 0x1 },
2251 { "CD", 0x4 },
2252 },
2253};
2254
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002255
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002256/*
2257 * ALC880 ASUS model
2258 *
2259 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2260 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2261 * Mic = 0x18, Line = 0x1a
2262 */
2263
2264#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2265#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2266
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002267static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002268 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002269 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002270 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002271 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002272 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2273 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002274 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2275 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002276 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2277 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2278 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2279 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2281 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002282 {
2283 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2284 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002285 .info = alc_ch_mode_info,
2286 .get = alc_ch_mode_get,
2287 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002288 },
2289 { } /* end */
2290};
2291
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002292/*
2293 * ALC880 ASUS W1V model
2294 *
2295 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2296 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2297 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2298 */
2299
2300/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002301static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002302 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2303 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002304 { } /* end */
2305};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002306
Kailang Yangdf694da2005-12-05 19:42:22 +01002307/* TCL S700 */
2308static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2309 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2310 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2311 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2312 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2313 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2314 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2315 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2316 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2317 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002318 { } /* end */
2319};
2320
Kailang Yangccc656c2006-10-17 12:32:26 +02002321/* Uniwill */
2322static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002323 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2324 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2325 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2326 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002327 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2328 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2329 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2330 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2331 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2332 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2333 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2334 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2336 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2337 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2338 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002339 {
2340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2341 .name = "Channel Mode",
2342 .info = alc_ch_mode_info,
2343 .get = alc_ch_mode_get,
2344 .put = alc_ch_mode_put,
2345 },
2346 { } /* end */
2347};
2348
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002349static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2350 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2351 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2352 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2353 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2354 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2355 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2356 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2357 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2358 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2359 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2360 { } /* end */
2361};
2362
Kailang Yangccc656c2006-10-17 12:32:26 +02002363static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002364 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2365 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2366 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2367 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2370 { } /* end */
2371};
2372
Linus Torvalds1da177e2005-04-16 15:20:36 -07002373/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002374 * virtual master controls
2375 */
2376
2377/*
2378 * slave controls for virtual master
2379 */
2380static const char *alc_slave_vols[] = {
2381 "Front Playback Volume",
2382 "Surround Playback Volume",
2383 "Center Playback Volume",
2384 "LFE Playback Volume",
2385 "Side Playback Volume",
2386 "Headphone Playback Volume",
2387 "Speaker Playback Volume",
2388 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002389 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002390 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002391 NULL,
2392};
2393
2394static const char *alc_slave_sws[] = {
2395 "Front Playback Switch",
2396 "Surround Playback Switch",
2397 "Center Playback Switch",
2398 "LFE Playback Switch",
2399 "Side Playback Switch",
2400 "Headphone Playback Switch",
2401 "Speaker Playback Switch",
2402 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002403 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002404 NULL,
2405};
2406
2407/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002408 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002409 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002410
2411static void alc_free_kctls(struct hda_codec *codec);
2412
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002413/* additional beep mixers; the actual parameters are overwritten at build */
2414static struct snd_kcontrol_new alc_beep_mixer[] = {
2415 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2416 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2417 { } /* end */
2418};
2419
Linus Torvalds1da177e2005-04-16 15:20:36 -07002420static int alc_build_controls(struct hda_codec *codec)
2421{
2422 struct alc_spec *spec = codec->spec;
2423 int err;
2424 int i;
2425
2426 for (i = 0; i < spec->num_mixers; i++) {
2427 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2428 if (err < 0)
2429 return err;
2430 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002431 if (spec->cap_mixer) {
2432 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2433 if (err < 0)
2434 return err;
2435 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002437 err = snd_hda_create_spdif_out_ctls(codec,
2438 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 if (err < 0)
2440 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002441 if (!spec->no_analog) {
2442 err = snd_hda_create_spdif_share_sw(codec,
2443 &spec->multiout);
2444 if (err < 0)
2445 return err;
2446 spec->multiout.share_spdif = 1;
2447 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002448 }
2449 if (spec->dig_in_nid) {
2450 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2451 if (err < 0)
2452 return err;
2453 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002454
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002455 /* create beep controls if needed */
2456 if (spec->beep_amp) {
2457 struct snd_kcontrol_new *knew;
2458 for (knew = alc_beep_mixer; knew->name; knew++) {
2459 struct snd_kcontrol *kctl;
2460 kctl = snd_ctl_new1(knew, codec);
2461 if (!kctl)
2462 return -ENOMEM;
2463 kctl->private_value = spec->beep_amp;
2464 err = snd_hda_ctl_add(codec, kctl);
2465 if (err < 0)
2466 return err;
2467 }
2468 }
2469
Takashi Iwai2134ea42008-01-10 16:53:55 +01002470 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002471 if (!spec->no_analog &&
2472 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002473 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002474 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002475 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002476 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002477 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002478 if (err < 0)
2479 return err;
2480 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002481 if (!spec->no_analog &&
2482 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002483 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2484 NULL, alc_slave_sws);
2485 if (err < 0)
2486 return err;
2487 }
2488
Takashi Iwai603c4012008-07-30 15:01:44 +02002489 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002490 return 0;
2491}
2492
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002493
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494/*
2495 * initialize the codec volumes, etc
2496 */
2497
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002498/*
2499 * generic initialization of ADC, input mixers and output mixers
2500 */
2501static struct hda_verb alc880_volume_init_verbs[] = {
2502 /*
2503 * Unmute ADC0-2 and set the default input to mic-in
2504 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002505 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002506 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002507 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002508 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002509 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002510 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002511
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002512 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2513 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002514 * Note: PASD motherboards uses the Line In 2 as the input for front
2515 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002516 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002517 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2523 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2524 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002525
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002526 /*
2527 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002528 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002529 /* set vol=0 to output mixers */
2530 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2531 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2532 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2533 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2534 /* set up input amps for analog loopback */
2535 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2539 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002540 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2541 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002542 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2543 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544
2545 { }
2546};
2547
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002548/*
2549 * 3-stack pin configuration:
2550 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2551 */
2552static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2553 /*
2554 * preset connection lists of input pins
2555 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2556 */
2557 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2558 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2559 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2560
2561 /*
2562 * Set pin mode and muting
2563 */
2564 /* set front pin widgets 0x14 for output */
2565 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2566 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2567 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2568 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2569 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2570 /* Mic2 (as headphone out) for HP output */
2571 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2572 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2573 /* Line In pin widget for input */
2574 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2575 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2576 /* Line2 (as front mic) pin widget for input and vref at 80% */
2577 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2578 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2579 /* CD pin widget for input */
2580 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2581
2582 { }
2583};
2584
2585/*
2586 * 5-stack pin configuration:
2587 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2588 * line-in/side = 0x1a, f-mic = 0x1b
2589 */
2590static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2591 /*
2592 * preset connection lists of input pins
2593 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2594 */
2595 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2596 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2597
2598 /*
2599 * Set pin mode and muting
2600 */
2601 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002602 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2604 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2605 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002606 /* unmute pins for output (no gain on this amp) */
2607 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2608 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2609 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2610 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2611
Linus Torvalds1da177e2005-04-16 15:20:36 -07002612 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002613 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002614 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2615 /* Mic2 (as headphone out) for HP output */
2616 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002617 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002618 /* Line In pin widget for input */
2619 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2620 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2621 /* Line2 (as front mic) pin widget for input and vref at 80% */
2622 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2623 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2624 /* CD pin widget for input */
2625 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002626
2627 { }
2628};
2629
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002630/*
2631 * W810 pin configuration:
2632 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2633 */
2634static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002635 /* hphone/speaker input selector: front DAC */
2636 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2637
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002638 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2639 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2642 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2643 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2644
2645 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002646 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002647
Linus Torvalds1da177e2005-04-16 15:20:36 -07002648 { }
2649};
2650
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002651/*
2652 * Z71V pin configuration:
2653 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2654 */
2655static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002656 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002657 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002658 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002659 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002660
Takashi Iwai16ded522005-06-10 19:58:24 +02002661 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002662 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002663 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002664 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002665
2666 { }
2667};
2668
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002669/*
2670 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002671 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2672 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002673 */
2674static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2675 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2676
Takashi Iwai16ded522005-06-10 19:58:24 +02002677 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002678 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002679 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002680 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002681 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002682 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002683 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002684 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2685
Takashi Iwai16ded522005-06-10 19:58:24 +02002686 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002687 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002688 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002689 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002690 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002692 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002693 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002694 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002695
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002696 { }
2697};
Takashi Iwai16ded522005-06-10 19:58:24 +02002698
Kailang Yangccc656c2006-10-17 12:32:26 +02002699/*
2700 * Uniwill pin configuration:
2701 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2702 * line = 0x1a
2703 */
2704static struct hda_verb alc880_uniwill_init_verbs[] = {
2705 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2706
2707 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2708 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2709 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2711 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2712 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2713 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2714 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2715 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2716 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2717 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2718 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2719 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2720 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2721
2722 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2723 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2724 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2725 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2726 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2727 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2728 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2729 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2730 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2731
2732 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2733 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2734
2735 { }
2736};
2737
2738/*
2739* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002740* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002741 */
2742static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2743 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2744
2745 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2746 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2747 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2748 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2749 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2750 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2751 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2753 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2755 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2757
2758 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2759 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2760 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2761 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2762 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2763 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2764
2765 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2766 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2767
2768 { }
2769};
2770
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002771static struct hda_verb alc880_beep_init_verbs[] = {
2772 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2773 { }
2774};
2775
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002776/* auto-toggle front mic */
2777static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2778{
2779 unsigned int present;
2780 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002781
2782 present = snd_hda_codec_read(codec, 0x18, 0,
2783 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002784 bits = present ? HDA_AMP_MUTE : 0;
2785 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002786}
2787
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002788static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002789{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002790 struct alc_spec *spec = codec->spec;
2791
2792 spec->autocfg.hp_pins[0] = 0x14;
2793 spec->autocfg.speaker_pins[0] = 0x15;
2794 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002795}
2796
2797static void alc880_uniwill_init_hook(struct hda_codec *codec)
2798{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002799 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002800 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002801}
2802
2803static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2804 unsigned int res)
2805{
2806 /* Looks like the unsol event is incompatible with the standard
2807 * definition. 4bit tag is placed at 28 bit!
2808 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002809 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002810 case ALC880_MIC_EVENT:
2811 alc880_uniwill_mic_automute(codec);
2812 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002813 default:
2814 alc_automute_amp_unsol_event(codec, res);
2815 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002816 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002817}
2818
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002819static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002820{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002821 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002822
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002823 spec->autocfg.hp_pins[0] = 0x14;
2824 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002825}
2826
2827static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2828{
2829 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002830
Kailang Yangccc656c2006-10-17 12:32:26 +02002831 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002832 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2833 present &= HDA_AMP_VOLMASK;
2834 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2835 HDA_AMP_VOLMASK, present);
2836 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2837 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002838}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002839
Kailang Yangccc656c2006-10-17 12:32:26 +02002840static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2841 unsigned int res)
2842{
2843 /* Looks like the unsol event is incompatible with the standard
2844 * definition. 4bit tag is placed at 28 bit!
2845 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002846 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002847 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002848 else
2849 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002850}
2851
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002852/*
2853 * F1734 pin configuration:
2854 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2855 */
2856static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002857 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002858 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2859 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2860 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2861 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2862
2863 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2864 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2865 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2866 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2867
2868 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2869 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002870 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002871 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2872 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2873 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2874 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2875 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2876 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002877
Takashi Iwai937b4162008-02-11 14:52:36 +01002878 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2879 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2880
Takashi Iwai16ded522005-06-10 19:58:24 +02002881 { }
2882};
2883
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002884/*
2885 * ASUS pin configuration:
2886 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2887 */
2888static struct hda_verb alc880_pin_asus_init_verbs[] = {
2889 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2890 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2891 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2892 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2893
2894 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2895 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2896 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2897 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2898 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2899 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2900 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2901 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2902
2903 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2904 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2905 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2906 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2907 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2909 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2911 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002912
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002913 { }
2914};
2915
2916/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002917#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2918#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002919#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002920
Kailang Yangdf694da2005-12-05 19:42:22 +01002921/* Clevo m520g init */
2922static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2923 /* headphone output */
2924 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2925 /* line-out */
2926 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2927 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2928 /* Line-in */
2929 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2930 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2931 /* CD */
2932 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2933 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2934 /* Mic1 (rear panel) */
2935 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2936 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2937 /* Mic2 (front panel) */
2938 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2939 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2940 /* headphone */
2941 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2942 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2943 /* change to EAPD mode */
2944 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2945 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2946
2947 { }
2948};
2949
2950static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002951 /* change to EAPD mode */
2952 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2953 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2954
Kailang Yangdf694da2005-12-05 19:42:22 +01002955 /* Headphone output */
2956 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2957 /* Front output*/
2958 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2959 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2960
2961 /* Line In pin widget for input */
2962 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2963 /* CD pin widget for input */
2964 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2965 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2966 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2967
2968 /* change to EAPD mode */
2969 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2970 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2971
2972 { }
2973};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002974
2975/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002976 * LG m1 express dual
2977 *
2978 * Pin assignment:
2979 * Rear Line-In/Out (blue): 0x14
2980 * Build-in Mic-In: 0x15
2981 * Speaker-out: 0x17
2982 * HP-Out (green): 0x1b
2983 * Mic-In/Out (red): 0x19
2984 * SPDIF-Out: 0x1e
2985 */
2986
2987/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2988static hda_nid_t alc880_lg_dac_nids[3] = {
2989 0x05, 0x02, 0x03
2990};
2991
2992/* seems analog CD is not working */
2993static struct hda_input_mux alc880_lg_capture_source = {
2994 .num_items = 3,
2995 .items = {
2996 { "Mic", 0x1 },
2997 { "Line", 0x5 },
2998 { "Internal Mic", 0x6 },
2999 },
3000};
3001
3002/* 2,4,6 channel modes */
3003static struct hda_verb alc880_lg_ch2_init[] = {
3004 /* set line-in and mic-in to input */
3005 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3006 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3007 { }
3008};
3009
3010static struct hda_verb alc880_lg_ch4_init[] = {
3011 /* set line-in to out and mic-in to input */
3012 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3013 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3014 { }
3015};
3016
3017static struct hda_verb alc880_lg_ch6_init[] = {
3018 /* set line-in and mic-in to output */
3019 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3020 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3021 { }
3022};
3023
3024static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3025 { 2, alc880_lg_ch2_init },
3026 { 4, alc880_lg_ch4_init },
3027 { 6, alc880_lg_ch6_init },
3028};
3029
3030static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003031 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3032 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003033 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3034 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3035 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3036 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3037 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3038 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3039 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3040 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3041 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3042 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3043 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3044 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3045 {
3046 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3047 .name = "Channel Mode",
3048 .info = alc_ch_mode_info,
3049 .get = alc_ch_mode_get,
3050 .put = alc_ch_mode_put,
3051 },
3052 { } /* end */
3053};
3054
3055static struct hda_verb alc880_lg_init_verbs[] = {
3056 /* set capture source to mic-in */
3057 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3058 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3059 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3060 /* mute all amp mixer inputs */
3061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003064 /* line-in to input */
3065 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3066 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3067 /* built-in mic */
3068 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3069 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3070 /* speaker-out */
3071 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3072 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3073 /* mic-in to input */
3074 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3075 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3077 /* HP-out */
3078 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3079 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3080 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3081 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003082 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003083 { }
3084};
3085
3086/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003087static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003088{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003089 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003090
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003091 spec->autocfg.hp_pins[0] = 0x1b;
3092 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003093}
3094
3095/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003096 * LG LW20
3097 *
3098 * Pin assignment:
3099 * Speaker-out: 0x14
3100 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003101 * Built-in Mic-In: 0x19
3102 * Line-In: 0x1b
3103 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003104 * SPDIF-Out: 0x1e
3105 */
3106
Takashi Iwaid6815182006-03-23 16:06:23 +01003107static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003108 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003109 .items = {
3110 { "Mic", 0x0 },
3111 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003112 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003113 },
3114};
3115
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003116#define alc880_lg_lw_modes alc880_threestack_modes
3117
Takashi Iwaid6815182006-03-23 16:06:23 +01003118static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003119 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3120 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3121 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3122 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3123 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3124 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3125 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3126 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3131 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3132 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003133 {
3134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3135 .name = "Channel Mode",
3136 .info = alc_ch_mode_info,
3137 .get = alc_ch_mode_get,
3138 .put = alc_ch_mode_put,
3139 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003140 { } /* end */
3141};
3142
3143static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003144 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3145 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3146 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3147
Takashi Iwaid6815182006-03-23 16:06:23 +01003148 /* set capture source to mic-in */
3149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3150 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3151 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003152 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003153 /* speaker-out */
3154 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3155 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3156 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003157 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3158 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3159 /* mic-in to input */
3160 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3161 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3162 /* built-in mic */
3163 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3164 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3165 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003166 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003167 { }
3168};
3169
3170/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003171static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003172{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003173 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003174
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003175 spec->autocfg.hp_pins[0] = 0x1b;
3176 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003177}
3178
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003179static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3180 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3181 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3182 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3183 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3184 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3185 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3186 { } /* end */
3187};
3188
3189static struct hda_input_mux alc880_medion_rim_capture_source = {
3190 .num_items = 2,
3191 .items = {
3192 { "Mic", 0x0 },
3193 { "Internal Mic", 0x1 },
3194 },
3195};
3196
3197static struct hda_verb alc880_medion_rim_init_verbs[] = {
3198 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3199
3200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3201 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3202
3203 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3204 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3205 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3206 /* Mic2 (as headphone out) for HP output */
3207 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3208 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3209 /* Internal Speaker */
3210 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3211 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3212
3213 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3214 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3215
3216 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3217 { }
3218};
3219
3220/* toggle speaker-output according to the hp-jack state */
3221static void alc880_medion_rim_automute(struct hda_codec *codec)
3222{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003223 struct alc_spec *spec = codec->spec;
3224 alc_automute_amp(codec);
3225 /* toggle EAPD */
3226 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003227 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3228 else
3229 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3230}
3231
3232static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3233 unsigned int res)
3234{
3235 /* Looks like the unsol event is incompatible with the standard
3236 * definition. 4bit tag is placed at 28 bit!
3237 */
3238 if ((res >> 28) == ALC880_HP_EVENT)
3239 alc880_medion_rim_automute(codec);
3240}
3241
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003242static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003243{
3244 struct alc_spec *spec = codec->spec;
3245
3246 spec->autocfg.hp_pins[0] = 0x14;
3247 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003248}
3249
Takashi Iwaicb53c622007-08-10 17:21:45 +02003250#ifdef CONFIG_SND_HDA_POWER_SAVE
3251static struct hda_amp_list alc880_loopbacks[] = {
3252 { 0x0b, HDA_INPUT, 0 },
3253 { 0x0b, HDA_INPUT, 1 },
3254 { 0x0b, HDA_INPUT, 2 },
3255 { 0x0b, HDA_INPUT, 3 },
3256 { 0x0b, HDA_INPUT, 4 },
3257 { } /* end */
3258};
3259
3260static struct hda_amp_list alc880_lg_loopbacks[] = {
3261 { 0x0b, HDA_INPUT, 1 },
3262 { 0x0b, HDA_INPUT, 6 },
3263 { 0x0b, HDA_INPUT, 7 },
3264 { } /* end */
3265};
3266#endif
3267
Takashi Iwaid6815182006-03-23 16:06:23 +01003268/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003269 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003270 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003271
Linus Torvalds1da177e2005-04-16 15:20:36 -07003272static int alc_init(struct hda_codec *codec)
3273{
3274 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003275 unsigned int i;
3276
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003277 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003278 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003279
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003280 for (i = 0; i < spec->num_init_verbs; i++)
3281 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003282
3283 if (spec->init_hook)
3284 spec->init_hook(codec);
3285
Linus Torvalds1da177e2005-04-16 15:20:36 -07003286 return 0;
3287}
3288
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003289static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3290{
3291 struct alc_spec *spec = codec->spec;
3292
3293 if (spec->unsol_event)
3294 spec->unsol_event(codec, res);
3295}
3296
Takashi Iwaicb53c622007-08-10 17:21:45 +02003297#ifdef CONFIG_SND_HDA_POWER_SAVE
3298static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3299{
3300 struct alc_spec *spec = codec->spec;
3301 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3302}
3303#endif
3304
Linus Torvalds1da177e2005-04-16 15:20:36 -07003305/*
3306 * Analog playback callbacks
3307 */
3308static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3309 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003310 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003311{
3312 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003313 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3314 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003315}
3316
3317static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3318 struct hda_codec *codec,
3319 unsigned int stream_tag,
3320 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003321 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003322{
3323 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003324 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3325 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003326}
3327
3328static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3329 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003330 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003331{
3332 struct alc_spec *spec = codec->spec;
3333 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3334}
3335
3336/*
3337 * Digital out
3338 */
3339static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3340 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003341 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003342{
3343 struct alc_spec *spec = codec->spec;
3344 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3345}
3346
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003347static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3348 struct hda_codec *codec,
3349 unsigned int stream_tag,
3350 unsigned int format,
3351 struct snd_pcm_substream *substream)
3352{
3353 struct alc_spec *spec = codec->spec;
3354 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3355 stream_tag, format, substream);
3356}
3357
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003358static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3359 struct hda_codec *codec,
3360 struct snd_pcm_substream *substream)
3361{
3362 struct alc_spec *spec = codec->spec;
3363 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3364}
3365
Linus Torvalds1da177e2005-04-16 15:20:36 -07003366static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3367 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003368 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003369{
3370 struct alc_spec *spec = codec->spec;
3371 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3372}
3373
3374/*
3375 * Analog capture
3376 */
Takashi Iwai63300792008-01-24 15:31:36 +01003377static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003378 struct hda_codec *codec,
3379 unsigned int stream_tag,
3380 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003381 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003382{
3383 struct alc_spec *spec = codec->spec;
3384
Takashi Iwai63300792008-01-24 15:31:36 +01003385 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003386 stream_tag, 0, format);
3387 return 0;
3388}
3389
Takashi Iwai63300792008-01-24 15:31:36 +01003390static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003391 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003392 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003393{
3394 struct alc_spec *spec = codec->spec;
3395
Takashi Iwai888afa12008-03-18 09:57:50 +01003396 snd_hda_codec_cleanup_stream(codec,
3397 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003398 return 0;
3399}
3400
3401
3402/*
3403 */
3404static struct hda_pcm_stream alc880_pcm_analog_playback = {
3405 .substreams = 1,
3406 .channels_min = 2,
3407 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003408 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003409 .ops = {
3410 .open = alc880_playback_pcm_open,
3411 .prepare = alc880_playback_pcm_prepare,
3412 .cleanup = alc880_playback_pcm_cleanup
3413 },
3414};
3415
3416static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003417 .substreams = 1,
3418 .channels_min = 2,
3419 .channels_max = 2,
3420 /* NID is set in alc_build_pcms */
3421};
3422
3423static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3424 .substreams = 1,
3425 .channels_min = 2,
3426 .channels_max = 2,
3427 /* NID is set in alc_build_pcms */
3428};
3429
3430static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3431 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003432 .channels_min = 2,
3433 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003434 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003435 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003436 .prepare = alc880_alt_capture_pcm_prepare,
3437 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003438 },
3439};
3440
3441static struct hda_pcm_stream alc880_pcm_digital_playback = {
3442 .substreams = 1,
3443 .channels_min = 2,
3444 .channels_max = 2,
3445 /* NID is set in alc_build_pcms */
3446 .ops = {
3447 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003448 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003449 .prepare = alc880_dig_playback_pcm_prepare,
3450 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003451 },
3452};
3453
3454static struct hda_pcm_stream alc880_pcm_digital_capture = {
3455 .substreams = 1,
3456 .channels_min = 2,
3457 .channels_max = 2,
3458 /* NID is set in alc_build_pcms */
3459};
3460
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003461/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003462static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003463 .substreams = 0,
3464 .channels_min = 0,
3465 .channels_max = 0,
3466};
3467
Linus Torvalds1da177e2005-04-16 15:20:36 -07003468static int alc_build_pcms(struct hda_codec *codec)
3469{
3470 struct alc_spec *spec = codec->spec;
3471 struct hda_pcm *info = spec->pcm_rec;
3472 int i;
3473
3474 codec->num_pcms = 1;
3475 codec->pcm_info = info;
3476
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003477 if (spec->no_analog)
3478 goto skip_analog;
3479
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003480 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3481 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003482 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003483
Takashi Iwai4a471b72005-12-07 13:56:29 +01003484 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003485 if (snd_BUG_ON(!spec->multiout.dac_nids))
3486 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003487 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3488 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3489 }
3490 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003491 if (snd_BUG_ON(!spec->adc_nids))
3492 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003493 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3494 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3495 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003496
Takashi Iwai4a471b72005-12-07 13:56:29 +01003497 if (spec->channel_mode) {
3498 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3499 for (i = 0; i < spec->num_channel_mode; i++) {
3500 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3501 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3502 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003503 }
3504 }
3505
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003506 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003507 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003508 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003509 snprintf(spec->stream_name_digital,
3510 sizeof(spec->stream_name_digital),
3511 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003512 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003513 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003514 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003515 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003516 if (spec->dig_out_type)
3517 info->pcm_type = spec->dig_out_type;
3518 else
3519 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003520 if (spec->multiout.dig_out_nid &&
3521 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003522 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3523 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3524 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003525 if (spec->dig_in_nid &&
3526 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003527 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3528 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3529 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003530 /* FIXME: do we need this for all Realtek codec models? */
3531 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003532 }
3533
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003534 if (spec->no_analog)
3535 return 0;
3536
Takashi Iwaie08a0072006-09-07 17:52:14 +02003537 /* If the use of more than one ADC is requested for the current
3538 * model, configure a second analog capture-only PCM.
3539 */
3540 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003541 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3542 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003543 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003544 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003545 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003546 if (spec->alt_dac_nid) {
3547 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3548 *spec->stream_analog_alt_playback;
3549 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3550 spec->alt_dac_nid;
3551 } else {
3552 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3553 alc_pcm_null_stream;
3554 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3555 }
3556 if (spec->num_adc_nids > 1) {
3557 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3558 *spec->stream_analog_alt_capture;
3559 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3560 spec->adc_nids[1];
3561 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3562 spec->num_adc_nids - 1;
3563 } else {
3564 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3565 alc_pcm_null_stream;
3566 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003567 }
3568 }
3569
Linus Torvalds1da177e2005-04-16 15:20:36 -07003570 return 0;
3571}
3572
Takashi Iwai603c4012008-07-30 15:01:44 +02003573static void alc_free_kctls(struct hda_codec *codec)
3574{
3575 struct alc_spec *spec = codec->spec;
3576
3577 if (spec->kctls.list) {
3578 struct snd_kcontrol_new *kctl = spec->kctls.list;
3579 int i;
3580 for (i = 0; i < spec->kctls.used; i++)
3581 kfree(kctl[i].name);
3582 }
3583 snd_array_free(&spec->kctls);
3584}
3585
Linus Torvalds1da177e2005-04-16 15:20:36 -07003586static void alc_free(struct hda_codec *codec)
3587{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003588 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003589
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003590 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003591 return;
3592
Takashi Iwai603c4012008-07-30 15:01:44 +02003593 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003594 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003595 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003596}
3597
Takashi Iwaie044c392008-10-27 16:56:24 +01003598#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003599static int alc_resume(struct hda_codec *codec)
3600{
Takashi Iwaie044c392008-10-27 16:56:24 +01003601 codec->patch_ops.init(codec);
3602 snd_hda_codec_resume_amp(codec);
3603 snd_hda_codec_resume_cache(codec);
3604 return 0;
3605}
Takashi Iwaie044c392008-10-27 16:56:24 +01003606#endif
3607
Linus Torvalds1da177e2005-04-16 15:20:36 -07003608/*
3609 */
3610static struct hda_codec_ops alc_patch_ops = {
3611 .build_controls = alc_build_controls,
3612 .build_pcms = alc_build_pcms,
3613 .init = alc_init,
3614 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003615 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003616#ifdef SND_HDA_NEEDS_RESUME
3617 .resume = alc_resume,
3618#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003619#ifdef CONFIG_SND_HDA_POWER_SAVE
3620 .check_power_status = alc_check_power_status,
3621#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003622};
3623
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003624
3625/*
3626 * Test configuration for debugging
3627 *
3628 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3629 * enum controls.
3630 */
3631#ifdef CONFIG_SND_DEBUG
3632static hda_nid_t alc880_test_dac_nids[4] = {
3633 0x02, 0x03, 0x04, 0x05
3634};
3635
3636static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003637 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003638 .items = {
3639 { "In-1", 0x0 },
3640 { "In-2", 0x1 },
3641 { "In-3", 0x2 },
3642 { "In-4", 0x3 },
3643 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003644 { "Front", 0x5 },
3645 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003646 },
3647};
3648
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003649static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003650 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003651 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003652 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003653 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003654};
3655
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003656static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3657 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003658{
3659 static char *texts[] = {
3660 "N/A", "Line Out", "HP Out",
3661 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3662 };
3663 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3664 uinfo->count = 1;
3665 uinfo->value.enumerated.items = 8;
3666 if (uinfo->value.enumerated.item >= 8)
3667 uinfo->value.enumerated.item = 7;
3668 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3669 return 0;
3670}
3671
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003672static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3673 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003674{
3675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3676 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3677 unsigned int pin_ctl, item = 0;
3678
3679 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3680 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3681 if (pin_ctl & AC_PINCTL_OUT_EN) {
3682 if (pin_ctl & AC_PINCTL_HP_EN)
3683 item = 2;
3684 else
3685 item = 1;
3686 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3687 switch (pin_ctl & AC_PINCTL_VREFEN) {
3688 case AC_PINCTL_VREF_HIZ: item = 3; break;
3689 case AC_PINCTL_VREF_50: item = 4; break;
3690 case AC_PINCTL_VREF_GRD: item = 5; break;
3691 case AC_PINCTL_VREF_80: item = 6; break;
3692 case AC_PINCTL_VREF_100: item = 7; break;
3693 }
3694 }
3695 ucontrol->value.enumerated.item[0] = item;
3696 return 0;
3697}
3698
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003699static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3700 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003701{
3702 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3703 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3704 static unsigned int ctls[] = {
3705 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3706 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3707 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3708 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3709 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3710 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3711 };
3712 unsigned int old_ctl, new_ctl;
3713
3714 old_ctl = snd_hda_codec_read(codec, nid, 0,
3715 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3716 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3717 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003718 int val;
3719 snd_hda_codec_write_cache(codec, nid, 0,
3720 AC_VERB_SET_PIN_WIDGET_CONTROL,
3721 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003722 val = ucontrol->value.enumerated.item[0] >= 3 ?
3723 HDA_AMP_MUTE : 0;
3724 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3725 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003726 return 1;
3727 }
3728 return 0;
3729}
3730
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003731static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3732 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003733{
3734 static char *texts[] = {
3735 "Front", "Surround", "CLFE", "Side"
3736 };
3737 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3738 uinfo->count = 1;
3739 uinfo->value.enumerated.items = 4;
3740 if (uinfo->value.enumerated.item >= 4)
3741 uinfo->value.enumerated.item = 3;
3742 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3743 return 0;
3744}
3745
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003746static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3747 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003748{
3749 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3750 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3751 unsigned int sel;
3752
3753 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3754 ucontrol->value.enumerated.item[0] = sel & 3;
3755 return 0;
3756}
3757
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003758static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3759 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003760{
3761 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3762 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3763 unsigned int sel;
3764
3765 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3766 if (ucontrol->value.enumerated.item[0] != sel) {
3767 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003768 snd_hda_codec_write_cache(codec, nid, 0,
3769 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003770 return 1;
3771 }
3772 return 0;
3773}
3774
3775#define PIN_CTL_TEST(xname,nid) { \
3776 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3777 .name = xname, \
3778 .info = alc_test_pin_ctl_info, \
3779 .get = alc_test_pin_ctl_get, \
3780 .put = alc_test_pin_ctl_put, \
3781 .private_value = nid \
3782 }
3783
3784#define PIN_SRC_TEST(xname,nid) { \
3785 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3786 .name = xname, \
3787 .info = alc_test_pin_src_info, \
3788 .get = alc_test_pin_src_get, \
3789 .put = alc_test_pin_src_put, \
3790 .private_value = nid \
3791 }
3792
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003793static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003794 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3795 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3796 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3797 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003798 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3799 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3800 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3801 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003802 PIN_CTL_TEST("Front Pin Mode", 0x14),
3803 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3804 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3805 PIN_CTL_TEST("Side Pin Mode", 0x17),
3806 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3807 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3808 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3809 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3810 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3811 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3812 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3813 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3814 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3815 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3816 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3817 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3818 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3819 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3820 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3821 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3822 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3823 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003824 {
3825 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3826 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003827 .info = alc_ch_mode_info,
3828 .get = alc_ch_mode_get,
3829 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003830 },
3831 { } /* end */
3832};
3833
3834static struct hda_verb alc880_test_init_verbs[] = {
3835 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003836 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3838 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3839 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3840 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3841 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3842 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3843 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003844 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003845 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3846 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3847 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3848 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003849 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003850 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3851 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3852 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3853 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003854 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003855 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3857 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3858 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003859 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003860 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3861 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003862 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3863 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3864 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003865 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003866 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3867 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3868 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3869 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003870 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003871 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003872 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003873 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003874 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003875 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003876 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003877 /* Analog input/passthru */
3878 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3879 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3880 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3881 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3882 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003883 { }
3884};
3885#endif
3886
Linus Torvalds1da177e2005-04-16 15:20:36 -07003887/*
3888 */
3889
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003890static const char *alc880_models[ALC880_MODEL_LAST] = {
3891 [ALC880_3ST] = "3stack",
3892 [ALC880_TCL_S700] = "tcl",
3893 [ALC880_3ST_DIG] = "3stack-digout",
3894 [ALC880_CLEVO] = "clevo",
3895 [ALC880_5ST] = "5stack",
3896 [ALC880_5ST_DIG] = "5stack-digout",
3897 [ALC880_W810] = "w810",
3898 [ALC880_Z71V] = "z71v",
3899 [ALC880_6ST] = "6stack",
3900 [ALC880_6ST_DIG] = "6stack-digout",
3901 [ALC880_ASUS] = "asus",
3902 [ALC880_ASUS_W1V] = "asus-w1v",
3903 [ALC880_ASUS_DIG] = "asus-dig",
3904 [ALC880_ASUS_DIG2] = "asus-dig2",
3905 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003906 [ALC880_UNIWILL_P53] = "uniwill-p53",
3907 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003908 [ALC880_F1734] = "F1734",
3909 [ALC880_LG] = "lg",
3910 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003911 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003912#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003913 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003914#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003915 [ALC880_AUTO] = "auto",
3916};
3917
3918static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003919 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003920 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3921 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3922 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3923 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3924 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3925 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3926 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3927 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003928 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3929 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003930 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3931 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3932 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3933 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3934 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3935 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3936 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3937 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3938 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3939 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003940 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003941 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3942 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3943 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003944 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003945 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003946 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3947 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003948 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3949 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003950 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3951 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3952 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3953 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003954 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3955 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003956 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003957 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003958 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003959 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003960 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3961 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003962 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003963 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003964 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003965 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003966 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003967 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003968 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003969 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003970 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003971 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3972 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003973 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003974 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3975 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3976 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3977 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003978 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3979 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003980 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003981 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003982 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3983 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003984 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3985 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3986 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003987 /* default Intel */
3988 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003989 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3990 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003991 {}
3992};
3993
Takashi Iwai16ded522005-06-10 19:58:24 +02003994/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003995 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003996 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003997static struct alc_config_preset alc880_presets[] = {
3998 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003999 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004000 .init_verbs = { alc880_volume_init_verbs,
4001 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004002 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004003 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004004 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4005 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004006 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004007 .input_mux = &alc880_capture_source,
4008 },
4009 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004010 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004011 .init_verbs = { alc880_volume_init_verbs,
4012 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004013 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004014 .dac_nids = alc880_dac_nids,
4015 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004016 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4017 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004018 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004019 .input_mux = &alc880_capture_source,
4020 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004021 [ALC880_TCL_S700] = {
4022 .mixers = { alc880_tcl_s700_mixer },
4023 .init_verbs = { alc880_volume_init_verbs,
4024 alc880_pin_tcl_S700_init_verbs,
4025 alc880_gpio2_init_verbs },
4026 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4027 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004028 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4029 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004030 .hp_nid = 0x03,
4031 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4032 .channel_mode = alc880_2_jack_modes,
4033 .input_mux = &alc880_capture_source,
4034 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004035 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004036 .mixers = { alc880_three_stack_mixer,
4037 alc880_five_stack_mixer},
4038 .init_verbs = { alc880_volume_init_verbs,
4039 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004040 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4041 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004042 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4043 .channel_mode = alc880_fivestack_modes,
4044 .input_mux = &alc880_capture_source,
4045 },
4046 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004047 .mixers = { alc880_three_stack_mixer,
4048 alc880_five_stack_mixer },
4049 .init_verbs = { alc880_volume_init_verbs,
4050 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004051 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4052 .dac_nids = alc880_dac_nids,
4053 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004054 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4055 .channel_mode = alc880_fivestack_modes,
4056 .input_mux = &alc880_capture_source,
4057 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004058 [ALC880_6ST] = {
4059 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004060 .init_verbs = { alc880_volume_init_verbs,
4061 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004062 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4063 .dac_nids = alc880_6st_dac_nids,
4064 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4065 .channel_mode = alc880_sixstack_modes,
4066 .input_mux = &alc880_6stack_capture_source,
4067 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004068 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004069 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004070 .init_verbs = { alc880_volume_init_verbs,
4071 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004072 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4073 .dac_nids = alc880_6st_dac_nids,
4074 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004075 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4076 .channel_mode = alc880_sixstack_modes,
4077 .input_mux = &alc880_6stack_capture_source,
4078 },
4079 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004080 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004081 .init_verbs = { alc880_volume_init_verbs,
4082 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004083 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004084 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4085 .dac_nids = alc880_w810_dac_nids,
4086 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004087 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4088 .channel_mode = alc880_w810_modes,
4089 .input_mux = &alc880_capture_source,
4090 },
4091 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004092 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004093 .init_verbs = { alc880_volume_init_verbs,
4094 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004095 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4096 .dac_nids = alc880_z71v_dac_nids,
4097 .dig_out_nid = ALC880_DIGOUT_NID,
4098 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004099 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4100 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004101 .input_mux = &alc880_capture_source,
4102 },
4103 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004104 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004105 .init_verbs = { alc880_volume_init_verbs,
4106 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004107 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4108 .dac_nids = alc880_f1734_dac_nids,
4109 .hp_nid = 0x02,
4110 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4111 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004112 .input_mux = &alc880_f1734_capture_source,
4113 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004114 .setup = alc880_uniwill_p53_setup,
4115 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004116 },
4117 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004118 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004119 .init_verbs = { alc880_volume_init_verbs,
4120 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004121 alc880_gpio1_init_verbs },
4122 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4123 .dac_nids = alc880_asus_dac_nids,
4124 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4125 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004126 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004127 .input_mux = &alc880_capture_source,
4128 },
4129 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004130 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004131 .init_verbs = { alc880_volume_init_verbs,
4132 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004133 alc880_gpio1_init_verbs },
4134 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4135 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004136 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004137 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4138 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004139 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004140 .input_mux = &alc880_capture_source,
4141 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004142 [ALC880_ASUS_DIG2] = {
4143 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004144 .init_verbs = { alc880_volume_init_verbs,
4145 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004146 alc880_gpio2_init_verbs }, /* use GPIO2 */
4147 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4148 .dac_nids = alc880_asus_dac_nids,
4149 .dig_out_nid = ALC880_DIGOUT_NID,
4150 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4151 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004152 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004153 .input_mux = &alc880_capture_source,
4154 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004155 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004156 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004157 .init_verbs = { alc880_volume_init_verbs,
4158 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004159 alc880_gpio1_init_verbs },
4160 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4161 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004162 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004163 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4164 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004165 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004166 .input_mux = &alc880_capture_source,
4167 },
4168 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004169 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004170 .init_verbs = { alc880_volume_init_verbs,
4171 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004172 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4173 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004174 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004175 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4176 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004177 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004178 .input_mux = &alc880_capture_source,
4179 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004180 [ALC880_UNIWILL] = {
4181 .mixers = { alc880_uniwill_mixer },
4182 .init_verbs = { alc880_volume_init_verbs,
4183 alc880_uniwill_init_verbs },
4184 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4185 .dac_nids = alc880_asus_dac_nids,
4186 .dig_out_nid = ALC880_DIGOUT_NID,
4187 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4188 .channel_mode = alc880_threestack_modes,
4189 .need_dac_fix = 1,
4190 .input_mux = &alc880_capture_source,
4191 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004192 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004193 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004194 },
4195 [ALC880_UNIWILL_P53] = {
4196 .mixers = { alc880_uniwill_p53_mixer },
4197 .init_verbs = { alc880_volume_init_verbs,
4198 alc880_uniwill_p53_init_verbs },
4199 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4200 .dac_nids = alc880_asus_dac_nids,
4201 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004202 .channel_mode = alc880_threestack_modes,
4203 .input_mux = &alc880_capture_source,
4204 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004205 .setup = alc880_uniwill_p53_setup,
4206 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004207 },
4208 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004209 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004210 .init_verbs = { alc880_volume_init_verbs,
4211 alc880_uniwill_p53_init_verbs,
4212 alc880_beep_init_verbs },
4213 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4214 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004215 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004216 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4217 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004218 .input_mux = &alc880_capture_source,
4219 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004220 .setup = alc880_uniwill_p53_setup,
4221 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004222 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004223 [ALC880_CLEVO] = {
4224 .mixers = { alc880_three_stack_mixer },
4225 .init_verbs = { alc880_volume_init_verbs,
4226 alc880_pin_clevo_init_verbs },
4227 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4228 .dac_nids = alc880_dac_nids,
4229 .hp_nid = 0x03,
4230 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4231 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004232 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004233 .input_mux = &alc880_capture_source,
4234 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004235 [ALC880_LG] = {
4236 .mixers = { alc880_lg_mixer },
4237 .init_verbs = { alc880_volume_init_verbs,
4238 alc880_lg_init_verbs },
4239 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4240 .dac_nids = alc880_lg_dac_nids,
4241 .dig_out_nid = ALC880_DIGOUT_NID,
4242 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4243 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004244 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004245 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004246 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004247 .setup = alc880_lg_setup,
4248 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004249#ifdef CONFIG_SND_HDA_POWER_SAVE
4250 .loopbacks = alc880_lg_loopbacks,
4251#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004252 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004253 [ALC880_LG_LW] = {
4254 .mixers = { alc880_lg_lw_mixer },
4255 .init_verbs = { alc880_volume_init_verbs,
4256 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004257 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004258 .dac_nids = alc880_dac_nids,
4259 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004260 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4261 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004262 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004263 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004264 .setup = alc880_lg_lw_setup,
4265 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004266 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004267 [ALC880_MEDION_RIM] = {
4268 .mixers = { alc880_medion_rim_mixer },
4269 .init_verbs = { alc880_volume_init_verbs,
4270 alc880_medion_rim_init_verbs,
4271 alc_gpio2_init_verbs },
4272 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4273 .dac_nids = alc880_dac_nids,
4274 .dig_out_nid = ALC880_DIGOUT_NID,
4275 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4276 .channel_mode = alc880_2_jack_modes,
4277 .input_mux = &alc880_medion_rim_capture_source,
4278 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004279 .setup = alc880_medion_rim_setup,
4280 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004281 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004282#ifdef CONFIG_SND_DEBUG
4283 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004284 .mixers = { alc880_test_mixer },
4285 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004286 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4287 .dac_nids = alc880_test_dac_nids,
4288 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004289 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4290 .channel_mode = alc880_test_modes,
4291 .input_mux = &alc880_test_capture_source,
4292 },
4293#endif
4294};
4295
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004296/*
4297 * Automatic parse of I/O pins from the BIOS configuration
4298 */
4299
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004300enum {
4301 ALC_CTL_WIDGET_VOL,
4302 ALC_CTL_WIDGET_MUTE,
4303 ALC_CTL_BIND_MUTE,
4304};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004305static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004306 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4307 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004308 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004309};
4310
4311/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004312static int add_control(struct alc_spec *spec, int type, const char *name,
4313 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004314{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004315 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004316
Takashi Iwai603c4012008-07-30 15:01:44 +02004317 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4318 knew = snd_array_new(&spec->kctls);
4319 if (!knew)
4320 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004321 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004322 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004323 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004324 return -ENOMEM;
4325 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004326 return 0;
4327}
4328
4329#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4330#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4331#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4332#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004333#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4334#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4335#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4336#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4337#define ALC880_PIN_CD_NID 0x1c
4338
4339/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004340static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4341 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004342{
4343 hda_nid_t nid;
4344 int assigned[4];
4345 int i, j;
4346
4347 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004348 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004349
4350 /* check the pins hardwired to audio widget */
4351 for (i = 0; i < cfg->line_outs; i++) {
4352 nid = cfg->line_out_pins[i];
4353 if (alc880_is_fixed_pin(nid)) {
4354 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004355 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004356 assigned[idx] = 1;
4357 }
4358 }
4359 /* left pins can be connect to any audio widget */
4360 for (i = 0; i < cfg->line_outs; i++) {
4361 nid = cfg->line_out_pins[i];
4362 if (alc880_is_fixed_pin(nid))
4363 continue;
4364 /* search for an empty channel */
4365 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004366 if (!assigned[j]) {
4367 spec->multiout.dac_nids[i] =
4368 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004369 assigned[j] = 1;
4370 break;
4371 }
4372 }
4373 }
4374 spec->multiout.num_dacs = cfg->line_outs;
4375 return 0;
4376}
4377
4378/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004379static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4380 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004381{
4382 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004383 static const char *chname[4] = {
4384 "Front", "Surround", NULL /*CLFE*/, "Side"
4385 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004386 hda_nid_t nid;
4387 int i, err;
4388
4389 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004390 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004391 continue;
4392 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4393 if (i == 2) {
4394 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004395 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4396 "Center Playback Volume",
4397 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4398 HDA_OUTPUT));
4399 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004400 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004401 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4402 "LFE Playback Volume",
4403 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4404 HDA_OUTPUT));
4405 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004406 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004407 err = add_control(spec, ALC_CTL_BIND_MUTE,
4408 "Center Playback Switch",
4409 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4410 HDA_INPUT));
4411 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004412 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004413 err = add_control(spec, ALC_CTL_BIND_MUTE,
4414 "LFE Playback Switch",
4415 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4416 HDA_INPUT));
4417 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004418 return err;
4419 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004420 const char *pfx;
4421 if (cfg->line_outs == 1 &&
4422 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4423 pfx = "Speaker";
4424 else
4425 pfx = chname[i];
4426 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004427 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4428 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4429 HDA_OUTPUT));
4430 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004431 return err;
Takashi Iwaicb162b62009-08-25 16:05:03 +02004432 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004433 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4434 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4435 HDA_INPUT));
4436 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004437 return err;
4438 }
4439 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004440 return 0;
4441}
4442
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004443/* add playback controls for speaker and HP outputs */
4444static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4445 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004446{
4447 hda_nid_t nid;
4448 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004449 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004450
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004451 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004452 return 0;
4453
4454 if (alc880_is_fixed_pin(pin)) {
4455 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004456 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004457 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004458 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004459 else
4460 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004461 /* control HP volume/switch on the output mixer amp */
4462 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004463 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004464 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4465 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4466 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004467 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004468 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004469 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4470 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4471 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004472 return err;
4473 } else if (alc880_is_multi_pin(pin)) {
4474 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004475 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004476 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004477 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4478 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4479 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004480 return err;
4481 }
4482 return 0;
4483}
4484
4485/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004486static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4487 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004488 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004489{
4490 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004491 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004492
4493 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004494 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4495 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4496 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004497 return err;
4498 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004499 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4500 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4501 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004502 return err;
4503 return 0;
4504}
4505
Takashi Iwai05f5f472009-08-25 13:10:18 +02004506static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004507{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004508 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4509 return (pincap & AC_PINCAP_IN) != 0;
4510}
4511
4512/* create playback/capture controls for input pins */
4513static int alc_auto_create_input_ctls(struct hda_codec *codec,
4514 const struct auto_pin_cfg *cfg,
4515 hda_nid_t mixer,
4516 hda_nid_t cap1, hda_nid_t cap2)
4517{
4518 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004519 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004520 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004521
4522 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004523 hda_nid_t pin;
4524
4525 pin = cfg->input_pins[i];
4526 if (!alc_is_input_pin(codec, pin))
4527 continue;
4528
4529 if (mixer) {
4530 idx = get_connection_index(codec, mixer, pin);
4531 if (idx >= 0) {
4532 err = new_analog_input(spec, pin,
4533 auto_pin_cfg_labels[i],
4534 idx, mixer);
4535 if (err < 0)
4536 return err;
4537 }
4538 }
4539
4540 if (!cap1)
4541 continue;
4542 idx = get_connection_index(codec, cap1, pin);
4543 if (idx < 0 && cap2)
4544 idx = get_connection_index(codec, cap2, pin);
4545 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004546 imux->items[imux->num_items].label =
4547 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004548 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004549 imux->num_items++;
4550 }
4551 }
4552 return 0;
4553}
4554
Takashi Iwai05f5f472009-08-25 13:10:18 +02004555static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4556 const struct auto_pin_cfg *cfg)
4557{
4558 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4559}
4560
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004561static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4562 unsigned int pin_type)
4563{
4564 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4565 pin_type);
4566 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004567 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4568 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004569}
4570
Kailang Yangdf694da2005-12-05 19:42:22 +01004571static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4572 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004573 int dac_idx)
4574{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004575 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004576 /* need the manual connection? */
4577 if (alc880_is_multi_pin(nid)) {
4578 struct alc_spec *spec = codec->spec;
4579 int idx = alc880_multi_pin_idx(nid);
4580 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4581 AC_VERB_SET_CONNECT_SEL,
4582 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4583 }
4584}
4585
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004586static int get_pin_type(int line_out_type)
4587{
4588 if (line_out_type == AUTO_PIN_HP_OUT)
4589 return PIN_HP;
4590 else
4591 return PIN_OUT;
4592}
4593
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004594static void alc880_auto_init_multi_out(struct hda_codec *codec)
4595{
4596 struct alc_spec *spec = codec->spec;
4597 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004598
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004599 for (i = 0; i < spec->autocfg.line_outs; i++) {
4600 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004601 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4602 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004603 }
4604}
4605
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004606static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004607{
4608 struct alc_spec *spec = codec->spec;
4609 hda_nid_t pin;
4610
Takashi Iwai82bc9552006-03-21 11:24:42 +01004611 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004612 if (pin) /* connect to front */
4613 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004614 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004615 if (pin) /* connect to front */
4616 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4617}
4618
4619static void alc880_auto_init_analog_input(struct hda_codec *codec)
4620{
4621 struct alc_spec *spec = codec->spec;
4622 int i;
4623
4624 for (i = 0; i < AUTO_PIN_LAST; i++) {
4625 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004626 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004627 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004628 if (nid != ALC880_PIN_CD_NID &&
4629 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004630 snd_hda_codec_write(codec, nid, 0,
4631 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004632 AMP_OUT_MUTE);
4633 }
4634 }
4635}
4636
4637/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004638/* return 1 if successful, 0 if the proper config is not found,
4639 * or a negative error code
4640 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004641static int alc880_parse_auto_config(struct hda_codec *codec)
4642{
4643 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004644 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004645 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004646
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004647 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4648 alc880_ignore);
4649 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004650 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004651 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004652 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004653
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004654 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4655 if (err < 0)
4656 return err;
4657 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4658 if (err < 0)
4659 return err;
4660 err = alc880_auto_create_extra_out(spec,
4661 spec->autocfg.speaker_pins[0],
4662 "Speaker");
4663 if (err < 0)
4664 return err;
4665 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4666 "Headphone");
4667 if (err < 0)
4668 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004669 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004670 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004671 return err;
4672
4673 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4674
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004675 /* check multiple SPDIF-out (for recent codecs) */
4676 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4677 hda_nid_t dig_nid;
4678 err = snd_hda_get_connections(codec,
4679 spec->autocfg.dig_out_pins[i],
4680 &dig_nid, 1);
4681 if (err < 0)
4682 continue;
4683 if (!i)
4684 spec->multiout.dig_out_nid = dig_nid;
4685 else {
4686 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004687 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004688 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004689 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004690 }
4691 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004692 if (spec->autocfg.dig_in_pin)
4693 spec->dig_in_nid = ALC880_DIGIN_NID;
4694
Takashi Iwai603c4012008-07-30 15:01:44 +02004695 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004696 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004697
Takashi Iwaid88897e2008-10-31 15:01:37 +01004698 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004699
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004700 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004701 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004702
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004703 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4704
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004705 return 1;
4706}
4707
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004708/* additional initialization for auto-configuration model */
4709static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004710{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004711 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004712 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004713 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004714 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004715 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004716 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004717}
4718
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004719/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4720 * one of two digital mic pins, e.g. on ALC272
4721 */
4722static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004723{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004724 struct alc_spec *spec = codec->spec;
4725 int i;
4726
4727 for (i = 0; i < spec->num_adc_nids; i++) {
4728 hda_nid_t cap = spec->capsrc_nids ?
4729 spec->capsrc_nids[i] : spec->adc_nids[i];
4730 int iidx, eidx;
4731
4732 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4733 if (iidx < 0)
4734 continue;
4735 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4736 if (eidx < 0)
4737 continue;
4738 spec->int_mic.mux_idx = iidx;
4739 spec->ext_mic.mux_idx = eidx;
4740 if (spec->capsrc_nids)
4741 spec->capsrc_nids += i;
4742 spec->adc_nids += i;
4743 spec->num_adc_nids = 1;
4744 return;
4745 }
4746 snd_printd(KERN_INFO "hda_codec: %s: "
4747 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4748 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4749 spec->auto_mic = 0; /* disable auto-mic to be sure */
4750}
4751
4752static void set_capture_mixer(struct hda_codec *codec)
4753{
4754 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004755 static struct snd_kcontrol_new *caps[2][3] = {
4756 { alc_capture_mixer_nosrc1,
4757 alc_capture_mixer_nosrc2,
4758 alc_capture_mixer_nosrc3 },
4759 { alc_capture_mixer1,
4760 alc_capture_mixer2,
4761 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004762 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004763 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4764 int mux;
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004765 if (spec->auto_mic) {
4766 mux = 0;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004767 fixup_automic_adc(codec);
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004768 } else if (spec->input_mux && spec->input_mux->num_items > 1)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004769 mux = 1;
4770 else
4771 mux = 0;
4772 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4773 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004774}
4775
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004776#define set_beep_amp(spec, nid, idx, dir) \
4777 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4778
4779/*
4780 * OK, here we have finally the patch for ALC880
4781 */
4782
Linus Torvalds1da177e2005-04-16 15:20:36 -07004783static int patch_alc880(struct hda_codec *codec)
4784{
4785 struct alc_spec *spec;
4786 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004787 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004788
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004789 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004790 if (spec == NULL)
4791 return -ENOMEM;
4792
4793 codec->spec = spec;
4794
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004795 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4796 alc880_models,
4797 alc880_cfg_tbl);
4798 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004799 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4800 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004801 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004802 }
4803
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004804 if (board_config == ALC880_AUTO) {
4805 /* automatic parse from the BIOS config */
4806 err = alc880_parse_auto_config(codec);
4807 if (err < 0) {
4808 alc_free(codec);
4809 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004810 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004811 printk(KERN_INFO
4812 "hda_codec: Cannot set up configuration "
4813 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004814 board_config = ALC880_3ST;
4815 }
4816 }
4817
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004818 err = snd_hda_attach_beep_device(codec, 0x1);
4819 if (err < 0) {
4820 alc_free(codec);
4821 return err;
4822 }
4823
Kailang Yangdf694da2005-12-05 19:42:22 +01004824 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004825 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004826
Linus Torvalds1da177e2005-04-16 15:20:36 -07004827 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4828 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004829 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004830
Linus Torvalds1da177e2005-04-16 15:20:36 -07004831 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4832 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4833
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004834 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004835 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004836 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004837 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004838 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004839 if (wcap != AC_WID_AUD_IN) {
4840 spec->adc_nids = alc880_adc_nids_alt;
4841 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004842 } else {
4843 spec->adc_nids = alc880_adc_nids;
4844 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004845 }
4846 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004847 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004848 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004849
Takashi Iwai2134ea42008-01-10 16:53:55 +01004850 spec->vmaster_nid = 0x0c;
4851
Linus Torvalds1da177e2005-04-16 15:20:36 -07004852 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004853 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004854 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004855#ifdef CONFIG_SND_HDA_POWER_SAVE
4856 if (!spec->loopback.amplist)
4857 spec->loopback.amplist = alc880_loopbacks;
4858#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004859 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004860
4861 return 0;
4862}
4863
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004864
Linus Torvalds1da177e2005-04-16 15:20:36 -07004865/*
4866 * ALC260 support
4867 */
4868
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004869static hda_nid_t alc260_dac_nids[1] = {
4870 /* front */
4871 0x02,
4872};
4873
4874static hda_nid_t alc260_adc_nids[1] = {
4875 /* ADC0 */
4876 0x04,
4877};
4878
Kailang Yangdf694da2005-12-05 19:42:22 +01004879static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004880 /* ADC1 */
4881 0x05,
4882};
4883
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004884/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4885 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4886 */
4887static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004888 /* ADC0, ADC1 */
4889 0x04, 0x05
4890};
4891
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004892#define ALC260_DIGOUT_NID 0x03
4893#define ALC260_DIGIN_NID 0x06
4894
4895static struct hda_input_mux alc260_capture_source = {
4896 .num_items = 4,
4897 .items = {
4898 { "Mic", 0x0 },
4899 { "Front Mic", 0x1 },
4900 { "Line", 0x2 },
4901 { "CD", 0x4 },
4902 },
4903};
4904
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004905/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004906 * headphone jack and the internal CD lines since these are the only pins at
4907 * which audio can appear. For flexibility, also allow the option of
4908 * recording the mixer output on the second ADC (ADC0 doesn't have a
4909 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004910 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004911static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4912 {
4913 .num_items = 3,
4914 .items = {
4915 { "Mic/Line", 0x0 },
4916 { "CD", 0x4 },
4917 { "Headphone", 0x2 },
4918 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004919 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004920 {
4921 .num_items = 4,
4922 .items = {
4923 { "Mic/Line", 0x0 },
4924 { "CD", 0x4 },
4925 { "Headphone", 0x2 },
4926 { "Mixer", 0x5 },
4927 },
4928 },
4929
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004930};
4931
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004932/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4933 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004934 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004935static struct hda_input_mux alc260_acer_capture_sources[2] = {
4936 {
4937 .num_items = 4,
4938 .items = {
4939 { "Mic", 0x0 },
4940 { "Line", 0x2 },
4941 { "CD", 0x4 },
4942 { "Headphone", 0x5 },
4943 },
4944 },
4945 {
4946 .num_items = 5,
4947 .items = {
4948 { "Mic", 0x0 },
4949 { "Line", 0x2 },
4950 { "CD", 0x4 },
4951 { "Headphone", 0x6 },
4952 { "Mixer", 0x5 },
4953 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004954 },
4955};
Michael Schwingencc959482009-02-22 18:58:45 +01004956
4957/* Maxdata Favorit 100XS */
4958static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4959 {
4960 .num_items = 2,
4961 .items = {
4962 { "Line/Mic", 0x0 },
4963 { "CD", 0x4 },
4964 },
4965 },
4966 {
4967 .num_items = 3,
4968 .items = {
4969 { "Line/Mic", 0x0 },
4970 { "CD", 0x4 },
4971 { "Mixer", 0x5 },
4972 },
4973 },
4974};
4975
Linus Torvalds1da177e2005-04-16 15:20:36 -07004976/*
4977 * This is just place-holder, so there's something for alc_build_pcms to look
4978 * at when it calculates the maximum number of channels. ALC260 has no mixer
4979 * element which allows changing the channel mode, so the verb list is
4980 * never used.
4981 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004982static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004983 { 2, NULL },
4984};
4985
Kailang Yangdf694da2005-12-05 19:42:22 +01004986
4987/* Mixer combinations
4988 *
4989 * basic: base_output + input + pc_beep + capture
4990 * HP: base_output + input + capture_alt
4991 * HP_3013: hp_3013 + input + capture
4992 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004993 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004994 */
4995
4996static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004997 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004998 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004999 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5000 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5001 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5002 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5003 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005004};
Kailang Yangdf694da2005-12-05 19:42:22 +01005005
5006static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005007 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5008 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5009 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5010 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5012 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5013 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5014 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005015 { } /* end */
5016};
5017
Takashi Iwaibec15c32008-01-28 18:16:30 +01005018/* update HP, line and mono out pins according to the master switch */
5019static void alc260_hp_master_update(struct hda_codec *codec,
5020 hda_nid_t hp, hda_nid_t line,
5021 hda_nid_t mono)
5022{
5023 struct alc_spec *spec = codec->spec;
5024 unsigned int val = spec->master_sw ? PIN_HP : 0;
5025 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005026 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005027 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005028 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005029 val);
5030 /* mono (speaker) depending on the HP jack sense */
5031 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005032 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005033 val);
5034}
5035
5036static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5037 struct snd_ctl_elem_value *ucontrol)
5038{
5039 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5040 struct alc_spec *spec = codec->spec;
5041 *ucontrol->value.integer.value = spec->master_sw;
5042 return 0;
5043}
5044
5045static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5046 struct snd_ctl_elem_value *ucontrol)
5047{
5048 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5049 struct alc_spec *spec = codec->spec;
5050 int val = !!*ucontrol->value.integer.value;
5051 hda_nid_t hp, line, mono;
5052
5053 if (val == spec->master_sw)
5054 return 0;
5055 spec->master_sw = val;
5056 hp = (kcontrol->private_value >> 16) & 0xff;
5057 line = (kcontrol->private_value >> 8) & 0xff;
5058 mono = kcontrol->private_value & 0xff;
5059 alc260_hp_master_update(codec, hp, line, mono);
5060 return 1;
5061}
5062
5063static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5064 {
5065 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5066 .name = "Master Playback Switch",
5067 .info = snd_ctl_boolean_mono_info,
5068 .get = alc260_hp_master_sw_get,
5069 .put = alc260_hp_master_sw_put,
5070 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5071 },
5072 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5073 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5074 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5075 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5076 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5077 HDA_OUTPUT),
5078 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5079 { } /* end */
5080};
5081
5082static struct hda_verb alc260_hp_unsol_verbs[] = {
5083 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5084 {},
5085};
5086
5087static void alc260_hp_automute(struct hda_codec *codec)
5088{
5089 struct alc_spec *spec = codec->spec;
5090 unsigned int present;
5091
5092 present = snd_hda_codec_read(codec, 0x10, 0,
5093 AC_VERB_GET_PIN_SENSE, 0);
5094 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5095 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5096}
5097
5098static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5099{
5100 if ((res >> 26) == ALC880_HP_EVENT)
5101 alc260_hp_automute(codec);
5102}
5103
Kailang Yangdf694da2005-12-05 19:42:22 +01005104static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005105 {
5106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5107 .name = "Master Playback Switch",
5108 .info = snd_ctl_boolean_mono_info,
5109 .get = alc260_hp_master_sw_get,
5110 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005111 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005112 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005113 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5114 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5115 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5116 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5117 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5118 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005119 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5120 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005121 { } /* end */
5122};
5123
Kailang Yang3f878302008-08-26 13:02:23 +02005124static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5125 .ops = &snd_hda_bind_vol,
5126 .values = {
5127 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5128 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5129 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5130 0
5131 },
5132};
5133
5134static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5135 .ops = &snd_hda_bind_sw,
5136 .values = {
5137 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5138 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5139 0
5140 },
5141};
5142
5143static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5144 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5145 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5146 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5147 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5148 { } /* end */
5149};
5150
Takashi Iwaibec15c32008-01-28 18:16:30 +01005151static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5152 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5153 {},
5154};
5155
5156static void alc260_hp_3013_automute(struct hda_codec *codec)
5157{
5158 struct alc_spec *spec = codec->spec;
5159 unsigned int present;
5160
5161 present = snd_hda_codec_read(codec, 0x15, 0,
5162 AC_VERB_GET_PIN_SENSE, 0);
5163 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005164 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005165}
5166
5167static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5168 unsigned int res)
5169{
5170 if ((res >> 26) == ALC880_HP_EVENT)
5171 alc260_hp_3013_automute(codec);
5172}
5173
Kailang Yang3f878302008-08-26 13:02:23 +02005174static void alc260_hp_3012_automute(struct hda_codec *codec)
5175{
5176 unsigned int present, bits;
5177
5178 present = snd_hda_codec_read(codec, 0x10, 0,
5179 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
5180
5181 bits = present ? 0 : PIN_OUT;
5182 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5183 bits);
5184 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5185 bits);
5186 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5187 bits);
5188}
5189
5190static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5191 unsigned int res)
5192{
5193 if ((res >> 26) == ALC880_HP_EVENT)
5194 alc260_hp_3012_automute(codec);
5195}
5196
5197/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005198 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5199 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005200static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005201 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005202 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005203 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005204 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5205 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5206 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5207 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005208 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005209 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5210 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005211 { } /* end */
5212};
5213
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005214/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5215 * versions of the ALC260 don't act on requests to enable mic bias from NID
5216 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5217 * datasheet doesn't mention this restriction. At this stage it's not clear
5218 * whether this behaviour is intentional or is a hardware bug in chip
5219 * revisions available in early 2006. Therefore for now allow the
5220 * "Headphone Jack Mode" control to span all choices, but if it turns out
5221 * that the lack of mic bias for this NID is intentional we could change the
5222 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5223 *
5224 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5225 * don't appear to make the mic bias available from the "line" jack, even
5226 * though the NID used for this jack (0x14) can supply it. The theory is
5227 * that perhaps Acer have included blocking capacitors between the ALC260
5228 * and the output jack. If this turns out to be the case for all such
5229 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5230 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005231 *
5232 * The C20x Tablet series have a mono internal speaker which is controlled
5233 * via the chip's Mono sum widget and pin complex, so include the necessary
5234 * controls for such models. On models without a "mono speaker" the control
5235 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005236 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005237static struct snd_kcontrol_new alc260_acer_mixer[] = {
5238 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5239 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005240 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005241 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005242 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005243 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005244 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005245 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5246 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5247 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5248 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5249 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5250 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5251 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5252 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005253 { } /* end */
5254};
5255
Michael Schwingencc959482009-02-22 18:58:45 +01005256/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5257 */
5258static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5259 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5260 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5261 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5262 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5263 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5264 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5265 { } /* end */
5266};
5267
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005268/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5269 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5270 */
5271static struct snd_kcontrol_new alc260_will_mixer[] = {
5272 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5273 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5274 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5275 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5276 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5277 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5278 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5279 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5280 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5281 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005282 { } /* end */
5283};
5284
5285/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5286 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5287 */
5288static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5289 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5290 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5291 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5292 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5293 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5294 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5295 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5296 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5297 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5298 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5299 { } /* end */
5300};
5301
Kailang Yangdf694da2005-12-05 19:42:22 +01005302/*
5303 * initialization verbs
5304 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005305static struct hda_verb alc260_init_verbs[] = {
5306 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005307 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005308 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005309 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005310 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005311 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005312 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005313 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005314 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005315 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005316 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005317 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005318 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005319 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005320 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005321 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005322 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005323 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5324 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005325 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005326 /* set connection select to line in (default select for this ADC) */
5327 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005328 /* mute capture amp left and right */
5329 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5330 /* set connection select to line in (default select for this ADC) */
5331 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005332 /* set vol=0 Line-Out mixer amp left and right */
5333 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5334 /* unmute pin widget amp left and right (no gain on this amp) */
5335 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5336 /* set vol=0 HP mixer amp left and right */
5337 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5338 /* unmute pin widget amp left and right (no gain on this amp) */
5339 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5340 /* set vol=0 Mono mixer amp left and right */
5341 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5342 /* unmute pin widget amp left and right (no gain on this amp) */
5343 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5344 /* unmute LINE-2 out pin */
5345 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005346 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5347 * Line In 2 = 0x03
5348 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005349 /* mute analog inputs */
5350 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5351 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5352 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5353 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5354 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005355 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005356 /* mute Front out path */
5357 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5358 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5359 /* mute Headphone out path */
5360 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5361 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5362 /* mute Mono out path */
5363 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5364 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005365 { }
5366};
5367
Takashi Iwai474167d2006-05-17 17:17:43 +02005368#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005369static struct hda_verb alc260_hp_init_verbs[] = {
5370 /* Headphone and output */
5371 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5372 /* mono output */
5373 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5374 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5375 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5376 /* Mic2 (front panel) pin widget for input and vref at 80% */
5377 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5378 /* Line In pin widget for input */
5379 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5380 /* Line-2 pin widget for output */
5381 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5382 /* CD pin widget for input */
5383 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5384 /* unmute amp left and right */
5385 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5386 /* set connection select to line in (default select for this ADC) */
5387 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5388 /* unmute Line-Out mixer amp left and right (volume = 0) */
5389 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5390 /* mute pin widget amp left and right (no gain on this amp) */
5391 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5392 /* unmute HP mixer amp left and right (volume = 0) */
5393 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5394 /* mute pin widget amp left and right (no gain on this amp) */
5395 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005396 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5397 * Line In 2 = 0x03
5398 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005399 /* mute analog inputs */
5400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5401 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005405 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5406 /* Unmute Front out path */
5407 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5408 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5409 /* Unmute Headphone out path */
5410 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5411 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5412 /* Unmute Mono out path */
5413 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5414 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5415 { }
5416};
Takashi Iwai474167d2006-05-17 17:17:43 +02005417#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005418
5419static struct hda_verb alc260_hp_3013_init_verbs[] = {
5420 /* Line out and output */
5421 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5422 /* mono output */
5423 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5424 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5425 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5426 /* Mic2 (front panel) pin widget for input and vref at 80% */
5427 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5428 /* Line In pin widget for input */
5429 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5430 /* Headphone pin widget for output */
5431 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5432 /* CD pin widget for input */
5433 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5434 /* unmute amp left and right */
5435 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5436 /* set connection select to line in (default select for this ADC) */
5437 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5438 /* unmute Line-Out mixer amp left and right (volume = 0) */
5439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5440 /* mute pin widget amp left and right (no gain on this amp) */
5441 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5442 /* unmute HP mixer amp left and right (volume = 0) */
5443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5444 /* mute pin widget amp left and right (no gain on this amp) */
5445 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005446 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5447 * Line In 2 = 0x03
5448 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005449 /* mute analog inputs */
5450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5451 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005455 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5456 /* Unmute Front out path */
5457 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5458 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5459 /* Unmute Headphone out path */
5460 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5461 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5462 /* Unmute Mono out path */
5463 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5464 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5465 { }
5466};
5467
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005468/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005469 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5470 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005471 */
5472static struct hda_verb alc260_fujitsu_init_verbs[] = {
5473 /* Disable all GPIOs */
5474 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5475 /* Internal speaker is connected to headphone pin */
5476 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5477 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5478 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005479 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5480 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5481 /* Ensure all other unused pins are disabled and muted. */
5482 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5483 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005484 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005485 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005486 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005487 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5488 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5489 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005490
Jonathan Woithef7ace402006-02-28 11:46:14 +01005491 /* Disable digital (SPDIF) pins */
5492 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5493 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005494
Kailang Yangea1fb292008-08-26 12:58:38 +02005495 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005496 * when acting as an output.
5497 */
5498 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5499
5500 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005501 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5502 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5503 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5504 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5505 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5506 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5507 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5508 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5509 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005510
Jonathan Woithef7ace402006-02-28 11:46:14 +01005511 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5512 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5513 /* Unmute Line1 pin widget output buffer since it starts as an output.
5514 * If the pin mode is changed by the user the pin mode control will
5515 * take care of enabling the pin's input/output buffers as needed.
5516 * Therefore there's no need to enable the input buffer at this
5517 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005518 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005519 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005520 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005521 * mixer ctrl)
5522 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005523 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005524
Jonathan Woithef7ace402006-02-28 11:46:14 +01005525 /* Mute capture amp left and right */
5526 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005527 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005528 * in (on mic1 pin)
5529 */
5530 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005531
Jonathan Woithef7ace402006-02-28 11:46:14 +01005532 /* Do the same for the second ADC: mute capture input amp and
5533 * set ADC connection to line in (on mic1 pin)
5534 */
5535 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5536 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005537
Jonathan Woithef7ace402006-02-28 11:46:14 +01005538 /* Mute all inputs to mixer widget (even unconnected ones) */
5539 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5540 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5541 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005547
5548 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005549};
5550
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005551/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5552 * similar laptops (adapted from Fujitsu init verbs).
5553 */
5554static struct hda_verb alc260_acer_init_verbs[] = {
5555 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5556 * the headphone jack. Turn this on and rely on the standard mute
5557 * methods whenever the user wants to turn these outputs off.
5558 */
5559 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5560 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5561 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5562 /* Internal speaker/Headphone jack is connected to Line-out pin */
5563 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5564 /* Internal microphone/Mic jack is connected to Mic1 pin */
5565 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5566 /* Line In jack is connected to Line1 pin */
5567 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005568 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5569 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005570 /* Ensure all other unused pins are disabled and muted. */
5571 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5572 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005573 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5574 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5577 /* Disable digital (SPDIF) pins */
5578 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5579 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5580
Kailang Yangea1fb292008-08-26 12:58:38 +02005581 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005582 * bus when acting as outputs.
5583 */
5584 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5585 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5586
5587 /* Start with output sum widgets muted and their output gains at min */
5588 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5589 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5590 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5591 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5592 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5593 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5594 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5595 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5596 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5597
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005598 /* Unmute Line-out pin widget amp left and right
5599 * (no equiv mixer ctrl)
5600 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005601 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005602 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5603 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005604 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5605 * inputs. If the pin mode is changed by the user the pin mode control
5606 * will take care of enabling the pin's input/output buffers as needed.
5607 * Therefore there's no need to enable the input buffer at this
5608 * stage.
5609 */
5610 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5611 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5612
5613 /* Mute capture amp left and right */
5614 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5615 /* Set ADC connection select to match default mixer setting - mic
5616 * (on mic1 pin)
5617 */
5618 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5619
5620 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005621 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005622 */
5623 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005624 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005625
5626 /* Mute all inputs to mixer widget (even unconnected ones) */
5627 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5629 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5630 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5633 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5634 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5635
5636 { }
5637};
5638
Michael Schwingencc959482009-02-22 18:58:45 +01005639/* Initialisation sequence for Maxdata Favorit 100XS
5640 * (adapted from Acer init verbs).
5641 */
5642static struct hda_verb alc260_favorit100_init_verbs[] = {
5643 /* GPIO 0 enables the output jack.
5644 * Turn this on and rely on the standard mute
5645 * methods whenever the user wants to turn these outputs off.
5646 */
5647 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5648 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5649 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5650 /* Line/Mic input jack is connected to Mic1 pin */
5651 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5652 /* Ensure all other unused pins are disabled and muted. */
5653 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5654 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5655 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5656 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5657 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5658 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5661 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5663 /* Disable digital (SPDIF) pins */
5664 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5665 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5666
5667 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5668 * bus when acting as outputs.
5669 */
5670 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5671 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5672
5673 /* Start with output sum widgets muted and their output gains at min */
5674 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5675 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5676 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5677 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5678 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5679 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5680 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5681 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5682 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5683
5684 /* Unmute Line-out pin widget amp left and right
5685 * (no equiv mixer ctrl)
5686 */
5687 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5688 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5689 * inputs. If the pin mode is changed by the user the pin mode control
5690 * will take care of enabling the pin's input/output buffers as needed.
5691 * Therefore there's no need to enable the input buffer at this
5692 * stage.
5693 */
5694 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5695
5696 /* Mute capture amp left and right */
5697 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5698 /* Set ADC connection select to match default mixer setting - mic
5699 * (on mic1 pin)
5700 */
5701 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5702
5703 /* Do similar with the second ADC: mute capture input amp and
5704 * set ADC connection to mic to match ALSA's default state.
5705 */
5706 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5707 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5708
5709 /* Mute all inputs to mixer widget (even unconnected ones) */
5710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5711 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5714 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5715 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5717 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5718
5719 { }
5720};
5721
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005722static struct hda_verb alc260_will_verbs[] = {
5723 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5724 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5725 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5726 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5727 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5728 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5729 {}
5730};
5731
5732static struct hda_verb alc260_replacer_672v_verbs[] = {
5733 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5734 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5735 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5736
5737 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5738 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5739 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5740
5741 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5742 {}
5743};
5744
5745/* toggle speaker-output according to the hp-jack state */
5746static void alc260_replacer_672v_automute(struct hda_codec *codec)
5747{
5748 unsigned int present;
5749
5750 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5751 present = snd_hda_codec_read(codec, 0x0f, 0,
5752 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5753 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005754 snd_hda_codec_write_cache(codec, 0x01, 0,
5755 AC_VERB_SET_GPIO_DATA, 1);
5756 snd_hda_codec_write_cache(codec, 0x0f, 0,
5757 AC_VERB_SET_PIN_WIDGET_CONTROL,
5758 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005759 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005760 snd_hda_codec_write_cache(codec, 0x01, 0,
5761 AC_VERB_SET_GPIO_DATA, 0);
5762 snd_hda_codec_write_cache(codec, 0x0f, 0,
5763 AC_VERB_SET_PIN_WIDGET_CONTROL,
5764 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005765 }
5766}
5767
5768static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5769 unsigned int res)
5770{
5771 if ((res >> 26) == ALC880_HP_EVENT)
5772 alc260_replacer_672v_automute(codec);
5773}
5774
Kailang Yang3f878302008-08-26 13:02:23 +02005775static struct hda_verb alc260_hp_dc7600_verbs[] = {
5776 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5777 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5778 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5779 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5780 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5781 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5782 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5783 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5784 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5785 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5786 {}
5787};
5788
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005789/* Test configuration for debugging, modelled after the ALC880 test
5790 * configuration.
5791 */
5792#ifdef CONFIG_SND_DEBUG
5793static hda_nid_t alc260_test_dac_nids[1] = {
5794 0x02,
5795};
5796static hda_nid_t alc260_test_adc_nids[2] = {
5797 0x04, 0x05,
5798};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005799/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005800 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005801 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005802 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005803static struct hda_input_mux alc260_test_capture_sources[2] = {
5804 {
5805 .num_items = 7,
5806 .items = {
5807 { "MIC1 pin", 0x0 },
5808 { "MIC2 pin", 0x1 },
5809 { "LINE1 pin", 0x2 },
5810 { "LINE2 pin", 0x3 },
5811 { "CD pin", 0x4 },
5812 { "LINE-OUT pin", 0x5 },
5813 { "HP-OUT pin", 0x6 },
5814 },
5815 },
5816 {
5817 .num_items = 8,
5818 .items = {
5819 { "MIC1 pin", 0x0 },
5820 { "MIC2 pin", 0x1 },
5821 { "LINE1 pin", 0x2 },
5822 { "LINE2 pin", 0x3 },
5823 { "CD pin", 0x4 },
5824 { "Mixer", 0x5 },
5825 { "LINE-OUT pin", 0x6 },
5826 { "HP-OUT pin", 0x7 },
5827 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005828 },
5829};
5830static struct snd_kcontrol_new alc260_test_mixer[] = {
5831 /* Output driver widgets */
5832 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5833 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5834 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5835 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5836 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5837 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5838
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005839 /* Modes for retasking pin widgets
5840 * Note: the ALC260 doesn't seem to act on requests to enable mic
5841 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5842 * mention this restriction. At this stage it's not clear whether
5843 * this behaviour is intentional or is a hardware bug in chip
5844 * revisions available at least up until early 2006. Therefore for
5845 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5846 * choices, but if it turns out that the lack of mic bias for these
5847 * NIDs is intentional we could change their modes from
5848 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5849 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005850 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5851 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5852 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5853 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5854 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5855 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5856
5857 /* Loopback mixer controls */
5858 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5859 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5860 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5861 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5862 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5863 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5864 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5865 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5866 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5867 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005868 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5869 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5870 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5871 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005872
5873 /* Controls for GPIO pins, assuming they are configured as outputs */
5874 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5875 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5876 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5877 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5878
Jonathan Woithe92621f12006-02-28 11:47:47 +01005879 /* Switches to allow the digital IO pins to be enabled. The datasheet
5880 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005881 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005882 */
5883 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5884 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5885
Jonathan Woithef8225f62008-01-08 12:16:54 +01005886 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5887 * this output to turn on an external amplifier.
5888 */
5889 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5890 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5891
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005892 { } /* end */
5893};
5894static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005895 /* Enable all GPIOs as outputs with an initial value of 0 */
5896 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5897 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5898 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5899
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005900 /* Enable retasking pins as output, initially without power amp */
5901 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5902 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5903 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5904 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5905 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5906 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5907
Jonathan Woithe92621f12006-02-28 11:47:47 +01005908 /* Disable digital (SPDIF) pins initially, but users can enable
5909 * them via a mixer switch. In the case of SPDIF-out, this initverb
5910 * payload also sets the generation to 0, output to be in "consumer"
5911 * PCM format, copyright asserted, no pre-emphasis and no validity
5912 * control.
5913 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005914 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5915 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5916
Kailang Yangea1fb292008-08-26 12:58:38 +02005917 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005918 * OUT1 sum bus when acting as an output.
5919 */
5920 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5921 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5922 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5923 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5924
5925 /* Start with output sum widgets muted and their output gains at min */
5926 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5927 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5928 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5929 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5930 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5931 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5932 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5933 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5934 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5935
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005936 /* Unmute retasking pin widget output buffers since the default
5937 * state appears to be output. As the pin mode is changed by the
5938 * user the pin mode control will take care of enabling the pin's
5939 * input/output buffers as needed.
5940 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005941 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5942 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5943 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5944 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5945 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5946 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5947 /* Also unmute the mono-out pin widget */
5948 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5949
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005950 /* Mute capture amp left and right */
5951 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005952 /* Set ADC connection select to match default mixer setting (mic1
5953 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005954 */
5955 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5956
5957 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005958 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005959 */
5960 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5961 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5962
5963 /* Mute all inputs to mixer widget (even unconnected ones) */
5964 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5965 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5967 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5969 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5972
5973 { }
5974};
5975#endif
5976
Takashi Iwai63300792008-01-24 15:31:36 +01005977#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5978#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005979
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005980#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5981#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5982
Kailang Yangdf694da2005-12-05 19:42:22 +01005983/*
5984 * for BIOS auto-configuration
5985 */
5986
5987static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005988 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005989{
5990 hda_nid_t nid_vol;
5991 unsigned long vol_val, sw_val;
5992 char name[32];
5993 int err;
5994
5995 if (nid >= 0x0f && nid < 0x11) {
5996 nid_vol = nid - 0x7;
5997 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5998 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5999 } else if (nid == 0x11) {
6000 nid_vol = nid - 0x7;
6001 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6002 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6003 } else if (nid >= 0x12 && nid <= 0x15) {
6004 nid_vol = 0x08;
6005 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6006 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6007 } else
6008 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006009
Takashi Iwai863b4512008-10-21 17:01:47 +02006010 if (!(*vol_bits & (1 << nid_vol))) {
6011 /* first control for the volume widget */
6012 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
6013 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
6014 if (err < 0)
6015 return err;
6016 *vol_bits |= (1 << nid_vol);
6017 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006018 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006019 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
6020 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006021 return err;
6022 return 1;
6023}
6024
6025/* add playback controls from the parsed DAC table */
6026static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6027 const struct auto_pin_cfg *cfg)
6028{
6029 hda_nid_t nid;
6030 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006031 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006032
6033 spec->multiout.num_dacs = 1;
6034 spec->multiout.dac_nids = spec->private_dac_nids;
6035 spec->multiout.dac_nids[0] = 0x02;
6036
6037 nid = cfg->line_out_pins[0];
6038 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006039 const char *pfx;
6040 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6041 pfx = "Master";
6042 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6043 pfx = "Speaker";
6044 else
6045 pfx = "Front";
6046 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006047 if (err < 0)
6048 return err;
6049 }
6050
Takashi Iwai82bc9552006-03-21 11:24:42 +01006051 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006052 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006053 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006054 if (err < 0)
6055 return err;
6056 }
6057
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006058 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006059 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006060 err = alc260_add_playback_controls(spec, nid, "Headphone",
6061 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006062 if (err < 0)
6063 return err;
6064 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006065 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006066}
6067
6068/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006069static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006070 const struct auto_pin_cfg *cfg)
6071{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006072 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006073}
6074
6075static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6076 hda_nid_t nid, int pin_type,
6077 int sel_idx)
6078{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006079 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006080 /* need the manual connection? */
6081 if (nid >= 0x12) {
6082 int idx = nid - 0x12;
6083 snd_hda_codec_write(codec, idx + 0x0b, 0,
6084 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006085 }
6086}
6087
6088static void alc260_auto_init_multi_out(struct hda_codec *codec)
6089{
6090 struct alc_spec *spec = codec->spec;
6091 hda_nid_t nid;
6092
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006093 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006094 if (nid) {
6095 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6096 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6097 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006098
Takashi Iwai82bc9552006-03-21 11:24:42 +01006099 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006100 if (nid)
6101 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6102
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006103 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006104 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006105 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006106}
Kailang Yangdf694da2005-12-05 19:42:22 +01006107
6108#define ALC260_PIN_CD_NID 0x16
6109static void alc260_auto_init_analog_input(struct hda_codec *codec)
6110{
6111 struct alc_spec *spec = codec->spec;
6112 int i;
6113
6114 for (i = 0; i < AUTO_PIN_LAST; i++) {
6115 hda_nid_t nid = spec->autocfg.input_pins[i];
6116 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006117 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006118 if (nid != ALC260_PIN_CD_NID &&
6119 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006120 snd_hda_codec_write(codec, nid, 0,
6121 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006122 AMP_OUT_MUTE);
6123 }
6124 }
6125}
6126
6127/*
6128 * generic initialization of ADC, input mixers and output mixers
6129 */
6130static struct hda_verb alc260_volume_init_verbs[] = {
6131 /*
6132 * Unmute ADC0-1 and set the default input to mic-in
6133 */
6134 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6135 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6136 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6137 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006138
Kailang Yangdf694da2005-12-05 19:42:22 +01006139 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6140 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006141 * Note: PASD motherboards uses the Line In 2 as the input for
6142 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006143 */
6144 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006145 /* mute analog inputs */
6146 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006151
6152 /*
6153 * Set up output mixers (0x08 - 0x0a)
6154 */
6155 /* set vol=0 to output mixers */
6156 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6157 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6158 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6159 /* set up input amps for analog loopback */
6160 /* Amp Indices: DAC = 0, mixer = 1 */
6161 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6162 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6163 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6164 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6165 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6166 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006167
Kailang Yangdf694da2005-12-05 19:42:22 +01006168 { }
6169};
6170
6171static int alc260_parse_auto_config(struct hda_codec *codec)
6172{
6173 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006174 int err;
6175 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6176
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006177 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6178 alc260_ignore);
6179 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006180 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006181 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6182 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006183 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006184 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006185 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006186 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006187 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006188 return err;
6189
6190 spec->multiout.max_channels = 2;
6191
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006192 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006193 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006194 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006195 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006196
Takashi Iwaid88897e2008-10-31 15:01:37 +01006197 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006198
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006199 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006200 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006201
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006202 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6203
Kailang Yangdf694da2005-12-05 19:42:22 +01006204 return 1;
6205}
6206
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006207/* additional initialization for auto-configuration model */
6208static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006209{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006210 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006211 alc260_auto_init_multi_out(codec);
6212 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006213 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006214 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006215}
6216
Takashi Iwaicb53c622007-08-10 17:21:45 +02006217#ifdef CONFIG_SND_HDA_POWER_SAVE
6218static struct hda_amp_list alc260_loopbacks[] = {
6219 { 0x07, HDA_INPUT, 0 },
6220 { 0x07, HDA_INPUT, 1 },
6221 { 0x07, HDA_INPUT, 2 },
6222 { 0x07, HDA_INPUT, 3 },
6223 { 0x07, HDA_INPUT, 4 },
6224 { } /* end */
6225};
6226#endif
6227
Kailang Yangdf694da2005-12-05 19:42:22 +01006228/*
6229 * ALC260 configurations
6230 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006231static const char *alc260_models[ALC260_MODEL_LAST] = {
6232 [ALC260_BASIC] = "basic",
6233 [ALC260_HP] = "hp",
6234 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006235 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006236 [ALC260_FUJITSU_S702X] = "fujitsu",
6237 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006238 [ALC260_WILL] = "will",
6239 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006240 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006241#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006242 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006243#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006244 [ALC260_AUTO] = "auto",
6245};
6246
6247static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006248 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006249 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006250 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006251 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006252 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006253 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006254 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006255 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006256 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6257 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6258 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6259 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6260 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6261 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6262 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6263 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6264 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006265 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006266 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006267 {}
6268};
6269
Kailang Yangdf694da2005-12-05 19:42:22 +01006270static struct alc_config_preset alc260_presets[] = {
6271 [ALC260_BASIC] = {
6272 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006273 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006274 .init_verbs = { alc260_init_verbs },
6275 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6276 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006277 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006278 .adc_nids = alc260_adc_nids,
6279 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6280 .channel_mode = alc260_modes,
6281 .input_mux = &alc260_capture_source,
6282 },
6283 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006284 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006285 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006286 .init_verbs = { alc260_init_verbs,
6287 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006288 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6289 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006290 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6291 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006292 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6293 .channel_mode = alc260_modes,
6294 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006295 .unsol_event = alc260_hp_unsol_event,
6296 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006297 },
Kailang Yang3f878302008-08-26 13:02:23 +02006298 [ALC260_HP_DC7600] = {
6299 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006300 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006301 .init_verbs = { alc260_init_verbs,
6302 alc260_hp_dc7600_verbs },
6303 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6304 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006305 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6306 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006307 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6308 .channel_mode = alc260_modes,
6309 .input_mux = &alc260_capture_source,
6310 .unsol_event = alc260_hp_3012_unsol_event,
6311 .init_hook = alc260_hp_3012_automute,
6312 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006313 [ALC260_HP_3013] = {
6314 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006315 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006316 .init_verbs = { alc260_hp_3013_init_verbs,
6317 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006318 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6319 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006320 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6321 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006322 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6323 .channel_mode = alc260_modes,
6324 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006325 .unsol_event = alc260_hp_3013_unsol_event,
6326 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006327 },
6328 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006329 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006330 .init_verbs = { alc260_fujitsu_init_verbs },
6331 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6332 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006333 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6334 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006335 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6336 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006337 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6338 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006339 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006340 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006341 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006342 .init_verbs = { alc260_acer_init_verbs },
6343 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6344 .dac_nids = alc260_dac_nids,
6345 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6346 .adc_nids = alc260_dual_adc_nids,
6347 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6348 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006349 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6350 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006351 },
Michael Schwingencc959482009-02-22 18:58:45 +01006352 [ALC260_FAVORIT100] = {
6353 .mixers = { alc260_favorit100_mixer },
6354 .init_verbs = { alc260_favorit100_init_verbs },
6355 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6356 .dac_nids = alc260_dac_nids,
6357 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6358 .adc_nids = alc260_dual_adc_nids,
6359 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6360 .channel_mode = alc260_modes,
6361 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6362 .input_mux = alc260_favorit100_capture_sources,
6363 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006364 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006365 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006366 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6367 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6368 .dac_nids = alc260_dac_nids,
6369 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6370 .adc_nids = alc260_adc_nids,
6371 .dig_out_nid = ALC260_DIGOUT_NID,
6372 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6373 .channel_mode = alc260_modes,
6374 .input_mux = &alc260_capture_source,
6375 },
6376 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006377 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006378 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6379 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6380 .dac_nids = alc260_dac_nids,
6381 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6382 .adc_nids = alc260_adc_nids,
6383 .dig_out_nid = ALC260_DIGOUT_NID,
6384 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6385 .channel_mode = alc260_modes,
6386 .input_mux = &alc260_capture_source,
6387 .unsol_event = alc260_replacer_672v_unsol_event,
6388 .init_hook = alc260_replacer_672v_automute,
6389 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006390#ifdef CONFIG_SND_DEBUG
6391 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006392 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006393 .init_verbs = { alc260_test_init_verbs },
6394 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6395 .dac_nids = alc260_test_dac_nids,
6396 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6397 .adc_nids = alc260_test_adc_nids,
6398 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6399 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006400 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6401 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006402 },
6403#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006404};
6405
Linus Torvalds1da177e2005-04-16 15:20:36 -07006406static int patch_alc260(struct hda_codec *codec)
6407{
6408 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006409 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006410
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006411 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006412 if (spec == NULL)
6413 return -ENOMEM;
6414
6415 codec->spec = spec;
6416
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006417 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6418 alc260_models,
6419 alc260_cfg_tbl);
6420 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006421 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006422 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006423 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006424 }
6425
Kailang Yangdf694da2005-12-05 19:42:22 +01006426 if (board_config == ALC260_AUTO) {
6427 /* automatic parse from the BIOS config */
6428 err = alc260_parse_auto_config(codec);
6429 if (err < 0) {
6430 alc_free(codec);
6431 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006432 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006433 printk(KERN_INFO
6434 "hda_codec: Cannot set up configuration "
6435 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006436 board_config = ALC260_BASIC;
6437 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006438 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006439
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006440 err = snd_hda_attach_beep_device(codec, 0x1);
6441 if (err < 0) {
6442 alc_free(codec);
6443 return err;
6444 }
6445
Kailang Yangdf694da2005-12-05 19:42:22 +01006446 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006447 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006448
Linus Torvalds1da177e2005-04-16 15:20:36 -07006449 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6450 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6451
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006452 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6453 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6454
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006455 if (!spec->adc_nids && spec->input_mux) {
6456 /* check whether NID 0x04 is valid */
6457 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006458 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006459 /* get type */
6460 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6461 spec->adc_nids = alc260_adc_nids_alt;
6462 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6463 } else {
6464 spec->adc_nids = alc260_adc_nids;
6465 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6466 }
6467 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006468 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006469 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006470
Takashi Iwai2134ea42008-01-10 16:53:55 +01006471 spec->vmaster_nid = 0x08;
6472
Linus Torvalds1da177e2005-04-16 15:20:36 -07006473 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006474 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006475 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006476#ifdef CONFIG_SND_HDA_POWER_SAVE
6477 if (!spec->loopback.amplist)
6478 spec->loopback.amplist = alc260_loopbacks;
6479#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006480 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006481
6482 return 0;
6483}
6484
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006485
Linus Torvalds1da177e2005-04-16 15:20:36 -07006486/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006487 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006488 *
6489 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6490 * configuration. Each pin widget can choose any input DACs and a mixer.
6491 * Each ADC is connected from a mixer of all inputs. This makes possible
6492 * 6-channel independent captures.
6493 *
6494 * In addition, an independent DAC for the multi-playback (not used in this
6495 * driver yet).
6496 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006497#define ALC882_DIGOUT_NID 0x06
6498#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006499#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6500#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6501#define ALC1200_DIGOUT_NID 0x10
6502
Linus Torvalds1da177e2005-04-16 15:20:36 -07006503
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006504static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006505 { 8, NULL }
6506};
6507
Takashi Iwai4953550a2009-06-30 15:28:30 +02006508/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006509static hda_nid_t alc882_dac_nids[4] = {
6510 /* front, rear, clfe, rear_surr */
6511 0x02, 0x03, 0x04, 0x05
6512};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006513#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006514
Takashi Iwai4953550a2009-06-30 15:28:30 +02006515/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006516#define alc882_adc_nids alc880_adc_nids
6517#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006518#define alc883_adc_nids alc882_adc_nids_alt
6519static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6520static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6521#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006522
Takashi Iwaie1406342008-02-11 18:32:32 +01006523static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6524static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006525#define alc883_capsrc_nids alc882_capsrc_nids_alt
6526static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6527#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006528
Linus Torvalds1da177e2005-04-16 15:20:36 -07006529/* input MUX */
6530/* FIXME: should be a matrix-type input source selection */
6531
6532static struct hda_input_mux alc882_capture_source = {
6533 .num_items = 4,
6534 .items = {
6535 { "Mic", 0x0 },
6536 { "Front Mic", 0x1 },
6537 { "Line", 0x2 },
6538 { "CD", 0x4 },
6539 },
6540};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006541
Takashi Iwai4953550a2009-06-30 15:28:30 +02006542#define alc883_capture_source alc882_capture_source
6543
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006544static struct hda_input_mux alc889_capture_source = {
6545 .num_items = 3,
6546 .items = {
6547 { "Front Mic", 0x0 },
6548 { "Mic", 0x3 },
6549 { "Line", 0x2 },
6550 },
6551};
6552
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006553static struct hda_input_mux mb5_capture_source = {
6554 .num_items = 3,
6555 .items = {
6556 { "Mic", 0x1 },
6557 { "Line", 0x2 },
6558 { "CD", 0x4 },
6559 },
6560};
6561
Takashi Iwai4953550a2009-06-30 15:28:30 +02006562static struct hda_input_mux alc883_3stack_6ch_intel = {
6563 .num_items = 4,
6564 .items = {
6565 { "Mic", 0x1 },
6566 { "Front Mic", 0x0 },
6567 { "Line", 0x2 },
6568 { "CD", 0x4 },
6569 },
6570};
6571
6572static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6573 .num_items = 2,
6574 .items = {
6575 { "Mic", 0x1 },
6576 { "Line", 0x2 },
6577 },
6578};
6579
6580static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6581 .num_items = 4,
6582 .items = {
6583 { "Mic", 0x0 },
6584 { "iMic", 0x1 },
6585 { "Line", 0x2 },
6586 { "CD", 0x4 },
6587 },
6588};
6589
6590static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6591 .num_items = 2,
6592 .items = {
6593 { "Mic", 0x0 },
6594 { "Int Mic", 0x1 },
6595 },
6596};
6597
6598static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6599 .num_items = 3,
6600 .items = {
6601 { "Mic", 0x0 },
6602 { "Front Mic", 0x1 },
6603 { "Line", 0x4 },
6604 },
6605};
6606
6607static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6608 .num_items = 2,
6609 .items = {
6610 { "Mic", 0x0 },
6611 { "Line", 0x2 },
6612 },
6613};
6614
6615static struct hda_input_mux alc889A_mb31_capture_source = {
6616 .num_items = 2,
6617 .items = {
6618 { "Mic", 0x0 },
6619 /* Front Mic (0x01) unused */
6620 { "Line", 0x2 },
6621 /* Line 2 (0x03) unused */
6622 /* CD (0x04) unsused? */
6623 },
6624};
6625
6626/*
6627 * 2ch mode
6628 */
6629static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6630 { 2, NULL }
6631};
6632
Kailang Yangdf694da2005-12-05 19:42:22 +01006633/*
Kailang Yang272a5272007-05-14 11:00:38 +02006634 * 2ch mode
6635 */
6636static struct hda_verb alc882_3ST_ch2_init[] = {
6637 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6638 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6639 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6640 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6641 { } /* end */
6642};
6643
6644/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006645 * 4ch mode
6646 */
6647static struct hda_verb alc882_3ST_ch4_init[] = {
6648 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6649 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6650 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6651 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6652 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6653 { } /* end */
6654};
6655
6656/*
Kailang Yang272a5272007-05-14 11:00:38 +02006657 * 6ch mode
6658 */
6659static struct hda_verb alc882_3ST_ch6_init[] = {
6660 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6661 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6662 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6663 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6664 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6665 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6666 { } /* end */
6667};
6668
Takashi Iwai4953550a2009-06-30 15:28:30 +02006669static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006670 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006671 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006672 { 6, alc882_3ST_ch6_init },
6673};
6674
Takashi Iwai4953550a2009-06-30 15:28:30 +02006675#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6676
Kailang Yang272a5272007-05-14 11:00:38 +02006677/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306678 * 2ch mode
6679 */
6680static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6681 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6682 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6683 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6684 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6685 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6686 { } /* end */
6687};
6688
6689/*
6690 * 4ch mode
6691 */
6692static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6693 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6694 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6695 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6696 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6697 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6698 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6699 { } /* end */
6700};
6701
6702/*
6703 * 6ch mode
6704 */
6705static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6706 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6707 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6708 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6709 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6710 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6711 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6712 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6713 { } /* end */
6714};
6715
6716static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6717 { 2, alc883_3ST_ch2_clevo_init },
6718 { 4, alc883_3ST_ch4_clevo_init },
6719 { 6, alc883_3ST_ch6_clevo_init },
6720};
6721
6722
6723/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006724 * 6ch mode
6725 */
6726static struct hda_verb alc882_sixstack_ch6_init[] = {
6727 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6728 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6729 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6730 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6731 { } /* end */
6732};
6733
6734/*
6735 * 8ch mode
6736 */
6737static struct hda_verb alc882_sixstack_ch8_init[] = {
6738 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6739 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6740 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6741 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6742 { } /* end */
6743};
6744
6745static struct hda_channel_mode alc882_sixstack_modes[2] = {
6746 { 6, alc882_sixstack_ch6_init },
6747 { 8, alc882_sixstack_ch8_init },
6748};
6749
Takashi Iwai87350ad2007-08-16 18:19:38 +02006750/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006751 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006752 */
6753
6754/*
6755 * 2ch mode
6756 */
6757static struct hda_verb alc885_mbp_ch2_init[] = {
6758 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6759 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6760 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6761 { } /* end */
6762};
6763
6764/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006765 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006766 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006767static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006768 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6769 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6770 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6771 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6772 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6773 { } /* end */
6774};
6775
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006776static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006777 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006778 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006779};
6780
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006781/*
6782 * 2ch
6783 * Speakers/Woofer/HP = Front
6784 * LineIn = Input
6785 */
6786static struct hda_verb alc885_mb5_ch2_init[] = {
6787 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6788 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6789 { } /* end */
6790};
6791
6792/*
6793 * 6ch mode
6794 * Speakers/HP = Front
6795 * Woofer = LFE
6796 * LineIn = Surround
6797 */
6798static struct hda_verb alc885_mb5_ch6_init[] = {
6799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6801 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6802 { } /* end */
6803};
6804
6805static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6806 { 2, alc885_mb5_ch2_init },
6807 { 6, alc885_mb5_ch6_init },
6808};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006809
Takashi Iwai4953550a2009-06-30 15:28:30 +02006810
6811/*
6812 * 2ch mode
6813 */
6814static struct hda_verb alc883_4ST_ch2_init[] = {
6815 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6816 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6817 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6818 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6819 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6820 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6821 { } /* end */
6822};
6823
6824/*
6825 * 4ch mode
6826 */
6827static struct hda_verb alc883_4ST_ch4_init[] = {
6828 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6829 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6830 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6831 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6832 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6833 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6834 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6835 { } /* end */
6836};
6837
6838/*
6839 * 6ch mode
6840 */
6841static struct hda_verb alc883_4ST_ch6_init[] = {
6842 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6843 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6844 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6845 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6846 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6847 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6848 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6849 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6850 { } /* end */
6851};
6852
6853/*
6854 * 8ch mode
6855 */
6856static struct hda_verb alc883_4ST_ch8_init[] = {
6857 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6858 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6859 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6860 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6861 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6862 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6863 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6864 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6865 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6866 { } /* end */
6867};
6868
6869static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6870 { 2, alc883_4ST_ch2_init },
6871 { 4, alc883_4ST_ch4_init },
6872 { 6, alc883_4ST_ch6_init },
6873 { 8, alc883_4ST_ch8_init },
6874};
6875
6876
6877/*
6878 * 2ch mode
6879 */
6880static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6881 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6882 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6883 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6884 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6885 { } /* end */
6886};
6887
6888/*
6889 * 4ch mode
6890 */
6891static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6892 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6893 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6894 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6895 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6896 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6897 { } /* end */
6898};
6899
6900/*
6901 * 6ch mode
6902 */
6903static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6904 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6905 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6906 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6907 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6908 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6909 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6910 { } /* end */
6911};
6912
6913static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6914 { 2, alc883_3ST_ch2_intel_init },
6915 { 4, alc883_3ST_ch4_intel_init },
6916 { 6, alc883_3ST_ch6_intel_init },
6917};
6918
6919/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006920 * 2ch mode
6921 */
6922static struct hda_verb alc889_ch2_intel_init[] = {
6923 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6924 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6925 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6926 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6927 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6928 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6929 { } /* end */
6930};
6931
6932/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006933 * 6ch mode
6934 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006935static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006936 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6937 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6938 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6939 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6940 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006941 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6942 { } /* end */
6943};
6944
6945/*
6946 * 8ch mode
6947 */
6948static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006949 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6950 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6951 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6952 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6953 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006954 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6955 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006956 { } /* end */
6957};
6958
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006959static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6960 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006961 { 6, alc889_ch6_intel_init },
6962 { 8, alc889_ch8_intel_init },
6963};
6964
6965/*
6966 * 6ch mode
6967 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006968static struct hda_verb alc883_sixstack_ch6_init[] = {
6969 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6970 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6971 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6972 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6973 { } /* end */
6974};
6975
6976/*
6977 * 8ch mode
6978 */
6979static struct hda_verb alc883_sixstack_ch8_init[] = {
6980 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6981 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6982 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6983 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6984 { } /* end */
6985};
6986
6987static struct hda_channel_mode alc883_sixstack_modes[2] = {
6988 { 6, alc883_sixstack_ch6_init },
6989 { 8, alc883_sixstack_ch8_init },
6990};
6991
6992
Linus Torvalds1da177e2005-04-16 15:20:36 -07006993/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6994 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6995 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006996static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006997 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006998 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006999 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007000 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007001 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7002 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007003 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7004 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007005 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007006 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007007 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7008 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7009 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7010 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7011 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7012 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007013 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7015 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007016 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007017 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007018 { } /* end */
7019};
7020
Takashi Iwai87350ad2007-08-16 18:19:38 +02007021static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007022 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7023 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7024 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7025 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7026 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007027 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7028 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7030 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007031 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007032 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7033 { } /* end */
7034};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007035
7036static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007037 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7038 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7039 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7040 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7041 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7042 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7043 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7044 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007045 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7046 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7048 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7049 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7050 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7051 { } /* end */
7052};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007053
Kailang Yangbdd148a2007-05-08 15:19:08 +02007054static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7055 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7056 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7057 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7058 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7059 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7060 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7062 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007064 { } /* end */
7065};
7066
Kailang Yang272a5272007-05-14 11:00:38 +02007067static struct snd_kcontrol_new alc882_targa_mixer[] = {
7068 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7069 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7070 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7071 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7072 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7073 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7074 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7076 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007077 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007078 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7079 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007080 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007081 { } /* end */
7082};
7083
7084/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7085 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7086 */
7087static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7088 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7089 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7091 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7092 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7093 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7094 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7095 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7096 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7097 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007100 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007101 { } /* end */
7102};
7103
Takashi Iwai914759b2007-09-06 14:52:04 +02007104static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7105 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7106 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7107 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7113 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007115 { } /* end */
7116};
7117
Kailang Yangdf694da2005-12-05 19:42:22 +01007118static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7119 {
7120 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7121 .name = "Channel Mode",
7122 .info = alc_ch_mode_info,
7123 .get = alc_ch_mode_get,
7124 .put = alc_ch_mode_put,
7125 },
7126 { } /* end */
7127};
7128
Takashi Iwai4953550a2009-06-30 15:28:30 +02007129static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007130 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007131 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7132 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7133 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007134 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007135 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7136 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7137 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007138 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007139 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7140 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7141 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007142 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007143 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7144 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7145 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007146
Takashi Iwaicb638122009-07-03 10:56:10 +02007147 /* mute analog input loopbacks */
7148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7149 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7151 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7152 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7153
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007154 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007155 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007156 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007157 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007158 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007159 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007160 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007161 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007162 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007163 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007164 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007165 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007166 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007167 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007168 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007169 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007170 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007171 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007172 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7173 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007174 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007175 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7176 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007177 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007178 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7179 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7180 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7181 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7182 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007183 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007184 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007185
7186 /* FIXME: use matrix-type input source selection */
7187 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007188 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007189 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7190 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7191 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7192 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007193 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007194 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7197 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007198 /* ADC2: mute amp left and right */
7199 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007200 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007201 /* ADC3: mute amp left and right */
7202 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007203 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007204
7205 { }
7206};
7207
Takashi Iwai4953550a2009-06-30 15:28:30 +02007208static struct hda_verb alc882_adc1_init_verbs[] = {
7209 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7212 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7213 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7214 /* ADC1: mute amp left and right */
7215 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7216 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7217 { }
7218};
7219
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007220static struct hda_verb alc882_eapd_verbs[] = {
7221 /* change to EAPD mode */
7222 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007223 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007224 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007225};
7226
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007227static struct hda_verb alc889_eapd_verbs[] = {
7228 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7229 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7230 { }
7231};
7232
Wu Fengguang6732bd02009-07-30 09:19:14 +02007233static struct hda_verb alc_hp15_unsol_verbs[] = {
7234 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7236 {}
7237};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007238
7239static struct hda_verb alc885_init_verbs[] = {
7240 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7241 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7244 /* Rear mixer */
7245 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7246 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7247 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7248 /* CLFE mixer */
7249 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7250 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7251 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7252 /* Side mixer */
7253 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7254 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7255 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7256
7257 /* mute analog input loopbacks */
7258 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7260 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7261
7262 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007263 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007264 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7265 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7266 /* Front Pin: output 0 (0x0c) */
7267 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7268 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7269 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7270 /* Rear Pin: output 1 (0x0d) */
7271 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7272 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7273 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7274 /* CLFE Pin: output 2 (0x0e) */
7275 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7276 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7277 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7278 /* Side Pin: output 3 (0x0f) */
7279 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7280 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7281 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7282 /* Mic (rear) pin: input vref at 80% */
7283 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7284 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7285 /* Front Mic pin: input vref at 80% */
7286 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7287 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7288 /* Line In pin: input */
7289 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7290 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7291
7292 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7293 /* Input mixer1 */
7294 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7295 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7296 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7297 /* Input mixer2 */
7298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7299 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7300 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7301 /* Input mixer3 */
7302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7305 /* ADC2: mute amp left and right */
7306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7307 /* ADC3: mute amp left and right */
7308 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7309
7310 { }
7311};
7312
7313static struct hda_verb alc885_init_input_verbs[] = {
7314 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7315 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7316 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7317 { }
7318};
7319
7320
7321/* Unmute Selector 24h and set the default input to front mic */
7322static struct hda_verb alc889_init_input_verbs[] = {
7323 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7324 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7325 { }
7326};
7327
7328
Takashi Iwai4953550a2009-06-30 15:28:30 +02007329#define alc883_init_verbs alc882_base_init_verbs
7330
Tobin Davis9102cd12006-12-15 10:02:12 +01007331/* Mac Pro test */
7332static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7333 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7334 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7335 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7336 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7337 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007338 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01007339 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
7340 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007341 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007342 { } /* end */
7343};
7344
7345static struct hda_verb alc882_macpro_init_verbs[] = {
7346 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7348 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7350 /* Front Pin: output 0 (0x0c) */
7351 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7352 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7353 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7354 /* Front Mic pin: input vref at 80% */
7355 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7356 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7357 /* Speaker: output */
7358 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7359 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7360 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7361 /* Headphone output (output 0 - 0x0c) */
7362 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7363 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7364 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7365
7366 /* FIXME: use matrix-type input source selection */
7367 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7368 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7369 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7370 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7371 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7372 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7373 /* Input mixer2 */
7374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7376 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7377 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7378 /* Input mixer3 */
7379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7380 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7381 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7382 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7383 /* ADC1: mute amp left and right */
7384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7385 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7386 /* ADC2: mute amp left and right */
7387 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7388 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7389 /* ADC3: mute amp left and right */
7390 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7391 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7392
7393 { }
7394};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007395
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007396/* Macbook 5,1 */
7397static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007398 /* DACs */
7399 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7400 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7401 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7402 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007403 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7405 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7406 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007407 /* Surround mixer */
7408 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7409 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7410 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7411 /* LFE mixer */
7412 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7414 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7415 /* HP mixer */
7416 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7417 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7418 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7419 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007420 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7421 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007422 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7423 /* LFE Pin (0x0e) */
7424 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7425 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7426 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7427 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007428 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7429 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007430 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007431 /* Front Mic pin: input vref at 80% */
7432 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7433 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7434 /* Line In pin */
7435 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7437
7438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7441 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7442 { }
7443};
7444
Takashi Iwai87350ad2007-08-16 18:19:38 +02007445/* Macbook Pro rev3 */
7446static struct hda_verb alc885_mbp3_init_verbs[] = {
7447 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7448 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7449 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7450 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7451 /* Rear mixer */
7452 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7453 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7454 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007455 /* HP mixer */
7456 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7457 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7458 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007459 /* Front Pin: output 0 (0x0c) */
7460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7461 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7462 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007463 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7466 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007467 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7468 /* Mic (rear) pin: input vref at 80% */
7469 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7470 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7471 /* Front Mic pin: input vref at 80% */
7472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7473 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7474 /* Line In pin: use output 1 when in LineOut mode */
7475 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7476 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7477 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7478
7479 /* FIXME: use matrix-type input source selection */
7480 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7481 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7482 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7483 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7484 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7485 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7486 /* Input mixer2 */
7487 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7488 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7489 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7490 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7491 /* Input mixer3 */
7492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7495 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7496 /* ADC1: mute amp left and right */
7497 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7498 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7499 /* ADC2: mute amp left and right */
7500 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7501 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7502 /* ADC3: mute amp left and right */
7503 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7504 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7505
7506 { }
7507};
7508
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007509/* iMac 24 mixer. */
7510static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7511 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7512 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7513 { } /* end */
7514};
7515
7516/* iMac 24 init verbs. */
7517static struct hda_verb alc885_imac24_init_verbs[] = {
7518 /* Internal speakers: output 0 (0x0c) */
7519 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7520 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7521 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7522 /* Internal speakers: output 0 (0x0c) */
7523 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7524 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7525 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7526 /* Headphone: output 0 (0x0c) */
7527 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7528 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7529 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7530 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7531 /* Front Mic: input vref at 80% */
7532 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7533 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7534 { }
7535};
7536
7537/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007538static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007539{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007540 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007541
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007542 spec->autocfg.hp_pins[0] = 0x14;
7543 spec->autocfg.speaker_pins[0] = 0x18;
7544 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007545}
7546
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007547static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007548{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007549 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007550
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007551 spec->autocfg.hp_pins[0] = 0x15;
7552 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007553}
7554
7555
Kailang Yang272a5272007-05-14 11:00:38 +02007556static struct hda_verb alc882_targa_verbs[] = {
7557 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7558 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7559
7560 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7561 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007562
Kailang Yang272a5272007-05-14 11:00:38 +02007563 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7564 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7565 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7566
7567 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007568 { } /* end */
7569};
7570
7571/* toggle speaker-output according to the hp-jack state */
7572static void alc882_targa_automute(struct hda_codec *codec)
7573{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007574 struct alc_spec *spec = codec->spec;
7575 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007576 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007577 spec->jack_present ? 1 : 3);
7578}
7579
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007580static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007581{
7582 struct alc_spec *spec = codec->spec;
7583
7584 spec->autocfg.hp_pins[0] = 0x14;
7585 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007586}
7587
7588static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7589{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007590 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007591 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007592}
7593
7594static struct hda_verb alc882_asus_a7j_verbs[] = {
7595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7596 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7597
7598 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7600 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007601
Kailang Yang272a5272007-05-14 11:00:38 +02007602 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7603 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7604 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7605
7606 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7607 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7608 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7609 { } /* end */
7610};
7611
Takashi Iwai914759b2007-09-06 14:52:04 +02007612static struct hda_verb alc882_asus_a7m_verbs[] = {
7613 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7614 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7615
7616 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7617 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7618 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007619
Takashi Iwai914759b2007-09-06 14:52:04 +02007620 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7621 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7622 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7623
7624 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7625 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7626 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7627 { } /* end */
7628};
7629
Tobin Davis9102cd12006-12-15 10:02:12 +01007630static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7631{
7632 unsigned int gpiostate, gpiomask, gpiodir;
7633
7634 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7635 AC_VERB_GET_GPIO_DATA, 0);
7636
7637 if (!muted)
7638 gpiostate |= (1 << pin);
7639 else
7640 gpiostate &= ~(1 << pin);
7641
7642 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7643 AC_VERB_GET_GPIO_MASK, 0);
7644 gpiomask |= (1 << pin);
7645
7646 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7647 AC_VERB_GET_GPIO_DIRECTION, 0);
7648 gpiodir |= (1 << pin);
7649
7650
7651 snd_hda_codec_write(codec, codec->afg, 0,
7652 AC_VERB_SET_GPIO_MASK, gpiomask);
7653 snd_hda_codec_write(codec, codec->afg, 0,
7654 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7655
7656 msleep(1);
7657
7658 snd_hda_codec_write(codec, codec->afg, 0,
7659 AC_VERB_SET_GPIO_DATA, gpiostate);
7660}
7661
Takashi Iwai7debbe52007-08-16 15:01:03 +02007662/* set up GPIO at initialization */
7663static void alc885_macpro_init_hook(struct hda_codec *codec)
7664{
7665 alc882_gpio_mute(codec, 0, 0);
7666 alc882_gpio_mute(codec, 1, 0);
7667}
7668
7669/* set up GPIO and update auto-muting at initialization */
7670static void alc885_imac24_init_hook(struct hda_codec *codec)
7671{
7672 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007673 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007674}
7675
Kailang Yangdf694da2005-12-05 19:42:22 +01007676/*
7677 * generic initialization of ADC, input mixers and output mixers
7678 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007679static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007680 /*
7681 * Unmute ADC0-2 and set the default input to mic-in
7682 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007683 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7684 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7685 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7686 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7687
Takashi Iwaicb53c622007-08-10 17:21:45 +02007688 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007689 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007690 * Note: PASD motherboards uses the Line In 2 as the input for
7691 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007692 */
7693 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7697 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7698 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007699
7700 /*
7701 * Set up output mixers (0x0c - 0x0f)
7702 */
7703 /* set vol=0 to output mixers */
7704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7705 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7706 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7707 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7708 /* set up input amps for analog loopback */
7709 /* Amp Indices: DAC = 0, mixer = 1 */
7710 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7712 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7713 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7714 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7715 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7716 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7717 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7718 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7719 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7720
7721 /* FIXME: use matrix-type input source selection */
7722 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007723 /* Input mixer2 */
7724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7725 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7726 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7727 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7728 /* Input mixer3 */
7729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7731 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7732 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7733
7734 { }
7735};
7736
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007737/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7738static struct hda_verb alc889A_mb31_ch2_init[] = {
7739 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7740 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7741 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7742 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7743 { } /* end */
7744};
7745
7746/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7747static struct hda_verb alc889A_mb31_ch4_init[] = {
7748 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7749 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7750 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7751 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7752 { } /* end */
7753};
7754
7755/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7756static struct hda_verb alc889A_mb31_ch5_init[] = {
7757 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7758 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7759 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7760 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7761 { } /* end */
7762};
7763
7764/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7765static struct hda_verb alc889A_mb31_ch6_init[] = {
7766 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7767 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7768 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7769 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7770 { } /* end */
7771};
7772
7773static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7774 { 2, alc889A_mb31_ch2_init },
7775 { 4, alc889A_mb31_ch4_init },
7776 { 5, alc889A_mb31_ch5_init },
7777 { 6, alc889A_mb31_ch6_init },
7778};
7779
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007780static struct hda_verb alc883_medion_eapd_verbs[] = {
7781 /* eanable EAPD on medion laptop */
7782 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7783 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7784 { }
7785};
7786
Takashi Iwai4953550a2009-06-30 15:28:30 +02007787#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007788
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007789static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7790 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7791 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7792 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7793 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7794 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7795 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7796 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7798 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7799 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7800 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7801 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7802 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007803 { } /* end */
7804};
7805
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007806static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007807 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7808 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7809 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7810 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7812 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7814 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7815 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7816 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007817 { } /* end */
7818};
7819
Jiang zhefb97dc62008-03-06 11:07:11 +01007820static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7821 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7822 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7823 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7824 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7826 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7828 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7829 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7830 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007831 { } /* end */
7832};
7833
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007834static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7835 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7836 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7837 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7838 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7839 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7840 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7841 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7842 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007843 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007844 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7845 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007846 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007847 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007848 { } /* end */
7849};
7850
7851static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7852 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7853 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7854 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7855 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7856 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7857 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7858 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7859 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7860 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7861 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7862 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7863 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7864 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7865 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007866 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007867 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7868 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007869 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007870 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007871 { } /* end */
7872};
7873
Jiang zhe17bba1b2008-06-04 12:11:07 +02007874static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7875 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7876 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7877 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7878 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7879 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7880 HDA_OUTPUT),
7881 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7882 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7883 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7884 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7885 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7886 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7887 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7888 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7890 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7892 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7893 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7894 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007895 { } /* end */
7896};
7897
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007898static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7899 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7900 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7901 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7902 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7903 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7904 HDA_OUTPUT),
7905 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7906 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7907 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7908 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7909 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7910 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7911 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7912 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7913 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7914 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7915 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7916 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7917 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7918 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7919 { } /* end */
7920};
7921
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007922static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007923 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007924 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007925 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007926 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007927 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7928 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007929 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7930 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007931 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7932 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7933 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7934 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7935 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7936 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007937 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7939 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007940 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007941 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007942 { } /* end */
7943};
7944
Sasha Alexandrc2592492009-06-16 14:52:54 -04007945static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007947 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007948 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007949 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007950 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7951 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7952 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7953 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7954 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7955 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7956 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7957 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7958 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7959 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7960 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007961 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007962 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007963 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007964};
Kailang Yangccc656c2006-10-17 12:32:26 +02007965
Sasha Alexandrc2592492009-06-16 14:52:54 -04007966static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007967 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007968 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007970 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007971 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7972 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007974 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007975 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007976 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7977 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7978 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007979 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007980};
Kailang Yangccc656c2006-10-17 12:32:26 +02007981
Takashi Iwaib99dba32009-09-17 18:23:00 +02007982static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
7983 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7984 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7985 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7986 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7987 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7988 { } /* end */
7989};
7990
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007991static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7992 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7993 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007994 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7995 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007996 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7998 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008000 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008001};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008002
Kailang Yang272a5272007-05-14 11:00:38 +02008003static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8004 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8005 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8007 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8008 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8009 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8010 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8011 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8012 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008013 { } /* end */
8014};
8015
8016static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8017 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8018 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8019 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8020 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8021 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8024 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8025 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008026 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008027};
Kailang Yang272a5272007-05-14 11:00:38 +02008028
Tobin Davis2880a862007-08-07 11:50:26 +02008029static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008030 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8031 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008032 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008033 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8034 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008035 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8036 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8037 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008038 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008039};
Tobin Davis2880a862007-08-07 11:50:26 +02008040
Tony Vroond2fd4b02009-06-21 00:40:10 +01008041static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8042 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8043 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8044 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8045 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008046 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8047 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008048 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8049 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8051 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8052 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8053 { } /* end */
8054};
8055
Kailang Yange2757d52008-08-26 13:17:46 +02008056static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8057 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8058 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8059 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8060 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8061 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8062 0x0d, 1, 0x0, HDA_OUTPUT),
8063 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8064 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8065 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8066 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8067 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008068 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8069 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8070 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8071 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8073 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8074 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8075 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8076 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8077 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008078 { } /* end */
8079};
8080
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008081static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8082 /* Output mixers */
8083 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8084 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8085 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8086 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8087 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8088 HDA_OUTPUT),
8089 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8090 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8091 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8092 /* Output switches */
8093 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8094 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8095 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8096 /* Boost mixers */
8097 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8098 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8099 /* Input mixers */
8100 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8102 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8103 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8104 { } /* end */
8105};
8106
Guido Günther3e1647c2009-06-05 00:47:26 +02008107static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8108 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8109 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8110 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8112 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8114 { } /* end */
8115};
8116
Kailang Yange2757d52008-08-26 13:17:46 +02008117static struct hda_bind_ctls alc883_bind_cap_vol = {
8118 .ops = &snd_hda_bind_vol,
8119 .values = {
8120 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8121 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8122 0
8123 },
8124};
8125
8126static struct hda_bind_ctls alc883_bind_cap_switch = {
8127 .ops = &snd_hda_bind_sw,
8128 .values = {
8129 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8130 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8131 0
8132 },
8133};
8134
8135static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8136 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8137 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8138 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8139 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8140 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8141 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8142 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8143 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008144 { } /* end */
8145};
8146
8147static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008148 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8149 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8150 {
8151 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8152 /* .name = "Capture Source", */
8153 .name = "Input Source",
8154 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008155 .info = alc_mux_enum_info,
8156 .get = alc_mux_enum_get,
8157 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008158 },
8159 { } /* end */
8160};
8161
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008162static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8163 {
8164 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8165 .name = "Channel Mode",
8166 .info = alc_ch_mode_info,
8167 .get = alc_ch_mode_get,
8168 .put = alc_ch_mode_put,
8169 },
8170 { } /* end */
8171};
8172
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008173/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008174static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008175{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008176 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008177
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008178 spec->autocfg.hp_pins[0] = 0x15;
8179 spec->autocfg.speaker_pins[0] = 0x14;
8180 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008181}
8182
8183/* auto-toggle front mic */
8184/*
8185static void alc883_mitac_mic_automute(struct hda_codec *codec)
8186{
8187 unsigned int present;
8188 unsigned char bits;
8189
8190 present = snd_hda_codec_read(codec, 0x18, 0,
8191 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8192 bits = present ? HDA_AMP_MUTE : 0;
8193 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8194}
8195*/
8196
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008197static struct hda_verb alc883_mitac_verbs[] = {
8198 /* HP */
8199 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8201 /* Subwoofer */
8202 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8203 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8204
8205 /* enable unsolicited event */
8206 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8207 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8208
8209 { } /* end */
8210};
8211
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308212static struct hda_verb alc883_clevo_m540r_verbs[] = {
8213 /* HP */
8214 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8215 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8216 /* Int speaker */
8217 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8218
8219 /* enable unsolicited event */
8220 /*
8221 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8222 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8223 */
8224
8225 { } /* end */
8226};
8227
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008228static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008229 /* HP */
8230 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8231 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8232 /* Int speaker */
8233 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8235
8236 /* enable unsolicited event */
8237 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008238 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008239
8240 { } /* end */
8241};
8242
Jiang zhefb97dc62008-03-06 11:07:11 +01008243static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8244 /* HP */
8245 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8246 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8247 /* Subwoofer */
8248 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8249 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8250
8251 /* enable unsolicited event */
8252 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8253
8254 { } /* end */
8255};
8256
Sasha Alexandrc2592492009-06-16 14:52:54 -04008257static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8260
8261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8262 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008263
David Heidelberger64a8be72009-06-08 16:15:18 +02008264/* Connect Line-Out side jack (SPDIF) to Side */
8265 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8266 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8267 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8268/* Connect Mic jack to CLFE */
8269 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8270 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8271 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8272/* Connect Line-in jack to Surround */
8273 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8275 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8276/* Connect HP out jack to Front */
8277 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8278 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8279 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008280
8281 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008282
8283 { } /* end */
8284};
8285
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008286static struct hda_verb alc883_lenovo_101e_verbs[] = {
8287 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8288 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8289 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8290 { } /* end */
8291};
8292
Kailang Yang272a5272007-05-14 11:00:38 +02008293static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8294 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8295 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8296 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8297 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8298 { } /* end */
8299};
8300
8301static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8303 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8304 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8305 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8306 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8307 { } /* end */
8308};
8309
Kailang Yang189609a2007-08-20 11:31:23 +02008310static struct hda_verb alc883_haier_w66_verbs[] = {
8311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8312 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8313
8314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8315
8316 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8317 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8318 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8319 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8320 { } /* end */
8321};
8322
Kailang Yange2757d52008-08-26 13:17:46 +02008323static struct hda_verb alc888_lenovo_sky_verbs[] = {
8324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8327 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8328 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8329 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8330 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8331 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8332 { } /* end */
8333};
8334
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008335static struct hda_verb alc888_6st_dell_verbs[] = {
8336 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8337 { }
8338};
8339
Guido Günther3e1647c2009-06-05 00:47:26 +02008340static struct hda_verb alc883_vaiott_verbs[] = {
8341 /* HP */
8342 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8344
8345 /* enable unsolicited event */
8346 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8347
8348 { } /* end */
8349};
8350
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008351static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008352{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008353 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008354
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008355 spec->autocfg.hp_pins[0] = 0x1b;
8356 spec->autocfg.speaker_pins[0] = 0x14;
8357 spec->autocfg.speaker_pins[1] = 0x16;
8358 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008359}
8360
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008361static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008362 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008363 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8364 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008365 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008366 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008367};
8368
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008369/*
8370 * 2ch mode
8371 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008372static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008373 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8374 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8375 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8376 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008377 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008378};
8379
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008380/*
8381 * 4ch mode
8382 */
8383static struct hda_verb alc888_3st_hp_4ch_init[] = {
8384 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8385 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8386 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8387 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8388 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8389 { } /* end */
8390};
8391
8392/*
8393 * 6ch mode
8394 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008395static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008396 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8397 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008398 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008399 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8400 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008401 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8402 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008403};
8404
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008405static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008406 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008407 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008408 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008409};
8410
Kailang Yang272a5272007-05-14 11:00:38 +02008411/* toggle front-jack and RCA according to the hp-jack state */
8412static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8413{
8414 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008415
Kailang Yang272a5272007-05-14 11:00:38 +02008416 present = snd_hda_codec_read(codec, 0x1b, 0,
8417 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008418 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8419 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8420 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8421 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008422}
8423
8424/* toggle RCA according to the front-jack state */
8425static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8426{
8427 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008428
Kailang Yang272a5272007-05-14 11:00:38 +02008429 present = snd_hda_codec_read(codec, 0x14, 0,
8430 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008431 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8432 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008433}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008434
Kailang Yang272a5272007-05-14 11:00:38 +02008435static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8436 unsigned int res)
8437{
8438 if ((res >> 26) == ALC880_HP_EVENT)
8439 alc888_lenovo_ms7195_front_automute(codec);
8440 if ((res >> 26) == ALC880_FRONT_EVENT)
8441 alc888_lenovo_ms7195_rca_automute(codec);
8442}
8443
8444static struct hda_verb alc883_medion_md2_verbs[] = {
8445 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8446 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8447
8448 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8449
8450 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8451 { } /* end */
8452};
8453
8454/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008455static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008456{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008457 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008458
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008459 spec->autocfg.hp_pins[0] = 0x14;
8460 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008461}
8462
Kailang Yangccc656c2006-10-17 12:32:26 +02008463/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008464#define alc883_targa_init_hook alc882_targa_init_hook
8465#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008466
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008467static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8468{
8469 unsigned int present;
8470
8471 present = snd_hda_codec_read(codec, 0x18, 0,
8472 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8473 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8474 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8475}
8476
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008477static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008478{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008479 struct alc_spec *spec = codec->spec;
8480
8481 spec->autocfg.hp_pins[0] = 0x15;
8482 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008483}
8484
8485static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8486{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008487 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008488 alc883_clevo_m720_mic_automute(codec);
8489}
8490
8491static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008492 unsigned int res)
8493{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008494 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008495 case ALC880_MIC_EVENT:
8496 alc883_clevo_m720_mic_automute(codec);
8497 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008498 default:
8499 alc_automute_amp_unsol_event(codec, res);
8500 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008501 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008502}
8503
Jiang zhefb97dc62008-03-06 11:07:11 +01008504/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008505static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008506{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008507 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008508
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008509 spec->autocfg.hp_pins[0] = 0x14;
8510 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008511}
8512
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008513static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008514{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008515 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008516
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008517 spec->autocfg.hp_pins[0] = 0x1b;
8518 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008519}
8520
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008521static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8522{
8523 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008524 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008525
David Heidelberger64a8be72009-06-08 16:15:18 +02008526 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8527 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008528 bits = present ? HDA_AMP_MUTE : 0;
8529 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8530 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008531}
8532
8533static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8534{
8535 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008536 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008537
8538 present = snd_hda_codec_read(codec, 0x1b, 0,
8539 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008540 bits = present ? HDA_AMP_MUTE : 0;
8541 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8542 HDA_AMP_MUTE, bits);
8543 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8544 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008545}
8546
8547static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8548 unsigned int res)
8549{
8550 if ((res >> 26) == ALC880_HP_EVENT)
8551 alc883_lenovo_101e_all_automute(codec);
8552 if ((res >> 26) == ALC880_FRONT_EVENT)
8553 alc883_lenovo_101e_ispeaker_automute(codec);
8554}
8555
Takashi Iwai676a9b52007-08-16 15:23:35 +02008556/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008557static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008558{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008559 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008560
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008561 spec->autocfg.hp_pins[0] = 0x14;
8562 spec->autocfg.speaker_pins[0] = 0x15;
8563 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008564}
8565
Kailang Yangd1a991a2007-08-15 16:21:59 +02008566static struct hda_verb alc883_acer_eapd_verbs[] = {
8567 /* HP Pin: output 0 (0x0c) */
8568 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8569 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8570 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8571 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008572 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8573 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008574 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008575 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8576 /* eanable EAPD on medion laptop */
8577 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8578 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008579 /* enable unsolicited event */
8580 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008581 { }
8582};
8583
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008584static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8585 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8586 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8587 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8588 { } /* end */
8589};
8590
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008591static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008592{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008593 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008594
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008595 spec->autocfg.hp_pins[0] = 0x1b;
8596 spec->autocfg.speaker_pins[0] = 0x14;
8597 spec->autocfg.speaker_pins[1] = 0x15;
8598 spec->autocfg.speaker_pins[2] = 0x16;
8599 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008600}
8601
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008602static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008603{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008604 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008605
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008606 spec->autocfg.hp_pins[0] = 0x1b;
8607 spec->autocfg.speaker_pins[0] = 0x14;
8608 spec->autocfg.speaker_pins[1] = 0x15;
8609 spec->autocfg.speaker_pins[2] = 0x16;
8610 spec->autocfg.speaker_pins[3] = 0x17;
8611 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008612}
8613
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008614static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008615{
8616 struct alc_spec *spec = codec->spec;
8617
8618 spec->autocfg.hp_pins[0] = 0x15;
8619 spec->autocfg.speaker_pins[0] = 0x14;
8620 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008621}
8622
Kailang Yange2757d52008-08-26 13:17:46 +02008623static struct hda_verb alc888_asus_m90v_verbs[] = {
8624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8625 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8626 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8627 /* enable unsolicited event */
8628 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8629 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8630 { } /* end */
8631};
8632
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008633static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008634{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008635 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008636
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008637 spec->autocfg.hp_pins[0] = 0x1b;
8638 spec->autocfg.speaker_pins[0] = 0x14;
8639 spec->autocfg.speaker_pins[1] = 0x15;
8640 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008641 spec->ext_mic.pin = 0x18;
8642 spec->int_mic.pin = 0x19;
8643 spec->ext_mic.mux_idx = 0;
8644 spec->int_mic.mux_idx = 1;
8645 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008646}
8647
8648static struct hda_verb alc888_asus_eee1601_verbs[] = {
8649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8651 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8654 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8655 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8656 /* enable unsolicited event */
8657 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8658 { } /* end */
8659};
8660
Kailang Yange2757d52008-08-26 13:17:46 +02008661static void alc883_eee1601_inithook(struct hda_codec *codec)
8662{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008663 struct alc_spec *spec = codec->spec;
8664
8665 spec->autocfg.hp_pins[0] = 0x14;
8666 spec->autocfg.speaker_pins[0] = 0x1b;
8667 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008668}
8669
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008670static struct hda_verb alc889A_mb31_verbs[] = {
8671 /* Init rear pin (used as headphone output) */
8672 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8673 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8674 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8675 /* Init line pin (used as output in 4ch and 6ch mode) */
8676 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8677 /* Init line 2 pin (used as headphone out by default) */
8678 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8679 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8680 { } /* end */
8681};
8682
8683/* Mute speakers according to the headphone jack state */
8684static void alc889A_mb31_automute(struct hda_codec *codec)
8685{
8686 unsigned int present;
8687
8688 /* Mute only in 2ch or 4ch mode */
8689 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8690 == 0x00) {
8691 present = snd_hda_codec_read(codec, 0x15, 0,
8692 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8693 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8694 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8695 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8696 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8697 }
8698}
8699
8700static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8701{
8702 if ((res >> 26) == ALC880_HP_EVENT)
8703 alc889A_mb31_automute(codec);
8704}
8705
Takashi Iwai4953550a2009-06-30 15:28:30 +02008706
Takashi Iwaicb53c622007-08-10 17:21:45 +02008707#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008708#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008709#endif
8710
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008711/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008712#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8713#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8714#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8715#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8716
8717static hda_nid_t alc883_slave_dig_outs[] = {
8718 ALC1200_DIGOUT_NID, 0,
8719};
8720
8721static hda_nid_t alc1200_slave_dig_outs[] = {
8722 ALC883_DIGOUT_NID, 0,
8723};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008724
8725/*
8726 * configuration and preset
8727 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008728static const char *alc882_models[ALC882_MODEL_LAST] = {
8729 [ALC882_3ST_DIG] = "3stack-dig",
8730 [ALC882_6ST_DIG] = "6stack-dig",
8731 [ALC882_ARIMA] = "arima",
8732 [ALC882_W2JC] = "w2jc",
8733 [ALC882_TARGA] = "targa",
8734 [ALC882_ASUS_A7J] = "asus-a7j",
8735 [ALC882_ASUS_A7M] = "asus-a7m",
8736 [ALC885_MACPRO] = "macpro",
8737 [ALC885_MB5] = "mb5",
8738 [ALC885_MBP3] = "mbp3",
8739 [ALC885_IMAC24] = "imac24",
8740 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008741 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8742 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008743 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008744 [ALC883_TARGA_DIG] = "targa-dig",
8745 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008746 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008747 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008748 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008749 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008750 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008751 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008752 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008753 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008754 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008755 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008756 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008757 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8758 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008759 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008760 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008761 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008762 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008763 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308764 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008765 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008766 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008767 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008768 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008769 [ALC889A_INTEL] = "intel-alc889a",
8770 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008771 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008772 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008773 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008774 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008775};
8776
Takashi Iwai4953550a2009-06-30 15:28:30 +02008777static struct snd_pci_quirk alc882_cfg_tbl[] = {
8778 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8779
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008780 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008781 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008782 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008783 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8784 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008785 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008786 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8787 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008788 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8789 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008790 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8791 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008792 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8793 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008794 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8795 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008796 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008797 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008798 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008799 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008800 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8801 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008802 /* default Acer -- disabled as it causes more problems.
8803 * model=auto should work fine now
8804 */
8805 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008806
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008807 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008808
Tobin Davisfebe3372007-06-12 11:27:46 +02008809 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008810 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8811 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008812 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008813 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008814 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008815
8816 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8817 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8818 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008819 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008820 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8821 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8822 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008823 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008824 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008825 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008826 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008827
8828 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008829 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008830 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008831 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008832 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8833 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008834 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008835 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008836 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8837
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008838 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8839 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8840 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008841 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Jiang zhe4383fae2008-04-14 12:58:57 +02008842 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008843 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008844 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008845 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008846 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8847 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8848 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8849 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8850 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8851 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008852 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008853 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8854 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8855 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008856 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008857 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8858 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008859 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008860 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008861 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008862 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008863 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008864 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008865 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008866 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008867
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008868 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008869 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8870 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308871 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008872 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008873 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008874 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008875 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008876 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008877 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008878 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008879 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008880 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008881 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008882 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8883 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008884 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008885 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008886 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008887 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008888 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008889
Jiang zhe17bba1b2008-06-04 12:11:07 +02008890 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8891 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008892 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008893 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8894 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8895 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008896 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008897
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008898 {}
8899};
8900
Takashi Iwai4953550a2009-06-30 15:28:30 +02008901/* codec SSID table for Intel Mac */
8902static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8903 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8904 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8905 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8906 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8907 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8908 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8909 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8910 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8911 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8912 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8913 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05008914 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
8915 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02008916 */
8917 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05008918 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008919 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008920};
8921
Takashi Iwai4953550a2009-06-30 15:28:30 +02008922static struct alc_config_preset alc882_presets[] = {
8923 [ALC882_3ST_DIG] = {
8924 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008925 .init_verbs = { alc882_base_init_verbs,
8926 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008927 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8928 .dac_nids = alc882_dac_nids,
8929 .dig_out_nid = ALC882_DIGOUT_NID,
8930 .dig_in_nid = ALC882_DIGIN_NID,
8931 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8932 .channel_mode = alc882_ch_modes,
8933 .need_dac_fix = 1,
8934 .input_mux = &alc882_capture_source,
8935 },
8936 [ALC882_6ST_DIG] = {
8937 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008938 .init_verbs = { alc882_base_init_verbs,
8939 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008940 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8941 .dac_nids = alc882_dac_nids,
8942 .dig_out_nid = ALC882_DIGOUT_NID,
8943 .dig_in_nid = ALC882_DIGIN_NID,
8944 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8945 .channel_mode = alc882_sixstack_modes,
8946 .input_mux = &alc882_capture_source,
8947 },
8948 [ALC882_ARIMA] = {
8949 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008950 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8951 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008952 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8953 .dac_nids = alc882_dac_nids,
8954 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8955 .channel_mode = alc882_sixstack_modes,
8956 .input_mux = &alc882_capture_source,
8957 },
8958 [ALC882_W2JC] = {
8959 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008960 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8961 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008962 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8963 .dac_nids = alc882_dac_nids,
8964 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8965 .channel_mode = alc880_threestack_modes,
8966 .need_dac_fix = 1,
8967 .input_mux = &alc882_capture_source,
8968 .dig_out_nid = ALC882_DIGOUT_NID,
8969 },
8970 [ALC885_MBP3] = {
8971 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8972 .init_verbs = { alc885_mbp3_init_verbs,
8973 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02008974 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008975 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02008976 .hp_nid = 0x04,
8977 .channel_mode = alc885_mbp_4ch_modes,
8978 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008979 .input_mux = &alc882_capture_source,
8980 .dig_out_nid = ALC882_DIGOUT_NID,
8981 .dig_in_nid = ALC882_DIGIN_NID,
8982 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008983 .setup = alc885_mbp3_setup,
8984 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008985 },
8986 [ALC885_MB5] = {
8987 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8988 .init_verbs = { alc885_mb5_init_verbs,
8989 alc880_gpio1_init_verbs },
8990 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8991 .dac_nids = alc882_dac_nids,
8992 .channel_mode = alc885_mb5_6ch_modes,
8993 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8994 .input_mux = &mb5_capture_source,
8995 .dig_out_nid = ALC882_DIGOUT_NID,
8996 .dig_in_nid = ALC882_DIGIN_NID,
8997 },
8998 [ALC885_MACPRO] = {
8999 .mixers = { alc882_macpro_mixer },
9000 .init_verbs = { alc882_macpro_init_verbs },
9001 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9002 .dac_nids = alc882_dac_nids,
9003 .dig_out_nid = ALC882_DIGOUT_NID,
9004 .dig_in_nid = ALC882_DIGIN_NID,
9005 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9006 .channel_mode = alc882_ch_modes,
9007 .input_mux = &alc882_capture_source,
9008 .init_hook = alc885_macpro_init_hook,
9009 },
9010 [ALC885_IMAC24] = {
9011 .mixers = { alc885_imac24_mixer },
9012 .init_verbs = { alc885_imac24_init_verbs },
9013 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9014 .dac_nids = alc882_dac_nids,
9015 .dig_out_nid = ALC882_DIGOUT_NID,
9016 .dig_in_nid = ALC882_DIGIN_NID,
9017 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9018 .channel_mode = alc882_ch_modes,
9019 .input_mux = &alc882_capture_source,
9020 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009021 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009022 .init_hook = alc885_imac24_init_hook,
9023 },
9024 [ALC882_TARGA] = {
9025 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009026 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009027 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009028 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9029 .dac_nids = alc882_dac_nids,
9030 .dig_out_nid = ALC882_DIGOUT_NID,
9031 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9032 .adc_nids = alc882_adc_nids,
9033 .capsrc_nids = alc882_capsrc_nids,
9034 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9035 .channel_mode = alc882_3ST_6ch_modes,
9036 .need_dac_fix = 1,
9037 .input_mux = &alc882_capture_source,
9038 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009039 .setup = alc882_targa_setup,
9040 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009041 },
9042 [ALC882_ASUS_A7J] = {
9043 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009044 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9045 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009046 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9047 .dac_nids = alc882_dac_nids,
9048 .dig_out_nid = ALC882_DIGOUT_NID,
9049 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9050 .adc_nids = alc882_adc_nids,
9051 .capsrc_nids = alc882_capsrc_nids,
9052 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9053 .channel_mode = alc882_3ST_6ch_modes,
9054 .need_dac_fix = 1,
9055 .input_mux = &alc882_capture_source,
9056 },
9057 [ALC882_ASUS_A7M] = {
9058 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009059 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9060 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009061 alc882_asus_a7m_verbs },
9062 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9063 .dac_nids = alc882_dac_nids,
9064 .dig_out_nid = ALC882_DIGOUT_NID,
9065 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9066 .channel_mode = alc880_threestack_modes,
9067 .need_dac_fix = 1,
9068 .input_mux = &alc882_capture_source,
9069 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009070 [ALC883_3ST_2ch_DIG] = {
9071 .mixers = { alc883_3ST_2ch_mixer },
9072 .init_verbs = { alc883_init_verbs },
9073 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9074 .dac_nids = alc883_dac_nids,
9075 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009076 .dig_in_nid = ALC883_DIGIN_NID,
9077 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9078 .channel_mode = alc883_3ST_2ch_modes,
9079 .input_mux = &alc883_capture_source,
9080 },
9081 [ALC883_3ST_6ch_DIG] = {
9082 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9083 .init_verbs = { alc883_init_verbs },
9084 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9085 .dac_nids = alc883_dac_nids,
9086 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009087 .dig_in_nid = ALC883_DIGIN_NID,
9088 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9089 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009090 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009091 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009092 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009093 [ALC883_3ST_6ch] = {
9094 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9095 .init_verbs = { alc883_init_verbs },
9096 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9097 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009098 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9099 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009100 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009101 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009102 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009103 [ALC883_3ST_6ch_INTEL] = {
9104 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9105 .init_verbs = { alc883_init_verbs },
9106 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9107 .dac_nids = alc883_dac_nids,
9108 .dig_out_nid = ALC883_DIGOUT_NID,
9109 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009110 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009111 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9112 .channel_mode = alc883_3ST_6ch_intel_modes,
9113 .need_dac_fix = 1,
9114 .input_mux = &alc883_3stack_6ch_intel,
9115 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009116 [ALC889A_INTEL] = {
9117 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009118 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9119 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009120 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9121 .dac_nids = alc883_dac_nids,
9122 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9123 .adc_nids = alc889_adc_nids,
9124 .dig_out_nid = ALC883_DIGOUT_NID,
9125 .dig_in_nid = ALC883_DIGIN_NID,
9126 .slave_dig_outs = alc883_slave_dig_outs,
9127 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9128 .channel_mode = alc889_8ch_intel_modes,
9129 .capsrc_nids = alc889_capsrc_nids,
9130 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009131 .setup = alc889_automute_setup,
9132 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009133 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009134 .need_dac_fix = 1,
9135 },
9136 [ALC889_INTEL] = {
9137 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9138 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009139 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009140 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9141 .dac_nids = alc883_dac_nids,
9142 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9143 .adc_nids = alc889_adc_nids,
9144 .dig_out_nid = ALC883_DIGOUT_NID,
9145 .dig_in_nid = ALC883_DIGIN_NID,
9146 .slave_dig_outs = alc883_slave_dig_outs,
9147 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9148 .channel_mode = alc889_8ch_intel_modes,
9149 .capsrc_nids = alc889_capsrc_nids,
9150 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009151 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009152 .init_hook = alc889_intel_init_hook,
9153 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009154 .need_dac_fix = 1,
9155 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009156 [ALC883_6ST_DIG] = {
9157 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9158 .init_verbs = { alc883_init_verbs },
9159 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9160 .dac_nids = alc883_dac_nids,
9161 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009162 .dig_in_nid = ALC883_DIGIN_NID,
9163 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9164 .channel_mode = alc883_sixstack_modes,
9165 .input_mux = &alc883_capture_source,
9166 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009167 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009168 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009169 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9170 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009171 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9172 .dac_nids = alc883_dac_nids,
9173 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009174 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9175 .channel_mode = alc883_3ST_6ch_modes,
9176 .need_dac_fix = 1,
9177 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009178 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009179 .setup = alc882_targa_setup,
9180 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009181 },
9182 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009183 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009184 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9185 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009186 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9187 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009188 .adc_nids = alc883_adc_nids_alt,
9189 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009190 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009191 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9192 .channel_mode = alc883_3ST_2ch_modes,
9193 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009194 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009195 .setup = alc882_targa_setup,
9196 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009197 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009198 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009199 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9200 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009201 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009202 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009203 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9204 .dac_nids = alc883_dac_nids,
9205 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9206 .adc_nids = alc883_adc_nids_rev,
9207 .capsrc_nids = alc883_capsrc_nids_rev,
9208 .dig_out_nid = ALC883_DIGOUT_NID,
9209 .dig_in_nid = ALC883_DIGIN_NID,
9210 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9211 .channel_mode = alc883_4ST_8ch_modes,
9212 .need_dac_fix = 1,
9213 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009214 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009215 .setup = alc882_targa_setup,
9216 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009217 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009218 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009219 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009220 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9221 * and the headphone jack. Turn this on and rely on the
9222 * standard mute methods whenever the user wants to turn
9223 * these outputs off.
9224 */
9225 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9226 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9227 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009228 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9229 .channel_mode = alc883_3ST_2ch_modes,
9230 .input_mux = &alc883_capture_source,
9231 },
Tobin Davis2880a862007-08-07 11:50:26 +02009232 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009233 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009234 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009235 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9236 .dac_nids = alc883_dac_nids,
9237 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009238 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9239 .channel_mode = alc883_3ST_2ch_modes,
9240 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009241 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009242 .setup = alc883_acer_aspire_setup,
9243 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009244 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009245 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009246 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009247 alc883_chmode_mixer },
9248 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9249 alc888_acer_aspire_4930g_verbs },
9250 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9251 .dac_nids = alc883_dac_nids,
9252 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9253 .adc_nids = alc883_adc_nids_rev,
9254 .capsrc_nids = alc883_capsrc_nids_rev,
9255 .dig_out_nid = ALC883_DIGOUT_NID,
9256 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9257 .channel_mode = alc883_3ST_6ch_modes,
9258 .need_dac_fix = 1,
9259 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009260 ARRAY_SIZE(alc888_2_capture_sources),
9261 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009262 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009263 .setup = alc888_acer_aspire_4930g_setup,
9264 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009265 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009266 [ALC888_ACER_ASPIRE_6530G] = {
9267 .mixers = { alc888_acer_aspire_6530_mixer },
9268 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9269 alc888_acer_aspire_6530g_verbs },
9270 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9271 .dac_nids = alc883_dac_nids,
9272 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9273 .adc_nids = alc883_adc_nids_rev,
9274 .capsrc_nids = alc883_capsrc_nids_rev,
9275 .dig_out_nid = ALC883_DIGOUT_NID,
9276 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9277 .channel_mode = alc883_3ST_2ch_modes,
9278 .num_mux_defs =
9279 ARRAY_SIZE(alc888_2_capture_sources),
9280 .input_mux = alc888_acer_aspire_6530_sources,
9281 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009282 .setup = alc888_acer_aspire_6530g_setup,
9283 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009284 },
Hector Martin3b315d72009-06-02 10:54:19 +02009285 [ALC888_ACER_ASPIRE_8930G] = {
9286 .mixers = { alc888_base_mixer,
9287 alc883_chmode_mixer },
9288 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009289 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009290 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9291 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009292 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9293 .adc_nids = alc889_adc_nids,
9294 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009295 .dig_out_nid = ALC883_DIGOUT_NID,
9296 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9297 .channel_mode = alc883_3ST_6ch_modes,
9298 .need_dac_fix = 1,
9299 .const_channel_count = 6,
9300 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009301 ARRAY_SIZE(alc889_capture_sources),
9302 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009303 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009304 .setup = alc889_acer_aspire_8930g_setup,
9305 .init_hook = alc_automute_amp,
Hector Martin3b315d72009-06-02 10:54:19 +02009306 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009307 [ALC888_ACER_ASPIRE_7730G] = {
9308 .mixers = { alc883_3ST_6ch_mixer,
9309 alc883_chmode_mixer },
9310 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9311 alc888_acer_aspire_7730G_verbs },
9312 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9313 .dac_nids = alc883_dac_nids,
9314 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9315 .adc_nids = alc883_adc_nids_rev,
9316 .capsrc_nids = alc883_capsrc_nids_rev,
9317 .dig_out_nid = ALC883_DIGOUT_NID,
9318 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9319 .channel_mode = alc883_3ST_6ch_modes,
9320 .need_dac_fix = 1,
9321 .const_channel_count = 6,
9322 .input_mux = &alc883_capture_source,
9323 .unsol_event = alc_automute_amp_unsol_event,
9324 .setup = alc888_acer_aspire_6530g_setup,
9325 .init_hook = alc_automute_amp,
9326 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009327 [ALC883_MEDION] = {
9328 .mixers = { alc883_fivestack_mixer,
9329 alc883_chmode_mixer },
9330 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009331 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009332 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9333 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009334 .adc_nids = alc883_adc_nids_alt,
9335 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009336 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9337 .channel_mode = alc883_sixstack_modes,
9338 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009339 },
Kailang Yang272a5272007-05-14 11:00:38 +02009340 [ALC883_MEDION_MD2] = {
9341 .mixers = { alc883_medion_md2_mixer},
9342 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9343 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9344 .dac_nids = alc883_dac_nids,
9345 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009346 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9347 .channel_mode = alc883_3ST_2ch_modes,
9348 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009349 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009350 .setup = alc883_medion_md2_setup,
9351 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009352 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009353 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009354 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009355 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9356 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9357 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009358 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9359 .channel_mode = alc883_3ST_2ch_modes,
9360 .input_mux = &alc883_capture_source,
9361 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309362 [ALC883_CLEVO_M540R] = {
9363 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9364 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9365 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9366 .dac_nids = alc883_dac_nids,
9367 .dig_out_nid = ALC883_DIGOUT_NID,
9368 .dig_in_nid = ALC883_DIGIN_NID,
9369 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9370 .channel_mode = alc883_3ST_6ch_clevo_modes,
9371 .need_dac_fix = 1,
9372 .input_mux = &alc883_capture_source,
9373 /* This machine has the hardware HP auto-muting, thus
9374 * we need no software mute via unsol event
9375 */
9376 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009377 [ALC883_CLEVO_M720] = {
9378 .mixers = { alc883_clevo_m720_mixer },
9379 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009380 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9381 .dac_nids = alc883_dac_nids,
9382 .dig_out_nid = ALC883_DIGOUT_NID,
9383 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9384 .channel_mode = alc883_3ST_2ch_modes,
9385 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009386 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009387 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009388 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009389 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009390 [ALC883_LENOVO_101E_2ch] = {
9391 .mixers = { alc883_lenovo_101e_2ch_mixer},
9392 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9393 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9394 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009395 .adc_nids = alc883_adc_nids_alt,
9396 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009397 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9398 .channel_mode = alc883_3ST_2ch_modes,
9399 .input_mux = &alc883_lenovo_101e_capture_source,
9400 .unsol_event = alc883_lenovo_101e_unsol_event,
9401 .init_hook = alc883_lenovo_101e_all_automute,
9402 },
Kailang Yang272a5272007-05-14 11:00:38 +02009403 [ALC883_LENOVO_NB0763] = {
9404 .mixers = { alc883_lenovo_nb0763_mixer },
9405 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9406 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9407 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009408 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9409 .channel_mode = alc883_3ST_2ch_modes,
9410 .need_dac_fix = 1,
9411 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009412 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009413 .setup = alc883_medion_md2_setup,
9414 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009415 },
9416 [ALC888_LENOVO_MS7195_DIG] = {
9417 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9418 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9419 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9420 .dac_nids = alc883_dac_nids,
9421 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009422 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9423 .channel_mode = alc883_3ST_6ch_modes,
9424 .need_dac_fix = 1,
9425 .input_mux = &alc883_capture_source,
9426 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9427 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009428 },
9429 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009430 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009431 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9432 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9433 .dac_nids = alc883_dac_nids,
9434 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009435 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9436 .channel_mode = alc883_3ST_2ch_modes,
9437 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009438 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009439 .setup = alc883_haier_w66_setup,
9440 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009441 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009442 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009443 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009444 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009445 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9446 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009447 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9448 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009449 .need_dac_fix = 1,
9450 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009451 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009452 .setup = alc888_3st_hp_setup,
9453 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009454 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009455 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009456 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009457 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9458 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9459 .dac_nids = alc883_dac_nids,
9460 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009461 .dig_in_nid = ALC883_DIGIN_NID,
9462 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9463 .channel_mode = alc883_sixstack_modes,
9464 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009465 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009466 .setup = alc888_6st_dell_setup,
9467 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009468 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009469 [ALC883_MITAC] = {
9470 .mixers = { alc883_mitac_mixer },
9471 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9472 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9473 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009474 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9475 .channel_mode = alc883_3ST_2ch_modes,
9476 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009477 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009478 .setup = alc883_mitac_setup,
9479 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009480 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009481 [ALC883_FUJITSU_PI2515] = {
9482 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9483 .init_verbs = { alc883_init_verbs,
9484 alc883_2ch_fujitsu_pi2515_verbs},
9485 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9486 .dac_nids = alc883_dac_nids,
9487 .dig_out_nid = ALC883_DIGOUT_NID,
9488 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9489 .channel_mode = alc883_3ST_2ch_modes,
9490 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009491 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009492 .setup = alc883_2ch_fujitsu_pi2515_setup,
9493 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009494 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009495 [ALC888_FUJITSU_XA3530] = {
9496 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9497 .init_verbs = { alc883_init_verbs,
9498 alc888_fujitsu_xa3530_verbs },
9499 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9500 .dac_nids = alc883_dac_nids,
9501 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9502 .adc_nids = alc883_adc_nids_rev,
9503 .capsrc_nids = alc883_capsrc_nids_rev,
9504 .dig_out_nid = ALC883_DIGOUT_NID,
9505 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9506 .channel_mode = alc888_4ST_8ch_intel_modes,
9507 .num_mux_defs =
9508 ARRAY_SIZE(alc888_2_capture_sources),
9509 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009510 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009511 .setup = alc888_fujitsu_xa3530_setup,
9512 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009513 },
Kailang Yange2757d52008-08-26 13:17:46 +02009514 [ALC888_LENOVO_SKY] = {
9515 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9516 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9517 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9518 .dac_nids = alc883_dac_nids,
9519 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009520 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9521 .channel_mode = alc883_sixstack_modes,
9522 .need_dac_fix = 1,
9523 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009524 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009525 .setup = alc888_lenovo_sky_setup,
9526 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009527 },
9528 [ALC888_ASUS_M90V] = {
9529 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9530 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9531 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9532 .dac_nids = alc883_dac_nids,
9533 .dig_out_nid = ALC883_DIGOUT_NID,
9534 .dig_in_nid = ALC883_DIGIN_NID,
9535 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9536 .channel_mode = alc883_3ST_6ch_modes,
9537 .need_dac_fix = 1,
9538 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009539 .unsol_event = alc_sku_unsol_event,
9540 .setup = alc883_mode2_setup,
9541 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009542 },
9543 [ALC888_ASUS_EEE1601] = {
9544 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009545 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009546 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9547 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9548 .dac_nids = alc883_dac_nids,
9549 .dig_out_nid = ALC883_DIGOUT_NID,
9550 .dig_in_nid = ALC883_DIGIN_NID,
9551 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9552 .channel_mode = alc883_3ST_2ch_modes,
9553 .need_dac_fix = 1,
9554 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009555 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009556 .init_hook = alc883_eee1601_inithook,
9557 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009558 [ALC1200_ASUS_P5Q] = {
9559 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9560 .init_verbs = { alc883_init_verbs },
9561 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9562 .dac_nids = alc883_dac_nids,
9563 .dig_out_nid = ALC1200_DIGOUT_NID,
9564 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009565 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009566 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9567 .channel_mode = alc883_sixstack_modes,
9568 .input_mux = &alc883_capture_source,
9569 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009570 [ALC889A_MB31] = {
9571 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9572 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9573 alc880_gpio1_init_verbs },
9574 .adc_nids = alc883_adc_nids,
9575 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9576 .dac_nids = alc883_dac_nids,
9577 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9578 .channel_mode = alc889A_mb31_6ch_modes,
9579 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9580 .input_mux = &alc889A_mb31_capture_source,
9581 .dig_out_nid = ALC883_DIGOUT_NID,
9582 .unsol_event = alc889A_mb31_unsol_event,
9583 .init_hook = alc889A_mb31_automute,
9584 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009585 [ALC883_SONY_VAIO_TT] = {
9586 .mixers = { alc883_vaiott_mixer },
9587 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9588 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9589 .dac_nids = alc883_dac_nids,
9590 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9591 .channel_mode = alc883_3ST_2ch_modes,
9592 .input_mux = &alc883_capture_source,
9593 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009594 .setup = alc883_vaiott_setup,
9595 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009596 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009597};
9598
9599
9600/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009601 * Pin config fixes
9602 */
9603enum {
9604 PINFIX_ABIT_AW9D_MAX
9605};
9606
9607static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9608 { 0x15, 0x01080104 }, /* side */
9609 { 0x16, 0x01011012 }, /* rear */
9610 { 0x17, 0x01016011 }, /* clfe */
9611 { }
9612};
9613
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009614static const struct alc_fixup alc882_fixups[] = {
9615 [PINFIX_ABIT_AW9D_MAX] = {
9616 .pins = alc882_abit_aw9d_pinfix
9617 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009618};
9619
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009620static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009621 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9622 {}
9623};
9624
9625/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009626 * BIOS auto configuration
9627 */
Takashi Iwai05f5f472009-08-25 13:10:18 +02009628static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9629 const struct auto_pin_cfg *cfg)
9630{
9631 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9632}
9633
Takashi Iwai4953550a2009-06-30 15:28:30 +02009634static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009635 hda_nid_t nid, int pin_type,
9636 int dac_idx)
9637{
9638 /* set as output */
9639 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009640 int idx;
9641
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009642 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009643 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9644 idx = 4;
9645 else
9646 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009647 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9648
9649}
9650
Takashi Iwai4953550a2009-06-30 15:28:30 +02009651static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009652{
9653 struct alc_spec *spec = codec->spec;
9654 int i;
9655
9656 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009657 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009658 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009659 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009660 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009661 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009662 }
9663}
9664
Takashi Iwai4953550a2009-06-30 15:28:30 +02009665static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009666{
9667 struct alc_spec *spec = codec->spec;
9668 hda_nid_t pin;
9669
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009670 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009671 if (pin) /* connect to front */
9672 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009673 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009674 pin = spec->autocfg.speaker_pins[0];
9675 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009676 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009677}
9678
Takashi Iwai4953550a2009-06-30 15:28:30 +02009679static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009680{
9681 struct alc_spec *spec = codec->spec;
9682 int i;
9683
9684 for (i = 0; i < AUTO_PIN_LAST; i++) {
9685 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009686 if (!nid)
9687 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009688 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009689 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9690 snd_hda_codec_write(codec, nid, 0,
9691 AC_VERB_SET_AMP_GAIN_MUTE,
9692 AMP_OUT_MUTE);
9693 }
9694}
9695
9696static void alc882_auto_init_input_src(struct hda_codec *codec)
9697{
9698 struct alc_spec *spec = codec->spec;
9699 int c;
9700
9701 for (c = 0; c < spec->num_adc_nids; c++) {
9702 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9703 hda_nid_t nid = spec->capsrc_nids[c];
9704 unsigned int mux_idx;
9705 const struct hda_input_mux *imux;
9706 int conns, mute, idx, item;
9707
9708 conns = snd_hda_get_connections(codec, nid, conn_list,
9709 ARRAY_SIZE(conn_list));
9710 if (conns < 0)
9711 continue;
9712 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9713 imux = &spec->input_mux[mux_idx];
9714 for (idx = 0; idx < conns; idx++) {
9715 /* if the current connection is the selected one,
9716 * unmute it as default - otherwise mute it
9717 */
9718 mute = AMP_IN_MUTE(idx);
9719 for (item = 0; item < imux->num_items; item++) {
9720 if (imux->items[item].index == idx) {
9721 if (spec->cur_mux[c] == item)
9722 mute = AMP_IN_UNMUTE(idx);
9723 break;
9724 }
9725 }
9726 /* check if we have a selector or mixer
9727 * we could check for the widget type instead, but
9728 * just check for Amp-In presence (in case of mixer
9729 * without amp-in there is something wrong, this
9730 * function shouldn't be used or capsrc nid is wrong)
9731 */
9732 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009733 snd_hda_codec_write(codec, nid, 0,
9734 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009735 mute);
9736 else if (mute != AMP_IN_MUTE(idx))
9737 snd_hda_codec_write(codec, nid, 0,
9738 AC_VERB_SET_CONNECT_SEL,
9739 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009740 }
9741 }
9742}
9743
Takashi Iwai4953550a2009-06-30 15:28:30 +02009744/* add mic boosts if needed */
9745static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009746{
9747 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009748 int err;
9749 hda_nid_t nid;
9750
9751 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9752 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9753 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9754 "Mic Boost",
9755 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9756 if (err < 0)
9757 return err;
9758 }
9759 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9760 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9761 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9762 "Front Mic Boost",
9763 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9764 if (err < 0)
9765 return err;
9766 }
9767 return 0;
9768}
9769
9770/* almost identical with ALC880 parser... */
9771static int alc882_parse_auto_config(struct hda_codec *codec)
9772{
9773 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009774 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9775 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009776
Takashi Iwai05f5f472009-08-25 13:10:18 +02009777 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9778 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009779 if (err < 0)
9780 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009781 if (!spec->autocfg.line_outs)
9782 return 0; /* can't find valid BIOS pin config */
9783
9784 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9785 if (err < 0)
9786 return err;
9787 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9788 if (err < 0)
9789 return err;
9790 err = alc880_auto_create_extra_out(spec,
9791 spec->autocfg.speaker_pins[0],
9792 "Speaker");
9793 if (err < 0)
9794 return err;
9795 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9796 "Headphone");
9797 if (err < 0)
9798 return err;
9799 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9800 if (err < 0)
9801 return err;
9802
9803 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9804
9805 /* check multiple SPDIF-out (for recent codecs) */
9806 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9807 hda_nid_t dig_nid;
9808 err = snd_hda_get_connections(codec,
9809 spec->autocfg.dig_out_pins[i],
9810 &dig_nid, 1);
9811 if (err < 0)
9812 continue;
9813 if (!i)
9814 spec->multiout.dig_out_nid = dig_nid;
9815 else {
9816 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01009817 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +02009818 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01009819 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009820 }
9821 }
9822 if (spec->autocfg.dig_in_pin)
9823 spec->dig_in_nid = ALC880_DIGIN_NID;
9824
9825 if (spec->kctls.list)
9826 add_mixer(spec, spec->kctls.list);
9827
9828 add_verb(spec, alc883_auto_init_verbs);
9829 /* if ADC 0x07 is available, initialize it, too */
9830 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9831 add_verb(spec, alc882_adc1_init_verbs);
9832
9833 spec->num_mux_defs = 1;
9834 spec->input_mux = &spec->private_imux[0];
9835
9836 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +02009837
9838 err = alc_auto_add_mic_boost(codec);
9839 if (err < 0)
9840 return err;
9841
Takashi Iwai776e1842007-08-29 15:07:11 +02009842 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009843}
9844
9845/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009846static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009847{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009848 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009849 alc882_auto_init_multi_out(codec);
9850 alc882_auto_init_hp_out(codec);
9851 alc882_auto_init_analog_input(codec);
9852 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009853 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009854 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009855}
9856
Takashi Iwai4953550a2009-06-30 15:28:30 +02009857static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009858{
9859 struct alc_spec *spec;
9860 int err, board_config;
9861
9862 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9863 if (spec == NULL)
9864 return -ENOMEM;
9865
9866 codec->spec = spec;
9867
Takashi Iwai4953550a2009-06-30 15:28:30 +02009868 switch (codec->vendor_id) {
9869 case 0x10ec0882:
9870 case 0x10ec0885:
9871 break;
9872 default:
9873 /* ALC883 and variants */
9874 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9875 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009876 }
9877
Takashi Iwai4953550a2009-06-30 15:28:30 +02009878 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9879 alc882_models,
9880 alc882_cfg_tbl);
9881
9882 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9883 board_config = snd_hda_check_board_codec_sid_config(codec,
9884 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9885
9886 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009887 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009888 codec->chip_name);
9889 board_config = ALC882_AUTO;
9890 }
9891
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009892 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009893
9894 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009895 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009896 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009897 if (err < 0) {
9898 alc_free(codec);
9899 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009900 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009901 printk(KERN_INFO
9902 "hda_codec: Cannot set up configuration "
9903 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +02009904 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009905 }
9906 }
9907
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009908 err = snd_hda_attach_beep_device(codec, 0x1);
9909 if (err < 0) {
9910 alc_free(codec);
9911 return err;
9912 }
9913
Takashi Iwai4953550a2009-06-30 15:28:30 +02009914 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02009915 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009916
Takashi Iwai4953550a2009-06-30 15:28:30 +02009917 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9918 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9919 /* FIXME: setup DAC5 */
9920 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9921 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9922
9923 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9924 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9925
9926 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009927 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009928
9929 if (!spec->adc_nids && spec->input_mux) {
9930 int i;
9931 spec->num_adc_nids = 0;
9932 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9933 hda_nid_t cap;
9934 hda_nid_t nid = alc882_adc_nids[i];
9935 unsigned int wcap = get_wcaps(codec, nid);
9936 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02009937 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009938 if (wcap != AC_WID_AUD_IN)
9939 continue;
9940 spec->private_adc_nids[spec->num_adc_nids] = nid;
9941 err = snd_hda_get_connections(codec, nid, &cap, 1);
9942 if (err < 0)
9943 continue;
9944 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9945 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009946 }
Takashi Iwai4953550a2009-06-30 15:28:30 +02009947 spec->adc_nids = spec->private_adc_nids;
9948 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009949 }
9950
Takashi Iwaib59bdf32009-08-11 09:47:30 +02009951 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009952 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009953
Takashi Iwai2134ea42008-01-10 16:53:55 +01009954 spec->vmaster_nid = 0x0c;
9955
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009956 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009957 if (board_config == ALC882_AUTO)
9958 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009959#ifdef CONFIG_SND_HDA_POWER_SAVE
9960 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009961 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009962#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009963 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009964
9965 return 0;
9966}
9967
Takashi Iwai4953550a2009-06-30 15:28:30 +02009968
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009969/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009970 * ALC262 support
9971 */
9972
9973#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9974#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9975
9976#define alc262_dac_nids alc260_dac_nids
9977#define alc262_adc_nids alc882_adc_nids
9978#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009979#define alc262_capsrc_nids alc882_capsrc_nids
9980#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009981
9982#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009983#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009984
Kailang Yang4e555fe2008-08-26 13:05:55 +02009985static hda_nid_t alc262_dmic_adc_nids[1] = {
9986 /* ADC0 */
9987 0x09
9988};
9989
9990static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9991
Kailang Yangdf694da2005-12-05 19:42:22 +01009992static struct snd_kcontrol_new alc262_base_mixer[] = {
9993 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9994 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9995 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9996 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9997 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9998 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9999 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10000 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010001 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010002 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10003 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010004 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010005 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10007 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10008 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010009 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010010};
10011
Takashi Iwaice875f02008-01-28 18:17:43 +010010012/* update HP, line and mono-out pins according to the master switch */
10013static void alc262_hp_master_update(struct hda_codec *codec)
10014{
10015 struct alc_spec *spec = codec->spec;
10016 int val = spec->master_sw;
10017
10018 /* HP & line-out */
10019 snd_hda_codec_write_cache(codec, 0x1b, 0,
10020 AC_VERB_SET_PIN_WIDGET_CONTROL,
10021 val ? PIN_HP : 0);
10022 snd_hda_codec_write_cache(codec, 0x15, 0,
10023 AC_VERB_SET_PIN_WIDGET_CONTROL,
10024 val ? PIN_HP : 0);
10025 /* mono (speaker) depending on the HP jack sense */
10026 val = val && !spec->jack_present;
10027 snd_hda_codec_write_cache(codec, 0x16, 0,
10028 AC_VERB_SET_PIN_WIDGET_CONTROL,
10029 val ? PIN_OUT : 0);
10030}
10031
10032static void alc262_hp_bpc_automute(struct hda_codec *codec)
10033{
10034 struct alc_spec *spec = codec->spec;
10035 unsigned int presence;
10036 presence = snd_hda_codec_read(codec, 0x1b, 0,
10037 AC_VERB_GET_PIN_SENSE, 0);
10038 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
10039 alc262_hp_master_update(codec);
10040}
10041
10042static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10043{
10044 if ((res >> 26) != ALC880_HP_EVENT)
10045 return;
10046 alc262_hp_bpc_automute(codec);
10047}
10048
10049static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10050{
10051 struct alc_spec *spec = codec->spec;
10052 unsigned int presence;
10053 presence = snd_hda_codec_read(codec, 0x15, 0,
10054 AC_VERB_GET_PIN_SENSE, 0);
10055 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
10056 alc262_hp_master_update(codec);
10057}
10058
10059static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10060 unsigned int res)
10061{
10062 if ((res >> 26) != ALC880_HP_EVENT)
10063 return;
10064 alc262_hp_wildwest_automute(codec);
10065}
10066
Takashi Iwaib72519b2009-05-08 14:31:55 +020010067#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010068
10069static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10070 struct snd_ctl_elem_value *ucontrol)
10071{
10072 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10073 struct alc_spec *spec = codec->spec;
10074 int val = !!*ucontrol->value.integer.value;
10075
10076 if (val == spec->master_sw)
10077 return 0;
10078 spec->master_sw = val;
10079 alc262_hp_master_update(codec);
10080 return 1;
10081}
10082
Takashi Iwaib72519b2009-05-08 14:31:55 +020010083#define ALC262_HP_MASTER_SWITCH \
10084 { \
10085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10086 .name = "Master Playback Switch", \
10087 .info = snd_ctl_boolean_mono_info, \
10088 .get = alc262_hp_master_sw_get, \
10089 .put = alc262_hp_master_sw_put, \
10090 }
10091
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010092static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010093 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010094 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10095 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10096 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010097 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10098 HDA_OUTPUT),
10099 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10100 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010101 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10102 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010103 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010104 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10105 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010106 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010107 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10108 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10109 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10110 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010111 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10112 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10113 { } /* end */
10114};
10115
Kailang Yangcd7509a2007-01-26 18:33:17 +010010116static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010117 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010118 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10119 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10120 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10121 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010122 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10123 HDA_OUTPUT),
10124 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10125 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010126 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10127 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010128 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010129 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10130 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10131 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10132 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010133 { } /* end */
10134};
10135
10136static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10137 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10138 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010139 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010140 { } /* end */
10141};
10142
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010143/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010144static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010145{
10146 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010147
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010148 spec->autocfg.hp_pins[0] = 0x15;
10149 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010150}
10151
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010152static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010153 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10154 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010155 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10156 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10157 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10158 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10159 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10160 { } /* end */
10161};
10162
10163static struct hda_verb alc262_hp_t5735_verbs[] = {
10164 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10166
10167 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10168 { }
10169};
10170
Kailang Yang8c427222008-01-10 13:03:59 +010010171static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010172 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10173 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010174 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10175 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010176 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10177 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10178 { } /* end */
10179};
10180
10181static struct hda_verb alc262_hp_rp5700_verbs[] = {
10182 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10183 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10184 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10185 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10186 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10187 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10188 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10189 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10190 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10191 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10192 {}
10193};
10194
10195static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10196 .num_items = 1,
10197 .items = {
10198 { "Line", 0x1 },
10199 },
10200};
10201
Takashi Iwai42171c12009-05-08 14:11:43 +020010202/* bind hp and internal speaker mute (with plug check) as master switch */
10203static void alc262_hippo_master_update(struct hda_codec *codec)
10204{
10205 struct alc_spec *spec = codec->spec;
10206 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10207 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10208 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10209 unsigned int mute;
10210
10211 /* HP */
10212 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10213 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10214 HDA_AMP_MUTE, mute);
10215 /* mute internal speaker per jack sense */
10216 if (spec->jack_present)
10217 mute = HDA_AMP_MUTE;
10218 if (line_nid)
10219 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10220 HDA_AMP_MUTE, mute);
10221 if (speaker_nid && speaker_nid != line_nid)
10222 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10223 HDA_AMP_MUTE, mute);
10224}
10225
10226#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10227
10228static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10229 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010230{
10231 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010232 struct alc_spec *spec = codec->spec;
10233 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010234
Takashi Iwai42171c12009-05-08 14:11:43 +020010235 if (val == spec->master_sw)
10236 return 0;
10237 spec->master_sw = val;
10238 alc262_hippo_master_update(codec);
10239 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010240}
Takashi Iwai5b319542007-07-26 11:49:22 +020010241
Takashi Iwai42171c12009-05-08 14:11:43 +020010242#define ALC262_HIPPO_MASTER_SWITCH \
10243 { \
10244 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10245 .name = "Master Playback Switch", \
10246 .info = snd_ctl_boolean_mono_info, \
10247 .get = alc262_hippo_master_sw_get, \
10248 .put = alc262_hippo_master_sw_put, \
10249 }
10250
10251static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10252 ALC262_HIPPO_MASTER_SWITCH,
10253 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10254 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10255 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10256 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10257 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10258 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10259 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10260 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10261 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10262 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10263 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10264 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10265 { } /* end */
10266};
10267
10268static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10269 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10270 ALC262_HIPPO_MASTER_SWITCH,
10271 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10272 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10273 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10274 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10275 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10276 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10277 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10278 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10279 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10280 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10281 { } /* end */
10282};
10283
10284/* mute/unmute internal speaker according to the hp jack and mute state */
10285static void alc262_hippo_automute(struct hda_codec *codec)
10286{
10287 struct alc_spec *spec = codec->spec;
10288 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10289 unsigned int present;
10290
10291 /* need to execute and sync at first */
10292 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10293 present = snd_hda_codec_read(codec, hp_nid, 0,
10294 AC_VERB_GET_PIN_SENSE, 0);
10295 spec->jack_present = (present & 0x80000000) != 0;
10296 alc262_hippo_master_update(codec);
10297}
10298
10299static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10300{
10301 if ((res >> 26) != ALC880_HP_EVENT)
10302 return;
10303 alc262_hippo_automute(codec);
10304}
10305
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010306static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010307{
10308 struct alc_spec *spec = codec->spec;
10309
10310 spec->autocfg.hp_pins[0] = 0x15;
10311 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010312}
10313
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010314static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010315{
10316 struct alc_spec *spec = codec->spec;
10317
10318 spec->autocfg.hp_pins[0] = 0x1b;
10319 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010320}
10321
10322
Kailang Yang272a5272007-05-14 11:00:38 +020010323static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010324 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010325 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010326 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10327 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10328 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10329 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10330 { } /* end */
10331};
10332
Kailang Yang83c34212007-07-05 11:43:05 +020010333static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010334 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10335 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010336 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10337 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10338 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10339 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10340 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10341 { } /* end */
10342};
Kailang Yang272a5272007-05-14 11:00:38 +020010343
Tony Vroonba340e82009-02-02 19:01:30 +000010344static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10345 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10346 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10347 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10348 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10349 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10350 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10352 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10353 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10354 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10355 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10356 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10357 { } /* end */
10358};
10359
10360static struct hda_verb alc262_tyan_verbs[] = {
10361 /* Headphone automute */
10362 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10363 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10364 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10365
10366 /* P11 AUX_IN, white 4-pin connector */
10367 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10368 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10369 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10370 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10371
10372 {}
10373};
10374
10375/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010376static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010377{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010378 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010379
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010380 spec->autocfg.hp_pins[0] = 0x1b;
10381 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010382}
10383
Tony Vroonba340e82009-02-02 19:01:30 +000010384
Kailang Yangdf694da2005-12-05 19:42:22 +010010385#define alc262_capture_mixer alc882_capture_mixer
10386#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10387
10388/*
10389 * generic initialization of ADC, input mixers and output mixers
10390 */
10391static struct hda_verb alc262_init_verbs[] = {
10392 /*
10393 * Unmute ADC0-2 and set the default input to mic-in
10394 */
10395 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10396 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10397 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10398 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10399 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10400 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10401
Takashi Iwaicb53c622007-08-10 17:21:45 +020010402 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010403 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010404 * Note: PASD motherboards uses the Line In 2 as the input for
10405 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010406 */
10407 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010408 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10409 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10410 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10411 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10412 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010413
10414 /*
10415 * Set up output mixers (0x0c - 0x0e)
10416 */
10417 /* set vol=0 to output mixers */
10418 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10419 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10420 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10421 /* set up input amps for analog loopback */
10422 /* Amp Indices: DAC = 0, mixer = 1 */
10423 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10424 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10425 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10426 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10427 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10428 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10429
10430 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10431 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10432 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10433 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10434 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10435 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10436
10437 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10438 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10439 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10440 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10441 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010442
Kailang Yangdf694da2005-12-05 19:42:22 +010010443 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10444 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010445
Kailang Yangdf694da2005-12-05 19:42:22 +010010446 /* FIXME: use matrix-type input source selection */
10447 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10448 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10450 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10451 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10452 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10453 /* Input mixer2 */
10454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10455 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10456 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10457 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10458 /* Input mixer3 */
10459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10461 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010462 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010463
10464 { }
10465};
10466
Kailang Yang4e555fe2008-08-26 13:05:55 +020010467static struct hda_verb alc262_eapd_verbs[] = {
10468 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10469 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10470 { }
10471};
10472
Kailang Yangccc656c2006-10-17 12:32:26 +020010473static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10474 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10475 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10476 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10477
10478 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10480 {}
10481};
10482
Kailang Yang272a5272007-05-14 11:00:38 +020010483static struct hda_verb alc262_sony_unsol_verbs[] = {
10484 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10485 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10486 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10487
10488 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010490 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010491};
10492
Kailang Yang4e555fe2008-08-26 13:05:55 +020010493static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10494 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10495 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10496 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10497 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10498 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010499 { } /* end */
10500};
10501
10502static struct hda_verb alc262_toshiba_s06_verbs[] = {
10503 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10505 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10506 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10507 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10508 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10509 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10510 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10511 {}
10512};
10513
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010514static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010515{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010516 struct alc_spec *spec = codec->spec;
10517
10518 spec->autocfg.hp_pins[0] = 0x15;
10519 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010520 spec->ext_mic.pin = 0x18;
10521 spec->ext_mic.mux_idx = 0;
10522 spec->int_mic.pin = 0x12;
10523 spec->int_mic.mux_idx = 9;
10524 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010525}
10526
Takashi Iwai834be882006-03-01 14:16:17 +010010527/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010528 * nec model
10529 * 0x15 = headphone
10530 * 0x16 = internal speaker
10531 * 0x18 = external mic
10532 */
10533
10534static struct snd_kcontrol_new alc262_nec_mixer[] = {
10535 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10536 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10537
10538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10539 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10540 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10541
10542 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10543 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10544 { } /* end */
10545};
10546
10547static struct hda_verb alc262_nec_verbs[] = {
10548 /* Unmute Speaker */
10549 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10550
10551 /* Headphone */
10552 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10553 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10554
10555 /* External mic to headphone */
10556 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10557 /* External mic to speaker */
10558 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10559 {}
10560};
10561
10562/*
Takashi Iwai834be882006-03-01 14:16:17 +010010563 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010564 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10565 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010566 */
10567
10568#define ALC_HP_EVENT 0x37
10569
10570static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10571 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10572 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010573 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10574 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010575 {}
10576};
10577
Jiang zhe0e31daf2008-03-20 12:12:39 +010010578static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10579 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10580 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10581 {}
10582};
10583
Takashi Iwai834be882006-03-01 14:16:17 +010010584static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010585 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010586 .items = {
10587 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010588 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010589 { "CD", 0x4 },
10590 },
10591};
10592
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010593static struct hda_input_mux alc262_HP_capture_source = {
10594 .num_items = 5,
10595 .items = {
10596 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010597 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010598 { "Line", 0x2 },
10599 { "CD", 0x4 },
10600 { "AUX IN", 0x6 },
10601 },
10602};
10603
zhejiangaccbe492007-08-31 12:36:05 +020010604static struct hda_input_mux alc262_HP_D7000_capture_source = {
10605 .num_items = 4,
10606 .items = {
10607 { "Mic", 0x0 },
10608 { "Front Mic", 0x2 },
10609 { "Line", 0x1 },
10610 { "CD", 0x4 },
10611 },
10612};
10613
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010614/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010615static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10616{
10617 struct alc_spec *spec = codec->spec;
10618 unsigned int mute;
10619
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010620 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010621 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010622 /* need to execute and sync at first */
10623 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010624 /* check laptop HP jack */
10625 present = snd_hda_codec_read(codec, 0x14, 0,
10626 AC_VERB_GET_PIN_SENSE, 0);
10627 /* need to execute and sync at first */
10628 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10629 /* check docking HP jack */
10630 present |= snd_hda_codec_read(codec, 0x1b, 0,
10631 AC_VERB_GET_PIN_SENSE, 0);
10632 if (present & AC_PINSENSE_PRESENCE)
10633 spec->jack_present = 1;
10634 else
10635 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010636 spec->sense_updated = 1;
10637 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010638 /* unmute internal speaker only if both HPs are unplugged and
10639 * master switch is on
10640 */
10641 if (spec->jack_present)
10642 mute = HDA_AMP_MUTE;
10643 else
Takashi Iwai834be882006-03-01 14:16:17 +010010644 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010645 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10646 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010647}
10648
10649/* unsolicited event for HP jack sensing */
10650static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10651 unsigned int res)
10652{
10653 if ((res >> 26) != ALC_HP_EVENT)
10654 return;
10655 alc262_fujitsu_automute(codec, 1);
10656}
10657
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010658static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10659{
10660 alc262_fujitsu_automute(codec, 1);
10661}
10662
Takashi Iwai834be882006-03-01 14:16:17 +010010663/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010664static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10665 .ops = &snd_hda_bind_vol,
10666 .values = {
10667 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10668 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10669 0
10670 },
10671};
Takashi Iwai834be882006-03-01 14:16:17 +010010672
Jiang zhe0e31daf2008-03-20 12:12:39 +010010673/* mute/unmute internal speaker according to the hp jack and mute state */
10674static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10675{
10676 struct alc_spec *spec = codec->spec;
10677 unsigned int mute;
10678
10679 if (force || !spec->sense_updated) {
10680 unsigned int present_int_hp;
10681 /* need to execute and sync at first */
10682 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10683 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10684 AC_VERB_GET_PIN_SENSE, 0);
10685 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10686 spec->sense_updated = 1;
10687 }
10688 if (spec->jack_present) {
10689 /* mute internal speaker */
10690 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10691 HDA_AMP_MUTE, HDA_AMP_MUTE);
10692 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10693 HDA_AMP_MUTE, HDA_AMP_MUTE);
10694 } else {
10695 /* unmute internal speaker if necessary */
10696 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10697 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10698 HDA_AMP_MUTE, mute);
10699 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10700 HDA_AMP_MUTE, mute);
10701 }
10702}
10703
10704/* unsolicited event for HP jack sensing */
10705static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10706 unsigned int res)
10707{
10708 if ((res >> 26) != ALC_HP_EVENT)
10709 return;
10710 alc262_lenovo_3000_automute(codec, 1);
10711}
10712
Takashi Iwai8de56b72009-07-24 16:51:47 +020010713static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10714 int dir, int idx, long *valp)
10715{
10716 int i, change = 0;
10717
10718 for (i = 0; i < 2; i++, valp++)
10719 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10720 HDA_AMP_MUTE,
10721 *valp ? 0 : HDA_AMP_MUTE);
10722 return change;
10723}
10724
Takashi Iwai834be882006-03-01 14:16:17 +010010725/* bind hp and internal speaker mute (with plug check) */
10726static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10727 struct snd_ctl_elem_value *ucontrol)
10728{
10729 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10730 long *valp = ucontrol->value.integer.value;
10731 int change;
10732
Takashi Iwai8de56b72009-07-24 16:51:47 +020010733 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10734 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010735 if (change)
10736 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010737 return change;
10738}
10739
10740static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010741 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010742 {
10743 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10744 .name = "Master Playback Switch",
10745 .info = snd_hda_mixer_amp_switch_info,
10746 .get = snd_hda_mixer_amp_switch_get,
10747 .put = alc262_fujitsu_master_sw_put,
10748 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10749 },
10750 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10751 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10752 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10753 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10754 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010755 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10756 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10757 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010758 { } /* end */
10759};
10760
Jiang zhe0e31daf2008-03-20 12:12:39 +010010761/* bind hp and internal speaker mute (with plug check) */
10762static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10763 struct snd_ctl_elem_value *ucontrol)
10764{
10765 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10766 long *valp = ucontrol->value.integer.value;
10767 int change;
10768
Takashi Iwai8de56b72009-07-24 16:51:47 +020010769 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010770 if (change)
10771 alc262_lenovo_3000_automute(codec, 0);
10772 return change;
10773}
10774
10775static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10776 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10777 {
10778 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10779 .name = "Master Playback Switch",
10780 .info = snd_hda_mixer_amp_switch_info,
10781 .get = snd_hda_mixer_amp_switch_get,
10782 .put = alc262_lenovo_3000_master_sw_put,
10783 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10784 },
10785 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10786 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10787 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10788 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10789 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10790 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10791 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10792 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10793 { } /* end */
10794};
10795
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010796static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10797 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010798 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10800 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10801 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10802 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10803 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10804 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10805 { } /* end */
10806};
10807
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010808/* additional init verbs for Benq laptops */
10809static struct hda_verb alc262_EAPD_verbs[] = {
10810 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10811 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10812 {}
10813};
10814
Kailang Yang83c34212007-07-05 11:43:05 +020010815static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10816 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10817 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10818
10819 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10820 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10821 {}
10822};
10823
Tobin Davisf651b502007-10-26 12:40:47 +020010824/* Samsung Q1 Ultra Vista model setup */
10825static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010826 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10827 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010828 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10829 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10830 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010831 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010832 { } /* end */
10833};
10834
10835static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010836 /* output mixer */
10837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10838 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10840 /* speaker */
10841 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10842 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10843 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10844 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10845 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010846 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010847 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10848 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10849 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10850 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10851 /* internal mic */
10852 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10854 /* ADC, choose mic */
10855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10856 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10857 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10858 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10864 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010865 {}
10866};
10867
Tobin Davisf651b502007-10-26 12:40:47 +020010868/* mute/unmute internal speaker according to the hp jack and mute state */
10869static void alc262_ultra_automute(struct hda_codec *codec)
10870{
10871 struct alc_spec *spec = codec->spec;
10872 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010873
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010874 mute = 0;
10875 /* auto-mute only when HP is used as HP */
10876 if (!spec->cur_mux[0]) {
10877 unsigned int present;
10878 /* need to execute and sync at first */
10879 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10880 present = snd_hda_codec_read(codec, 0x15, 0,
10881 AC_VERB_GET_PIN_SENSE, 0);
10882 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10883 if (spec->jack_present)
10884 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010885 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010886 /* mute/unmute internal speaker */
10887 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10888 HDA_AMP_MUTE, mute);
10889 /* mute/unmute HP */
10890 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10891 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010892}
10893
10894/* unsolicited event for HP jack sensing */
10895static void alc262_ultra_unsol_event(struct hda_codec *codec,
10896 unsigned int res)
10897{
10898 if ((res >> 26) != ALC880_HP_EVENT)
10899 return;
10900 alc262_ultra_automute(codec);
10901}
10902
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010903static struct hda_input_mux alc262_ultra_capture_source = {
10904 .num_items = 2,
10905 .items = {
10906 { "Mic", 0x1 },
10907 { "Headphone", 0x7 },
10908 },
10909};
10910
10911static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10912 struct snd_ctl_elem_value *ucontrol)
10913{
10914 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10915 struct alc_spec *spec = codec->spec;
10916 int ret;
10917
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010918 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010919 if (!ret)
10920 return 0;
10921 /* reprogram the HP pin as mic or HP according to the input source */
10922 snd_hda_codec_write_cache(codec, 0x15, 0,
10923 AC_VERB_SET_PIN_WIDGET_CONTROL,
10924 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10925 alc262_ultra_automute(codec); /* mute/unmute HP */
10926 return ret;
10927}
10928
10929static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10930 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10931 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10932 {
10933 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10934 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010935 .info = alc_mux_enum_info,
10936 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010937 .put = alc262_ultra_mux_enum_put,
10938 },
10939 { } /* end */
10940};
10941
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010942/* We use two mixers depending on the output pin; 0x16 is a mono output
10943 * and thus it's bound with a different mixer.
10944 * This function returns which mixer amp should be used.
10945 */
10946static int alc262_check_volbit(hda_nid_t nid)
10947{
10948 if (!nid)
10949 return 0;
10950 else if (nid == 0x16)
10951 return 2;
10952 else
10953 return 1;
10954}
10955
10956static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
10957 const char *pfx, int *vbits)
10958{
10959 char name[32];
10960 unsigned long val;
10961 int vbit;
10962
10963 vbit = alc262_check_volbit(nid);
10964 if (!vbit)
10965 return 0;
10966 if (*vbits & vbit) /* a volume control for this mixer already there */
10967 return 0;
10968 *vbits |= vbit;
10969 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
10970 if (vbit == 2)
10971 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
10972 else
10973 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
10974 return add_control(spec, ALC_CTL_WIDGET_VOL, name, val);
10975}
10976
10977static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
10978 const char *pfx)
10979{
10980 char name[32];
10981 unsigned long val;
10982
10983 if (!nid)
10984 return 0;
10985 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
10986 if (nid == 0x16)
10987 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
10988 else
10989 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
10990 return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val);
10991}
10992
Kailang Yangdf694da2005-12-05 19:42:22 +010010993/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010994static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10995 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010996{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010997 const char *pfx;
10998 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010010999 int err;
11000
11001 spec->multiout.num_dacs = 1; /* only use one dac */
11002 spec->multiout.dac_nids = spec->private_dac_nids;
11003 spec->multiout.dac_nids[0] = 2;
11004
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011005 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11006 pfx = "Master";
11007 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11008 pfx = "Speaker";
11009 else
11010 pfx = "Front";
11011 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11012 if (err < 0)
11013 return err;
11014 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11015 if (err < 0)
11016 return err;
11017 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11018 if (err < 0)
11019 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011020
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011021 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11022 alc262_check_volbit(cfg->speaker_pins[0]) |
11023 alc262_check_volbit(cfg->hp_pins[0]);
11024 if (vbits == 1 || vbits == 2)
11025 pfx = "Master"; /* only one mixer is used */
11026 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11027 pfx = "Speaker";
11028 else
11029 pfx = "Front";
11030 vbits = 0;
11031 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11032 if (err < 0)
11033 return err;
11034 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11035 &vbits);
11036 if (err < 0)
11037 return err;
11038 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11039 &vbits);
11040 if (err < 0)
11041 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011042 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011043}
11044
Takashi Iwai05f5f472009-08-25 13:10:18 +020011045#define alc262_auto_create_input_ctls \
11046 alc880_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011047
11048/*
11049 * generic initialization of ADC, input mixers and output mixers
11050 */
11051static struct hda_verb alc262_volume_init_verbs[] = {
11052 /*
11053 * Unmute ADC0-2 and set the default input to mic-in
11054 */
11055 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11057 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11058 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11059 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11060 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11061
Takashi Iwaicb53c622007-08-10 17:21:45 +020011062 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011063 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011064 * Note: PASD motherboards uses the Line In 2 as the input for
11065 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011066 */
11067 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011073
11074 /*
11075 * Set up output mixers (0x0c - 0x0f)
11076 */
11077 /* set vol=0 to output mixers */
11078 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11079 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11080 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011081
Kailang Yangdf694da2005-12-05 19:42:22 +010011082 /* set up input amps for analog loopback */
11083 /* Amp Indices: DAC = 0, mixer = 1 */
11084 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11085 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11086 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11087 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11088 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11089 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11090
11091 /* FIXME: use matrix-type input source selection */
11092 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11093 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11094 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11095 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11096 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11097 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11098 /* Input mixer2 */
11099 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11102 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11103 /* Input mixer3 */
11104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11108
11109 { }
11110};
11111
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011112static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11113 /*
11114 * Unmute ADC0-2 and set the default input to mic-in
11115 */
11116 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11118 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11119 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11120 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11121 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11122
Takashi Iwaicb53c622007-08-10 17:21:45 +020011123 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011124 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011125 * Note: PASD motherboards uses the Line In 2 as the input for
11126 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011127 */
11128 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011136
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011137 /*
11138 * Set up output mixers (0x0c - 0x0e)
11139 */
11140 /* set vol=0 to output mixers */
11141 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11142 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11143 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11144
11145 /* set up input amps for analog loopback */
11146 /* Amp Indices: DAC = 0, mixer = 1 */
11147 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11148 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11149 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11150 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11151 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11152 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11153
Takashi Iwaice875f02008-01-28 18:17:43 +010011154 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011155 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11156 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11157
11158 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11159 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11160
11161 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11162 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11163
11164 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11165 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11166 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11167 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11168 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11169
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011170 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011171 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11172 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011173 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011174 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11175 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11176
11177
11178 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011179 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11180 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011181 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011182 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11183 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11184 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11185 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11186 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11187 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11188 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11189 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011190 /* Input mixer2 */
11191 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011192 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11193 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11194 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11195 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11196 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11197 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11198 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11199 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011200 /* Input mixer3 */
11201 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011202 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11203 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11204 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11205 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11206 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11207 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11208 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11209 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011210
Takashi Iwaice875f02008-01-28 18:17:43 +010011211 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11212
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011213 { }
11214};
11215
Kailang Yangcd7509a2007-01-26 18:33:17 +010011216static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11217 /*
11218 * Unmute ADC0-2 and set the default input to mic-in
11219 */
11220 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11221 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11222 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11224 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11225 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11226
Takashi Iwaicb53c622007-08-10 17:21:45 +020011227 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011228 * mixer widget
11229 * Note: PASD motherboards uses the Line In 2 as the input for front
11230 * panel mic (mic 2)
11231 */
11232 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11238 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11239 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11240 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011241 /*
11242 * Set up output mixers (0x0c - 0x0e)
11243 */
11244 /* set vol=0 to output mixers */
11245 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11246 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11247 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11248
11249 /* set up input amps for analog loopback */
11250 /* Amp Indices: DAC = 0, mixer = 1 */
11251 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11252 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11253 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11254 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11255 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11256 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11257
11258
11259 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11260 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11261 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11262 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11263 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11264 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11265 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11266
11267 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11268 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11269
11270 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11271 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11272
11273 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11274 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11275 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11276 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11277 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11278 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11279
11280 /* FIXME: use matrix-type input source selection */
11281 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11282 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11283 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11284 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11285 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11287 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11288 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11289 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11290 /* Input mixer2 */
11291 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11292 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11293 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11294 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11295 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11296 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11297 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11298 /* Input mixer3 */
11299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11300 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11301 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11304 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11305 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11306
Takashi Iwaice875f02008-01-28 18:17:43 +010011307 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11308
Kailang Yangcd7509a2007-01-26 18:33:17 +010011309 { }
11310};
11311
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011312static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11313
11314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11315 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11316 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11317
11318 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11319 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11320 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11321 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11322
11323 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11324 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11325 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11326 {}
11327};
11328
11329
Takashi Iwaicb53c622007-08-10 17:21:45 +020011330#ifdef CONFIG_SND_HDA_POWER_SAVE
11331#define alc262_loopbacks alc880_loopbacks
11332#endif
11333
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011334/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011335#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11336#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11337#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11338#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11339
11340/*
11341 * BIOS auto configuration
11342 */
11343static int alc262_parse_auto_config(struct hda_codec *codec)
11344{
11345 struct alc_spec *spec = codec->spec;
11346 int err;
11347 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11348
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011349 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11350 alc262_ignore);
11351 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011352 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011353 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011354 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011355 spec->multiout.max_channels = 2;
11356 spec->no_analog = 1;
11357 goto dig_only;
11358 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011359 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011360 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011361 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11362 if (err < 0)
11363 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011364 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011365 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011366 return err;
11367
11368 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11369
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011370 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011371 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011372 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011373 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011374 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011375 if (spec->autocfg.dig_in_pin)
11376 spec->dig_in_nid = ALC262_DIGIN_NID;
11377
Takashi Iwai603c4012008-07-30 15:01:44 +020011378 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011379 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011380
Takashi Iwaid88897e2008-10-31 15:01:37 +010011381 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011382 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011383 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011384
Takashi Iwai776e1842007-08-29 15:07:11 +020011385 err = alc_auto_add_mic_boost(codec);
11386 if (err < 0)
11387 return err;
11388
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011389 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11390
Kailang Yangdf694da2005-12-05 19:42:22 +010011391 return 1;
11392}
11393
11394#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11395#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11396#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011397#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011398
11399
11400/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011401static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011402{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011403 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011404 alc262_auto_init_multi_out(codec);
11405 alc262_auto_init_hp_out(codec);
11406 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011407 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011408 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011409 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011410}
11411
11412/*
11413 * configuration and preset
11414 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011415static const char *alc262_models[ALC262_MODEL_LAST] = {
11416 [ALC262_BASIC] = "basic",
11417 [ALC262_HIPPO] = "hippo",
11418 [ALC262_HIPPO_1] = "hippo_1",
11419 [ALC262_FUJITSU] = "fujitsu",
11420 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011421 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011422 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011423 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011424 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011425 [ALC262_BENQ_T31] = "benq-t31",
11426 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011427 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011428 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011429 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011430 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011431 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011432 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011433 [ALC262_AUTO] = "auto",
11434};
11435
11436static struct snd_pci_quirk alc262_cfg_tbl[] = {
11437 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011438 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011439 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11440 ALC262_HP_BPC),
11441 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11442 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011443 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11444 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011445 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011446 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011447 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011448 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011449 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011450 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011451 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011452 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011453 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11454 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11455 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011456 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11457 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011458 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011459 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011460 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011461 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011462 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011463 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011464 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwaif872a912009-02-26 00:57:01 +010011465 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11466 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011467 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011468 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011469 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011470 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011471 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011472 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011473 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11474 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011475 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011476 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011477 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011478 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011479 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011480 {}
11481};
11482
11483static struct alc_config_preset alc262_presets[] = {
11484 [ALC262_BASIC] = {
11485 .mixers = { alc262_base_mixer },
11486 .init_verbs = { alc262_init_verbs },
11487 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11488 .dac_nids = alc262_dac_nids,
11489 .hp_nid = 0x03,
11490 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11491 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011492 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011493 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011494 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011495 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011496 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011497 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11498 .dac_nids = alc262_dac_nids,
11499 .hp_nid = 0x03,
11500 .dig_out_nid = ALC262_DIGOUT_NID,
11501 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11502 .channel_mode = alc262_modes,
11503 .input_mux = &alc262_capture_source,
11504 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011505 .setup = alc262_hippo_setup,
11506 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011507 },
11508 [ALC262_HIPPO_1] = {
11509 .mixers = { alc262_hippo1_mixer },
11510 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11511 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11512 .dac_nids = alc262_dac_nids,
11513 .hp_nid = 0x02,
11514 .dig_out_nid = ALC262_DIGOUT_NID,
11515 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11516 .channel_mode = alc262_modes,
11517 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011518 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011519 .setup = alc262_hippo1_setup,
11520 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011521 },
Takashi Iwai834be882006-03-01 14:16:17 +010011522 [ALC262_FUJITSU] = {
11523 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011524 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11525 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011526 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11527 .dac_nids = alc262_dac_nids,
11528 .hp_nid = 0x03,
11529 .dig_out_nid = ALC262_DIGOUT_NID,
11530 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11531 .channel_mode = alc262_modes,
11532 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011533 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011534 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011535 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011536 [ALC262_HP_BPC] = {
11537 .mixers = { alc262_HP_BPC_mixer },
11538 .init_verbs = { alc262_HP_BPC_init_verbs },
11539 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11540 .dac_nids = alc262_dac_nids,
11541 .hp_nid = 0x03,
11542 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11543 .channel_mode = alc262_modes,
11544 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011545 .unsol_event = alc262_hp_bpc_unsol_event,
11546 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011547 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011548 [ALC262_HP_BPC_D7000_WF] = {
11549 .mixers = { alc262_HP_BPC_WildWest_mixer },
11550 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11551 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11552 .dac_nids = alc262_dac_nids,
11553 .hp_nid = 0x03,
11554 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11555 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011556 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011557 .unsol_event = alc262_hp_wildwest_unsol_event,
11558 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011559 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011560 [ALC262_HP_BPC_D7000_WL] = {
11561 .mixers = { alc262_HP_BPC_WildWest_mixer,
11562 alc262_HP_BPC_WildWest_option_mixer },
11563 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11564 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11565 .dac_nids = alc262_dac_nids,
11566 .hp_nid = 0x03,
11567 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11568 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011569 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011570 .unsol_event = alc262_hp_wildwest_unsol_event,
11571 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011572 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011573 [ALC262_HP_TC_T5735] = {
11574 .mixers = { alc262_hp_t5735_mixer },
11575 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11576 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11577 .dac_nids = alc262_dac_nids,
11578 .hp_nid = 0x03,
11579 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11580 .channel_mode = alc262_modes,
11581 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011582 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011583 .setup = alc262_hp_t5735_setup,
11584 .init_hook = alc_automute_amp,
Kailang Yang8c427222008-01-10 13:03:59 +010011585 },
11586 [ALC262_HP_RP5700] = {
11587 .mixers = { alc262_hp_rp5700_mixer },
11588 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11589 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11590 .dac_nids = alc262_dac_nids,
11591 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11592 .channel_mode = alc262_modes,
11593 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011594 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011595 [ALC262_BENQ_ED8] = {
11596 .mixers = { alc262_base_mixer },
11597 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11598 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11599 .dac_nids = alc262_dac_nids,
11600 .hp_nid = 0x03,
11601 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11602 .channel_mode = alc262_modes,
11603 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011604 },
Kailang Yang272a5272007-05-14 11:00:38 +020011605 [ALC262_SONY_ASSAMD] = {
11606 .mixers = { alc262_sony_mixer },
11607 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11608 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11609 .dac_nids = alc262_dac_nids,
11610 .hp_nid = 0x02,
11611 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11612 .channel_mode = alc262_modes,
11613 .input_mux = &alc262_capture_source,
11614 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011615 .setup = alc262_hippo_setup,
11616 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011617 },
11618 [ALC262_BENQ_T31] = {
11619 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011620 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11621 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011622 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11623 .dac_nids = alc262_dac_nids,
11624 .hp_nid = 0x03,
11625 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11626 .channel_mode = alc262_modes,
11627 .input_mux = &alc262_capture_source,
11628 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011629 .setup = alc262_hippo_setup,
11630 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011631 },
Tobin Davisf651b502007-10-26 12:40:47 +020011632 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011633 .mixers = { alc262_ultra_mixer },
11634 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011635 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011636 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11637 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011638 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11639 .channel_mode = alc262_modes,
11640 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011641 .adc_nids = alc262_adc_nids, /* ADC0 */
11642 .capsrc_nids = alc262_capsrc_nids,
11643 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011644 .unsol_event = alc262_ultra_unsol_event,
11645 .init_hook = alc262_ultra_automute,
11646 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011647 [ALC262_LENOVO_3000] = {
11648 .mixers = { alc262_lenovo_3000_mixer },
11649 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11650 alc262_lenovo_3000_unsol_verbs },
11651 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11652 .dac_nids = alc262_dac_nids,
11653 .hp_nid = 0x03,
11654 .dig_out_nid = ALC262_DIGOUT_NID,
11655 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11656 .channel_mode = alc262_modes,
11657 .input_mux = &alc262_fujitsu_capture_source,
11658 .unsol_event = alc262_lenovo_3000_unsol_event,
11659 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011660 [ALC262_NEC] = {
11661 .mixers = { alc262_nec_mixer },
11662 .init_verbs = { alc262_nec_verbs },
11663 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11664 .dac_nids = alc262_dac_nids,
11665 .hp_nid = 0x03,
11666 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11667 .channel_mode = alc262_modes,
11668 .input_mux = &alc262_capture_source,
11669 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011670 [ALC262_TOSHIBA_S06] = {
11671 .mixers = { alc262_toshiba_s06_mixer },
11672 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11673 alc262_eapd_verbs },
11674 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11675 .capsrc_nids = alc262_dmic_capsrc_nids,
11676 .dac_nids = alc262_dac_nids,
11677 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011678 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011679 .dig_out_nid = ALC262_DIGOUT_NID,
11680 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11681 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011682 .unsol_event = alc_sku_unsol_event,
11683 .setup = alc262_toshiba_s06_setup,
11684 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011685 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011686 [ALC262_TOSHIBA_RX1] = {
11687 .mixers = { alc262_toshiba_rx1_mixer },
11688 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11689 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11690 .dac_nids = alc262_dac_nids,
11691 .hp_nid = 0x03,
11692 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11693 .channel_mode = alc262_modes,
11694 .input_mux = &alc262_capture_source,
11695 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011696 .setup = alc262_hippo_setup,
11697 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011698 },
Tony Vroonba340e82009-02-02 19:01:30 +000011699 [ALC262_TYAN] = {
11700 .mixers = { alc262_tyan_mixer },
11701 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11702 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11703 .dac_nids = alc262_dac_nids,
11704 .hp_nid = 0x02,
11705 .dig_out_nid = ALC262_DIGOUT_NID,
11706 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11707 .channel_mode = alc262_modes,
11708 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011709 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011710 .setup = alc262_tyan_setup,
11711 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011712 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011713};
11714
11715static int patch_alc262(struct hda_codec *codec)
11716{
11717 struct alc_spec *spec;
11718 int board_config;
11719 int err;
11720
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011721 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011722 if (spec == NULL)
11723 return -ENOMEM;
11724
11725 codec->spec = spec;
11726#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011727 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11728 * under-run
11729 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011730 {
11731 int tmp;
11732 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11733 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11734 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11735 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11736 }
11737#endif
11738
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011739 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11740
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011741 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11742 alc262_models,
11743 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011744
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011745 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011746 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11747 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011748 board_config = ALC262_AUTO;
11749 }
11750
11751 if (board_config == ALC262_AUTO) {
11752 /* automatic parse from the BIOS config */
11753 err = alc262_parse_auto_config(codec);
11754 if (err < 0) {
11755 alc_free(codec);
11756 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011757 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011758 printk(KERN_INFO
11759 "hda_codec: Cannot set up configuration "
11760 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011761 board_config = ALC262_BASIC;
11762 }
11763 }
11764
Takashi Iwai07eba612009-02-19 08:06:35 +010011765 if (!spec->no_analog) {
11766 err = snd_hda_attach_beep_device(codec, 0x1);
11767 if (err < 0) {
11768 alc_free(codec);
11769 return err;
11770 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011771 }
11772
Kailang Yangdf694da2005-12-05 19:42:22 +010011773 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011774 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011775
Kailang Yangdf694da2005-12-05 19:42:22 +010011776 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11777 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011778
Kailang Yangdf694da2005-12-05 19:42:22 +010011779 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11780 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11781
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011782 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011783 int i;
11784 /* check whether the digital-mic has to be supported */
11785 for (i = 0; i < spec->input_mux->num_items; i++) {
11786 if (spec->input_mux->items[i].index >= 9)
11787 break;
11788 }
11789 if (i < spec->input_mux->num_items) {
11790 /* use only ADC0 */
11791 spec->adc_nids = alc262_dmic_adc_nids;
11792 spec->num_adc_nids = 1;
11793 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011794 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011795 /* all analog inputs */
11796 /* check whether NID 0x07 is valid */
11797 unsigned int wcap = get_wcaps(codec, 0x07);
11798
11799 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011800 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011801 if (wcap != AC_WID_AUD_IN) {
11802 spec->adc_nids = alc262_adc_nids_alt;
11803 spec->num_adc_nids =
11804 ARRAY_SIZE(alc262_adc_nids_alt);
11805 spec->capsrc_nids = alc262_capsrc_nids_alt;
11806 } else {
11807 spec->adc_nids = alc262_adc_nids;
11808 spec->num_adc_nids =
11809 ARRAY_SIZE(alc262_adc_nids);
11810 spec->capsrc_nids = alc262_capsrc_nids;
11811 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011812 }
11813 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011814 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011815 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011816 if (!spec->no_analog)
11817 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011818
Takashi Iwai2134ea42008-01-10 16:53:55 +010011819 spec->vmaster_nid = 0x0c;
11820
Kailang Yangdf694da2005-12-05 19:42:22 +010011821 codec->patch_ops = alc_patch_ops;
11822 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011823 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011824#ifdef CONFIG_SND_HDA_POWER_SAVE
11825 if (!spec->loopback.amplist)
11826 spec->loopback.amplist = alc262_loopbacks;
11827#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011828 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011829
Kailang Yangdf694da2005-12-05 19:42:22 +010011830 return 0;
11831}
11832
Kailang Yangdf694da2005-12-05 19:42:22 +010011833/*
Kailang Yanga361d842007-06-05 12:30:55 +020011834 * ALC268 channel source setting (2 channel)
11835 */
11836#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11837#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011838
Kailang Yanga361d842007-06-05 12:30:55 +020011839static hda_nid_t alc268_dac_nids[2] = {
11840 /* front, hp */
11841 0x02, 0x03
11842};
11843
11844static hda_nid_t alc268_adc_nids[2] = {
11845 /* ADC0-1 */
11846 0x08, 0x07
11847};
11848
11849static hda_nid_t alc268_adc_nids_alt[1] = {
11850 /* ADC0 */
11851 0x08
11852};
11853
Takashi Iwaie1406342008-02-11 18:32:32 +010011854static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11855
Kailang Yanga361d842007-06-05 12:30:55 +020011856static struct snd_kcontrol_new alc268_base_mixer[] = {
11857 /* output mixer control */
11858 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11859 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11860 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11861 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011862 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11863 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11864 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011865 { }
11866};
11867
Takashi Iwai42171c12009-05-08 14:11:43 +020011868static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11869 /* output mixer control */
11870 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11871 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11872 ALC262_HIPPO_MASTER_SWITCH,
11873 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11874 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11875 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11876 { }
11877};
11878
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011879/* bind Beep switches of both NID 0x0f and 0x10 */
11880static struct hda_bind_ctls alc268_bind_beep_sw = {
11881 .ops = &snd_hda_bind_sw,
11882 .values = {
11883 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11884 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11885 0
11886 },
11887};
11888
11889static struct snd_kcontrol_new alc268_beep_mixer[] = {
11890 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11891 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11892 { }
11893};
11894
Kailang Yangd1a991a2007-08-15 16:21:59 +020011895static struct hda_verb alc268_eapd_verbs[] = {
11896 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11897 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11898 { }
11899};
11900
Takashi Iwaid2738092007-08-16 14:59:45 +020011901/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011902static struct hda_verb alc268_toshiba_verbs[] = {
11903 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11904 { } /* end */
11905};
11906
11907/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011908/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011909static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11910 .ops = &snd_hda_bind_vol,
11911 .values = {
11912 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11913 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11914 0
11915 },
11916};
11917
Takashi Iwai889c4392007-08-23 18:56:52 +020011918/* mute/unmute internal speaker according to the hp jack and mute state */
11919static void alc268_acer_automute(struct hda_codec *codec, int force)
11920{
11921 struct alc_spec *spec = codec->spec;
11922 unsigned int mute;
11923
11924 if (force || !spec->sense_updated) {
11925 unsigned int present;
11926 present = snd_hda_codec_read(codec, 0x14, 0,
11927 AC_VERB_GET_PIN_SENSE, 0);
11928 spec->jack_present = (present & 0x80000000) != 0;
11929 spec->sense_updated = 1;
11930 }
11931 if (spec->jack_present)
11932 mute = HDA_AMP_MUTE; /* mute internal speaker */
11933 else /* unmute internal speaker if necessary */
11934 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11935 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11936 HDA_AMP_MUTE, mute);
11937}
11938
11939
11940/* bind hp and internal speaker mute (with plug check) */
11941static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11942 struct snd_ctl_elem_value *ucontrol)
11943{
11944 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11945 long *valp = ucontrol->value.integer.value;
11946 int change;
11947
Takashi Iwai8de56b72009-07-24 16:51:47 +020011948 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020011949 if (change)
11950 alc268_acer_automute(codec, 0);
11951 return change;
11952}
Takashi Iwaid2738092007-08-16 14:59:45 +020011953
Kailang Yang8ef355d2008-08-26 13:10:22 +020011954static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11955 /* output mixer control */
11956 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11957 {
11958 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11959 .name = "Master Playback Switch",
11960 .info = snd_hda_mixer_amp_switch_info,
11961 .get = snd_hda_mixer_amp_switch_get,
11962 .put = alc268_acer_master_sw_put,
11963 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11964 },
11965 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11966 { }
11967};
11968
Takashi Iwaid2738092007-08-16 14:59:45 +020011969static struct snd_kcontrol_new alc268_acer_mixer[] = {
11970 /* output mixer control */
11971 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11972 {
11973 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11974 .name = "Master Playback Switch",
11975 .info = snd_hda_mixer_amp_switch_info,
11976 .get = snd_hda_mixer_amp_switch_get,
11977 .put = alc268_acer_master_sw_put,
11978 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11979 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011980 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11981 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11982 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011983 { }
11984};
11985
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011986static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11987 /* output mixer control */
11988 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11989 {
11990 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11991 .name = "Master Playback Switch",
11992 .info = snd_hda_mixer_amp_switch_info,
11993 .get = snd_hda_mixer_amp_switch_get,
11994 .put = alc268_acer_master_sw_put,
11995 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11996 },
11997 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11998 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11999 { }
12000};
12001
Kailang Yang8ef355d2008-08-26 13:10:22 +020012002static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12003 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12005 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12006 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12007 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12008 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12009 { }
12010};
12011
Takashi Iwaid2738092007-08-16 14:59:45 +020012012static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012013 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12014 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012015 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12016 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012017 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12018 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012019 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12020 { }
12021};
12022
12023/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012024#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012025#define alc268_toshiba_setup alc262_hippo_setup
12026#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012027
12028static void alc268_acer_unsol_event(struct hda_codec *codec,
12029 unsigned int res)
12030{
Takashi Iwai889c4392007-08-23 18:56:52 +020012031 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012032 return;
12033 alc268_acer_automute(codec, 1);
12034}
12035
Takashi Iwai889c4392007-08-23 18:56:52 +020012036static void alc268_acer_init_hook(struct hda_codec *codec)
12037{
12038 alc268_acer_automute(codec, 1);
12039}
12040
Kailang Yang8ef355d2008-08-26 13:10:22 +020012041/* toggle speaker-output according to the hp-jack state */
12042static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12043{
12044 unsigned int present;
12045 unsigned char bits;
12046
12047 present = snd_hda_codec_read(codec, 0x15, 0,
12048 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12049 bits = present ? AMP_IN_MUTE(0) : 0;
12050 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12051 AMP_IN_MUTE(0), bits);
12052 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12053 AMP_IN_MUTE(0), bits);
12054}
12055
Kailang Yang8ef355d2008-08-26 13:10:22 +020012056static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12057 unsigned int res)
12058{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012059 switch (res >> 26) {
12060 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012061 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012062 break;
12063 case ALC880_MIC_EVENT:
12064 alc_mic_automute(codec);
12065 break;
12066 }
12067}
12068
12069static void alc268_acer_lc_setup(struct hda_codec *codec)
12070{
12071 struct alc_spec *spec = codec->spec;
12072 spec->ext_mic.pin = 0x18;
12073 spec->ext_mic.mux_idx = 0;
12074 spec->int_mic.pin = 0x12;
12075 spec->int_mic.mux_idx = 6;
12076 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012077}
12078
12079static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12080{
12081 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012082 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012083}
12084
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012085static struct snd_kcontrol_new alc268_dell_mixer[] = {
12086 /* output mixer control */
12087 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12088 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12089 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12091 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12092 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12093 { }
12094};
12095
12096static struct hda_verb alc268_dell_verbs[] = {
12097 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12098 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12099 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012100 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012101 { }
12102};
12103
12104/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012105static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012106{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012107 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012108
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012109 spec->autocfg.hp_pins[0] = 0x15;
12110 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012111 spec->ext_mic.pin = 0x18;
12112 spec->ext_mic.mux_idx = 0;
12113 spec->int_mic.pin = 0x19;
12114 spec->int_mic.mux_idx = 1;
12115 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012116}
12117
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012118static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12119 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12120 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12121 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12122 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12123 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12124 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12125 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12126 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12127 { }
12128};
12129
12130static struct hda_verb alc267_quanta_il1_verbs[] = {
12131 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12132 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12133 { }
12134};
12135
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012136static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012137{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012138 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012139 spec->autocfg.hp_pins[0] = 0x15;
12140 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012141 spec->ext_mic.pin = 0x18;
12142 spec->ext_mic.mux_idx = 0;
12143 spec->int_mic.pin = 0x19;
12144 spec->int_mic.mux_idx = 1;
12145 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012146}
12147
Kailang Yanga361d842007-06-05 12:30:55 +020012148/*
12149 * generic initialization of ADC, input mixers and output mixers
12150 */
12151static struct hda_verb alc268_base_init_verbs[] = {
12152 /* Unmute DAC0-1 and set vol = 0 */
12153 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012154 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012155
12156 /*
12157 * Set up output mixers (0x0c - 0x0e)
12158 */
12159 /* set vol=0 to output mixers */
12160 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012161 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12162
12163 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12164 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12165
12166 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12167 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12168 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12169 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12170 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12171 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12172 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12173 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12174
12175 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12176 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12177 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12178 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012179 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012180
12181 /* set PCBEEP vol = 0, mute connections */
12182 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12183 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12184 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012185
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012186 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012187
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012188 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12189 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12190 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12191 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012192
Kailang Yanga361d842007-06-05 12:30:55 +020012193 { }
12194};
12195
12196/*
12197 * generic initialization of ADC, input mixers and output mixers
12198 */
12199static struct hda_verb alc268_volume_init_verbs[] = {
12200 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012201 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12202 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012203
12204 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12205 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12206 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12207 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12208 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12209
Kailang Yanga361d842007-06-05 12:30:55 +020012210 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012211 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12212 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12213
12214 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012215 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012216
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012217 /* set PCBEEP vol = 0, mute connections */
12218 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12219 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12220 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012221
12222 { }
12223};
12224
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012225static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12226 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12227 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12228 { } /* end */
12229};
12230
Kailang Yanga361d842007-06-05 12:30:55 +020012231static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12232 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12233 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012234 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012235 { } /* end */
12236};
12237
12238static struct snd_kcontrol_new alc268_capture_mixer[] = {
12239 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12240 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12241 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12242 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012243 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012244 { } /* end */
12245};
12246
12247static struct hda_input_mux alc268_capture_source = {
12248 .num_items = 4,
12249 .items = {
12250 { "Mic", 0x0 },
12251 { "Front Mic", 0x1 },
12252 { "Line", 0x2 },
12253 { "CD", 0x3 },
12254 },
12255};
12256
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012257static struct hda_input_mux alc268_acer_capture_source = {
12258 .num_items = 3,
12259 .items = {
12260 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012261 { "Internal Mic", 0x1 },
12262 { "Line", 0x2 },
12263 },
12264};
12265
12266static struct hda_input_mux alc268_acer_dmic_capture_source = {
12267 .num_items = 3,
12268 .items = {
12269 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012270 { "Internal Mic", 0x6 },
12271 { "Line", 0x2 },
12272 },
12273};
12274
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012275#ifdef CONFIG_SND_DEBUG
12276static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012277 /* Volume widgets */
12278 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12279 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12280 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12281 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12282 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12283 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12284 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12285 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12286 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12287 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12288 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12289 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12290 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012291 /* The below appears problematic on some hardwares */
12292 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012293 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12294 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12295 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12296 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12297
12298 /* Modes for retasking pin widgets */
12299 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12300 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12301 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12302 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12303
12304 /* Controls for GPIO pins, assuming they are configured as outputs */
12305 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12306 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12307 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12308 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12309
12310 /* Switches to allow the digital SPDIF output pin to be enabled.
12311 * The ALC268 does not have an SPDIF input.
12312 */
12313 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12314
12315 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12316 * this output to turn on an external amplifier.
12317 */
12318 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12319 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12320
12321 { } /* end */
12322};
12323#endif
12324
Kailang Yanga361d842007-06-05 12:30:55 +020012325/* create input playback/capture controls for the given pin */
12326static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12327 const char *ctlname, int idx)
12328{
12329 char name[32];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012330 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012331 int err;
12332
12333 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012334 switch (nid) {
12335 case 0x14:
12336 case 0x16:
12337 dac = 0x02;
12338 break;
12339 case 0x15:
12340 dac = 0x03;
12341 break;
12342 default:
12343 return 0;
12344 }
12345 if (spec->multiout.dac_nids[0] != dac &&
12346 spec->multiout.dac_nids[1] != dac) {
Kailang Yanga361d842007-06-05 12:30:55 +020012347 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012348 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012349 HDA_OUTPUT));
12350 if (err < 0)
12351 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012352 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12353 }
12354
Kailang Yanga361d842007-06-05 12:30:55 +020012355 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012356 if (nid != 0x16)
12357 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yanga361d842007-06-05 12:30:55 +020012358 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012359 else /* mono */
12360 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12361 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012362 if (err < 0)
12363 return err;
12364 return 0;
12365}
12366
12367/* add playback controls from the parsed DAC table */
12368static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12369 const struct auto_pin_cfg *cfg)
12370{
12371 hda_nid_t nid;
12372 int err;
12373
Kailang Yanga361d842007-06-05 12:30:55 +020012374 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012375
12376 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012377 if (nid) {
12378 const char *name;
12379 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12380 name = "Speaker";
12381 else
12382 name = "Front";
12383 err = alc268_new_analog_output(spec, nid, name, 0);
12384 if (err < 0)
12385 return err;
12386 }
Kailang Yanga361d842007-06-05 12:30:55 +020012387
12388 nid = cfg->speaker_pins[0];
12389 if (nid == 0x1d) {
12390 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12391 "Speaker Playback Volume",
12392 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12393 if (err < 0)
12394 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012395 } else {
12396 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12397 if (err < 0)
12398 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012399 }
12400 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012401 if (nid) {
12402 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12403 if (err < 0)
12404 return err;
12405 }
Kailang Yanga361d842007-06-05 12:30:55 +020012406
12407 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12408 if (nid == 0x16) {
12409 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12410 "Mono Playback Switch",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012411 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012412 if (err < 0)
12413 return err;
12414 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012415 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012416}
12417
12418/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012419static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012420 const struct auto_pin_cfg *cfg)
12421{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012422 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012423}
12424
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012425static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12426 hda_nid_t nid, int pin_type)
12427{
12428 int idx;
12429
12430 alc_set_pin_output(codec, nid, pin_type);
12431 if (nid == 0x14 || nid == 0x16)
12432 idx = 0;
12433 else
12434 idx = 1;
12435 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12436}
12437
12438static void alc268_auto_init_multi_out(struct hda_codec *codec)
12439{
12440 struct alc_spec *spec = codec->spec;
12441 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12442 if (nid) {
12443 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12444 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12445 }
12446}
12447
12448static void alc268_auto_init_hp_out(struct hda_codec *codec)
12449{
12450 struct alc_spec *spec = codec->spec;
12451 hda_nid_t pin;
12452
12453 pin = spec->autocfg.hp_pins[0];
12454 if (pin)
12455 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12456 pin = spec->autocfg.speaker_pins[0];
12457 if (pin)
12458 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12459}
12460
Kailang Yanga361d842007-06-05 12:30:55 +020012461static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12462{
12463 struct alc_spec *spec = codec->spec;
12464 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12465 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12466 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12467 unsigned int dac_vol1, dac_vol2;
12468
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012469 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012470 snd_hda_codec_write(codec, speaker_nid, 0,
12471 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012472 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012473 snd_hda_codec_write(codec, 0x0f, 0,
12474 AC_VERB_SET_AMP_GAIN_MUTE,
12475 AMP_IN_UNMUTE(1));
12476 snd_hda_codec_write(codec, 0x10, 0,
12477 AC_VERB_SET_AMP_GAIN_MUTE,
12478 AMP_IN_UNMUTE(1));
12479 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012480 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012481 snd_hda_codec_write(codec, 0x0f, 0,
12482 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12483 snd_hda_codec_write(codec, 0x10, 0,
12484 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12485 }
12486
12487 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012488 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012489 dac_vol2 = AMP_OUT_ZERO;
12490 else if (line_nid == 0x15)
12491 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012492 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012493 dac_vol2 = AMP_OUT_ZERO;
12494 else if (hp_nid == 0x15)
12495 dac_vol1 = AMP_OUT_ZERO;
12496 if (line_nid != 0x16 || hp_nid != 0x16 ||
12497 spec->autocfg.line_out_pins[1] != 0x16 ||
12498 spec->autocfg.line_out_pins[2] != 0x16)
12499 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12500
12501 snd_hda_codec_write(codec, 0x02, 0,
12502 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12503 snd_hda_codec_write(codec, 0x03, 0,
12504 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12505}
12506
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012507/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012508#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12509#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012510#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012511#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12512
12513/*
12514 * BIOS auto configuration
12515 */
12516static int alc268_parse_auto_config(struct hda_codec *codec)
12517{
12518 struct alc_spec *spec = codec->spec;
12519 int err;
12520 static hda_nid_t alc268_ignore[] = { 0 };
12521
12522 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12523 alc268_ignore);
12524 if (err < 0)
12525 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012526 if (!spec->autocfg.line_outs) {
12527 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12528 spec->multiout.max_channels = 2;
12529 spec->no_analog = 1;
12530 goto dig_only;
12531 }
Kailang Yanga361d842007-06-05 12:30:55 +020012532 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012533 }
Kailang Yanga361d842007-06-05 12:30:55 +020012534 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12535 if (err < 0)
12536 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012537 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012538 if (err < 0)
12539 return err;
12540
12541 spec->multiout.max_channels = 2;
12542
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012543 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012544 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012545 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012546 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012547 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12548 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012549 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012550 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012551
Takashi Iwai892981f2009-03-02 08:04:35 +010012552 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012553 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012554
Takashi Iwaid88897e2008-10-31 15:01:37 +010012555 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012556 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012557 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012558
Takashi Iwai776e1842007-08-29 15:07:11 +020012559 err = alc_auto_add_mic_boost(codec);
12560 if (err < 0)
12561 return err;
12562
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012563 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12564
Kailang Yanga361d842007-06-05 12:30:55 +020012565 return 1;
12566}
12567
Kailang Yanga361d842007-06-05 12:30:55 +020012568#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12569
12570/* init callback for auto-configuration model -- overriding the default init */
12571static void alc268_auto_init(struct hda_codec *codec)
12572{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012573 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012574 alc268_auto_init_multi_out(codec);
12575 alc268_auto_init_hp_out(codec);
12576 alc268_auto_init_mono_speaker_out(codec);
12577 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012578 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012579 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012580}
12581
12582/*
12583 * configuration and preset
12584 */
12585static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012586 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012587 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012588 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012589 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012590 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012591 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012592 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012593 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012594#ifdef CONFIG_SND_DEBUG
12595 [ALC268_TEST] = "test",
12596#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012597 [ALC268_AUTO] = "auto",
12598};
12599
12600static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012601 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012602 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012603 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012604 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012605 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012606 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12607 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012608 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050012609 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
12610 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020012611 /* almost compatible with toshiba but with optional digital outs;
12612 * auto-probing seems working fine
12613 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012614 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020012615 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012616 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012617 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012618 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012619 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012620 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012621 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012622 {}
12623};
12624
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012625/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12626static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12627 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12628 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12629 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12630 ALC268_TOSHIBA),
12631 {}
12632};
12633
Kailang Yanga361d842007-06-05 12:30:55 +020012634static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012635 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012636 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12637 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012638 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12639 alc267_quanta_il1_verbs },
12640 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12641 .dac_nids = alc268_dac_nids,
12642 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12643 .adc_nids = alc268_adc_nids_alt,
12644 .hp_nid = 0x03,
12645 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12646 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012647 .unsol_event = alc_sku_unsol_event,
12648 .setup = alc267_quanta_il1_setup,
12649 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012650 },
Kailang Yanga361d842007-06-05 12:30:55 +020012651 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012652 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12653 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012654 .init_verbs = { alc268_base_init_verbs },
12655 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12656 .dac_nids = alc268_dac_nids,
12657 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12658 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012659 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012660 .hp_nid = 0x03,
12661 .dig_out_nid = ALC268_DIGOUT_NID,
12662 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12663 .channel_mode = alc268_modes,
12664 .input_mux = &alc268_capture_source,
12665 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012666 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012667 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012668 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012669 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12670 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012671 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12672 .dac_nids = alc268_dac_nids,
12673 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12674 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012675 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012676 .hp_nid = 0x03,
12677 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12678 .channel_mode = alc268_modes,
12679 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012680 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012681 .setup = alc268_toshiba_setup,
12682 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012683 },
12684 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020012685 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012686 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012687 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12688 alc268_acer_verbs },
12689 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12690 .dac_nids = alc268_dac_nids,
12691 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12692 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012693 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012694 .hp_nid = 0x02,
12695 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12696 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012697 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012698 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012699 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012700 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012701 [ALC268_ACER_DMIC] = {
12702 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12703 alc268_beep_mixer },
12704 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12705 alc268_acer_verbs },
12706 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12707 .dac_nids = alc268_dac_nids,
12708 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12709 .adc_nids = alc268_adc_nids_alt,
12710 .capsrc_nids = alc268_capsrc_nids,
12711 .hp_nid = 0x02,
12712 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12713 .channel_mode = alc268_modes,
12714 .input_mux = &alc268_acer_dmic_capture_source,
12715 .unsol_event = alc268_acer_unsol_event,
12716 .init_hook = alc268_acer_init_hook,
12717 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012718 [ALC268_ACER_ASPIRE_ONE] = {
12719 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012720 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012721 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012722 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12723 alc268_acer_aspire_one_verbs },
12724 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12725 .dac_nids = alc268_dac_nids,
12726 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12727 .adc_nids = alc268_adc_nids_alt,
12728 .capsrc_nids = alc268_capsrc_nids,
12729 .hp_nid = 0x03,
12730 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12731 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012732 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012733 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012734 .init_hook = alc268_acer_lc_init_hook,
12735 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012736 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012737 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12738 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012739 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12740 alc268_dell_verbs },
12741 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12742 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012743 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12744 .adc_nids = alc268_adc_nids_alt,
12745 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012746 .hp_nid = 0x02,
12747 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12748 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012749 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012750 .setup = alc268_dell_setup,
12751 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012752 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012753 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012754 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12755 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012756 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12757 alc268_toshiba_verbs },
12758 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12759 .dac_nids = alc268_dac_nids,
12760 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12761 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012762 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012763 .hp_nid = 0x03,
12764 .dig_out_nid = ALC268_DIGOUT_NID,
12765 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12766 .channel_mode = alc268_modes,
12767 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012768 .setup = alc268_toshiba_setup,
12769 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012770 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012771#ifdef CONFIG_SND_DEBUG
12772 [ALC268_TEST] = {
12773 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12774 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12775 alc268_volume_init_verbs },
12776 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12777 .dac_nids = alc268_dac_nids,
12778 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12779 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012780 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012781 .hp_nid = 0x03,
12782 .dig_out_nid = ALC268_DIGOUT_NID,
12783 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12784 .channel_mode = alc268_modes,
12785 .input_mux = &alc268_capture_source,
12786 },
12787#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012788};
12789
12790static int patch_alc268(struct hda_codec *codec)
12791{
12792 struct alc_spec *spec;
12793 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012794 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012795
12796 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12797 if (spec == NULL)
12798 return -ENOMEM;
12799
12800 codec->spec = spec;
12801
12802 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12803 alc268_models,
12804 alc268_cfg_tbl);
12805
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012806 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12807 board_config = snd_hda_check_board_codec_sid_config(codec,
12808 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12809
Kailang Yanga361d842007-06-05 12:30:55 +020012810 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012811 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12812 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012813 board_config = ALC268_AUTO;
12814 }
12815
12816 if (board_config == ALC268_AUTO) {
12817 /* automatic parse from the BIOS config */
12818 err = alc268_parse_auto_config(codec);
12819 if (err < 0) {
12820 alc_free(codec);
12821 return err;
12822 } else if (!err) {
12823 printk(KERN_INFO
12824 "hda_codec: Cannot set up configuration "
12825 "from BIOS. Using base mode...\n");
12826 board_config = ALC268_3ST;
12827 }
12828 }
12829
12830 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012831 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020012832
Kailang Yanga361d842007-06-05 12:30:55 +020012833 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12834 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012835 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012836
Kailang Yanga361d842007-06-05 12:30:55 +020012837 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12838
Takashi Iwai22971e32009-02-10 11:56:44 +010012839 has_beep = 0;
12840 for (i = 0; i < spec->num_mixers; i++) {
12841 if (spec->mixers[i] == alc268_beep_mixer) {
12842 has_beep = 1;
12843 break;
12844 }
12845 }
12846
12847 if (has_beep) {
12848 err = snd_hda_attach_beep_device(codec, 0x1);
12849 if (err < 0) {
12850 alc_free(codec);
12851 return err;
12852 }
12853 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12854 /* override the amp caps for beep generator */
12855 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012856 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12857 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12858 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12859 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012860 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012861
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012862 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012863 /* check whether NID 0x07 is valid */
12864 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012865 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012866
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020012867 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012868 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012869 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012870 if (spec->auto_mic ||
12871 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012872 spec->adc_nids = alc268_adc_nids_alt;
12873 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020012874 if (spec->auto_mic)
12875 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012876 if (spec->auto_mic || spec->input_mux->num_items == 1)
12877 add_mixer(spec, alc268_capture_nosrc_mixer);
12878 else
12879 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012880 } else {
12881 spec->adc_nids = alc268_adc_nids;
12882 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012883 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012884 }
Takashi Iwai85860c02008-02-19 15:00:15 +010012885 /* set default input source */
12886 for (i = 0; i < spec->num_adc_nids; i++)
12887 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12888 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012889 i < spec->num_mux_defs ?
12890 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010012891 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012892 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012893
12894 spec->vmaster_nid = 0x02;
12895
Kailang Yanga361d842007-06-05 12:30:55 +020012896 codec->patch_ops = alc_patch_ops;
12897 if (board_config == ALC268_AUTO)
12898 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012899
Takashi Iwaidaead532008-11-28 12:55:36 +010012900 codec->proc_widget_hook = print_realtek_coef;
12901
Kailang Yanga361d842007-06-05 12:30:55 +020012902 return 0;
12903}
12904
12905/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012906 * ALC269 channel source setting (2 channel)
12907 */
12908#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12909
12910#define alc269_dac_nids alc260_dac_nids
12911
12912static hda_nid_t alc269_adc_nids[1] = {
12913 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012914 0x08,
12915};
12916
Takashi Iwaie01bf502008-08-21 16:25:07 +020012917static hda_nid_t alc269_capsrc_nids[1] = {
12918 0x23,
12919};
12920
12921/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12922 * not a mux!
12923 */
12924
Kailang Yangf6a92242007-12-13 16:52:54 +010012925#define alc269_modes alc260_modes
12926#define alc269_capture_source alc880_lg_lw_capture_source
12927
12928static struct snd_kcontrol_new alc269_base_mixer[] = {
12929 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12930 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12931 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12932 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12934 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12935 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12936 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12937 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12938 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12939 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12940 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12941 { } /* end */
12942};
12943
Kailang Yang60db6b52008-08-26 13:13:00 +020012944static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12945 /* output mixer control */
12946 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12947 {
12948 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12949 .name = "Master Playback Switch",
12950 .info = snd_hda_mixer_amp_switch_info,
12951 .get = snd_hda_mixer_amp_switch_get,
12952 .put = alc268_acer_master_sw_put,
12953 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12954 },
12955 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12956 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12957 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12958 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12959 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12960 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012961 { }
12962};
12963
Tony Vroon64154832008-11-06 15:08:49 +000012964static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12965 /* output mixer control */
12966 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12967 {
12968 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12969 .name = "Master Playback Switch",
12970 .info = snd_hda_mixer_amp_switch_info,
12971 .get = snd_hda_mixer_amp_switch_get,
12972 .put = alc268_acer_master_sw_put,
12973 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12974 },
12975 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12976 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12977 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12978 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12979 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12980 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12981 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12982 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12983 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012984 { }
12985};
12986
Kailang Yangf53281e2008-07-18 12:36:43 +020012987static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012988 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012989 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012990 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012991 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012992 { } /* end */
12993};
12994
Kailang Yangf6a92242007-12-13 16:52:54 +010012995/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012996static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12997 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12998 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012999 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13000 { } /* end */
13001};
13002
13003/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020013004#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013005
Kailang Yang60db6b52008-08-26 13:13:00 +020013006static struct hda_verb alc269_quanta_fl1_verbs[] = {
13007 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13008 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13009 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13010 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13011 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13012 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13013 { }
13014};
13015
Tony Vroon64154832008-11-06 15:08:49 +000013016static struct hda_verb alc269_lifebook_verbs[] = {
13017 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13018 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13019 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13020 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13021 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13022 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13023 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13024 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13025 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13026 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13027 { }
13028};
13029
Kailang Yang60db6b52008-08-26 13:13:00 +020013030/* toggle speaker-output according to the hp-jack state */
13031static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13032{
13033 unsigned int present;
13034 unsigned char bits;
13035
13036 present = snd_hda_codec_read(codec, 0x15, 0,
13037 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13038 bits = present ? AMP_IN_MUTE(0) : 0;
13039 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13040 AMP_IN_MUTE(0), bits);
13041 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13042 AMP_IN_MUTE(0), bits);
13043
13044 snd_hda_codec_write(codec, 0x20, 0,
13045 AC_VERB_SET_COEF_INDEX, 0x0c);
13046 snd_hda_codec_write(codec, 0x20, 0,
13047 AC_VERB_SET_PROC_COEF, 0x680);
13048
13049 snd_hda_codec_write(codec, 0x20, 0,
13050 AC_VERB_SET_COEF_INDEX, 0x0c);
13051 snd_hda_codec_write(codec, 0x20, 0,
13052 AC_VERB_SET_PROC_COEF, 0x480);
13053}
13054
Tony Vroon64154832008-11-06 15:08:49 +000013055/* toggle speaker-output according to the hp-jacks state */
13056static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13057{
13058 unsigned int present;
13059 unsigned char bits;
13060
13061 /* Check laptop headphone socket */
13062 present = snd_hda_codec_read(codec, 0x15, 0,
13063 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13064
13065 /* Check port replicator headphone socket */
13066 present |= snd_hda_codec_read(codec, 0x1a, 0,
13067 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13068
13069 bits = present ? AMP_IN_MUTE(0) : 0;
13070 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13071 AMP_IN_MUTE(0), bits);
13072 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13073 AMP_IN_MUTE(0), bits);
13074
13075 snd_hda_codec_write(codec, 0x20, 0,
13076 AC_VERB_SET_COEF_INDEX, 0x0c);
13077 snd_hda_codec_write(codec, 0x20, 0,
13078 AC_VERB_SET_PROC_COEF, 0x680);
13079
13080 snd_hda_codec_write(codec, 0x20, 0,
13081 AC_VERB_SET_COEF_INDEX, 0x0c);
13082 snd_hda_codec_write(codec, 0x20, 0,
13083 AC_VERB_SET_PROC_COEF, 0x480);
13084}
13085
Tony Vroon64154832008-11-06 15:08:49 +000013086static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13087{
13088 unsigned int present_laptop;
13089 unsigned int present_dock;
13090
13091 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
13092 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13093
13094 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
13095 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13096
13097 /* Laptop mic port overrides dock mic port, design decision */
13098 if (present_dock)
13099 snd_hda_codec_write(codec, 0x23, 0,
13100 AC_VERB_SET_CONNECT_SEL, 0x3);
13101 if (present_laptop)
13102 snd_hda_codec_write(codec, 0x23, 0,
13103 AC_VERB_SET_CONNECT_SEL, 0x0);
13104 if (!present_dock && !present_laptop)
13105 snd_hda_codec_write(codec, 0x23, 0,
13106 AC_VERB_SET_CONNECT_SEL, 0x1);
13107}
13108
Kailang Yang60db6b52008-08-26 13:13:00 +020013109static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13110 unsigned int res)
13111{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013112 switch (res >> 26) {
13113 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013114 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013115 break;
13116 case ALC880_MIC_EVENT:
13117 alc_mic_automute(codec);
13118 break;
13119 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013120}
13121
Tony Vroon64154832008-11-06 15:08:49 +000013122static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13123 unsigned int res)
13124{
13125 if ((res >> 26) == ALC880_HP_EVENT)
13126 alc269_lifebook_speaker_automute(codec);
13127 if ((res >> 26) == ALC880_MIC_EVENT)
13128 alc269_lifebook_mic_autoswitch(codec);
13129}
13130
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013131static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13132{
13133 struct alc_spec *spec = codec->spec;
13134 spec->ext_mic.pin = 0x18;
13135 spec->ext_mic.mux_idx = 0;
13136 spec->int_mic.pin = 0x19;
13137 spec->int_mic.mux_idx = 1;
13138 spec->auto_mic = 1;
13139}
13140
Kailang Yang60db6b52008-08-26 13:13:00 +020013141static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13142{
13143 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013144 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013145}
13146
Tony Vroon64154832008-11-06 15:08:49 +000013147static void alc269_lifebook_init_hook(struct hda_codec *codec)
13148{
13149 alc269_lifebook_speaker_automute(codec);
13150 alc269_lifebook_mic_autoswitch(codec);
13151}
13152
Kailang Yang60db6b52008-08-26 13:13:00 +020013153static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13154 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13155 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13156 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13157 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13158 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13159 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13160 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13161 {}
13162};
13163
13164static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13165 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13166 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13167 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13168 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13169 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13170 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13171 {}
13172};
13173
13174/* toggle speaker-output according to the hp-jack state */
13175static void alc269_speaker_automute(struct hda_codec *codec)
13176{
13177 unsigned int present;
13178 unsigned char bits;
13179
13180 present = snd_hda_codec_read(codec, 0x15, 0,
13181 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13182 bits = present ? AMP_IN_MUTE(0) : 0;
13183 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13184 AMP_IN_MUTE(0), bits);
13185 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13186 AMP_IN_MUTE(0), bits);
13187}
13188
Kailang Yang60db6b52008-08-26 13:13:00 +020013189/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013190static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013191 unsigned int res)
13192{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013193 switch (res >> 26) {
13194 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013195 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013196 break;
13197 case ALC880_MIC_EVENT:
13198 alc_mic_automute(codec);
13199 break;
13200 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013201}
13202
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013203static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13204{
13205 struct alc_spec *spec = codec->spec;
13206 spec->ext_mic.pin = 0x18;
13207 spec->ext_mic.mux_idx = 0;
13208 spec->int_mic.pin = 0x12;
13209 spec->int_mic.mux_idx = 5;
13210 spec->auto_mic = 1;
13211}
13212
13213static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13214{
13215 struct alc_spec *spec = codec->spec;
13216 spec->ext_mic.pin = 0x18;
13217 spec->ext_mic.mux_idx = 0;
13218 spec->int_mic.pin = 0x19;
13219 spec->int_mic.mux_idx = 1;
13220 spec->auto_mic = 1;
13221}
13222
13223static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013224{
13225 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013226 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013227}
13228
Kailang Yangf6a92242007-12-13 16:52:54 +010013229/*
13230 * generic initialization of ADC, input mixers and output mixers
13231 */
13232static struct hda_verb alc269_init_verbs[] = {
13233 /*
13234 * Unmute ADC0 and set the default input to mic-in
13235 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013236 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013237
13238 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13239 * analog-loopback mixer widget
13240 * Note: PASD motherboards uses the Line In 2 as the input for
13241 * front panel mic (mic 2)
13242 */
13243 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13244 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13247 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13248 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13249
13250 /*
13251 * Set up output mixers (0x0c - 0x0e)
13252 */
13253 /* set vol=0 to output mixers */
13254 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13255 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13256
13257 /* set up input amps for analog loopback */
13258 /* Amp Indices: DAC = 0, mixer = 1 */
13259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13260 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13261 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13262 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13263 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13264 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13265
13266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13267 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13268 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13269 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13270 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13271 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13273
13274 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13275 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13276 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13277 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13278 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13279 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13280 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13281
13282 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13283 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13284
13285 /* FIXME: use matrix-type input source selection */
13286 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13287 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013288 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13289 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013290 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13291 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13292
13293 /* set EAPD */
13294 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13295 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13296 { }
13297};
13298
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013299#define alc269_auto_create_multi_out_ctls \
13300 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013301#define alc269_auto_create_input_ctls \
13302 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013303
13304#ifdef CONFIG_SND_HDA_POWER_SAVE
13305#define alc269_loopbacks alc880_loopbacks
13306#endif
13307
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013308/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013309#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13310#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13311#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13312#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13313
Takashi Iwaif03d3112009-03-05 14:18:16 +010013314static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13315 .substreams = 1,
13316 .channels_min = 2,
13317 .channels_max = 8,
13318 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13319 /* NID is set in alc_build_pcms */
13320 .ops = {
13321 .open = alc880_playback_pcm_open,
13322 .prepare = alc880_playback_pcm_prepare,
13323 .cleanup = alc880_playback_pcm_cleanup
13324 },
13325};
13326
13327static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13328 .substreams = 1,
13329 .channels_min = 2,
13330 .channels_max = 2,
13331 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13332 /* NID is set in alc_build_pcms */
13333};
13334
Kailang Yangf6a92242007-12-13 16:52:54 +010013335/*
13336 * BIOS auto configuration
13337 */
13338static int alc269_parse_auto_config(struct hda_codec *codec)
13339{
13340 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013341 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013342 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13343
13344 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13345 alc269_ignore);
13346 if (err < 0)
13347 return err;
13348
13349 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13350 if (err < 0)
13351 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013352 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013353 if (err < 0)
13354 return err;
13355
13356 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13357
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013358 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013359 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13360
Takashi Iwai603c4012008-07-30 15:01:44 +020013361 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013362 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013363
Takashi Iwaid88897e2008-10-31 15:01:37 +010013364 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013365 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013366 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013367 /* set default input source */
13368 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13369 0, AC_VERB_SET_CONNECT_SEL,
13370 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013371
13372 err = alc_auto_add_mic_boost(codec);
13373 if (err < 0)
13374 return err;
13375
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013376 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013377 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013378
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013379 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13380
Kailang Yangf6a92242007-12-13 16:52:54 +010013381 return 1;
13382}
13383
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013384#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13385#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013386#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13387
13388
13389/* init callback for auto-configuration model -- overriding the default init */
13390static void alc269_auto_init(struct hda_codec *codec)
13391{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013392 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013393 alc269_auto_init_multi_out(codec);
13394 alc269_auto_init_hp_out(codec);
13395 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013396 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013397 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013398}
13399
13400/*
13401 * configuration and preset
13402 */
13403static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013404 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013405 [ALC269_QUANTA_FL1] = "quanta",
13406 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013407 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013408 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013409 [ALC269_LIFEBOOK] = "lifebook",
13410 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013411};
13412
13413static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013414 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013415 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13416 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013417 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13418 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13419 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13420 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13421 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13422 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013423 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13424 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013425 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13426 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013427 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013428 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013429 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013430 {}
13431};
13432
13433static struct alc_config_preset alc269_presets[] = {
13434 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013435 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013436 .init_verbs = { alc269_init_verbs },
13437 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13438 .dac_nids = alc269_dac_nids,
13439 .hp_nid = 0x03,
13440 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13441 .channel_mode = alc269_modes,
13442 .input_mux = &alc269_capture_source,
13443 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013444 [ALC269_QUANTA_FL1] = {
13445 .mixers = { alc269_quanta_fl1_mixer },
13446 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13447 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13448 .dac_nids = alc269_dac_nids,
13449 .hp_nid = 0x03,
13450 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13451 .channel_mode = alc269_modes,
13452 .input_mux = &alc269_capture_source,
13453 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013454 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013455 .init_hook = alc269_quanta_fl1_init_hook,
13456 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013457 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013458 .mixers = { alc269_eeepc_mixer },
13459 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013460 .init_verbs = { alc269_init_verbs,
13461 alc269_eeepc_amic_init_verbs },
13462 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13463 .dac_nids = alc269_dac_nids,
13464 .hp_nid = 0x03,
13465 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13466 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013467 .unsol_event = alc269_eeepc_unsol_event,
13468 .setup = alc269_eeepc_amic_setup,
13469 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013470 },
13471 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013472 .mixers = { alc269_eeepc_mixer },
13473 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013474 .init_verbs = { alc269_init_verbs,
13475 alc269_eeepc_dmic_init_verbs },
13476 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13477 .dac_nids = alc269_dac_nids,
13478 .hp_nid = 0x03,
13479 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13480 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013481 .unsol_event = alc269_eeepc_unsol_event,
13482 .setup = alc269_eeepc_dmic_setup,
13483 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013484 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013485 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013486 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013487 .cap_mixer = alc269_epc_capture_mixer,
13488 .init_verbs = { alc269_init_verbs,
13489 alc269_eeepc_dmic_init_verbs },
13490 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13491 .dac_nids = alc269_dac_nids,
13492 .hp_nid = 0x03,
13493 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13494 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013495 .unsol_event = alc269_eeepc_unsol_event,
13496 .setup = alc269_eeepc_dmic_setup,
13497 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013498 },
Tony Vroon64154832008-11-06 15:08:49 +000013499 [ALC269_LIFEBOOK] = {
13500 .mixers = { alc269_lifebook_mixer },
13501 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13502 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13503 .dac_nids = alc269_dac_nids,
13504 .hp_nid = 0x03,
13505 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13506 .channel_mode = alc269_modes,
13507 .input_mux = &alc269_capture_source,
13508 .unsol_event = alc269_lifebook_unsol_event,
13509 .init_hook = alc269_lifebook_init_hook,
13510 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013511};
13512
13513static int patch_alc269(struct hda_codec *codec)
13514{
13515 struct alc_spec *spec;
13516 int board_config;
13517 int err;
13518
13519 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13520 if (spec == NULL)
13521 return -ENOMEM;
13522
13523 codec->spec = spec;
13524
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013525 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13526
Kailang Yangf6a92242007-12-13 16:52:54 +010013527 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13528 alc269_models,
13529 alc269_cfg_tbl);
13530
13531 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013532 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13533 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013534 board_config = ALC269_AUTO;
13535 }
13536
13537 if (board_config == ALC269_AUTO) {
13538 /* automatic parse from the BIOS config */
13539 err = alc269_parse_auto_config(codec);
13540 if (err < 0) {
13541 alc_free(codec);
13542 return err;
13543 } else if (!err) {
13544 printk(KERN_INFO
13545 "hda_codec: Cannot set up configuration "
13546 "from BIOS. Using base mode...\n");
13547 board_config = ALC269_BASIC;
13548 }
13549 }
13550
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013551 err = snd_hda_attach_beep_device(codec, 0x1);
13552 if (err < 0) {
13553 alc_free(codec);
13554 return err;
13555 }
13556
Kailang Yangf6a92242007-12-13 16:52:54 +010013557 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013558 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013559
Takashi Iwaif03d3112009-03-05 14:18:16 +010013560 if (codec->subsystem_id == 0x17aa3bf8) {
13561 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13562 * fix the sample rate of analog I/O to 44.1kHz
13563 */
13564 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13565 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13566 } else {
13567 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13568 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13569 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013570 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13571 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13572
13573 spec->adc_nids = alc269_adc_nids;
13574 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013575 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013576 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013577 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013578 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013579
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013580 spec->vmaster_nid = 0x02;
13581
Kailang Yangf6a92242007-12-13 16:52:54 +010013582 codec->patch_ops = alc_patch_ops;
13583 if (board_config == ALC269_AUTO)
13584 spec->init_hook = alc269_auto_init;
13585#ifdef CONFIG_SND_HDA_POWER_SAVE
13586 if (!spec->loopback.amplist)
13587 spec->loopback.amplist = alc269_loopbacks;
13588#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013589 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013590
13591 return 0;
13592}
13593
13594/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013595 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13596 */
13597
13598/*
13599 * set the path ways for 2 channel output
13600 * need to set the codec line out and mic 1 pin widgets to inputs
13601 */
13602static struct hda_verb alc861_threestack_ch2_init[] = {
13603 /* set pin widget 1Ah (line in) for input */
13604 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013605 /* set pin widget 18h (mic1/2) for input, for mic also enable
13606 * the vref
13607 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013608 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13609
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013610 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13611#if 0
13612 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13613 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13614#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013615 { } /* end */
13616};
13617/*
13618 * 6ch mode
13619 * need to set the codec line out and mic 1 pin widgets to outputs
13620 */
13621static struct hda_verb alc861_threestack_ch6_init[] = {
13622 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13623 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13624 /* set pin widget 18h (mic1) for output (CLFE)*/
13625 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13626
13627 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013628 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013629
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013630 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13631#if 0
13632 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13633 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13634#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013635 { } /* end */
13636};
13637
13638static struct hda_channel_mode alc861_threestack_modes[2] = {
13639 { 2, alc861_threestack_ch2_init },
13640 { 6, alc861_threestack_ch6_init },
13641};
Takashi Iwai22309c32006-08-09 16:57:28 +020013642/* Set mic1 as input and unmute the mixer */
13643static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13644 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13645 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13646 { } /* end */
13647};
13648/* Set mic1 as output and mute mixer */
13649static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13650 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13651 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13652 { } /* end */
13653};
13654
13655static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13656 { 2, alc861_uniwill_m31_ch2_init },
13657 { 4, alc861_uniwill_m31_ch4_init },
13658};
Kailang Yangdf694da2005-12-05 19:42:22 +010013659
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013660/* Set mic1 and line-in as input and unmute the mixer */
13661static struct hda_verb alc861_asus_ch2_init[] = {
13662 /* set pin widget 1Ah (line in) for input */
13663 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013664 /* set pin widget 18h (mic1/2) for input, for mic also enable
13665 * the vref
13666 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013667 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13668
13669 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13670#if 0
13671 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13672 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13673#endif
13674 { } /* end */
13675};
13676/* Set mic1 nad line-in as output and mute mixer */
13677static struct hda_verb alc861_asus_ch6_init[] = {
13678 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13679 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13680 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13681 /* set pin widget 18h (mic1) for output (CLFE)*/
13682 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13683 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13684 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13685 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13686
13687 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13688#if 0
13689 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13690 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13691#endif
13692 { } /* end */
13693};
13694
13695static struct hda_channel_mode alc861_asus_modes[2] = {
13696 { 2, alc861_asus_ch2_init },
13697 { 6, alc861_asus_ch6_init },
13698};
13699
Kailang Yangdf694da2005-12-05 19:42:22 +010013700/* patch-ALC861 */
13701
13702static struct snd_kcontrol_new alc861_base_mixer[] = {
13703 /* output mixer control */
13704 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13705 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13706 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13707 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13708 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13709
13710 /*Input mixer control */
13711 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13712 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13713 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13714 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13715 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13716 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13717 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13718 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13719 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13720 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013721
Kailang Yangdf694da2005-12-05 19:42:22 +010013722 { } /* end */
13723};
13724
13725static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13726 /* output mixer control */
13727 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13728 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13729 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13730 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13731 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13732
13733 /* Input mixer control */
13734 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13735 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13736 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13737 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13738 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13739 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13740 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13741 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13742 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13743 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013744
Kailang Yangdf694da2005-12-05 19:42:22 +010013745 {
13746 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13747 .name = "Channel Mode",
13748 .info = alc_ch_mode_info,
13749 .get = alc_ch_mode_get,
13750 .put = alc_ch_mode_put,
13751 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13752 },
13753 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013754};
13755
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013756static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013757 /* output mixer control */
13758 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13760 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013761
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013762 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013763};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013764
Takashi Iwai22309c32006-08-09 16:57:28 +020013765static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13766 /* output mixer control */
13767 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13768 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13769 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13770 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13771 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13772
13773 /* Input mixer control */
13774 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13775 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13776 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13777 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13778 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13779 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13780 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13781 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13782 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13783 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013784
Takashi Iwai22309c32006-08-09 16:57:28 +020013785 {
13786 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13787 .name = "Channel Mode",
13788 .info = alc_ch_mode_info,
13789 .get = alc_ch_mode_get,
13790 .put = alc_ch_mode_put,
13791 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13792 },
13793 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013794};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013795
13796static struct snd_kcontrol_new alc861_asus_mixer[] = {
13797 /* output mixer control */
13798 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13799 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13800 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13801 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13802 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13803
13804 /* Input mixer control */
13805 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13806 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13807 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13808 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13809 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13810 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13812 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13813 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013814 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13815
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013816 {
13817 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13818 .name = "Channel Mode",
13819 .info = alc_ch_mode_info,
13820 .get = alc_ch_mode_get,
13821 .put = alc_ch_mode_put,
13822 .private_value = ARRAY_SIZE(alc861_asus_modes),
13823 },
13824 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013825};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013826
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013827/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013828static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013829 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13830 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013831 { }
13832};
13833
Kailang Yangdf694da2005-12-05 19:42:22 +010013834/*
13835 * generic initialization of ADC, input mixers and output mixers
13836 */
13837static struct hda_verb alc861_base_init_verbs[] = {
13838 /*
13839 * Unmute ADC0 and set the default input to mic-in
13840 */
13841 /* port-A for surround (rear panel) */
13842 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13843 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13844 /* port-B for mic-in (rear panel) with vref */
13845 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13846 /* port-C for line-in (rear panel) */
13847 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13848 /* port-D for Front */
13849 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13850 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13851 /* port-E for HP out (front panel) */
13852 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13853 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013854 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013855 /* port-F for mic-in (front panel) with vref */
13856 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13857 /* port-G for CLFE (rear panel) */
13858 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13859 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13860 /* port-H for side (rear panel) */
13861 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13862 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13863 /* CD-in */
13864 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13865 /* route front mic to ADC1*/
13866 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013868
Kailang Yangdf694da2005-12-05 19:42:22 +010013869 /* Unmute DAC0~3 & spdif out*/
13870 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13871 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13872 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13873 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13874 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013875
Kailang Yangdf694da2005-12-05 19:42:22 +010013876 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13877 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13878 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13879 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13880 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013881
Kailang Yangdf694da2005-12-05 19:42:22 +010013882 /* Unmute Stereo Mixer 15 */
13883 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013886 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013887
13888 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13889 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13890 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13891 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13892 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13893 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13894 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13895 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013896 /* hp used DAC 3 (Front) */
13897 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013898 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13899
13900 { }
13901};
13902
13903static struct hda_verb alc861_threestack_init_verbs[] = {
13904 /*
13905 * Unmute ADC0 and set the default input to mic-in
13906 */
13907 /* port-A for surround (rear panel) */
13908 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13909 /* port-B for mic-in (rear panel) with vref */
13910 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13911 /* port-C for line-in (rear panel) */
13912 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13913 /* port-D for Front */
13914 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13915 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13916 /* port-E for HP out (front panel) */
13917 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13918 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013919 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013920 /* port-F for mic-in (front panel) with vref */
13921 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13922 /* port-G for CLFE (rear panel) */
13923 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13924 /* port-H for side (rear panel) */
13925 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13926 /* CD-in */
13927 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13928 /* route front mic to ADC1*/
13929 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13930 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13931 /* Unmute DAC0~3 & spdif out*/
13932 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13933 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13934 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13935 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013937
Kailang Yangdf694da2005-12-05 19:42:22 +010013938 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13939 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13940 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13941 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13942 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013943
Kailang Yangdf694da2005-12-05 19:42:22 +010013944 /* Unmute Stereo Mixer 15 */
13945 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13946 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13947 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013948 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013949
13950 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13951 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13952 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13953 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13954 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13955 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13956 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13957 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013958 /* hp used DAC 3 (Front) */
13959 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013960 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13961 { }
13962};
Takashi Iwai22309c32006-08-09 16:57:28 +020013963
13964static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13965 /*
13966 * Unmute ADC0 and set the default input to mic-in
13967 */
13968 /* port-A for surround (rear panel) */
13969 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13970 /* port-B for mic-in (rear panel) with vref */
13971 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13972 /* port-C for line-in (rear panel) */
13973 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13974 /* port-D for Front */
13975 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13976 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13977 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013978 /* this has to be set to VREF80 */
13979 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013980 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013981 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013982 /* port-F for mic-in (front panel) with vref */
13983 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13984 /* port-G for CLFE (rear panel) */
13985 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13986 /* port-H for side (rear panel) */
13987 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13988 /* CD-in */
13989 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13990 /* route front mic to ADC1*/
13991 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13992 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13993 /* Unmute DAC0~3 & spdif out*/
13994 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13995 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13996 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13997 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13998 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013999
Takashi Iwai22309c32006-08-09 16:57:28 +020014000 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14001 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14002 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14003 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14004 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014005
Takashi Iwai22309c32006-08-09 16:57:28 +020014006 /* Unmute Stereo Mixer 15 */
14007 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14008 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14009 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014010 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014011
14012 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14013 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14014 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14015 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14016 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14017 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14018 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14019 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014020 /* hp used DAC 3 (Front) */
14021 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014022 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14023 { }
14024};
14025
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014026static struct hda_verb alc861_asus_init_verbs[] = {
14027 /*
14028 * Unmute ADC0 and set the default input to mic-in
14029 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014030 /* port-A for surround (rear panel)
14031 * according to codec#0 this is the HP jack
14032 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014033 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14034 /* route front PCM to HP */
14035 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14036 /* port-B for mic-in (rear panel) with vref */
14037 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14038 /* port-C for line-in (rear panel) */
14039 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14040 /* port-D for Front */
14041 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14042 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14043 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014044 /* this has to be set to VREF80 */
14045 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014046 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014047 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014048 /* port-F for mic-in (front panel) with vref */
14049 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14050 /* port-G for CLFE (rear panel) */
14051 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14052 /* port-H for side (rear panel) */
14053 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14054 /* CD-in */
14055 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14056 /* route front mic to ADC1*/
14057 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14058 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14059 /* Unmute DAC0~3 & spdif out*/
14060 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14061 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14062 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14063 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14064 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14065 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14066 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14067 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14068 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14069 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014070
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014071 /* Unmute Stereo Mixer 15 */
14072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14074 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014075 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014076
14077 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14078 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14079 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14080 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14081 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14082 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14083 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14084 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014085 /* hp used DAC 3 (Front) */
14086 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014087 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14088 { }
14089};
14090
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014091/* additional init verbs for ASUS laptops */
14092static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14093 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14094 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14095 { }
14096};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014097
Kailang Yangdf694da2005-12-05 19:42:22 +010014098/*
14099 * generic initialization of ADC, input mixers and output mixers
14100 */
14101static struct hda_verb alc861_auto_init_verbs[] = {
14102 /*
14103 * Unmute ADC0 and set the default input to mic-in
14104 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014105 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014106 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014107
Kailang Yangdf694da2005-12-05 19:42:22 +010014108 /* Unmute DAC0~3 & spdif out*/
14109 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14110 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14111 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14112 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14113 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014114
Kailang Yangdf694da2005-12-05 19:42:22 +010014115 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14116 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14117 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14118 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14119 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014120
Kailang Yangdf694da2005-12-05 19:42:22 +010014121 /* Unmute Stereo Mixer 15 */
14122 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14123 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14124 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14125 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14126
Takashi Iwai1c209302009-07-22 15:17:45 +020014127 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14128 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14129 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14130 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14131 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14132 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14133 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14134 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014135
14136 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14137 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014138 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14139 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014140 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14141 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014142 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14143 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014144
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014145 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014146
14147 { }
14148};
14149
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014150static struct hda_verb alc861_toshiba_init_verbs[] = {
14151 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014152
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014153 { }
14154};
14155
14156/* toggle speaker-output according to the hp-jack state */
14157static void alc861_toshiba_automute(struct hda_codec *codec)
14158{
14159 unsigned int present;
14160
14161 present = snd_hda_codec_read(codec, 0x0f, 0,
14162 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014163 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14164 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14165 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14166 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014167}
14168
14169static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14170 unsigned int res)
14171{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014172 if ((res >> 26) == ALC880_HP_EVENT)
14173 alc861_toshiba_automute(codec);
14174}
14175
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014176/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014177#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14178#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14179#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14180#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14181
14182
14183#define ALC861_DIGOUT_NID 0x07
14184
14185static struct hda_channel_mode alc861_8ch_modes[1] = {
14186 { 8, NULL }
14187};
14188
14189static hda_nid_t alc861_dac_nids[4] = {
14190 /* front, surround, clfe, side */
14191 0x03, 0x06, 0x05, 0x04
14192};
14193
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014194static hda_nid_t alc660_dac_nids[3] = {
14195 /* front, clfe, surround */
14196 0x03, 0x05, 0x06
14197};
14198
Kailang Yangdf694da2005-12-05 19:42:22 +010014199static hda_nid_t alc861_adc_nids[1] = {
14200 /* ADC0-2 */
14201 0x08,
14202};
14203
14204static struct hda_input_mux alc861_capture_source = {
14205 .num_items = 5,
14206 .items = {
14207 { "Mic", 0x0 },
14208 { "Front Mic", 0x3 },
14209 { "Line", 0x1 },
14210 { "CD", 0x4 },
14211 { "Mixer", 0x5 },
14212 },
14213};
14214
Takashi Iwai1c209302009-07-22 15:17:45 +020014215static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14216{
14217 struct alc_spec *spec = codec->spec;
14218 hda_nid_t mix, srcs[5];
14219 int i, j, num;
14220
14221 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14222 return 0;
14223 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14224 if (num < 0)
14225 return 0;
14226 for (i = 0; i < num; i++) {
14227 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014228 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014229 if (type != AC_WID_AUD_OUT)
14230 continue;
14231 for (j = 0; j < spec->multiout.num_dacs; j++)
14232 if (spec->multiout.dac_nids[j] == srcs[i])
14233 break;
14234 if (j >= spec->multiout.num_dacs)
14235 return srcs[i];
14236 }
14237 return 0;
14238}
14239
Kailang Yangdf694da2005-12-05 19:42:22 +010014240/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014241static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014242 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014243{
Takashi Iwai1c209302009-07-22 15:17:45 +020014244 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014245 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014246 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014247
14248 spec->multiout.dac_nids = spec->private_dac_nids;
14249 for (i = 0; i < cfg->line_outs; i++) {
14250 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014251 dac = alc861_look_for_dac(codec, nid);
14252 if (!dac)
14253 continue;
14254 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014255 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014256 return 0;
14257}
14258
Takashi Iwai1c209302009-07-22 15:17:45 +020014259static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14260 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014261{
14262 char name[32];
Takashi Iwai1c209302009-07-22 15:17:45 +020014263 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14264 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14265 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14266}
14267
14268/* add playback controls from the parsed DAC table */
14269static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14270 const struct auto_pin_cfg *cfg)
14271{
14272 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014273 static const char *chname[4] = {
14274 "Front", "Surround", NULL /*CLFE*/, "Side"
14275 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014276 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014277 int i, err;
14278
14279 if (cfg->line_outs == 1) {
14280 const char *pfx = NULL;
14281 if (!cfg->hp_outs)
14282 pfx = "Master";
14283 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14284 pfx = "Speaker";
14285 if (pfx) {
14286 nid = spec->multiout.dac_nids[0];
14287 return alc861_create_out_sw(codec, pfx, nid, 3);
14288 }
14289 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014290
14291 for (i = 0; i < cfg->line_outs; i++) {
14292 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014293 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014294 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014295 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014296 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014297 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014298 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014299 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014300 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014301 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014302 return err;
14303 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014304 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014305 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014306 return err;
14307 }
14308 }
14309 return 0;
14310}
14311
Takashi Iwai1c209302009-07-22 15:17:45 +020014312static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014313{
Takashi Iwai1c209302009-07-22 15:17:45 +020014314 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014315 int err;
14316 hda_nid_t nid;
14317
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014318 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014319 return 0;
14320
14321 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014322 nid = alc861_look_for_dac(codec, pin);
14323 if (nid) {
14324 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14325 if (err < 0)
14326 return err;
14327 spec->multiout.hp_nid = nid;
14328 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014329 }
14330 return 0;
14331}
14332
14333/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014334static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014335 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014336{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014337 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014338}
14339
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014340static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14341 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014342 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014343{
Takashi Iwai1c209302009-07-22 15:17:45 +020014344 hda_nid_t mix, srcs[5];
14345 int i, num;
14346
Jacek Luczak564c5be2008-05-03 18:41:23 +020014347 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14348 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014349 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014350 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014351 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14352 return;
14353 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14354 if (num < 0)
14355 return;
14356 for (i = 0; i < num; i++) {
14357 unsigned int mute;
14358 if (srcs[i] == dac || srcs[i] == 0x15)
14359 mute = AMP_IN_UNMUTE(i);
14360 else
14361 mute = AMP_IN_MUTE(i);
14362 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14363 mute);
14364 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014365}
14366
14367static void alc861_auto_init_multi_out(struct hda_codec *codec)
14368{
14369 struct alc_spec *spec = codec->spec;
14370 int i;
14371
14372 for (i = 0; i < spec->autocfg.line_outs; i++) {
14373 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014374 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014375 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014376 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014377 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014378 }
14379}
14380
14381static void alc861_auto_init_hp_out(struct hda_codec *codec)
14382{
14383 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014384
Takashi Iwai15870f02009-10-05 08:25:13 +020014385 if (spec->autocfg.hp_outs)
14386 alc861_auto_set_output_and_unmute(codec,
14387 spec->autocfg.hp_pins[0],
14388 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014389 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014390 if (spec->autocfg.speaker_outs)
14391 alc861_auto_set_output_and_unmute(codec,
14392 spec->autocfg.speaker_pins[0],
14393 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014394 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014395}
14396
14397static void alc861_auto_init_analog_input(struct hda_codec *codec)
14398{
14399 struct alc_spec *spec = codec->spec;
14400 int i;
14401
14402 for (i = 0; i < AUTO_PIN_LAST; i++) {
14403 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014404 if (nid >= 0x0c && nid <= 0x11)
14405 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014406 }
14407}
14408
14409/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014410/* return 1 if successful, 0 if the proper config is not found,
14411 * or a negative error code
14412 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014413static int alc861_parse_auto_config(struct hda_codec *codec)
14414{
14415 struct alc_spec *spec = codec->spec;
14416 int err;
14417 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14418
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014419 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14420 alc861_ignore);
14421 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014422 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014423 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014424 return 0; /* can't find valid BIOS pin config */
14425
Takashi Iwai1c209302009-07-22 15:17:45 +020014426 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014427 if (err < 0)
14428 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014429 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014430 if (err < 0)
14431 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014432 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014433 if (err < 0)
14434 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014435 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014436 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014437 return err;
14438
14439 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14440
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014441 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014442 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14443
Takashi Iwai603c4012008-07-30 15:01:44 +020014444 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014445 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014446
Takashi Iwaid88897e2008-10-31 15:01:37 +010014447 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014448
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014449 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014450 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014451
14452 spec->adc_nids = alc861_adc_nids;
14453 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014454 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014455
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014456 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14457
Kailang Yangdf694da2005-12-05 19:42:22 +010014458 return 1;
14459}
14460
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014461/* additional initialization for auto-configuration model */
14462static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014463{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014464 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014465 alc861_auto_init_multi_out(codec);
14466 alc861_auto_init_hp_out(codec);
14467 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014468 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014469 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014470}
14471
Takashi Iwaicb53c622007-08-10 17:21:45 +020014472#ifdef CONFIG_SND_HDA_POWER_SAVE
14473static struct hda_amp_list alc861_loopbacks[] = {
14474 { 0x15, HDA_INPUT, 0 },
14475 { 0x15, HDA_INPUT, 1 },
14476 { 0x15, HDA_INPUT, 2 },
14477 { 0x15, HDA_INPUT, 3 },
14478 { } /* end */
14479};
14480#endif
14481
Kailang Yangdf694da2005-12-05 19:42:22 +010014482
14483/*
14484 * configuration and preset
14485 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014486static const char *alc861_models[ALC861_MODEL_LAST] = {
14487 [ALC861_3ST] = "3stack",
14488 [ALC660_3ST] = "3stack-660",
14489 [ALC861_3ST_DIG] = "3stack-dig",
14490 [ALC861_6ST_DIG] = "6stack-dig",
14491 [ALC861_UNIWILL_M31] = "uniwill-m31",
14492 [ALC861_TOSHIBA] = "toshiba",
14493 [ALC861_ASUS] = "asus",
14494 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14495 [ALC861_AUTO] = "auto",
14496};
14497
14498static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014499 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014500 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14501 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14502 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014503 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014504 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014505 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014506 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14507 * Any other models that need this preset?
14508 */
14509 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014510 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14511 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014512 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14513 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14514 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14515 /* FIXME: the below seems conflict */
14516 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14517 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14518 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014519 {}
14520};
14521
14522static struct alc_config_preset alc861_presets[] = {
14523 [ALC861_3ST] = {
14524 .mixers = { alc861_3ST_mixer },
14525 .init_verbs = { alc861_threestack_init_verbs },
14526 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14527 .dac_nids = alc861_dac_nids,
14528 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14529 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014530 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014531 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14532 .adc_nids = alc861_adc_nids,
14533 .input_mux = &alc861_capture_source,
14534 },
14535 [ALC861_3ST_DIG] = {
14536 .mixers = { alc861_base_mixer },
14537 .init_verbs = { alc861_threestack_init_verbs },
14538 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14539 .dac_nids = alc861_dac_nids,
14540 .dig_out_nid = ALC861_DIGOUT_NID,
14541 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14542 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014543 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014544 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14545 .adc_nids = alc861_adc_nids,
14546 .input_mux = &alc861_capture_source,
14547 },
14548 [ALC861_6ST_DIG] = {
14549 .mixers = { alc861_base_mixer },
14550 .init_verbs = { alc861_base_init_verbs },
14551 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14552 .dac_nids = alc861_dac_nids,
14553 .dig_out_nid = ALC861_DIGOUT_NID,
14554 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14555 .channel_mode = alc861_8ch_modes,
14556 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14557 .adc_nids = alc861_adc_nids,
14558 .input_mux = &alc861_capture_source,
14559 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014560 [ALC660_3ST] = {
14561 .mixers = { alc861_3ST_mixer },
14562 .init_verbs = { alc861_threestack_init_verbs },
14563 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14564 .dac_nids = alc660_dac_nids,
14565 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14566 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014567 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014568 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14569 .adc_nids = alc861_adc_nids,
14570 .input_mux = &alc861_capture_source,
14571 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014572 [ALC861_UNIWILL_M31] = {
14573 .mixers = { alc861_uniwill_m31_mixer },
14574 .init_verbs = { alc861_uniwill_m31_init_verbs },
14575 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14576 .dac_nids = alc861_dac_nids,
14577 .dig_out_nid = ALC861_DIGOUT_NID,
14578 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14579 .channel_mode = alc861_uniwill_m31_modes,
14580 .need_dac_fix = 1,
14581 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14582 .adc_nids = alc861_adc_nids,
14583 .input_mux = &alc861_capture_source,
14584 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014585 [ALC861_TOSHIBA] = {
14586 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014587 .init_verbs = { alc861_base_init_verbs,
14588 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014589 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14590 .dac_nids = alc861_dac_nids,
14591 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14592 .channel_mode = alc883_3ST_2ch_modes,
14593 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14594 .adc_nids = alc861_adc_nids,
14595 .input_mux = &alc861_capture_source,
14596 .unsol_event = alc861_toshiba_unsol_event,
14597 .init_hook = alc861_toshiba_automute,
14598 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014599 [ALC861_ASUS] = {
14600 .mixers = { alc861_asus_mixer },
14601 .init_verbs = { alc861_asus_init_verbs },
14602 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14603 .dac_nids = alc861_dac_nids,
14604 .dig_out_nid = ALC861_DIGOUT_NID,
14605 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14606 .channel_mode = alc861_asus_modes,
14607 .need_dac_fix = 1,
14608 .hp_nid = 0x06,
14609 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14610 .adc_nids = alc861_adc_nids,
14611 .input_mux = &alc861_capture_source,
14612 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014613 [ALC861_ASUS_LAPTOP] = {
14614 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14615 .init_verbs = { alc861_asus_init_verbs,
14616 alc861_asus_laptop_init_verbs },
14617 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14618 .dac_nids = alc861_dac_nids,
14619 .dig_out_nid = ALC861_DIGOUT_NID,
14620 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14621 .channel_mode = alc883_3ST_2ch_modes,
14622 .need_dac_fix = 1,
14623 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14624 .adc_nids = alc861_adc_nids,
14625 .input_mux = &alc861_capture_source,
14626 },
14627};
Kailang Yangdf694da2005-12-05 19:42:22 +010014628
14629
14630static int patch_alc861(struct hda_codec *codec)
14631{
14632 struct alc_spec *spec;
14633 int board_config;
14634 int err;
14635
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014636 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014637 if (spec == NULL)
14638 return -ENOMEM;
14639
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014640 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014641
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014642 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14643 alc861_models,
14644 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014645
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014646 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014647 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14648 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014649 board_config = ALC861_AUTO;
14650 }
14651
14652 if (board_config == ALC861_AUTO) {
14653 /* automatic parse from the BIOS config */
14654 err = alc861_parse_auto_config(codec);
14655 if (err < 0) {
14656 alc_free(codec);
14657 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014658 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014659 printk(KERN_INFO
14660 "hda_codec: Cannot set up configuration "
14661 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014662 board_config = ALC861_3ST_DIG;
14663 }
14664 }
14665
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014666 err = snd_hda_attach_beep_device(codec, 0x23);
14667 if (err < 0) {
14668 alc_free(codec);
14669 return err;
14670 }
14671
Kailang Yangdf694da2005-12-05 19:42:22 +010014672 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014673 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014674
Kailang Yangdf694da2005-12-05 19:42:22 +010014675 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14676 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14677
Kailang Yangdf694da2005-12-05 19:42:22 +010014678 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14679 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14680
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014681 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14682
Takashi Iwai2134ea42008-01-10 16:53:55 +010014683 spec->vmaster_nid = 0x03;
14684
Kailang Yangdf694da2005-12-05 19:42:22 +010014685 codec->patch_ops = alc_patch_ops;
14686 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014687 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014688#ifdef CONFIG_SND_HDA_POWER_SAVE
14689 if (!spec->loopback.amplist)
14690 spec->loopback.amplist = alc861_loopbacks;
14691#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014692 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014693
Kailang Yangdf694da2005-12-05 19:42:22 +010014694 return 0;
14695}
14696
14697/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014698 * ALC861-VD support
14699 *
14700 * Based on ALC882
14701 *
14702 * In addition, an independent DAC
14703 */
14704#define ALC861VD_DIGOUT_NID 0x06
14705
14706static hda_nid_t alc861vd_dac_nids[4] = {
14707 /* front, surr, clfe, side surr */
14708 0x02, 0x03, 0x04, 0x05
14709};
14710
14711/* dac_nids for ALC660vd are in a different order - according to
14712 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014713 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014714 * of ALC660vd codecs, but for now there is only 3stack mixer
14715 * - and it is the same as in 861vd.
14716 * adc_nids in ALC660vd are (is) the same as in 861vd
14717 */
14718static hda_nid_t alc660vd_dac_nids[3] = {
14719 /* front, rear, clfe, rear_surr */
14720 0x02, 0x04, 0x03
14721};
14722
14723static hda_nid_t alc861vd_adc_nids[1] = {
14724 /* ADC0 */
14725 0x09,
14726};
14727
Takashi Iwaie1406342008-02-11 18:32:32 +010014728static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14729
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014730/* input MUX */
14731/* FIXME: should be a matrix-type input source selection */
14732static struct hda_input_mux alc861vd_capture_source = {
14733 .num_items = 4,
14734 .items = {
14735 { "Mic", 0x0 },
14736 { "Front Mic", 0x1 },
14737 { "Line", 0x2 },
14738 { "CD", 0x4 },
14739 },
14740};
14741
Kailang Yang272a5272007-05-14 11:00:38 +020014742static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014743 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014744 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014745 { "Ext Mic", 0x0 },
14746 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014747 },
14748};
14749
Kailang Yangd1a991a2007-08-15 16:21:59 +020014750static struct hda_input_mux alc861vd_hp_capture_source = {
14751 .num_items = 2,
14752 .items = {
14753 { "Front Mic", 0x0 },
14754 { "ATAPI Mic", 0x1 },
14755 },
14756};
14757
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014758/*
14759 * 2ch mode
14760 */
14761static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14762 { 2, NULL }
14763};
14764
14765/*
14766 * 6ch mode
14767 */
14768static struct hda_verb alc861vd_6stack_ch6_init[] = {
14769 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14770 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14771 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14772 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14773 { } /* end */
14774};
14775
14776/*
14777 * 8ch mode
14778 */
14779static struct hda_verb alc861vd_6stack_ch8_init[] = {
14780 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14781 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14782 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14783 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14784 { } /* end */
14785};
14786
14787static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14788 { 6, alc861vd_6stack_ch6_init },
14789 { 8, alc861vd_6stack_ch8_init },
14790};
14791
14792static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14793 {
14794 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14795 .name = "Channel Mode",
14796 .info = alc_ch_mode_info,
14797 .get = alc_ch_mode_get,
14798 .put = alc_ch_mode_put,
14799 },
14800 { } /* end */
14801};
14802
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014803/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14804 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14805 */
14806static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14807 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14808 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14809
14810 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14811 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14812
14813 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14814 HDA_OUTPUT),
14815 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14816 HDA_OUTPUT),
14817 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14818 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14819
14820 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14821 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14822
14823 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14824
14825 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14826 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14828
14829 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14830 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14831 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14832
14833 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14834 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14835
14836 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14837 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14838
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014839 { } /* end */
14840};
14841
14842static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14843 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14844 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14845
14846 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14847
14848 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14850 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14851
14852 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14853 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14854 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14855
14856 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14857 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14858
14859 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14860 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14861
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014862 { } /* end */
14863};
14864
Kailang Yangbdd148a2007-05-08 15:19:08 +020014865static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14866 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14867 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14868 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14869
14870 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14871
14872 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14873 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14874 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14875
14876 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14877 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14878 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14879
14880 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14881 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14882
14883 { } /* end */
14884};
14885
Tobin Davisb419f342008-03-07 11:57:51 +010014886/* Pin assignment: Speaker=0x14, HP = 0x15,
14887 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014888 */
14889static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014890 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14891 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014892 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14893 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014894 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14895 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14896 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14897 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14898 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14899 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014900 { } /* end */
14901};
14902
Kailang Yangd1a991a2007-08-15 16:21:59 +020014903/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14904 * Front Mic=0x18, ATAPI Mic = 0x19,
14905 */
14906static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14907 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14908 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14909 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14910 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14911 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14912 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14913 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14914 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014915
Kailang Yangd1a991a2007-08-15 16:21:59 +020014916 { } /* end */
14917};
14918
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014919/*
14920 * generic initialization of ADC, input mixers and output mixers
14921 */
14922static struct hda_verb alc861vd_volume_init_verbs[] = {
14923 /*
14924 * Unmute ADC0 and set the default input to mic-in
14925 */
14926 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14927 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14928
14929 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14930 * the analog-loopback mixer widget
14931 */
14932 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14934 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14936 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14937 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014938
14939 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14942 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014943 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014944
14945 /*
14946 * Set up output mixers (0x02 - 0x05)
14947 */
14948 /* set vol=0 to output mixers */
14949 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14950 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14951 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14952 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14953
14954 /* set up input amps for analog loopback */
14955 /* Amp Indices: DAC = 0, mixer = 1 */
14956 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14957 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14958 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14959 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14960 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14961 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14962 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14963 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14964
14965 { }
14966};
14967
14968/*
14969 * 3-stack pin configuration:
14970 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14971 */
14972static struct hda_verb alc861vd_3stack_init_verbs[] = {
14973 /*
14974 * Set pin mode and muting
14975 */
14976 /* set front pin widgets 0x14 for output */
14977 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14978 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14979 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14980
14981 /* Mic (rear) pin: input vref at 80% */
14982 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14983 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14984 /* Front Mic pin: input vref at 80% */
14985 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14986 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14987 /* Line In pin: input */
14988 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14989 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14990 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14991 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14992 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14993 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14994 /* CD pin widget for input */
14995 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14996
14997 { }
14998};
14999
15000/*
15001 * 6-stack pin configuration:
15002 */
15003static struct hda_verb alc861vd_6stack_init_verbs[] = {
15004 /*
15005 * Set pin mode and muting
15006 */
15007 /* set front pin widgets 0x14 for output */
15008 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15009 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15010 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15011
15012 /* Rear Pin: output 1 (0x0d) */
15013 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15014 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15015 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15016 /* CLFE Pin: output 2 (0x0e) */
15017 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15018 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15019 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15020 /* Side Pin: output 3 (0x0f) */
15021 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15022 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15023 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15024
15025 /* Mic (rear) pin: input vref at 80% */
15026 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15027 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15028 /* Front Mic pin: input vref at 80% */
15029 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15030 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15031 /* Line In pin: input */
15032 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15033 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15034 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15035 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15036 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15037 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15038 /* CD pin widget for input */
15039 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15040
15041 { }
15042};
15043
Kailang Yangbdd148a2007-05-08 15:19:08 +020015044static struct hda_verb alc861vd_eapd_verbs[] = {
15045 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15046 { }
15047};
15048
Kailang Yangf9423e72008-05-27 12:32:25 +020015049static struct hda_verb alc660vd_eapd_verbs[] = {
15050 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15051 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15052 { }
15053};
15054
Kailang Yangbdd148a2007-05-08 15:19:08 +020015055static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15056 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15057 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15058 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15059 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015060 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015061 {}
15062};
15063
Kailang Yangbdd148a2007-05-08 15:19:08 +020015064static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15065{
15066 unsigned int present;
15067 unsigned char bits;
15068
15069 present = snd_hda_codec_read(codec, 0x18, 0,
15070 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015071 bits = present ? HDA_AMP_MUTE : 0;
15072 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15073 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015074}
15075
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015076static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015077{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015078 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015079 spec->autocfg.hp_pins[0] = 0x1b;
15080 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015081}
15082
15083static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15084{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015085 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015086 alc861vd_lenovo_mic_automute(codec);
15087}
15088
15089static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15090 unsigned int res)
15091{
15092 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015093 case ALC880_MIC_EVENT:
15094 alc861vd_lenovo_mic_automute(codec);
15095 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015096 default:
15097 alc_automute_amp_unsol_event(codec, res);
15098 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015099 }
15100}
15101
Kailang Yang272a5272007-05-14 11:00:38 +020015102static struct hda_verb alc861vd_dallas_verbs[] = {
15103 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15104 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15105 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15106 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15107
15108 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15109 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15110 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15111 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15112 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15113 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15114 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15115 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015116
Kailang Yang272a5272007-05-14 11:00:38 +020015117 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15118 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15119 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15120 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15121 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15122 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15123 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15124 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15125
15126 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15127 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15128 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15129 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15130 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15131 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15132 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15133 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15134
15135 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15136 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15137 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15138 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15139
15140 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015141 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015142 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15143
15144 { } /* end */
15145};
15146
15147/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015148static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015149{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015150 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015151
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015152 spec->autocfg.hp_pins[0] = 0x15;
15153 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015154}
15155
Takashi Iwaicb53c622007-08-10 17:21:45 +020015156#ifdef CONFIG_SND_HDA_POWER_SAVE
15157#define alc861vd_loopbacks alc880_loopbacks
15158#endif
15159
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015160/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015161#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15162#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15163#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15164#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15165
15166/*
15167 * configuration and preset
15168 */
15169static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15170 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015171 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015172 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015173 [ALC861VD_3ST] = "3stack",
15174 [ALC861VD_3ST_DIG] = "3stack-digout",
15175 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015176 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015177 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015178 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015179 [ALC861VD_AUTO] = "auto",
15180};
15181
15182static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015183 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15184 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015185 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015186 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015187 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015188 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015189 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015190 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015191 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015192 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015193 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015194 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015195 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015196 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015197 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015198 {}
15199};
15200
15201static struct alc_config_preset alc861vd_presets[] = {
15202 [ALC660VD_3ST] = {
15203 .mixers = { alc861vd_3st_mixer },
15204 .init_verbs = { alc861vd_volume_init_verbs,
15205 alc861vd_3stack_init_verbs },
15206 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15207 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015208 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15209 .channel_mode = alc861vd_3stack_2ch_modes,
15210 .input_mux = &alc861vd_capture_source,
15211 },
Mike Crash6963f842007-06-25 12:12:51 +020015212 [ALC660VD_3ST_DIG] = {
15213 .mixers = { alc861vd_3st_mixer },
15214 .init_verbs = { alc861vd_volume_init_verbs,
15215 alc861vd_3stack_init_verbs },
15216 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15217 .dac_nids = alc660vd_dac_nids,
15218 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015219 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15220 .channel_mode = alc861vd_3stack_2ch_modes,
15221 .input_mux = &alc861vd_capture_source,
15222 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015223 [ALC861VD_3ST] = {
15224 .mixers = { alc861vd_3st_mixer },
15225 .init_verbs = { alc861vd_volume_init_verbs,
15226 alc861vd_3stack_init_verbs },
15227 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15228 .dac_nids = alc861vd_dac_nids,
15229 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15230 .channel_mode = alc861vd_3stack_2ch_modes,
15231 .input_mux = &alc861vd_capture_source,
15232 },
15233 [ALC861VD_3ST_DIG] = {
15234 .mixers = { alc861vd_3st_mixer },
15235 .init_verbs = { alc861vd_volume_init_verbs,
15236 alc861vd_3stack_init_verbs },
15237 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15238 .dac_nids = alc861vd_dac_nids,
15239 .dig_out_nid = ALC861VD_DIGOUT_NID,
15240 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15241 .channel_mode = alc861vd_3stack_2ch_modes,
15242 .input_mux = &alc861vd_capture_source,
15243 },
15244 [ALC861VD_6ST_DIG] = {
15245 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15246 .init_verbs = { alc861vd_volume_init_verbs,
15247 alc861vd_6stack_init_verbs },
15248 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15249 .dac_nids = alc861vd_dac_nids,
15250 .dig_out_nid = ALC861VD_DIGOUT_NID,
15251 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15252 .channel_mode = alc861vd_6stack_modes,
15253 .input_mux = &alc861vd_capture_source,
15254 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015255 [ALC861VD_LENOVO] = {
15256 .mixers = { alc861vd_lenovo_mixer },
15257 .init_verbs = { alc861vd_volume_init_verbs,
15258 alc861vd_3stack_init_verbs,
15259 alc861vd_eapd_verbs,
15260 alc861vd_lenovo_unsol_verbs },
15261 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15262 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015263 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15264 .channel_mode = alc861vd_3stack_2ch_modes,
15265 .input_mux = &alc861vd_capture_source,
15266 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015267 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015268 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015269 },
Kailang Yang272a5272007-05-14 11:00:38 +020015270 [ALC861VD_DALLAS] = {
15271 .mixers = { alc861vd_dallas_mixer },
15272 .init_verbs = { alc861vd_dallas_verbs },
15273 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15274 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015275 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15276 .channel_mode = alc861vd_3stack_2ch_modes,
15277 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015278 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015279 .setup = alc861vd_dallas_setup,
15280 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015281 },
15282 [ALC861VD_HP] = {
15283 .mixers = { alc861vd_hp_mixer },
15284 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15285 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15286 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015287 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015288 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15289 .channel_mode = alc861vd_3stack_2ch_modes,
15290 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015291 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015292 .setup = alc861vd_dallas_setup,
15293 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015294 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015295 [ALC660VD_ASUS_V1S] = {
15296 .mixers = { alc861vd_lenovo_mixer },
15297 .init_verbs = { alc861vd_volume_init_verbs,
15298 alc861vd_3stack_init_verbs,
15299 alc861vd_eapd_verbs,
15300 alc861vd_lenovo_unsol_verbs },
15301 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15302 .dac_nids = alc660vd_dac_nids,
15303 .dig_out_nid = ALC861VD_DIGOUT_NID,
15304 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15305 .channel_mode = alc861vd_3stack_2ch_modes,
15306 .input_mux = &alc861vd_capture_source,
15307 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015308 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015309 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015310 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015311};
15312
15313/*
15314 * BIOS auto configuration
15315 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015316static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15317 const struct auto_pin_cfg *cfg)
15318{
15319 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15320}
15321
15322
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015323static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15324 hda_nid_t nid, int pin_type, int dac_idx)
15325{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015326 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015327}
15328
15329static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15330{
15331 struct alc_spec *spec = codec->spec;
15332 int i;
15333
15334 for (i = 0; i <= HDA_SIDE; i++) {
15335 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015336 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015337 if (nid)
15338 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015339 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015340 }
15341}
15342
15343
15344static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15345{
15346 struct alc_spec *spec = codec->spec;
15347 hda_nid_t pin;
15348
15349 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015350 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015351 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015352 pin = spec->autocfg.speaker_pins[0];
15353 if (pin)
15354 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015355}
15356
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015357#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15358
15359static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15360{
15361 struct alc_spec *spec = codec->spec;
15362 int i;
15363
15364 for (i = 0; i < AUTO_PIN_LAST; i++) {
15365 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015366 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015367 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015368 if (nid != ALC861VD_PIN_CD_NID &&
15369 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015370 snd_hda_codec_write(codec, nid, 0,
15371 AC_VERB_SET_AMP_GAIN_MUTE,
15372 AMP_OUT_MUTE);
15373 }
15374 }
15375}
15376
Takashi Iwaif511b012008-08-15 16:46:42 +020015377#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15378
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015379#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15380#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15381
15382/* add playback controls from the parsed DAC table */
15383/* Based on ALC880 version. But ALC861VD has separate,
15384 * different NIDs for mute/unmute switch and volume control */
15385static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15386 const struct auto_pin_cfg *cfg)
15387{
15388 char name[32];
15389 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15390 hda_nid_t nid_v, nid_s;
15391 int i, err;
15392
15393 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015394 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015395 continue;
15396 nid_v = alc861vd_idx_to_mixer_vol(
15397 alc880_dac_to_idx(
15398 spec->multiout.dac_nids[i]));
15399 nid_s = alc861vd_idx_to_mixer_switch(
15400 alc880_dac_to_idx(
15401 spec->multiout.dac_nids[i]));
15402
15403 if (i == 2) {
15404 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015405 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15406 "Center Playback Volume",
15407 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15408 HDA_OUTPUT));
15409 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015410 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015411 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15412 "LFE Playback Volume",
15413 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15414 HDA_OUTPUT));
15415 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015416 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015417 err = add_control(spec, ALC_CTL_BIND_MUTE,
15418 "Center Playback Switch",
15419 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15420 HDA_INPUT));
15421 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015422 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015423 err = add_control(spec, ALC_CTL_BIND_MUTE,
15424 "LFE Playback Switch",
15425 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15426 HDA_INPUT));
15427 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015428 return err;
15429 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015430 const char *pfx;
15431 if (cfg->line_outs == 1 &&
15432 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15433 if (!cfg->hp_pins)
15434 pfx = "Speaker";
15435 else
15436 pfx = "PCM";
15437 } else
15438 pfx = chname[i];
15439 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015440 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15441 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15442 HDA_OUTPUT));
15443 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015444 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015445 if (cfg->line_outs == 1 &&
15446 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15447 pfx = "Speaker";
15448 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015449 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015450 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015451 HDA_INPUT));
15452 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015453 return err;
15454 }
15455 }
15456 return 0;
15457}
15458
15459/* add playback controls for speaker and HP outputs */
15460/* Based on ALC880 version. But ALC861VD has separate,
15461 * different NIDs for mute/unmute switch and volume control */
15462static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15463 hda_nid_t pin, const char *pfx)
15464{
15465 hda_nid_t nid_v, nid_s;
15466 int err;
15467 char name[32];
15468
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015469 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015470 return 0;
15471
15472 if (alc880_is_fixed_pin(pin)) {
15473 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15474 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015475 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015476 spec->multiout.hp_nid = nid_v;
15477 else
15478 spec->multiout.extra_out_nid[0] = nid_v;
15479 /* control HP volume/switch on the output mixer amp */
15480 nid_v = alc861vd_idx_to_mixer_vol(
15481 alc880_fixed_pin_idx(pin));
15482 nid_s = alc861vd_idx_to_mixer_switch(
15483 alc880_fixed_pin_idx(pin));
15484
15485 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015486 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15487 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15488 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015489 return err;
15490 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015491 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15492 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15493 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015494 return err;
15495 } else if (alc880_is_multi_pin(pin)) {
15496 /* set manual connection */
15497 /* we have only a switch on HP-out PIN */
15498 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015499 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15500 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15501 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015502 return err;
15503 }
15504 return 0;
15505}
15506
15507/* parse the BIOS configuration and set up the alc_spec
15508 * return 1 if successful, 0 if the proper config is not found,
15509 * or a negative error code
15510 * Based on ALC880 version - had to change it to override
15511 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15512static int alc861vd_parse_auto_config(struct hda_codec *codec)
15513{
15514 struct alc_spec *spec = codec->spec;
15515 int err;
15516 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15517
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015518 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15519 alc861vd_ignore);
15520 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015521 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015522 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015523 return 0; /* can't find valid BIOS pin config */
15524
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015525 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15526 if (err < 0)
15527 return err;
15528 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15529 if (err < 0)
15530 return err;
15531 err = alc861vd_auto_create_extra_out(spec,
15532 spec->autocfg.speaker_pins[0],
15533 "Speaker");
15534 if (err < 0)
15535 return err;
15536 err = alc861vd_auto_create_extra_out(spec,
15537 spec->autocfg.hp_pins[0],
15538 "Headphone");
15539 if (err < 0)
15540 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015541 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015542 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015543 return err;
15544
15545 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15546
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015547 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015548 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15549
Takashi Iwai603c4012008-07-30 15:01:44 +020015550 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015551 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015552
Takashi Iwaid88897e2008-10-31 15:01:37 +010015553 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015554
15555 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015556 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015557
Takashi Iwai776e1842007-08-29 15:07:11 +020015558 err = alc_auto_add_mic_boost(codec);
15559 if (err < 0)
15560 return err;
15561
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015562 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15563
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015564 return 1;
15565}
15566
15567/* additional initialization for auto-configuration model */
15568static void alc861vd_auto_init(struct hda_codec *codec)
15569{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015570 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015571 alc861vd_auto_init_multi_out(codec);
15572 alc861vd_auto_init_hp_out(codec);
15573 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015574 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015575 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015576 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015577}
15578
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015579enum {
15580 ALC660VD_FIX_ASUS_GPIO1
15581};
15582
15583/* reset GPIO1 */
15584static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
15585 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
15586 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
15587 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
15588 { }
15589};
15590
15591static const struct alc_fixup alc861vd_fixups[] = {
15592 [ALC660VD_FIX_ASUS_GPIO1] = {
15593 .verbs = alc660vd_fix_asus_gpio1_verbs,
15594 },
15595};
15596
15597static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
15598 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
15599 {}
15600};
15601
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015602static int patch_alc861vd(struct hda_codec *codec)
15603{
15604 struct alc_spec *spec;
15605 int err, board_config;
15606
15607 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15608 if (spec == NULL)
15609 return -ENOMEM;
15610
15611 codec->spec = spec;
15612
15613 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15614 alc861vd_models,
15615 alc861vd_cfg_tbl);
15616
15617 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015618 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15619 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015620 board_config = ALC861VD_AUTO;
15621 }
15622
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015623 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
15624
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015625 if (board_config == ALC861VD_AUTO) {
15626 /* automatic parse from the BIOS config */
15627 err = alc861vd_parse_auto_config(codec);
15628 if (err < 0) {
15629 alc_free(codec);
15630 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015631 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015632 printk(KERN_INFO
15633 "hda_codec: Cannot set up configuration "
15634 "from BIOS. Using base mode...\n");
15635 board_config = ALC861VD_3ST;
15636 }
15637 }
15638
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015639 err = snd_hda_attach_beep_device(codec, 0x23);
15640 if (err < 0) {
15641 alc_free(codec);
15642 return err;
15643 }
15644
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015645 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015646 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015647
Kailang Yang2f893282008-05-27 12:14:47 +020015648 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015649 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015650 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015651 }
15652
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015653 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15654 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15655
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015656 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15657 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15658
Takashi Iwaidd704692009-08-11 08:45:11 +020015659 if (!spec->adc_nids) {
15660 spec->adc_nids = alc861vd_adc_nids;
15661 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15662 }
15663 if (!spec->capsrc_nids)
15664 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015665
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015666 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015667 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015668
Takashi Iwai2134ea42008-01-10 16:53:55 +010015669 spec->vmaster_nid = 0x02;
15670
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015671 codec->patch_ops = alc_patch_ops;
15672
15673 if (board_config == ALC861VD_AUTO)
15674 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015675#ifdef CONFIG_SND_HDA_POWER_SAVE
15676 if (!spec->loopback.amplist)
15677 spec->loopback.amplist = alc861vd_loopbacks;
15678#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015679 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015680
15681 return 0;
15682}
15683
15684/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015685 * ALC662 support
15686 *
15687 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15688 * configuration. Each pin widget can choose any input DACs and a mixer.
15689 * Each ADC is connected from a mixer of all inputs. This makes possible
15690 * 6-channel independent captures.
15691 *
15692 * In addition, an independent DAC for the multi-playback (not used in this
15693 * driver yet).
15694 */
15695#define ALC662_DIGOUT_NID 0x06
15696#define ALC662_DIGIN_NID 0x0a
15697
15698static hda_nid_t alc662_dac_nids[4] = {
15699 /* front, rear, clfe, rear_surr */
15700 0x02, 0x03, 0x04
15701};
15702
Kailang Yang622e84c2009-04-21 07:39:04 +020015703static hda_nid_t alc272_dac_nids[2] = {
15704 0x02, 0x03
15705};
15706
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015707static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015708 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015709 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015710};
Takashi Iwaie1406342008-02-11 18:32:32 +010015711
Kailang Yang622e84c2009-04-21 07:39:04 +020015712static hda_nid_t alc272_adc_nids[1] = {
15713 /* ADC1-2 */
15714 0x08,
15715};
15716
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015717static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015718static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15719
Takashi Iwaie1406342008-02-11 18:32:32 +010015720
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015721/* input MUX */
15722/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015723static struct hda_input_mux alc662_capture_source = {
15724 .num_items = 4,
15725 .items = {
15726 { "Mic", 0x0 },
15727 { "Front Mic", 0x1 },
15728 { "Line", 0x2 },
15729 { "CD", 0x4 },
15730 },
15731};
15732
15733static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15734 .num_items = 2,
15735 .items = {
15736 { "Mic", 0x1 },
15737 { "Line", 0x2 },
15738 },
15739};
Kailang Yang291702f2007-10-16 14:28:03 +020015740
Kailang Yang6dda9f42008-05-27 12:05:31 +020015741static struct hda_input_mux alc663_capture_source = {
15742 .num_items = 3,
15743 .items = {
15744 { "Mic", 0x0 },
15745 { "Front Mic", 0x1 },
15746 { "Line", 0x2 },
15747 },
15748};
15749
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015750#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015751static struct hda_input_mux alc272_nc10_capture_source = {
15752 .num_items = 16,
15753 .items = {
15754 { "Autoselect Mic", 0x0 },
15755 { "Internal Mic", 0x1 },
15756 { "In-0x02", 0x2 },
15757 { "In-0x03", 0x3 },
15758 { "In-0x04", 0x4 },
15759 { "In-0x05", 0x5 },
15760 { "In-0x06", 0x6 },
15761 { "In-0x07", 0x7 },
15762 { "In-0x08", 0x8 },
15763 { "In-0x09", 0x9 },
15764 { "In-0x0a", 0x0a },
15765 { "In-0x0b", 0x0b },
15766 { "In-0x0c", 0x0c },
15767 { "In-0x0d", 0x0d },
15768 { "In-0x0e", 0x0e },
15769 { "In-0x0f", 0x0f },
15770 },
15771};
15772#endif
15773
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015774/*
15775 * 2ch mode
15776 */
15777static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15778 { 2, NULL }
15779};
15780
15781/*
15782 * 2ch mode
15783 */
15784static struct hda_verb alc662_3ST_ch2_init[] = {
15785 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15786 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15787 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15788 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15789 { } /* end */
15790};
15791
15792/*
15793 * 6ch mode
15794 */
15795static struct hda_verb alc662_3ST_ch6_init[] = {
15796 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15797 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15798 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15799 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15800 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15801 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15802 { } /* end */
15803};
15804
15805static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15806 { 2, alc662_3ST_ch2_init },
15807 { 6, alc662_3ST_ch6_init },
15808};
15809
15810/*
15811 * 2ch mode
15812 */
15813static struct hda_verb alc662_sixstack_ch6_init[] = {
15814 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15815 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15816 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15817 { } /* end */
15818};
15819
15820/*
15821 * 6ch mode
15822 */
15823static struct hda_verb alc662_sixstack_ch8_init[] = {
15824 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15825 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15826 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15827 { } /* end */
15828};
15829
15830static struct hda_channel_mode alc662_5stack_modes[2] = {
15831 { 2, alc662_sixstack_ch6_init },
15832 { 6, alc662_sixstack_ch8_init },
15833};
15834
15835/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15836 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15837 */
15838
15839static struct snd_kcontrol_new alc662_base_mixer[] = {
15840 /* output mixer control */
15841 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015842 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015843 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015844 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015845 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15846 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015847 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15848 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015849 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15850
15851 /*Input mixer control */
15852 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15853 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15854 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15855 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15856 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15857 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15858 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15859 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015860 { } /* end */
15861};
15862
15863static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15864 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015865 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015866 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15867 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15868 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15869 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15870 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15871 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15872 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15873 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15874 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015875 { } /* end */
15876};
15877
15878static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15879 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015880 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015881 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015882 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015883 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15884 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015885 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15886 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015887 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15888 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15889 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15890 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15891 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15892 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15894 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15895 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015896 { } /* end */
15897};
15898
15899static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15900 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15901 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015902 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15903 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015904 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15905 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15906 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15908 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015909 { } /* end */
15910};
15911
Kailang Yang291702f2007-10-16 14:28:03 +020015912static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015913 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15914 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015915
15916 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15917 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15918 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15919
15920 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15921 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15922 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15923 { } /* end */
15924};
15925
Kailang Yang8c427222008-01-10 13:03:59 +010015926static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015927 ALC262_HIPPO_MASTER_SWITCH,
15928 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015929 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015930 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15931 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015932 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15937 { } /* end */
15938};
15939
Kailang Yangf1d4e282008-08-26 14:03:29 +020015940static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15941 .ops = &snd_hda_bind_vol,
15942 .values = {
15943 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15944 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15945 0
15946 },
15947};
15948
15949static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15950 .ops = &snd_hda_bind_sw,
15951 .values = {
15952 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15953 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15954 0
15955 },
15956};
15957
Kailang Yang6dda9f42008-05-27 12:05:31 +020015958static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015959 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15960 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15961 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15962 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15963 { } /* end */
15964};
15965
15966static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15967 .ops = &snd_hda_bind_sw,
15968 .values = {
15969 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15970 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15971 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15972 0
15973 },
15974};
15975
15976static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15977 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15978 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15979 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15981 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15982 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15983
15984 { } /* end */
15985};
15986
15987static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15988 .ops = &snd_hda_bind_sw,
15989 .values = {
15990 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15991 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15992 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15993 0
15994 },
15995};
15996
15997static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15998 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15999 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16001 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16002 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16003 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16004 { } /* end */
16005};
16006
16007static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016008 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16009 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016010 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16013 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16014 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16015 { } /* end */
16016};
16017
16018static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16019 .ops = &snd_hda_bind_vol,
16020 .values = {
16021 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16022 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16023 0
16024 },
16025};
16026
16027static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16028 .ops = &snd_hda_bind_sw,
16029 .values = {
16030 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16031 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16032 0
16033 },
16034};
16035
16036static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16037 HDA_BIND_VOL("Master Playback Volume",
16038 &alc663_asus_two_bind_master_vol),
16039 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16040 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016041 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16042 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16043 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016044 { } /* end */
16045};
16046
16047static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16048 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16049 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16050 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16051 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16052 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16053 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016054 { } /* end */
16055};
16056
16057static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16058 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16059 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16060 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16061 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16062 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16063
16064 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16065 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16066 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16067 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16068 { } /* end */
16069};
16070
16071static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16072 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16073 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16074 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16075
16076 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16077 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16078 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16079 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16080 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16081 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16082 { } /* end */
16083};
16084
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016085static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16086 {
16087 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16088 .name = "Channel Mode",
16089 .info = alc_ch_mode_info,
16090 .get = alc_ch_mode_get,
16091 .put = alc_ch_mode_put,
16092 },
16093 { } /* end */
16094};
16095
16096static struct hda_verb alc662_init_verbs[] = {
16097 /* ADC: mute amp left and right */
16098 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16099 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16100 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16101
Takashi Iwaicb53c622007-08-10 17:21:45 +020016102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16105 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16106 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016107
Kailang Yangb60dd392007-09-20 12:50:29 +020016108 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16109 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16110 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16111 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16112 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16113 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016114
16115 /* Front Pin: output 0 (0x0c) */
16116 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16117 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16118
16119 /* Rear Pin: output 1 (0x0d) */
16120 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16121 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16122
16123 /* CLFE Pin: output 2 (0x0e) */
16124 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16125 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16126
16127 /* Mic (rear) pin: input vref at 80% */
16128 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16129 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16130 /* Front Mic pin: input vref at 80% */
16131 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16132 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16133 /* Line In pin: input */
16134 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16135 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16136 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16137 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16138 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16139 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16140 /* CD pin widget for input */
16141 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16142
16143 /* FIXME: use matrix-type input source selection */
16144 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16145 /* Input mixer */
16146 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016147 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016148
16149 /* always trun on EAPD */
16150 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16151 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16152
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016153 { }
16154};
16155
16156static struct hda_verb alc662_sue_init_verbs[] = {
16157 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16158 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016159 {}
16160};
16161
16162static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16163 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16164 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16165 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016166};
16167
Kailang Yang8c427222008-01-10 13:03:59 +010016168/* Set Unsolicited Event*/
16169static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16170 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16171 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16172 {}
16173};
16174
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016175/*
16176 * generic initialization of ADC, input mixers and output mixers
16177 */
16178static struct hda_verb alc662_auto_init_verbs[] = {
16179 /*
16180 * Unmute ADC and set the default input to mic-in
16181 */
16182 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16183 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16184
16185 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16186 * mixer widget
16187 * Note: PASD motherboards uses the Line In 2 as the input for front
16188 * panel mic (mic 2)
16189 */
16190 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016191 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16192 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16193 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16194 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16195 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016196
16197 /*
16198 * Set up output mixers (0x0c - 0x0f)
16199 */
16200 /* set vol=0 to output mixers */
16201 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16202 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16203 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16204
16205 /* set up input amps for analog loopback */
16206 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016207 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16208 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16209 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16210 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16211 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16212 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016213
16214
16215 /* FIXME: use matrix-type input source selection */
16216 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16217 /* Input mixer */
16218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016219 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016220 { }
16221};
16222
Takashi Iwai24fb9172008-09-02 14:48:20 +020016223/* additional verbs for ALC663 */
16224static struct hda_verb alc663_auto_init_verbs[] = {
16225 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16226 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16227 { }
16228};
16229
Kailang Yang6dda9f42008-05-27 12:05:31 +020016230static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016231 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16232 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016233 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16234 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016235 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16236 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16237 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016238 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16239 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16240 {}
16241};
16242
Kailang Yangf1d4e282008-08-26 14:03:29 +020016243static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16244 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16245 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16246 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16247 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16248 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16249 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16250 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16251 {}
16252};
16253
16254static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16255 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16256 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16257 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16258 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16259 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16260 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16261 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16262 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16263 {}
16264};
16265
16266static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16267 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16268 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16269 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16270 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16271 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16272 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16273 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16274 {}
16275};
16276
16277static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16278 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16279 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16280 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16281 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16284 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16287 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16288 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16289 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16290 {}
16291};
16292
16293static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16294 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16295 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16296 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16297 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16298 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16299 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16300 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16301 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16303 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16304 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16305 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16306 {}
16307};
16308
Kailang Yang6dda9f42008-05-27 12:05:31 +020016309static struct hda_verb alc663_g71v_init_verbs[] = {
16310 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16311 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16312 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16313
16314 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16315 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16316 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16317
16318 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16319 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16320 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16321 {}
16322};
16323
16324static struct hda_verb alc663_g50v_init_verbs[] = {
16325 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16326 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16327 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16328
16329 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16330 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16331 {}
16332};
16333
Kailang Yangf1d4e282008-08-26 14:03:29 +020016334static struct hda_verb alc662_ecs_init_verbs[] = {
16335 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16336 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16337 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16338 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16339 {}
16340};
16341
Kailang Yang622e84c2009-04-21 07:39:04 +020016342static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16343 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16344 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16345 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16346 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16347 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16348 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16349 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16350 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16351 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16352 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16353 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16354 {}
16355};
16356
16357static struct hda_verb alc272_dell_init_verbs[] = {
16358 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16359 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16360 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16361 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16362 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16363 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16364 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16365 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16366 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16367 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16368 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16369 {}
16370};
16371
Kailang Yangf1d4e282008-08-26 14:03:29 +020016372static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16373 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16374 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16375 { } /* end */
16376};
16377
Kailang Yang622e84c2009-04-21 07:39:04 +020016378static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16379 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16380 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16381 { } /* end */
16382};
16383
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016384static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16385{
16386 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016387 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016388
16389 present = snd_hda_codec_read(codec, 0x14, 0,
16390 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016391 bits = present ? HDA_AMP_MUTE : 0;
16392 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16393 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016394}
16395
16396static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16397{
16398 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016399 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016400
16401 present = snd_hda_codec_read(codec, 0x1b, 0,
16402 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016403 bits = present ? HDA_AMP_MUTE : 0;
16404 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16405 HDA_AMP_MUTE, bits);
16406 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16407 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016408}
16409
16410static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16411 unsigned int res)
16412{
16413 if ((res >> 26) == ALC880_HP_EVENT)
16414 alc662_lenovo_101e_all_automute(codec);
16415 if ((res >> 26) == ALC880_FRONT_EVENT)
16416 alc662_lenovo_101e_ispeaker_automute(codec);
16417}
16418
Kailang Yang291702f2007-10-16 14:28:03 +020016419/* unsolicited event for HP jack sensing */
16420static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16421 unsigned int res)
16422{
Kailang Yang291702f2007-10-16 14:28:03 +020016423 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016424 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016425 else
16426 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016427}
16428
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016429static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016430{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016431 struct alc_spec *spec = codec->spec;
16432
16433 alc262_hippo1_setup(codec);
16434 spec->ext_mic.pin = 0x18;
16435 spec->ext_mic.mux_idx = 0;
16436 spec->int_mic.pin = 0x19;
16437 spec->int_mic.mux_idx = 1;
16438 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016439}
16440
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016441static void alc662_eeepc_inithook(struct hda_codec *codec)
16442{
16443 alc262_hippo_automute(codec);
16444 alc_mic_automute(codec);
16445}
16446
16447static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016448{
Takashi Iwai42171c12009-05-08 14:11:43 +020016449 struct alc_spec *spec = codec->spec;
16450
16451 spec->autocfg.hp_pins[0] = 0x14;
16452 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016453}
16454
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016455#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16456
Kailang Yang6dda9f42008-05-27 12:05:31 +020016457static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16458{
16459 unsigned int present;
16460 unsigned char bits;
16461
16462 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016463 AC_VERB_GET_PIN_SENSE, 0)
16464 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016465 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016466 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16467 AMP_IN_MUTE(0), bits);
16468 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16469 AMP_IN_MUTE(0), bits);
16470}
16471
16472static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16473{
16474 unsigned int present;
16475 unsigned char bits;
16476
16477 present = snd_hda_codec_read(codec, 0x21, 0,
16478 AC_VERB_GET_PIN_SENSE, 0)
16479 & AC_PINSENSE_PRESENCE;
16480 bits = present ? HDA_AMP_MUTE : 0;
16481 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16482 AMP_IN_MUTE(0), bits);
16483 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16484 AMP_IN_MUTE(0), bits);
16485 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16486 AMP_IN_MUTE(0), bits);
16487 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16488 AMP_IN_MUTE(0), bits);
16489}
16490
16491static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16492{
16493 unsigned int present;
16494 unsigned char bits;
16495
16496 present = snd_hda_codec_read(codec, 0x15, 0,
16497 AC_VERB_GET_PIN_SENSE, 0)
16498 & AC_PINSENSE_PRESENCE;
16499 bits = present ? HDA_AMP_MUTE : 0;
16500 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16501 AMP_IN_MUTE(0), bits);
16502 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16503 AMP_IN_MUTE(0), bits);
16504 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16505 AMP_IN_MUTE(0), bits);
16506 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16507 AMP_IN_MUTE(0), bits);
16508}
16509
16510static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16511{
16512 unsigned int present;
16513 unsigned char bits;
16514
16515 present = snd_hda_codec_read(codec, 0x1b, 0,
16516 AC_VERB_GET_PIN_SENSE, 0)
16517 & AC_PINSENSE_PRESENCE;
16518 bits = present ? 0 : PIN_OUT;
16519 snd_hda_codec_write(codec, 0x14, 0,
16520 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16521}
16522
16523static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16524{
16525 unsigned int present1, present2;
16526
16527 present1 = snd_hda_codec_read(codec, 0x21, 0,
16528 AC_VERB_GET_PIN_SENSE, 0)
16529 & AC_PINSENSE_PRESENCE;
16530 present2 = snd_hda_codec_read(codec, 0x15, 0,
16531 AC_VERB_GET_PIN_SENSE, 0)
16532 & AC_PINSENSE_PRESENCE;
16533
16534 if (present1 || present2) {
16535 snd_hda_codec_write_cache(codec, 0x14, 0,
16536 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16537 } else {
16538 snd_hda_codec_write_cache(codec, 0x14, 0,
16539 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16540 }
16541}
16542
16543static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16544{
16545 unsigned int present1, present2;
16546
16547 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16548 AC_VERB_GET_PIN_SENSE, 0)
16549 & AC_PINSENSE_PRESENCE;
16550 present2 = snd_hda_codec_read(codec, 0x15, 0,
16551 AC_VERB_GET_PIN_SENSE, 0)
16552 & AC_PINSENSE_PRESENCE;
16553
16554 if (present1 || present2) {
16555 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16556 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16557 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16558 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16559 } else {
16560 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16561 AMP_IN_MUTE(0), 0);
16562 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16563 AMP_IN_MUTE(0), 0);
16564 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016565}
16566
Kailang Yang6dda9f42008-05-27 12:05:31 +020016567static void alc663_m51va_unsol_event(struct hda_codec *codec,
16568 unsigned int res)
16569{
16570 switch (res >> 26) {
16571 case ALC880_HP_EVENT:
16572 alc663_m51va_speaker_automute(codec);
16573 break;
16574 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016575 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016576 break;
16577 }
16578}
16579
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016580static void alc663_m51va_setup(struct hda_codec *codec)
16581{
16582 struct alc_spec *spec = codec->spec;
16583 spec->ext_mic.pin = 0x18;
16584 spec->ext_mic.mux_idx = 0;
16585 spec->int_mic.pin = 0x12;
16586 spec->int_mic.mux_idx = 1;
16587 spec->auto_mic = 1;
16588}
16589
Kailang Yang6dda9f42008-05-27 12:05:31 +020016590static void alc663_m51va_inithook(struct hda_codec *codec)
16591{
16592 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016593 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016594}
16595
Kailang Yangf1d4e282008-08-26 14:03:29 +020016596/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016597#define alc663_mode1_unsol_event alc663_m51va_unsol_event
16598#define alc663_mode1_setup alc663_m51va_setup
16599#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016600
Kailang Yangf1d4e282008-08-26 14:03:29 +020016601/* ***************** Mode2 ******************************/
16602static void alc662_mode2_unsol_event(struct hda_codec *codec,
16603 unsigned int res)
16604{
16605 switch (res >> 26) {
16606 case ALC880_HP_EVENT:
16607 alc662_f5z_speaker_automute(codec);
16608 break;
16609 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016610 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016611 break;
16612 }
16613}
16614
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016615#define alc662_mode2_setup alc663_m51va_setup
16616
Kailang Yangf1d4e282008-08-26 14:03:29 +020016617static void alc662_mode2_inithook(struct hda_codec *codec)
16618{
16619 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016620 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016621}
16622/* ***************** Mode3 ******************************/
16623static void alc663_mode3_unsol_event(struct hda_codec *codec,
16624 unsigned int res)
16625{
16626 switch (res >> 26) {
16627 case ALC880_HP_EVENT:
16628 alc663_two_hp_m1_speaker_automute(codec);
16629 break;
16630 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016631 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016632 break;
16633 }
16634}
16635
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016636#define alc663_mode3_setup alc663_m51va_setup
16637
Kailang Yangf1d4e282008-08-26 14:03:29 +020016638static void alc663_mode3_inithook(struct hda_codec *codec)
16639{
16640 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016641 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016642}
16643/* ***************** Mode4 ******************************/
16644static void alc663_mode4_unsol_event(struct hda_codec *codec,
16645 unsigned int res)
16646{
16647 switch (res >> 26) {
16648 case ALC880_HP_EVENT:
16649 alc663_21jd_two_speaker_automute(codec);
16650 break;
16651 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016652 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016653 break;
16654 }
16655}
16656
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016657#define alc663_mode4_setup alc663_m51va_setup
16658
Kailang Yangf1d4e282008-08-26 14:03:29 +020016659static void alc663_mode4_inithook(struct hda_codec *codec)
16660{
16661 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016662 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016663}
16664/* ***************** Mode5 ******************************/
16665static void alc663_mode5_unsol_event(struct hda_codec *codec,
16666 unsigned int res)
16667{
16668 switch (res >> 26) {
16669 case ALC880_HP_EVENT:
16670 alc663_15jd_two_speaker_automute(codec);
16671 break;
16672 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016673 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016674 break;
16675 }
16676}
16677
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016678#define alc663_mode5_setup alc663_m51va_setup
16679
Kailang Yangf1d4e282008-08-26 14:03:29 +020016680static void alc663_mode5_inithook(struct hda_codec *codec)
16681{
16682 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016683 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016684}
16685/* ***************** Mode6 ******************************/
16686static void alc663_mode6_unsol_event(struct hda_codec *codec,
16687 unsigned int res)
16688{
16689 switch (res >> 26) {
16690 case ALC880_HP_EVENT:
16691 alc663_two_hp_m2_speaker_automute(codec);
16692 break;
16693 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016694 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016695 break;
16696 }
16697}
16698
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016699#define alc663_mode6_setup alc663_m51va_setup
16700
Kailang Yangf1d4e282008-08-26 14:03:29 +020016701static void alc663_mode6_inithook(struct hda_codec *codec)
16702{
16703 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016704 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016705}
16706
Kailang Yang6dda9f42008-05-27 12:05:31 +020016707static void alc663_g71v_hp_automute(struct hda_codec *codec)
16708{
16709 unsigned int present;
16710 unsigned char bits;
16711
16712 present = snd_hda_codec_read(codec, 0x21, 0,
16713 AC_VERB_GET_PIN_SENSE, 0)
16714 & AC_PINSENSE_PRESENCE;
16715 bits = present ? HDA_AMP_MUTE : 0;
16716 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16717 HDA_AMP_MUTE, bits);
16718 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16719 HDA_AMP_MUTE, bits);
16720}
16721
16722static void alc663_g71v_front_automute(struct hda_codec *codec)
16723{
16724 unsigned int present;
16725 unsigned char bits;
16726
16727 present = snd_hda_codec_read(codec, 0x15, 0,
16728 AC_VERB_GET_PIN_SENSE, 0)
16729 & AC_PINSENSE_PRESENCE;
16730 bits = present ? HDA_AMP_MUTE : 0;
16731 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16732 HDA_AMP_MUTE, bits);
16733}
16734
16735static void alc663_g71v_unsol_event(struct hda_codec *codec,
16736 unsigned int res)
16737{
16738 switch (res >> 26) {
16739 case ALC880_HP_EVENT:
16740 alc663_g71v_hp_automute(codec);
16741 break;
16742 case ALC880_FRONT_EVENT:
16743 alc663_g71v_front_automute(codec);
16744 break;
16745 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016746 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016747 break;
16748 }
16749}
16750
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016751#define alc663_g71v_setup alc663_m51va_setup
16752
Kailang Yang6dda9f42008-05-27 12:05:31 +020016753static void alc663_g71v_inithook(struct hda_codec *codec)
16754{
16755 alc663_g71v_front_automute(codec);
16756 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016757 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016758}
16759
16760static void alc663_g50v_unsol_event(struct hda_codec *codec,
16761 unsigned int res)
16762{
16763 switch (res >> 26) {
16764 case ALC880_HP_EVENT:
16765 alc663_m51va_speaker_automute(codec);
16766 break;
16767 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016768 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016769 break;
16770 }
16771}
16772
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016773#define alc663_g50v_setup alc663_m51va_setup
16774
Kailang Yang6dda9f42008-05-27 12:05:31 +020016775static void alc663_g50v_inithook(struct hda_codec *codec)
16776{
16777 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016778 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016779}
16780
Kailang Yangf1d4e282008-08-26 14:03:29 +020016781static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16782 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016783 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016784
16785 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16786 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16787 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16788
16789 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16790 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16791 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16792 { } /* end */
16793};
16794
Chris Pockelé9541ba12009-05-12 08:08:53 +020016795static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16796 /* Master Playback automatically created from Speaker and Headphone */
16797 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16798 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16799 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16800 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16801
16802 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16803 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16804 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16805
16806 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16807 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16808 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16809 { } /* end */
16810};
16811
Takashi Iwaicb53c622007-08-10 17:21:45 +020016812#ifdef CONFIG_SND_HDA_POWER_SAVE
16813#define alc662_loopbacks alc880_loopbacks
16814#endif
16815
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016816
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016817/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016818#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16819#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16820#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16821#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16822
16823/*
16824 * configuration and preset
16825 */
16826static const char *alc662_models[ALC662_MODEL_LAST] = {
16827 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16828 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16829 [ALC662_3ST_6ch] = "3stack-6ch",
16830 [ALC662_5ST_DIG] = "6stack-dig",
16831 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016832 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016833 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016834 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016835 [ALC663_ASUS_M51VA] = "m51va",
16836 [ALC663_ASUS_G71V] = "g71v",
16837 [ALC663_ASUS_H13] = "h13",
16838 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016839 [ALC663_ASUS_MODE1] = "asus-mode1",
16840 [ALC662_ASUS_MODE2] = "asus-mode2",
16841 [ALC663_ASUS_MODE3] = "asus-mode3",
16842 [ALC663_ASUS_MODE4] = "asus-mode4",
16843 [ALC663_ASUS_MODE5] = "asus-mode5",
16844 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016845 [ALC272_DELL] = "dell",
16846 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016847 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016848 [ALC662_AUTO] = "auto",
16849};
16850
16851static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016852 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016853 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16854 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016855 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16856 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16857 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16858 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16859 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16860 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16861 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16862 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16863 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16864 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16865 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16866 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016867 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16868 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16869 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016870 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16871 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16872 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16873 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016874 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016875 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16876 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016877 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016878 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16879 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16880 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016881 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16882 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16883 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016884 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16885 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16886 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016887 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016888 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16889 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016890 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016891 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016892 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016893 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16894 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16895 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016896 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016897 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16898 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016899 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016900 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016901 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016902 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016903 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16904 ALC662_3ST_6ch_DIG),
Manoj Iyer3db6c032009-09-22 18:33:29 -050016905 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB200", ALC663_ASUS_MODE4),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016906 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016907 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16908 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016909 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016910 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016911 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016912 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016913 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016914 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16915 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016916 {}
16917};
16918
16919static struct alc_config_preset alc662_presets[] = {
16920 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016921 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016922 .init_verbs = { alc662_init_verbs },
16923 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16924 .dac_nids = alc662_dac_nids,
16925 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016926 .dig_in_nid = ALC662_DIGIN_NID,
16927 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16928 .channel_mode = alc662_3ST_2ch_modes,
16929 .input_mux = &alc662_capture_source,
16930 },
16931 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016932 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016933 .init_verbs = { alc662_init_verbs },
16934 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16935 .dac_nids = alc662_dac_nids,
16936 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016937 .dig_in_nid = ALC662_DIGIN_NID,
16938 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16939 .channel_mode = alc662_3ST_6ch_modes,
16940 .need_dac_fix = 1,
16941 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016942 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016943 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016944 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016945 .init_verbs = { alc662_init_verbs },
16946 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16947 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016948 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16949 .channel_mode = alc662_3ST_6ch_modes,
16950 .need_dac_fix = 1,
16951 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016952 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016953 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016954 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016955 .init_verbs = { alc662_init_verbs },
16956 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16957 .dac_nids = alc662_dac_nids,
16958 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016959 .dig_in_nid = ALC662_DIGIN_NID,
16960 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16961 .channel_mode = alc662_5stack_modes,
16962 .input_mux = &alc662_capture_source,
16963 },
16964 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016965 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016966 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16967 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16968 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016969 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16970 .channel_mode = alc662_3ST_2ch_modes,
16971 .input_mux = &alc662_lenovo_101e_capture_source,
16972 .unsol_event = alc662_lenovo_101e_unsol_event,
16973 .init_hook = alc662_lenovo_101e_all_automute,
16974 },
Kailang Yang291702f2007-10-16 14:28:03 +020016975 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016976 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016977 .init_verbs = { alc662_init_verbs,
16978 alc662_eeepc_sue_init_verbs },
16979 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16980 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016981 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16982 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020016983 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016984 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020016985 .init_hook = alc662_eeepc_inithook,
16986 },
Kailang Yang8c427222008-01-10 13:03:59 +010016987 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016988 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016989 alc662_chmode_mixer },
16990 .init_verbs = { alc662_init_verbs,
16991 alc662_eeepc_ep20_sue_init_verbs },
16992 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16993 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016994 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16995 .channel_mode = alc662_3ST_6ch_modes,
16996 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016997 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016998 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010016999 .init_hook = alc662_eeepc_ep20_inithook,
17000 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017001 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017002 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017003 .init_verbs = { alc662_init_verbs,
17004 alc662_ecs_init_verbs },
17005 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17006 .dac_nids = alc662_dac_nids,
17007 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17008 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017009 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017010 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017011 .init_hook = alc662_eeepc_inithook,
17012 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017013 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017014 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017015 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17016 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17017 .dac_nids = alc662_dac_nids,
17018 .dig_out_nid = ALC662_DIGOUT_NID,
17019 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17020 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017021 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017022 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017023 .init_hook = alc663_m51va_inithook,
17024 },
17025 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017026 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017027 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17028 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17029 .dac_nids = alc662_dac_nids,
17030 .dig_out_nid = ALC662_DIGOUT_NID,
17031 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17032 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017033 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017034 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017035 .init_hook = alc663_g71v_inithook,
17036 },
17037 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017038 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017039 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17040 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17041 .dac_nids = alc662_dac_nids,
17042 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17043 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017044 .unsol_event = alc663_m51va_unsol_event,
17045 .init_hook = alc663_m51va_inithook,
17046 },
17047 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017048 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017049 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17050 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17051 .dac_nids = alc662_dac_nids,
17052 .dig_out_nid = ALC662_DIGOUT_NID,
17053 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17054 .channel_mode = alc662_3ST_6ch_modes,
17055 .input_mux = &alc663_capture_source,
17056 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017057 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017058 .init_hook = alc663_g50v_inithook,
17059 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017060 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017061 .mixers = { alc663_m51va_mixer },
17062 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017063 .init_verbs = { alc662_init_verbs,
17064 alc663_21jd_amic_init_verbs },
17065 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17066 .hp_nid = 0x03,
17067 .dac_nids = alc662_dac_nids,
17068 .dig_out_nid = ALC662_DIGOUT_NID,
17069 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17070 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017071 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017072 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017073 .init_hook = alc663_mode1_inithook,
17074 },
17075 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017076 .mixers = { alc662_1bjd_mixer },
17077 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017078 .init_verbs = { alc662_init_verbs,
17079 alc662_1bjd_amic_init_verbs },
17080 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17081 .dac_nids = alc662_dac_nids,
17082 .dig_out_nid = ALC662_DIGOUT_NID,
17083 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17084 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017085 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017086 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017087 .init_hook = alc662_mode2_inithook,
17088 },
17089 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017090 .mixers = { alc663_two_hp_m1_mixer },
17091 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017092 .init_verbs = { alc662_init_verbs,
17093 alc663_two_hp_amic_m1_init_verbs },
17094 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17095 .hp_nid = 0x03,
17096 .dac_nids = alc662_dac_nids,
17097 .dig_out_nid = ALC662_DIGOUT_NID,
17098 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17099 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017100 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017101 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017102 .init_hook = alc663_mode3_inithook,
17103 },
17104 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017105 .mixers = { alc663_asus_21jd_clfe_mixer },
17106 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017107 .init_verbs = { alc662_init_verbs,
17108 alc663_21jd_amic_init_verbs},
17109 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17110 .hp_nid = 0x03,
17111 .dac_nids = alc662_dac_nids,
17112 .dig_out_nid = ALC662_DIGOUT_NID,
17113 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17114 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017115 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017116 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017117 .init_hook = alc663_mode4_inithook,
17118 },
17119 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017120 .mixers = { alc663_asus_15jd_clfe_mixer },
17121 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017122 .init_verbs = { alc662_init_verbs,
17123 alc663_15jd_amic_init_verbs },
17124 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17125 .hp_nid = 0x03,
17126 .dac_nids = alc662_dac_nids,
17127 .dig_out_nid = ALC662_DIGOUT_NID,
17128 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17129 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017130 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017131 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017132 .init_hook = alc663_mode5_inithook,
17133 },
17134 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017135 .mixers = { alc663_two_hp_m2_mixer },
17136 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017137 .init_verbs = { alc662_init_verbs,
17138 alc663_two_hp_amic_m2_init_verbs },
17139 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17140 .hp_nid = 0x03,
17141 .dac_nids = alc662_dac_nids,
17142 .dig_out_nid = ALC662_DIGOUT_NID,
17143 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17144 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017145 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017146 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017147 .init_hook = alc663_mode6_inithook,
17148 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017149 [ALC272_DELL] = {
17150 .mixers = { alc663_m51va_mixer },
17151 .cap_mixer = alc272_auto_capture_mixer,
17152 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17153 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17154 .dac_nids = alc662_dac_nids,
17155 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17156 .adc_nids = alc272_adc_nids,
17157 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17158 .capsrc_nids = alc272_capsrc_nids,
17159 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017160 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017161 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017162 .init_hook = alc663_m51va_inithook,
17163 },
17164 [ALC272_DELL_ZM1] = {
17165 .mixers = { alc663_m51va_mixer },
17166 .cap_mixer = alc662_auto_capture_mixer,
17167 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17168 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17169 .dac_nids = alc662_dac_nids,
17170 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17171 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017172 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017173 .capsrc_nids = alc662_capsrc_nids,
17174 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017175 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017176 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017177 .init_hook = alc663_m51va_inithook,
17178 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017179 [ALC272_SAMSUNG_NC10] = {
17180 .mixers = { alc272_nc10_mixer },
17181 .init_verbs = { alc662_init_verbs,
17182 alc663_21jd_amic_init_verbs },
17183 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17184 .dac_nids = alc272_dac_nids,
17185 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17186 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017187 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017188 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017189 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017190 .init_hook = alc663_mode4_inithook,
17191 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017192};
17193
17194
17195/*
17196 * BIOS auto configuration
17197 */
17198
Takashi Iwai7085ec12009-10-02 09:03:58 +020017199/* convert from MIX nid to DAC */
17200static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17201{
17202 if (nid == 0x0f)
17203 return 0x02;
17204 else if (nid >= 0x0c && nid <= 0x0e)
17205 return nid - 0x0c + 0x02;
17206 else
17207 return 0;
17208}
17209
17210/* get MIX nid connected to the given pin targeted to DAC */
17211static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17212 hda_nid_t dac)
17213{
17214 hda_nid_t mix[4];
17215 int i, num;
17216
17217 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17218 for (i = 0; i < num; i++) {
17219 if (alc662_mix_to_dac(mix[i]) == dac)
17220 return mix[i];
17221 }
17222 return 0;
17223}
17224
17225/* look for an empty DAC slot */
17226static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17227{
17228 struct alc_spec *spec = codec->spec;
17229 hda_nid_t srcs[5];
17230 int i, j, num;
17231
17232 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17233 if (num < 0)
17234 return 0;
17235 for (i = 0; i < num; i++) {
17236 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17237 if (!nid)
17238 continue;
17239 for (j = 0; j < spec->multiout.num_dacs; j++)
17240 if (spec->multiout.dac_nids[j] == nid)
17241 break;
17242 if (j >= spec->multiout.num_dacs)
17243 return nid;
17244 }
17245 return 0;
17246}
17247
17248/* fill in the dac_nids table from the parsed pin configuration */
17249static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
17250 const struct auto_pin_cfg *cfg)
17251{
17252 struct alc_spec *spec = codec->spec;
17253 int i;
17254 hda_nid_t dac;
17255
17256 spec->multiout.dac_nids = spec->private_dac_nids;
17257 for (i = 0; i < cfg->line_outs; i++) {
17258 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
17259 if (!dac)
17260 continue;
17261 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
17262 }
17263 return 0;
17264}
17265
17266static int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
17267 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017268{
17269 char name[32];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017270 sprintf(name, "%s Playback Volume", pfx);
17271 return add_control(spec, ALC_CTL_WIDGET_VOL, name,
17272 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
17273}
17274
17275static int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
17276 hda_nid_t nid, unsigned int chs)
17277{
17278 char name[32];
17279 sprintf(name, "%s Playback Switch", pfx);
17280 return add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17281 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
17282}
17283
17284#define alc662_add_stereo_vol(spec, pfx, nid) \
17285 alc662_add_vol_ctl(spec, pfx, nid, 3)
17286#define alc662_add_stereo_sw(spec, pfx, nid) \
17287 alc662_add_sw_ctl(spec, pfx, nid, 3)
17288
17289/* add playback controls from the parsed DAC table */
17290static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
17291 const struct auto_pin_cfg *cfg)
17292{
17293 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017294 static const char *chname[4] = {
17295 "Front", "Surround", NULL /*CLFE*/, "Side"
17296 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020017297 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017298 int i, err;
17299
17300 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017301 nid = spec->multiout.dac_nids[i];
17302 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017303 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017304 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
17305 if (!mix)
17306 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017307 if (i == 2) {
17308 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017309 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017310 if (err < 0)
17311 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017312 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017313 if (err < 0)
17314 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017315 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017316 if (err < 0)
17317 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017318 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017319 if (err < 0)
17320 return err;
17321 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017322 const char *pfx;
17323 if (cfg->line_outs == 1 &&
17324 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017325 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017326 pfx = "Speaker";
17327 else
17328 pfx = "PCM";
17329 } else
17330 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017331 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017332 if (err < 0)
17333 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017334 if (cfg->line_outs == 1 &&
17335 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17336 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020017337 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017338 if (err < 0)
17339 return err;
17340 }
17341 }
17342 return 0;
17343}
17344
17345/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017346/* return DAC nid if any new DAC is assigned */
17347static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017348 const char *pfx)
17349{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017350 struct alc_spec *spec = codec->spec;
17351 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017352 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017353
17354 if (!pin)
17355 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017356 nid = alc662_look_for_dac(codec, pin);
17357 if (!nid) {
17358 char name[32];
17359 /* the corresponding DAC is already occupied */
17360 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
17361 return 0; /* no way */
17362 /* create a switch only */
Takashi Iwai24fb9172008-09-02 14:48:20 +020017363 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwai7085ec12009-10-02 09:03:58 +020017364 return add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17365 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17366 }
17367
17368 mix = alc662_dac_to_mix(codec, pin, nid);
17369 if (!mix)
17370 return 0;
17371 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17372 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020017373 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017374 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17375 if (err < 0)
17376 return err;
17377 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017378}
17379
17380/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017381#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020017382 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017383
17384static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17385 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017386 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017387{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017388 int i, num;
17389 hda_nid_t srcs[4];
17390
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017391 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017392 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017393 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
17394 if (num <= 1)
17395 return;
17396 for (i = 0; i < num; i++) {
17397 if (alc662_mix_to_dac(srcs[i]) != dac)
17398 continue;
17399 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
17400 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017401 }
17402}
17403
17404static void alc662_auto_init_multi_out(struct hda_codec *codec)
17405{
17406 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017407 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017408 int i;
17409
17410 for (i = 0; i <= HDA_SIDE; i++) {
17411 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17412 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017413 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017414 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017415 }
17416}
17417
17418static void alc662_auto_init_hp_out(struct hda_codec *codec)
17419{
17420 struct alc_spec *spec = codec->spec;
17421 hda_nid_t pin;
17422
17423 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017424 if (pin)
17425 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
17426 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017427 pin = spec->autocfg.speaker_pins[0];
17428 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020017429 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
17430 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017431}
17432
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017433#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17434
17435static void alc662_auto_init_analog_input(struct hda_codec *codec)
17436{
17437 struct alc_spec *spec = codec->spec;
17438 int i;
17439
17440 for (i = 0; i < AUTO_PIN_LAST; i++) {
17441 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020017442 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017443 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017444 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017445 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017446 snd_hda_codec_write(codec, nid, 0,
17447 AC_VERB_SET_AMP_GAIN_MUTE,
17448 AMP_OUT_MUTE);
17449 }
17450 }
17451}
17452
Takashi Iwaif511b012008-08-15 16:46:42 +020017453#define alc662_auto_init_input_src alc882_auto_init_input_src
17454
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017455static int alc662_parse_auto_config(struct hda_codec *codec)
17456{
17457 struct alc_spec *spec = codec->spec;
17458 int err;
17459 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17460
17461 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17462 alc662_ignore);
17463 if (err < 0)
17464 return err;
17465 if (!spec->autocfg.line_outs)
17466 return 0; /* can't find valid BIOS pin config */
17467
Takashi Iwai7085ec12009-10-02 09:03:58 +020017468 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017469 if (err < 0)
17470 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017471 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017472 if (err < 0)
17473 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017474 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017475 spec->autocfg.speaker_pins[0],
17476 "Speaker");
17477 if (err < 0)
17478 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017479 if (err)
17480 spec->multiout.extra_out_nid[0] = err;
17481 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017482 "Headphone");
17483 if (err < 0)
17484 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017485 if (err)
17486 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017487 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017488 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017489 return err;
17490
17491 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17492
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017493 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017494 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17495
Takashi Iwai603c4012008-07-30 15:01:44 +020017496 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017497 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017498
17499 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017500 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017501
Takashi Iwaid88897e2008-10-31 15:01:37 +010017502 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017503 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017504 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017505
17506 err = alc_auto_add_mic_boost(codec);
17507 if (err < 0)
17508 return err;
17509
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017510 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17511
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017512 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017513}
17514
17515/* additional initialization for auto-configuration model */
17516static void alc662_auto_init(struct hda_codec *codec)
17517{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017518 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017519 alc662_auto_init_multi_out(codec);
17520 alc662_auto_init_hp_out(codec);
17521 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017522 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017523 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017524 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017525}
17526
17527static int patch_alc662(struct hda_codec *codec)
17528{
17529 struct alc_spec *spec;
17530 int err, board_config;
17531
17532 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17533 if (!spec)
17534 return -ENOMEM;
17535
17536 codec->spec = spec;
17537
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017538 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17539
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017540 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17541 alc662_models,
17542 alc662_cfg_tbl);
17543 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017544 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17545 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017546 board_config = ALC662_AUTO;
17547 }
17548
17549 if (board_config == ALC662_AUTO) {
17550 /* automatic parse from the BIOS config */
17551 err = alc662_parse_auto_config(codec);
17552 if (err < 0) {
17553 alc_free(codec);
17554 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017555 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017556 printk(KERN_INFO
17557 "hda_codec: Cannot set up configuration "
17558 "from BIOS. Using base mode...\n");
17559 board_config = ALC662_3ST_2ch_DIG;
17560 }
17561 }
17562
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017563 err = snd_hda_attach_beep_device(codec, 0x1);
17564 if (err < 0) {
17565 alc_free(codec);
17566 return err;
17567 }
17568
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017569 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017570 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017571
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017572 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17573 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17574
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017575 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17576 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17577
Takashi Iwaidd704692009-08-11 08:45:11 +020017578 if (!spec->adc_nids) {
17579 spec->adc_nids = alc662_adc_nids;
17580 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17581 }
17582 if (!spec->capsrc_nids)
17583 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017584
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017585 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017586 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017587 if (codec->vendor_id == 0x10ec0662)
17588 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17589 else
17590 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017591
Takashi Iwai2134ea42008-01-10 16:53:55 +010017592 spec->vmaster_nid = 0x02;
17593
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017594 codec->patch_ops = alc_patch_ops;
17595 if (board_config == ALC662_AUTO)
17596 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017597#ifdef CONFIG_SND_HDA_POWER_SAVE
17598 if (!spec->loopback.amplist)
17599 spec->loopback.amplist = alc662_loopbacks;
17600#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017601 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017602
17603 return 0;
17604}
17605
17606/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017607 * patch entries
17608 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017609static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017610 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017611 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017612 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017613 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017614 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017615 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017616 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017617 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017618 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17619 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17620 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017621 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017622 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017623 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17624 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017625 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017626 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017627 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017628 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017629 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017630 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017631 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017632 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017633 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017634 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017635 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017636 .patch = patch_alc882 },
17637 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17638 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017639 {} /* terminator */
17640};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017641
17642MODULE_ALIAS("snd-hda-codec-id:10ec*");
17643
17644MODULE_LICENSE("GPL");
17645MODULE_DESCRIPTION("Realtek HD-audio codec");
17646
17647static struct hda_codec_preset_list realtek_list = {
17648 .preset = snd_hda_preset_realtek,
17649 .owner = THIS_MODULE,
17650};
17651
17652static int __init patch_realtek_init(void)
17653{
17654 return snd_hda_add_codec_preset(&realtek_list);
17655}
17656
17657static void __exit patch_realtek_exit(void)
17658{
17659 snd_hda_delete_codec_preset(&realtek_list);
17660}
17661
17662module_init(patch_realtek_init)
17663module_exit(patch_realtek_exit)