blob: d967836f36bb84cc6f54aac351637e4ec1854fe3 [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 Iwaia9fd4f32009-05-08 15:57:59 +0200964 unsigned int nid = spec->autocfg.hp_pins[0];
965 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200966
Takashi Iwaiad87c642009-11-02 14:23:15 +0100967 if (!nid)
968 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800969 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200970 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
971 nid = spec->autocfg.speaker_pins[i];
972 if (!nid)
973 break;
974 snd_hda_codec_write(codec, nid, 0,
975 AC_VERB_SET_PIN_WIDGET_CONTROL,
976 spec->jack_present ? 0 : PIN_OUT);
977 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200978}
979
Takashi Iwai6c819492009-08-10 18:47:44 +0200980static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
981 hda_nid_t nid)
982{
983 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
984 int i, nums;
985
986 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
987 for (i = 0; i < nums; i++)
988 if (conn[i] == nid)
989 return i;
990 return -1;
991}
992
Kailang Yang7fb0d782008-10-15 11:12:35 +0200993static void alc_mic_automute(struct hda_codec *codec)
994{
995 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +0200996 struct alc_mic_route *dead, *alive;
997 unsigned int present, type;
998 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200999
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001000 if (!spec->auto_mic)
1001 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001002 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1003 return;
1004 if (snd_BUG_ON(!spec->adc_nids))
1005 return;
1006
1007 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1008
Wu Fengguang864f92b2009-11-18 12:38:02 +08001009 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001010 if (present) {
1011 alive = &spec->ext_mic;
1012 dead = &spec->int_mic;
1013 } else {
1014 alive = &spec->int_mic;
1015 dead = &spec->ext_mic;
1016 }
1017
Takashi Iwai6c819492009-08-10 18:47:44 +02001018 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1019 if (type == AC_WID_AUD_MIX) {
1020 /* Matrix-mixer style (e.g. ALC882) */
1021 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1022 alive->mux_idx,
1023 HDA_AMP_MUTE, 0);
1024 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1025 dead->mux_idx,
1026 HDA_AMP_MUTE, HDA_AMP_MUTE);
1027 } else {
1028 /* MUX style (e.g. ALC880) */
1029 snd_hda_codec_write_cache(codec, cap_nid, 0,
1030 AC_VERB_SET_CONNECT_SEL,
1031 alive->mux_idx);
1032 }
1033
1034 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001035}
1036
Kailang Yangc9b58002007-10-16 14:30:01 +02001037/* unsolicited event for HP jack sensing */
1038static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1039{
1040 if (codec->vendor_id == 0x10ec0880)
1041 res >>= 28;
1042 else
1043 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001044 switch (res) {
1045 case ALC880_HP_EVENT:
1046 alc_automute_pin(codec);
1047 break;
1048 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001049 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001050 break;
1051 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001052}
1053
1054static void alc_inithook(struct hda_codec *codec)
1055{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001056 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001057 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001058}
1059
Kailang Yangf9423e72008-05-27 12:32:25 +02001060/* additional initialization for ALC888 variants */
1061static void alc888_coef_init(struct hda_codec *codec)
1062{
1063 unsigned int tmp;
1064
1065 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1066 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1067 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001068 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001069 /* alc888S-VC */
1070 snd_hda_codec_read(codec, 0x20, 0,
1071 AC_VERB_SET_PROC_COEF, 0x830);
1072 else
1073 /* alc888-VB */
1074 snd_hda_codec_read(codec, 0x20, 0,
1075 AC_VERB_SET_PROC_COEF, 0x3030);
1076}
1077
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001078static void alc889_coef_init(struct hda_codec *codec)
1079{
1080 unsigned int tmp;
1081
1082 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1083 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1084 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1085 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1086}
1087
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001088static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001089{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001090 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001091
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001092 switch (type) {
1093 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001094 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1095 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001096 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001097 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1098 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001099 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001100 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1101 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001102 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001103 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001104 case 0x10ec0260:
1105 snd_hda_codec_write(codec, 0x0f, 0,
1106 AC_VERB_SET_EAPD_BTLENABLE, 2);
1107 snd_hda_codec_write(codec, 0x10, 0,
1108 AC_VERB_SET_EAPD_BTLENABLE, 2);
1109 break;
1110 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001111 case 0x10ec0267:
1112 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001113 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001114 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001115 case 0x10ec0660:
1116 case 0x10ec0662:
1117 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001118 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001119 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001120 snd_hda_codec_write(codec, 0x14, 0,
1121 AC_VERB_SET_EAPD_BTLENABLE, 2);
1122 snd_hda_codec_write(codec, 0x15, 0,
1123 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001124 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001125 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001126 switch (codec->vendor_id) {
1127 case 0x10ec0260:
1128 snd_hda_codec_write(codec, 0x1a, 0,
1129 AC_VERB_SET_COEF_INDEX, 7);
1130 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1131 AC_VERB_GET_PROC_COEF, 0);
1132 snd_hda_codec_write(codec, 0x1a, 0,
1133 AC_VERB_SET_COEF_INDEX, 7);
1134 snd_hda_codec_write(codec, 0x1a, 0,
1135 AC_VERB_SET_PROC_COEF,
1136 tmp | 0x2010);
1137 break;
1138 case 0x10ec0262:
1139 case 0x10ec0880:
1140 case 0x10ec0882:
1141 case 0x10ec0883:
1142 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001143 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001144 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001145 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001146 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001147 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001148 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001149 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001150 case 0x10ec0267:
1151 case 0x10ec0268:
1152 snd_hda_codec_write(codec, 0x20, 0,
1153 AC_VERB_SET_COEF_INDEX, 7);
1154 tmp = snd_hda_codec_read(codec, 0x20, 0,
1155 AC_VERB_GET_PROC_COEF, 0);
1156 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001157 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001158 snd_hda_codec_write(codec, 0x20, 0,
1159 AC_VERB_SET_PROC_COEF,
1160 tmp | 0x3000);
1161 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001162 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001163 break;
1164 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001165}
Kailang Yangea1fb292008-08-26 12:58:38 +02001166
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001167static void alc_init_auto_hp(struct hda_codec *codec)
1168{
1169 struct alc_spec *spec = codec->spec;
1170
1171 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001172 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001173
Kailang Yangc9b58002007-10-16 14:30:01 +02001174 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001175 if (spec->autocfg.line_out_pins[0] &&
1176 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001177 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001178 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001179 else
1180 return;
1181 }
1182
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001183 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1184 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001185 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1186 AC_VERB_SET_UNSOLICITED_ENABLE,
1187 AC_USRSP_EN | ALC880_HP_EVENT);
1188 spec->unsol_event = alc_sku_unsol_event;
1189}
1190
Takashi Iwai6c819492009-08-10 18:47:44 +02001191static void alc_init_auto_mic(struct hda_codec *codec)
1192{
1193 struct alc_spec *spec = codec->spec;
1194 struct auto_pin_cfg *cfg = &spec->autocfg;
1195 hda_nid_t fixed, ext;
1196 int i;
1197
1198 /* there must be only two mic inputs exclusively */
1199 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1200 if (cfg->input_pins[i])
1201 return;
1202
1203 fixed = ext = 0;
1204 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1205 hda_nid_t nid = cfg->input_pins[i];
1206 unsigned int defcfg;
1207 if (!nid)
1208 return;
1209 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1210 switch (get_defcfg_connect(defcfg)) {
1211 case AC_JACK_PORT_FIXED:
1212 if (fixed)
1213 return; /* already occupied */
1214 fixed = nid;
1215 break;
1216 case AC_JACK_PORT_COMPLEX:
1217 if (ext)
1218 return; /* already occupied */
1219 ext = nid;
1220 break;
1221 default:
1222 return; /* invalid entry */
1223 }
1224 }
1225 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1226 return; /* no unsol support */
1227 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1228 ext, fixed);
1229 spec->ext_mic.pin = ext;
1230 spec->int_mic.pin = fixed;
1231 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1232 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1233 spec->auto_mic = 1;
1234 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1235 AC_VERB_SET_UNSOLICITED_ENABLE,
1236 AC_USRSP_EN | ALC880_MIC_EVENT);
1237 spec->unsol_event = alc_sku_unsol_event;
1238}
1239
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001240/* check subsystem ID and set up device-specific initialization;
1241 * return 1 if initialized, 0 if invalid SSID
1242 */
1243/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1244 * 31 ~ 16 : Manufacture ID
1245 * 15 ~ 8 : SKU ID
1246 * 7 ~ 0 : Assembly ID
1247 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1248 */
1249static int alc_subsystem_id(struct hda_codec *codec,
1250 hda_nid_t porta, hda_nid_t porte,
1251 hda_nid_t portd)
1252{
1253 unsigned int ass, tmp, i;
1254 unsigned nid;
1255 struct alc_spec *spec = codec->spec;
1256
1257 ass = codec->subsystem_id & 0xffff;
1258 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1259 goto do_sku;
1260
1261 /* invalid SSID, check the special NID pin defcfg instead */
1262 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001263 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001264 * 29~21 : reserve
1265 * 20 : PCBEEP input
1266 * 19~16 : Check sum (15:1)
1267 * 15~1 : Custom
1268 * 0 : override
1269 */
1270 nid = 0x1d;
1271 if (codec->vendor_id == 0x10ec0260)
1272 nid = 0x17;
1273 ass = snd_hda_codec_get_pincfg(codec, nid);
1274 snd_printd("realtek: No valid SSID, "
1275 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001276 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001277 if (!(ass & 1) && !(ass & 0x100000))
1278 return 0;
1279 if ((ass >> 30) != 1) /* no physical connection */
1280 return 0;
1281
1282 /* check sum */
1283 tmp = 0;
1284 for (i = 1; i < 16; i++) {
1285 if ((ass >> i) & 1)
1286 tmp++;
1287 }
1288 if (((ass >> 16) & 0xf) != tmp)
1289 return 0;
1290do_sku:
1291 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1292 ass & 0xffff, codec->vendor_id);
1293 /*
1294 * 0 : override
1295 * 1 : Swap Jack
1296 * 2 : 0 --> Desktop, 1 --> Laptop
1297 * 3~5 : External Amplifier control
1298 * 7~6 : Reserved
1299 */
1300 tmp = (ass & 0x38) >> 3; /* external Amp control */
1301 switch (tmp) {
1302 case 1:
1303 spec->init_amp = ALC_INIT_GPIO1;
1304 break;
1305 case 3:
1306 spec->init_amp = ALC_INIT_GPIO2;
1307 break;
1308 case 7:
1309 spec->init_amp = ALC_INIT_GPIO3;
1310 break;
1311 case 5:
1312 spec->init_amp = ALC_INIT_DEFAULT;
1313 break;
1314 }
1315
1316 /* is laptop or Desktop and enable the function "Mute internal speaker
1317 * when the external headphone out jack is plugged"
1318 */
1319 if (!(ass & 0x8000))
1320 return 1;
1321 /*
1322 * 10~8 : Jack location
1323 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1324 * 14~13: Resvered
1325 * 15 : 1 --> enable the function "Mute internal speaker
1326 * when the external headphone out jack is plugged"
1327 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001328 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001329 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001330 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1331 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001332 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001333 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001334 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001335 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001336 nid = portd;
Kailang Yangc9b58002007-10-16 14:30:01 +02001337 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001338 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001339 for (i = 0; i < spec->autocfg.line_outs; i++)
1340 if (spec->autocfg.line_out_pins[i] == nid)
1341 return 1;
1342 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001343 }
1344
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001345 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001346 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001347 return 1;
1348}
Kailang Yangea1fb292008-08-26 12:58:38 +02001349
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001350static void alc_ssid_check(struct hda_codec *codec,
1351 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1352{
1353 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1354 struct alc_spec *spec = codec->spec;
1355 snd_printd("realtek: "
1356 "Enable default setup for auto mode as fallback\n");
1357 spec->init_amp = ALC_INIT_DEFAULT;
1358 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001359 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001360 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001361}
1362
Takashi Iwai41e41f12005-06-08 14:48:49 +02001363/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001364 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001365 */
1366
1367struct alc_pincfg {
1368 hda_nid_t nid;
1369 u32 val;
1370};
1371
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001372struct alc_fixup {
1373 const struct alc_pincfg *pins;
1374 const struct hda_verb *verbs;
1375};
1376
1377static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001378 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001379 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001380{
1381 const struct alc_pincfg *cfg;
1382
1383 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1384 if (!quirk)
1385 return;
1386
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001387 fix += quirk->value;
1388 cfg = fix->pins;
1389 if (cfg) {
1390 for (; cfg->nid; cfg++)
1391 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1392 }
1393 if (fix->verbs)
1394 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001395}
1396
Kailang Yang274693f2009-12-03 10:07:50 +01001397static int alc_read_coef_idx(struct hda_codec *codec,
1398 unsigned int coef_idx)
1399{
1400 unsigned int val;
1401 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1402 coef_idx);
1403 val = snd_hda_codec_read(codec, 0x20, 0,
1404 AC_VERB_GET_PROC_COEF, 0);
1405 return val;
1406}
1407
Takashi Iwaif95474e2007-07-10 00:47:43 +02001408/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001409 * ALC888
1410 */
1411
1412/*
1413 * 2ch mode
1414 */
1415static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1416/* Mic-in jack as mic in */
1417 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1418 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1419/* Line-in jack as Line in */
1420 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1421 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1422/* Line-Out as Front */
1423 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1424 { } /* end */
1425};
1426
1427/*
1428 * 4ch mode
1429 */
1430static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1431/* Mic-in jack as mic in */
1432 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1433 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1434/* Line-in jack as Surround */
1435 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1436 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1437/* Line-Out as Front */
1438 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1439 { } /* end */
1440};
1441
1442/*
1443 * 6ch mode
1444 */
1445static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1446/* Mic-in jack as CLFE */
1447 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1448 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1449/* Line-in jack as Surround */
1450 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1451 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1452/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1453 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1454 { } /* end */
1455};
1456
1457/*
1458 * 8ch mode
1459 */
1460static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1461/* Mic-in jack as CLFE */
1462 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1463 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1464/* Line-in jack as Surround */
1465 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1466 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1467/* Line-Out as Side */
1468 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1469 { } /* end */
1470};
1471
1472static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1473 { 2, alc888_4ST_ch2_intel_init },
1474 { 4, alc888_4ST_ch4_intel_init },
1475 { 6, alc888_4ST_ch6_intel_init },
1476 { 8, alc888_4ST_ch8_intel_init },
1477};
1478
1479/*
1480 * ALC888 Fujitsu Siemens Amillo xa3530
1481 */
1482
1483static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1484/* Front Mic: set to PIN_IN (empty by default) */
1485 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1486/* Connect Internal HP to Front */
1487 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1488 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1489 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1490/* Connect Bass HP to Front */
1491 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1492 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1493 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1494/* Connect Line-Out side jack (SPDIF) to Side */
1495 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1496 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1497 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1498/* Connect Mic jack to CLFE */
1499 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1500 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1501 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1502/* Connect Line-in jack to Surround */
1503 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1504 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1505 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1506/* Connect HP out jack to Front */
1507 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1508 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1509 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1510/* Enable unsolicited event for HP jack and Line-out jack */
1511 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1512 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1513 {}
1514};
1515
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001516static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001517{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001518 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001519 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001520 hda_nid_t nid;
1521 int i;
1522
1523 spec->jack_present = 0;
1524 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1525 nid = spec->autocfg.hp_pins[i];
1526 if (!nid)
1527 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001528 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001529 spec->jack_present = 1;
1530 break;
1531 }
1532 }
1533
1534 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001535 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001536 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1537 nid = spec->autocfg.speaker_pins[i];
1538 if (!nid)
1539 break;
1540 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1541 HDA_AMP_MUTE, mute);
1542 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001543}
1544
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001545static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1546 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001547{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001548 if (codec->vendor_id == 0x10ec0880)
1549 res >>= 28;
1550 else
1551 res >>= 26;
1552 if (res == ALC880_HP_EVENT)
1553 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001554}
1555
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001556static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001557{
1558 struct alc_spec *spec = codec->spec;
1559
1560 spec->autocfg.hp_pins[0] = 0x15;
1561 spec->autocfg.speaker_pins[0] = 0x14;
1562 spec->autocfg.speaker_pins[1] = 0x16;
1563 spec->autocfg.speaker_pins[2] = 0x17;
1564 spec->autocfg.speaker_pins[3] = 0x19;
1565 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001566}
1567
1568static void alc889_intel_init_hook(struct hda_codec *codec)
1569{
1570 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001571 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001572}
1573
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001574static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001575{
1576 struct alc_spec *spec = codec->spec;
1577
1578 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1579 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1580 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1581 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001582}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001583
1584/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001585 * ALC888 Acer Aspire 4930G model
1586 */
1587
1588static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1589/* Front Mic: set to PIN_IN (empty by default) */
1590 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1591/* Unselect Front Mic by default in input mixer 3 */
1592 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001593/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001594 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1595/* Connect Internal HP to front */
1596 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1597 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1598 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1599/* Connect HP out to front */
1600 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1601 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1602 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1603 { }
1604};
1605
Hector Martin3b315d72009-06-02 10:54:19 +02001606/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001607 * ALC888 Acer Aspire 6530G model
1608 */
1609
1610static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1611/* Bias voltage on for external mic port */
1612 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001613/* Front Mic: set to PIN_IN (empty by default) */
1614 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1615/* Unselect Front Mic by default in input mixer 3 */
1616 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001617/* Enable unsolicited event for HP jack */
1618 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1619/* Enable speaker output */
1620 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1621 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1622/* Enable headphone output */
1623 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1625 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1626 { }
1627};
1628
1629/*
Hector Martin018df412009-06-04 00:13:40 +02001630 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001631 */
1632
Hector Martin018df412009-06-04 00:13:40 +02001633static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001634/* Front Mic: set to PIN_IN (empty by default) */
1635 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1636/* Unselect Front Mic by default in input mixer 3 */
1637 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1638/* Enable unsolicited event for HP jack */
1639 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1640/* Connect Internal Front to Front */
1641 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1642 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1643 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1644/* Connect Internal Rear to Rear */
1645 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1646 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1647 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1648/* Connect Internal CLFE to CLFE */
1649 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1650 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1651 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1652/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001653 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001654 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1655 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1656/* Enable all DACs */
1657/* DAC DISABLE/MUTE 1? */
1658/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1659 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1660 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1661/* DAC DISABLE/MUTE 2? */
1662/* some bit here disables the other DACs. Init=0x4900 */
1663 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1664 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1665/* Enable amplifiers */
1666 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1667 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001668/* DMIC fix
1669 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1670 * which makes the stereo useless. However, either the mic or the ALC889
1671 * makes the signal become a difference/sum signal instead of standard
1672 * stereo, which is annoying. So instead we flip this bit which makes the
1673 * codec replicate the sum signal to both channels, turning it into a
1674 * normal mono mic.
1675 */
1676/* DMIC_CONTROL? Init value = 0x0001 */
1677 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1678 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001679 { }
1680};
1681
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001682static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001683 /* Front mic only available on one ADC */
1684 {
1685 .num_items = 4,
1686 .items = {
1687 { "Mic", 0x0 },
1688 { "Line", 0x2 },
1689 { "CD", 0x4 },
1690 { "Front Mic", 0xb },
1691 },
1692 },
1693 {
1694 .num_items = 3,
1695 .items = {
1696 { "Mic", 0x0 },
1697 { "Line", 0x2 },
1698 { "CD", 0x4 },
1699 },
1700 }
1701};
1702
Tony Vroond2fd4b02009-06-21 00:40:10 +01001703static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1704 /* Interal mic only available on one ADC */
1705 {
Tony Vroon684a8842009-06-26 09:27:50 +01001706 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001707 .items = {
1708 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001709 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001710 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001711 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001712 { "Int Mic", 0xb },
1713 },
1714 },
1715 {
Tony Vroon684a8842009-06-26 09:27:50 +01001716 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001717 .items = {
1718 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001719 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001720 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001721 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001722 },
1723 }
1724};
1725
Hector Martin018df412009-06-04 00:13:40 +02001726static struct hda_input_mux alc889_capture_sources[3] = {
1727 /* Digital mic only available on first "ADC" */
1728 {
1729 .num_items = 5,
1730 .items = {
1731 { "Mic", 0x0 },
1732 { "Line", 0x2 },
1733 { "CD", 0x4 },
1734 { "Front Mic", 0xb },
1735 { "Input Mix", 0xa },
1736 },
1737 },
1738 {
1739 .num_items = 4,
1740 .items = {
1741 { "Mic", 0x0 },
1742 { "Line", 0x2 },
1743 { "CD", 0x4 },
1744 { "Input Mix", 0xa },
1745 },
1746 },
1747 {
1748 .num_items = 4,
1749 .items = {
1750 { "Mic", 0x0 },
1751 { "Line", 0x2 },
1752 { "CD", 0x4 },
1753 { "Input Mix", 0xa },
1754 },
1755 }
1756};
1757
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001758static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001759 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1760 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1761 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1762 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1763 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1764 HDA_OUTPUT),
1765 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1766 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1767 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1768 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1769 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1770 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1771 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1772 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1773 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1775 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1776 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001777 { } /* end */
1778};
1779
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001780static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001781{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001782 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001783
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001784 spec->autocfg.hp_pins[0] = 0x15;
1785 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001786 spec->autocfg.speaker_pins[1] = 0x16;
1787 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001788}
1789
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001790static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001791{
1792 struct alc_spec *spec = codec->spec;
1793
1794 spec->autocfg.hp_pins[0] = 0x15;
1795 spec->autocfg.speaker_pins[0] = 0x14;
1796 spec->autocfg.speaker_pins[1] = 0x16;
1797 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001798}
1799
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001800static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001801{
1802 struct alc_spec *spec = codec->spec;
1803
1804 spec->autocfg.hp_pins[0] = 0x15;
1805 spec->autocfg.speaker_pins[0] = 0x14;
1806 spec->autocfg.speaker_pins[1] = 0x16;
1807 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001808}
1809
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001810/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001811 * ALC880 3-stack model
1812 *
1813 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001814 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1815 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001816 */
1817
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001818static hda_nid_t alc880_dac_nids[4] = {
1819 /* front, rear, clfe, rear_surr */
1820 0x02, 0x05, 0x04, 0x03
1821};
1822
1823static hda_nid_t alc880_adc_nids[3] = {
1824 /* ADC0-2 */
1825 0x07, 0x08, 0x09,
1826};
1827
1828/* The datasheet says the node 0x07 is connected from inputs,
1829 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001830 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001831 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001832static hda_nid_t alc880_adc_nids_alt[2] = {
1833 /* ADC1-2 */
1834 0x08, 0x09,
1835};
1836
1837#define ALC880_DIGOUT_NID 0x06
1838#define ALC880_DIGIN_NID 0x0a
1839
1840static struct hda_input_mux alc880_capture_source = {
1841 .num_items = 4,
1842 .items = {
1843 { "Mic", 0x0 },
1844 { "Front Mic", 0x3 },
1845 { "Line", 0x2 },
1846 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001847 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001848};
1849
1850/* channel source setting (2/6 channel selection for 3-stack) */
1851/* 2ch mode */
1852static struct hda_verb alc880_threestack_ch2_init[] = {
1853 /* set line-in to input, mute it */
1854 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1855 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1856 /* set mic-in to input vref 80%, mute it */
1857 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1858 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001859 { } /* end */
1860};
1861
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001862/* 6ch mode */
1863static struct hda_verb alc880_threestack_ch6_init[] = {
1864 /* set line-in to output, unmute it */
1865 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1866 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1867 /* set mic-in to output, unmute it */
1868 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1869 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1870 { } /* end */
1871};
1872
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001873static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001874 { 2, alc880_threestack_ch2_init },
1875 { 6, alc880_threestack_ch6_init },
1876};
1877
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001878static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001879 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001880 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001881 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001882 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001883 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1884 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001885 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1886 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001887 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1888 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1889 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1890 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1893 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1894 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001895 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001896 {
1897 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1898 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001899 .info = alc_ch_mode_info,
1900 .get = alc_ch_mode_get,
1901 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001902 },
1903 { } /* end */
1904};
1905
1906/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001907static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1908 struct snd_ctl_elem_info *uinfo)
1909{
1910 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1911 struct alc_spec *spec = codec->spec;
1912 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001913
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001914 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001915 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1916 HDA_INPUT);
1917 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001918 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001919 return err;
1920}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001921
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001922static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1923 unsigned int size, unsigned int __user *tlv)
1924{
1925 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1926 struct alc_spec *spec = codec->spec;
1927 int err;
1928
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001929 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001930 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1931 HDA_INPUT);
1932 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001933 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001934 return err;
1935}
1936
1937typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1938 struct snd_ctl_elem_value *ucontrol);
1939
1940static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1941 struct snd_ctl_elem_value *ucontrol,
1942 getput_call_t func)
1943{
1944 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1945 struct alc_spec *spec = codec->spec;
1946 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1947 int err;
1948
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001949 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001950 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1951 3, 0, HDA_INPUT);
1952 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001953 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001954 return err;
1955}
1956
1957static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1958 struct snd_ctl_elem_value *ucontrol)
1959{
1960 return alc_cap_getput_caller(kcontrol, ucontrol,
1961 snd_hda_mixer_amp_volume_get);
1962}
1963
1964static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1965 struct snd_ctl_elem_value *ucontrol)
1966{
1967 return alc_cap_getput_caller(kcontrol, ucontrol,
1968 snd_hda_mixer_amp_volume_put);
1969}
1970
1971/* capture mixer elements */
1972#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1973
1974static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1975 struct snd_ctl_elem_value *ucontrol)
1976{
1977 return alc_cap_getput_caller(kcontrol, ucontrol,
1978 snd_hda_mixer_amp_switch_get);
1979}
1980
1981static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1982 struct snd_ctl_elem_value *ucontrol)
1983{
1984 return alc_cap_getput_caller(kcontrol, ucontrol,
1985 snd_hda_mixer_amp_switch_put);
1986}
1987
Takashi Iwaia23b6882009-03-23 15:21:36 +01001988#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001989 { \
1990 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1991 .name = "Capture Switch", \
1992 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1993 .count = num, \
1994 .info = alc_cap_sw_info, \
1995 .get = alc_cap_sw_get, \
1996 .put = alc_cap_sw_put, \
1997 }, \
1998 { \
1999 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2000 .name = "Capture Volume", \
2001 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2002 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2003 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2004 .count = num, \
2005 .info = alc_cap_vol_info, \
2006 .get = alc_cap_vol_get, \
2007 .put = alc_cap_vol_put, \
2008 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002009 }
2010
2011#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002012 { \
2013 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2014 /* .name = "Capture Source", */ \
2015 .name = "Input Source", \
2016 .count = num, \
2017 .info = alc_mux_enum_info, \
2018 .get = alc_mux_enum_get, \
2019 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002020 }
2021
2022#define DEFINE_CAPMIX(num) \
2023static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2024 _DEFINE_CAPMIX(num), \
2025 _DEFINE_CAPSRC(num), \
2026 { } /* end */ \
2027}
2028
2029#define DEFINE_CAPMIX_NOSRC(num) \
2030static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2031 _DEFINE_CAPMIX(num), \
2032 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002033}
2034
2035/* up to three ADCs */
2036DEFINE_CAPMIX(1);
2037DEFINE_CAPMIX(2);
2038DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002039DEFINE_CAPMIX_NOSRC(1);
2040DEFINE_CAPMIX_NOSRC(2);
2041DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002042
2043/*
2044 * ALC880 5-stack model
2045 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002046 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2047 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002048 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2049 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2050 */
2051
2052/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002053static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002054 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002055 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002056 { } /* end */
2057};
2058
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002059/* channel source setting (6/8 channel selection for 5-stack) */
2060/* 6ch mode */
2061static struct hda_verb alc880_fivestack_ch6_init[] = {
2062 /* set line-in to input, mute it */
2063 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2064 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002065 { } /* end */
2066};
2067
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002068/* 8ch mode */
2069static struct hda_verb alc880_fivestack_ch8_init[] = {
2070 /* set line-in to output, unmute it */
2071 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2072 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2073 { } /* end */
2074};
2075
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002076static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002077 { 6, alc880_fivestack_ch6_init },
2078 { 8, alc880_fivestack_ch8_init },
2079};
2080
2081
2082/*
2083 * ALC880 6-stack model
2084 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002085 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2086 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002087 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2088 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2089 */
2090
2091static hda_nid_t alc880_6st_dac_nids[4] = {
2092 /* front, rear, clfe, rear_surr */
2093 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002094};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002095
2096static struct hda_input_mux alc880_6stack_capture_source = {
2097 .num_items = 4,
2098 .items = {
2099 { "Mic", 0x0 },
2100 { "Front Mic", 0x1 },
2101 { "Line", 0x2 },
2102 { "CD", 0x4 },
2103 },
2104};
2105
2106/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002107static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002108 { 8, NULL },
2109};
2110
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002111static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002112 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002113 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002114 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002115 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002116 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2117 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002118 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2119 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002120 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002121 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002122 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2123 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2124 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2125 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2126 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2127 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2128 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2129 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002130 {
2131 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2132 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002133 .info = alc_ch_mode_info,
2134 .get = alc_ch_mode_get,
2135 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002136 },
2137 { } /* end */
2138};
2139
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002140
2141/*
2142 * ALC880 W810 model
2143 *
2144 * W810 has rear IO for:
2145 * Front (DAC 02)
2146 * Surround (DAC 03)
2147 * Center/LFE (DAC 04)
2148 * Digital out (06)
2149 *
2150 * The system also has a pair of internal speakers, and a headphone jack.
2151 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002152 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002153 * There is a variable resistor to control the speaker or headphone
2154 * volume. This is a hardware-only device without a software API.
2155 *
2156 * Plugging headphones in will disable the internal speakers. This is
2157 * implemented in hardware, not via the driver using jack sense. In
2158 * a similar fashion, plugging into the rear socket marked "front" will
2159 * disable both the speakers and headphones.
2160 *
2161 * For input, there's a microphone jack, and an "audio in" jack.
2162 * These may not do anything useful with this driver yet, because I
2163 * haven't setup any initialization verbs for these yet...
2164 */
2165
2166static hda_nid_t alc880_w810_dac_nids[3] = {
2167 /* front, rear/surround, clfe */
2168 0x02, 0x03, 0x04
2169};
2170
2171/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002172static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002173 { 6, NULL }
2174};
2175
2176/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002177static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002178 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002179 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002180 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002181 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002182 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2183 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002184 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2185 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002186 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2187 { } /* end */
2188};
2189
2190
2191/*
2192 * Z710V model
2193 *
2194 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002195 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2196 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002197 */
2198
2199static hda_nid_t alc880_z71v_dac_nids[1] = {
2200 0x02
2201};
2202#define ALC880_Z71V_HP_DAC 0x03
2203
2204/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002205static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002206 { 2, NULL }
2207};
2208
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002209static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002210 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002211 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002212 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002213 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002214 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2215 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2217 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2218 { } /* end */
2219};
2220
2221
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002222/*
2223 * ALC880 F1734 model
2224 *
2225 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2226 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2227 */
2228
2229static hda_nid_t alc880_f1734_dac_nids[1] = {
2230 0x03
2231};
2232#define ALC880_F1734_HP_DAC 0x02
2233
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002234static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002235 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002236 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002237 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2238 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002239 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2240 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002241 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2242 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002243 { } /* end */
2244};
2245
Takashi Iwai937b4162008-02-11 14:52:36 +01002246static struct hda_input_mux alc880_f1734_capture_source = {
2247 .num_items = 2,
2248 .items = {
2249 { "Mic", 0x1 },
2250 { "CD", 0x4 },
2251 },
2252};
2253
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002254
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002255/*
2256 * ALC880 ASUS model
2257 *
2258 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2259 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2260 * Mic = 0x18, Line = 0x1a
2261 */
2262
2263#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2264#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2265
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002266static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002267 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002268 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002269 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002270 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002271 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2272 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002273 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2274 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002275 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2276 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2277 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2278 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2279 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2280 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002281 {
2282 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2283 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002284 .info = alc_ch_mode_info,
2285 .get = alc_ch_mode_get,
2286 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002287 },
2288 { } /* end */
2289};
2290
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002291/*
2292 * ALC880 ASUS W1V model
2293 *
2294 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2295 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2296 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2297 */
2298
2299/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002300static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002301 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2302 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002303 { } /* end */
2304};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002305
Kailang Yangdf694da2005-12-05 19:42:22 +01002306/* TCL S700 */
2307static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2308 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2309 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2310 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2311 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2312 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2313 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2314 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2315 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2316 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002317 { } /* end */
2318};
2319
Kailang Yangccc656c2006-10-17 12:32:26 +02002320/* Uniwill */
2321static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002322 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2323 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2324 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2325 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002326 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2327 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2328 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2329 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2330 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2331 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2336 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2337 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002338 {
2339 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2340 .name = "Channel Mode",
2341 .info = alc_ch_mode_info,
2342 .get = alc_ch_mode_get,
2343 .put = alc_ch_mode_put,
2344 },
2345 { } /* end */
2346};
2347
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002348static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2349 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2350 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2351 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2352 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2353 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2354 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2355 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2356 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2357 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2358 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2359 { } /* end */
2360};
2361
Kailang Yangccc656c2006-10-17 12:32:26 +02002362static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002363 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2364 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2365 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2366 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002367 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2368 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2369 { } /* end */
2370};
2371
Linus Torvalds1da177e2005-04-16 15:20:36 -07002372/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002373 * virtual master controls
2374 */
2375
2376/*
2377 * slave controls for virtual master
2378 */
2379static const char *alc_slave_vols[] = {
2380 "Front Playback Volume",
2381 "Surround Playback Volume",
2382 "Center Playback Volume",
2383 "LFE Playback Volume",
2384 "Side Playback Volume",
2385 "Headphone Playback Volume",
2386 "Speaker Playback Volume",
2387 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002388 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002389 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002390 NULL,
2391};
2392
2393static const char *alc_slave_sws[] = {
2394 "Front Playback Switch",
2395 "Surround Playback Switch",
2396 "Center Playback Switch",
2397 "LFE Playback Switch",
2398 "Side Playback Switch",
2399 "Headphone Playback Switch",
2400 "Speaker Playback Switch",
2401 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002402 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002403 NULL,
2404};
2405
2406/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002407 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002408 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002409
2410static void alc_free_kctls(struct hda_codec *codec);
2411
Takashi Iwai67d634c2009-11-16 15:35:59 +01002412#ifdef CONFIG_SND_HDA_INPUT_BEEP
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),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002416 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002417 { } /* end */
2418};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002419#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002420
Linus Torvalds1da177e2005-04-16 15:20:36 -07002421static int alc_build_controls(struct hda_codec *codec)
2422{
2423 struct alc_spec *spec = codec->spec;
2424 int err;
2425 int i;
2426
2427 for (i = 0; i < spec->num_mixers; i++) {
2428 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2429 if (err < 0)
2430 return err;
2431 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002432 if (spec->cap_mixer) {
2433 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2434 if (err < 0)
2435 return err;
2436 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002437 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002438 err = snd_hda_create_spdif_out_ctls(codec,
2439 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002440 if (err < 0)
2441 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002442 if (!spec->no_analog) {
2443 err = snd_hda_create_spdif_share_sw(codec,
2444 &spec->multiout);
2445 if (err < 0)
2446 return err;
2447 spec->multiout.share_spdif = 1;
2448 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002449 }
2450 if (spec->dig_in_nid) {
2451 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2452 if (err < 0)
2453 return err;
2454 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002455
Takashi Iwai67d634c2009-11-16 15:35:59 +01002456#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002457 /* create beep controls if needed */
2458 if (spec->beep_amp) {
2459 struct snd_kcontrol_new *knew;
2460 for (knew = alc_beep_mixer; knew->name; knew++) {
2461 struct snd_kcontrol *kctl;
2462 kctl = snd_ctl_new1(knew, codec);
2463 if (!kctl)
2464 return -ENOMEM;
2465 kctl->private_value = spec->beep_amp;
Jaroslav Kysela3911a4c2009-11-11 13:43:01 +01002466 err = snd_hda_ctl_add(codec,
2467 get_amp_nid_(spec->beep_amp), kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002468 if (err < 0)
2469 return err;
2470 }
2471 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002472#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002473
Takashi Iwai2134ea42008-01-10 16:53:55 +01002474 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002475 if (!spec->no_analog &&
2476 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002477 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002478 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002479 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002480 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002481 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002482 if (err < 0)
2483 return err;
2484 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002485 if (!spec->no_analog &&
2486 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002487 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2488 NULL, alc_slave_sws);
2489 if (err < 0)
2490 return err;
2491 }
2492
Takashi Iwai603c4012008-07-30 15:01:44 +02002493 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494 return 0;
2495}
2496
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002497
Linus Torvalds1da177e2005-04-16 15:20:36 -07002498/*
2499 * initialize the codec volumes, etc
2500 */
2501
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002502/*
2503 * generic initialization of ADC, input mixers and output mixers
2504 */
2505static struct hda_verb alc880_volume_init_verbs[] = {
2506 /*
2507 * Unmute ADC0-2 and set the default input to mic-in
2508 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002509 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002510 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002511 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002512 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002513 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002514 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002515
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002516 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2517 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002518 * Note: PASD motherboards uses the Line In 2 as the input for front
2519 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002520 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002521 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2523 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2524 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2525 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2526 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002529
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002530 /*
2531 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002532 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002533 /* set vol=0 to output mixers */
2534 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2535 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2536 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2537 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2538 /* set up input amps for analog loopback */
2539 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2541 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002542 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2543 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002544 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2545 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002546 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2547 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002548
2549 { }
2550};
2551
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002552/*
2553 * 3-stack pin configuration:
2554 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2555 */
2556static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2557 /*
2558 * preset connection lists of input pins
2559 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2560 */
2561 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2562 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2563 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2564
2565 /*
2566 * Set pin mode and muting
2567 */
2568 /* set front pin widgets 0x14 for output */
2569 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2570 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2571 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2572 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2573 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2574 /* Mic2 (as headphone out) for HP output */
2575 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2576 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2577 /* Line In pin widget for input */
2578 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2579 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2580 /* Line2 (as front mic) pin widget for input and vref at 80% */
2581 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2582 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2583 /* CD pin widget for input */
2584 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2585
2586 { }
2587};
2588
2589/*
2590 * 5-stack pin configuration:
2591 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2592 * line-in/side = 0x1a, f-mic = 0x1b
2593 */
2594static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2595 /*
2596 * preset connection lists of input pins
2597 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2598 */
2599 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2600 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2601
2602 /*
2603 * Set pin mode and muting
2604 */
2605 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002606 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2607 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2608 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2609 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002610 /* unmute pins for output (no gain on this amp) */
2611 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2612 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2613 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2614 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2615
Linus Torvalds1da177e2005-04-16 15:20:36 -07002616 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002617 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002618 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2619 /* Mic2 (as headphone out) for HP output */
2620 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002621 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002622 /* Line In pin widget for input */
2623 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2624 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2625 /* Line2 (as front mic) pin widget for input and vref at 80% */
2626 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2627 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2628 /* CD pin widget for input */
2629 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002630
2631 { }
2632};
2633
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002634/*
2635 * W810 pin configuration:
2636 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2637 */
2638static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002639 /* hphone/speaker input selector: front DAC */
2640 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2641
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002642 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2643 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2644 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2645 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2646 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2647 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2648
2649 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002650 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002651
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652 { }
2653};
2654
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002655/*
2656 * Z71V pin configuration:
2657 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2658 */
2659static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002660 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002661 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002664
Takashi Iwai16ded522005-06-10 19:58:24 +02002665 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002666 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002667 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002668 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002669
2670 { }
2671};
2672
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002673/*
2674 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002675 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2676 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002677 */
2678static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2679 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2680
Takashi Iwai16ded522005-06-10 19:58:24 +02002681 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002682 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002683 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002684 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002685 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002686 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002687 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002688 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2689
Takashi Iwai16ded522005-06-10 19:58:24 +02002690 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002691 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002692 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002693 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002694 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002695 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002696 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002697 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002698 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002699
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002700 { }
2701};
Takashi Iwai16ded522005-06-10 19:58:24 +02002702
Kailang Yangccc656c2006-10-17 12:32:26 +02002703/*
2704 * Uniwill pin configuration:
2705 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2706 * line = 0x1a
2707 */
2708static struct hda_verb alc880_uniwill_init_verbs[] = {
2709 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2710
2711 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2712 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2713 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2714 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2715 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2716 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2717 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2718 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2721 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2722 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2723 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2724 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2725
2726 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2727 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2728 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2729 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2730 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2731 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2732 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2733 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2734 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2735
2736 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2737 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2738
2739 { }
2740};
2741
2742/*
2743* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002744* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002745 */
2746static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2747 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2748
2749 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2750 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2752 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2753 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2754 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2755 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2756 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2757 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2758 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2759 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2760 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2761
2762 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2763 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2764 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2765 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2766 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2767 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2768
2769 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2770 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2771
2772 { }
2773};
2774
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002775static struct hda_verb alc880_beep_init_verbs[] = {
2776 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2777 { }
2778};
2779
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002780/* auto-toggle front mic */
2781static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2782{
2783 unsigned int present;
2784 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002785
Wu Fengguang864f92b2009-11-18 12:38:02 +08002786 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002787 bits = present ? HDA_AMP_MUTE : 0;
2788 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002789}
2790
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002791static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002792{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002793 struct alc_spec *spec = codec->spec;
2794
2795 spec->autocfg.hp_pins[0] = 0x14;
2796 spec->autocfg.speaker_pins[0] = 0x15;
2797 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002798}
2799
2800static void alc880_uniwill_init_hook(struct hda_codec *codec)
2801{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002802 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002803 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002804}
2805
2806static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2807 unsigned int res)
2808{
2809 /* Looks like the unsol event is incompatible with the standard
2810 * definition. 4bit tag is placed at 28 bit!
2811 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002812 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002813 case ALC880_MIC_EVENT:
2814 alc880_uniwill_mic_automute(codec);
2815 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002816 default:
2817 alc_automute_amp_unsol_event(codec, res);
2818 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002819 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002820}
2821
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002822static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002823{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002824 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002825
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002826 spec->autocfg.hp_pins[0] = 0x14;
2827 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002828}
2829
2830static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2831{
2832 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002833
Kailang Yangccc656c2006-10-17 12:32:26 +02002834 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002835 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2836 present &= HDA_AMP_VOLMASK;
2837 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2838 HDA_AMP_VOLMASK, present);
2839 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2840 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002841}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002842
Kailang Yangccc656c2006-10-17 12:32:26 +02002843static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2844 unsigned int res)
2845{
2846 /* Looks like the unsol event is incompatible with the standard
2847 * definition. 4bit tag is placed at 28 bit!
2848 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002849 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002850 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002851 else
2852 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002853}
2854
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002855/*
2856 * F1734 pin configuration:
2857 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2858 */
2859static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002860 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002861 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2862 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2863 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2864 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2865
2866 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2867 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2868 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2869 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2870
2871 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2872 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002873 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002874 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2875 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2876 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2877 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2878 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2879 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002880
Takashi Iwai937b4162008-02-11 14:52:36 +01002881 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2882 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2883
Takashi Iwai16ded522005-06-10 19:58:24 +02002884 { }
2885};
2886
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002887/*
2888 * ASUS pin configuration:
2889 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2890 */
2891static struct hda_verb alc880_pin_asus_init_verbs[] = {
2892 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2893 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2894 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2895 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2896
2897 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2898 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2899 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2900 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2901 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2902 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2903 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2904 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2905
2906 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2907 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2908 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2909 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2910 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2911 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2912 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2913 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2914 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002915
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002916 { }
2917};
2918
2919/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002920#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2921#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002922#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002923
Kailang Yangdf694da2005-12-05 19:42:22 +01002924/* Clevo m520g init */
2925static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2926 /* headphone output */
2927 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2928 /* line-out */
2929 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2930 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2931 /* Line-in */
2932 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2933 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2934 /* CD */
2935 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2936 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2937 /* Mic1 (rear panel) */
2938 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2939 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2940 /* Mic2 (front panel) */
2941 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2942 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2943 /* headphone */
2944 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2945 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2946 /* change to EAPD mode */
2947 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2948 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2949
2950 { }
2951};
2952
2953static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002954 /* change to EAPD mode */
2955 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2956 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2957
Kailang Yangdf694da2005-12-05 19:42:22 +01002958 /* Headphone output */
2959 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2960 /* Front output*/
2961 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2962 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2963
2964 /* Line In pin widget for input */
2965 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2966 /* CD pin widget for input */
2967 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2968 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2969 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2970
2971 /* change to EAPD mode */
2972 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2973 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2974
2975 { }
2976};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002977
2978/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002979 * LG m1 express dual
2980 *
2981 * Pin assignment:
2982 * Rear Line-In/Out (blue): 0x14
2983 * Build-in Mic-In: 0x15
2984 * Speaker-out: 0x17
2985 * HP-Out (green): 0x1b
2986 * Mic-In/Out (red): 0x19
2987 * SPDIF-Out: 0x1e
2988 */
2989
2990/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2991static hda_nid_t alc880_lg_dac_nids[3] = {
2992 0x05, 0x02, 0x03
2993};
2994
2995/* seems analog CD is not working */
2996static struct hda_input_mux alc880_lg_capture_source = {
2997 .num_items = 3,
2998 .items = {
2999 { "Mic", 0x1 },
3000 { "Line", 0x5 },
3001 { "Internal Mic", 0x6 },
3002 },
3003};
3004
3005/* 2,4,6 channel modes */
3006static struct hda_verb alc880_lg_ch2_init[] = {
3007 /* set line-in and mic-in to input */
3008 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3009 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3010 { }
3011};
3012
3013static struct hda_verb alc880_lg_ch4_init[] = {
3014 /* set line-in to out and mic-in to input */
3015 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3016 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3017 { }
3018};
3019
3020static struct hda_verb alc880_lg_ch6_init[] = {
3021 /* set line-in and mic-in to output */
3022 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3023 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3024 { }
3025};
3026
3027static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3028 { 2, alc880_lg_ch2_init },
3029 { 4, alc880_lg_ch4_init },
3030 { 6, alc880_lg_ch6_init },
3031};
3032
3033static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003034 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3035 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003036 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3037 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3038 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3039 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3040 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3041 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3042 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3043 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3044 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3045 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3046 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3047 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3048 {
3049 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3050 .name = "Channel Mode",
3051 .info = alc_ch_mode_info,
3052 .get = alc_ch_mode_get,
3053 .put = alc_ch_mode_put,
3054 },
3055 { } /* end */
3056};
3057
3058static struct hda_verb alc880_lg_init_verbs[] = {
3059 /* set capture source to mic-in */
3060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3061 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3063 /* mute all amp mixer inputs */
3064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003067 /* line-in to input */
3068 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3069 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3070 /* built-in mic */
3071 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3073 /* speaker-out */
3074 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3075 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3076 /* mic-in to input */
3077 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3078 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3079 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3080 /* HP-out */
3081 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3082 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3083 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3084 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003085 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003086 { }
3087};
3088
3089/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003090static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003091{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003092 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003093
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003094 spec->autocfg.hp_pins[0] = 0x1b;
3095 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003096}
3097
3098/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003099 * LG LW20
3100 *
3101 * Pin assignment:
3102 * Speaker-out: 0x14
3103 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003104 * Built-in Mic-In: 0x19
3105 * Line-In: 0x1b
3106 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003107 * SPDIF-Out: 0x1e
3108 */
3109
Takashi Iwaid6815182006-03-23 16:06:23 +01003110static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003111 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003112 .items = {
3113 { "Mic", 0x0 },
3114 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003115 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003116 },
3117};
3118
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003119#define alc880_lg_lw_modes alc880_threestack_modes
3120
Takashi Iwaid6815182006-03-23 16:06:23 +01003121static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003122 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3123 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3124 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3125 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3126 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3127 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3128 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3129 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3130 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3131 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003132 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3133 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3134 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3135 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003136 {
3137 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3138 .name = "Channel Mode",
3139 .info = alc_ch_mode_info,
3140 .get = alc_ch_mode_get,
3141 .put = alc_ch_mode_put,
3142 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003143 { } /* end */
3144};
3145
3146static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003147 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3148 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3149 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3150
Takashi Iwaid6815182006-03-23 16:06:23 +01003151 /* set capture source to mic-in */
3152 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3153 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3154 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003155 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003156 /* speaker-out */
3157 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3158 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3159 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003160 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3161 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3162 /* mic-in to input */
3163 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3164 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3165 /* built-in mic */
3166 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3167 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3168 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003169 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003170 { }
3171};
3172
3173/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003174static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003175{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003176 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003177
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003178 spec->autocfg.hp_pins[0] = 0x1b;
3179 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003180}
3181
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003182static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3183 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3184 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3185 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3186 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3187 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3188 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3189 { } /* end */
3190};
3191
3192static struct hda_input_mux alc880_medion_rim_capture_source = {
3193 .num_items = 2,
3194 .items = {
3195 { "Mic", 0x0 },
3196 { "Internal Mic", 0x1 },
3197 },
3198};
3199
3200static struct hda_verb alc880_medion_rim_init_verbs[] = {
3201 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3202
3203 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3204 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3205
3206 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3207 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3208 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3209 /* Mic2 (as headphone out) for HP output */
3210 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3211 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3212 /* Internal Speaker */
3213 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3214 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3215
3216 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3217 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3218
3219 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3220 { }
3221};
3222
3223/* toggle speaker-output according to the hp-jack state */
3224static void alc880_medion_rim_automute(struct hda_codec *codec)
3225{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003226 struct alc_spec *spec = codec->spec;
3227 alc_automute_amp(codec);
3228 /* toggle EAPD */
3229 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003230 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3231 else
3232 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3233}
3234
3235static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3236 unsigned int res)
3237{
3238 /* Looks like the unsol event is incompatible with the standard
3239 * definition. 4bit tag is placed at 28 bit!
3240 */
3241 if ((res >> 28) == ALC880_HP_EVENT)
3242 alc880_medion_rim_automute(codec);
3243}
3244
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003245static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003246{
3247 struct alc_spec *spec = codec->spec;
3248
3249 spec->autocfg.hp_pins[0] = 0x14;
3250 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003251}
3252
Takashi Iwaicb53c622007-08-10 17:21:45 +02003253#ifdef CONFIG_SND_HDA_POWER_SAVE
3254static struct hda_amp_list alc880_loopbacks[] = {
3255 { 0x0b, HDA_INPUT, 0 },
3256 { 0x0b, HDA_INPUT, 1 },
3257 { 0x0b, HDA_INPUT, 2 },
3258 { 0x0b, HDA_INPUT, 3 },
3259 { 0x0b, HDA_INPUT, 4 },
3260 { } /* end */
3261};
3262
3263static struct hda_amp_list alc880_lg_loopbacks[] = {
3264 { 0x0b, HDA_INPUT, 1 },
3265 { 0x0b, HDA_INPUT, 6 },
3266 { 0x0b, HDA_INPUT, 7 },
3267 { } /* end */
3268};
3269#endif
3270
Takashi Iwaid6815182006-03-23 16:06:23 +01003271/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003272 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003273 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003274
Linus Torvalds1da177e2005-04-16 15:20:36 -07003275static int alc_init(struct hda_codec *codec)
3276{
3277 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003278 unsigned int i;
3279
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003280 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003281 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003282
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003283 for (i = 0; i < spec->num_init_verbs; i++)
3284 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003285
3286 if (spec->init_hook)
3287 spec->init_hook(codec);
3288
Linus Torvalds1da177e2005-04-16 15:20:36 -07003289 return 0;
3290}
3291
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003292static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3293{
3294 struct alc_spec *spec = codec->spec;
3295
3296 if (spec->unsol_event)
3297 spec->unsol_event(codec, res);
3298}
3299
Takashi Iwaicb53c622007-08-10 17:21:45 +02003300#ifdef CONFIG_SND_HDA_POWER_SAVE
3301static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3302{
3303 struct alc_spec *spec = codec->spec;
3304 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3305}
3306#endif
3307
Linus Torvalds1da177e2005-04-16 15:20:36 -07003308/*
3309 * Analog playback callbacks
3310 */
3311static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3312 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003313 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003314{
3315 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003316 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3317 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003318}
3319
3320static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3321 struct hda_codec *codec,
3322 unsigned int stream_tag,
3323 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003324 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003325{
3326 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003327 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3328 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003329}
3330
3331static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3332 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003333 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003334{
3335 struct alc_spec *spec = codec->spec;
3336 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3337}
3338
3339/*
3340 * Digital out
3341 */
3342static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3343 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003344 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003345{
3346 struct alc_spec *spec = codec->spec;
3347 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3348}
3349
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003350static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3351 struct hda_codec *codec,
3352 unsigned int stream_tag,
3353 unsigned int format,
3354 struct snd_pcm_substream *substream)
3355{
3356 struct alc_spec *spec = codec->spec;
3357 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3358 stream_tag, format, substream);
3359}
3360
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003361static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3362 struct hda_codec *codec,
3363 struct snd_pcm_substream *substream)
3364{
3365 struct alc_spec *spec = codec->spec;
3366 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3367}
3368
Linus Torvalds1da177e2005-04-16 15:20:36 -07003369static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3370 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003371 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003372{
3373 struct alc_spec *spec = codec->spec;
3374 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3375}
3376
3377/*
3378 * Analog capture
3379 */
Takashi Iwai63300792008-01-24 15:31:36 +01003380static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003381 struct hda_codec *codec,
3382 unsigned int stream_tag,
3383 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003384 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003385{
3386 struct alc_spec *spec = codec->spec;
3387
Takashi Iwai63300792008-01-24 15:31:36 +01003388 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003389 stream_tag, 0, format);
3390 return 0;
3391}
3392
Takashi Iwai63300792008-01-24 15:31:36 +01003393static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003394 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003395 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003396{
3397 struct alc_spec *spec = codec->spec;
3398
Takashi Iwai888afa12008-03-18 09:57:50 +01003399 snd_hda_codec_cleanup_stream(codec,
3400 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003401 return 0;
3402}
3403
3404
3405/*
3406 */
3407static struct hda_pcm_stream alc880_pcm_analog_playback = {
3408 .substreams = 1,
3409 .channels_min = 2,
3410 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003411 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003412 .ops = {
3413 .open = alc880_playback_pcm_open,
3414 .prepare = alc880_playback_pcm_prepare,
3415 .cleanup = alc880_playback_pcm_cleanup
3416 },
3417};
3418
3419static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003420 .substreams = 1,
3421 .channels_min = 2,
3422 .channels_max = 2,
3423 /* NID is set in alc_build_pcms */
3424};
3425
3426static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3427 .substreams = 1,
3428 .channels_min = 2,
3429 .channels_max = 2,
3430 /* NID is set in alc_build_pcms */
3431};
3432
3433static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3434 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003435 .channels_min = 2,
3436 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003437 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003438 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003439 .prepare = alc880_alt_capture_pcm_prepare,
3440 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003441 },
3442};
3443
3444static struct hda_pcm_stream alc880_pcm_digital_playback = {
3445 .substreams = 1,
3446 .channels_min = 2,
3447 .channels_max = 2,
3448 /* NID is set in alc_build_pcms */
3449 .ops = {
3450 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003451 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003452 .prepare = alc880_dig_playback_pcm_prepare,
3453 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003454 },
3455};
3456
3457static struct hda_pcm_stream alc880_pcm_digital_capture = {
3458 .substreams = 1,
3459 .channels_min = 2,
3460 .channels_max = 2,
3461 /* NID is set in alc_build_pcms */
3462};
3463
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003464/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003465static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003466 .substreams = 0,
3467 .channels_min = 0,
3468 .channels_max = 0,
3469};
3470
Linus Torvalds1da177e2005-04-16 15:20:36 -07003471static int alc_build_pcms(struct hda_codec *codec)
3472{
3473 struct alc_spec *spec = codec->spec;
3474 struct hda_pcm *info = spec->pcm_rec;
3475 int i;
3476
3477 codec->num_pcms = 1;
3478 codec->pcm_info = info;
3479
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003480 if (spec->no_analog)
3481 goto skip_analog;
3482
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003483 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3484 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003485 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003486
Takashi Iwai4a471b72005-12-07 13:56:29 +01003487 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003488 if (snd_BUG_ON(!spec->multiout.dac_nids))
3489 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003490 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3491 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3492 }
3493 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003494 if (snd_BUG_ON(!spec->adc_nids))
3495 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003496 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3497 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3498 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003499
Takashi Iwai4a471b72005-12-07 13:56:29 +01003500 if (spec->channel_mode) {
3501 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3502 for (i = 0; i < spec->num_channel_mode; i++) {
3503 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3504 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3505 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003506 }
3507 }
3508
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003509 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003510 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003511 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003512 snprintf(spec->stream_name_digital,
3513 sizeof(spec->stream_name_digital),
3514 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003515 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003516 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003517 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003518 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003519 if (spec->dig_out_type)
3520 info->pcm_type = spec->dig_out_type;
3521 else
3522 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003523 if (spec->multiout.dig_out_nid &&
3524 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003525 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3526 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3527 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003528 if (spec->dig_in_nid &&
3529 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003530 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3531 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3532 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003533 /* FIXME: do we need this for all Realtek codec models? */
3534 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003535 }
3536
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003537 if (spec->no_analog)
3538 return 0;
3539
Takashi Iwaie08a0072006-09-07 17:52:14 +02003540 /* If the use of more than one ADC is requested for the current
3541 * model, configure a second analog capture-only PCM.
3542 */
3543 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003544 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3545 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003546 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003547 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003548 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003549 if (spec->alt_dac_nid) {
3550 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3551 *spec->stream_analog_alt_playback;
3552 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3553 spec->alt_dac_nid;
3554 } else {
3555 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3556 alc_pcm_null_stream;
3557 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3558 }
3559 if (spec->num_adc_nids > 1) {
3560 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3561 *spec->stream_analog_alt_capture;
3562 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3563 spec->adc_nids[1];
3564 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3565 spec->num_adc_nids - 1;
3566 } else {
3567 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3568 alc_pcm_null_stream;
3569 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003570 }
3571 }
3572
Linus Torvalds1da177e2005-04-16 15:20:36 -07003573 return 0;
3574}
3575
Takashi Iwai603c4012008-07-30 15:01:44 +02003576static void alc_free_kctls(struct hda_codec *codec)
3577{
3578 struct alc_spec *spec = codec->spec;
3579
3580 if (spec->kctls.list) {
3581 struct snd_kcontrol_new *kctl = spec->kctls.list;
3582 int i;
3583 for (i = 0; i < spec->kctls.used; i++)
3584 kfree(kctl[i].name);
3585 }
3586 snd_array_free(&spec->kctls);
3587}
3588
Linus Torvalds1da177e2005-04-16 15:20:36 -07003589static void alc_free(struct hda_codec *codec)
3590{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003591 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003592
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003593 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003594 return;
3595
Takashi Iwai603c4012008-07-30 15:01:44 +02003596 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003597 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003598 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003599}
3600
Takashi Iwaie044c392008-10-27 16:56:24 +01003601#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003602static int alc_resume(struct hda_codec *codec)
3603{
Takashi Iwaie044c392008-10-27 16:56:24 +01003604 codec->patch_ops.init(codec);
3605 snd_hda_codec_resume_amp(codec);
3606 snd_hda_codec_resume_cache(codec);
3607 return 0;
3608}
Takashi Iwaie044c392008-10-27 16:56:24 +01003609#endif
3610
Linus Torvalds1da177e2005-04-16 15:20:36 -07003611/*
3612 */
3613static struct hda_codec_ops alc_patch_ops = {
3614 .build_controls = alc_build_controls,
3615 .build_pcms = alc_build_pcms,
3616 .init = alc_init,
3617 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003618 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003619#ifdef SND_HDA_NEEDS_RESUME
3620 .resume = alc_resume,
3621#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003622#ifdef CONFIG_SND_HDA_POWER_SAVE
3623 .check_power_status = alc_check_power_status,
3624#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003625};
3626
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003627
3628/*
3629 * Test configuration for debugging
3630 *
3631 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3632 * enum controls.
3633 */
3634#ifdef CONFIG_SND_DEBUG
3635static hda_nid_t alc880_test_dac_nids[4] = {
3636 0x02, 0x03, 0x04, 0x05
3637};
3638
3639static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003640 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003641 .items = {
3642 { "In-1", 0x0 },
3643 { "In-2", 0x1 },
3644 { "In-3", 0x2 },
3645 { "In-4", 0x3 },
3646 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003647 { "Front", 0x5 },
3648 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003649 },
3650};
3651
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003652static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003653 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003654 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003655 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003656 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003657};
3658
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003659static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3660 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003661{
3662 static char *texts[] = {
3663 "N/A", "Line Out", "HP Out",
3664 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3665 };
3666 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3667 uinfo->count = 1;
3668 uinfo->value.enumerated.items = 8;
3669 if (uinfo->value.enumerated.item >= 8)
3670 uinfo->value.enumerated.item = 7;
3671 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3672 return 0;
3673}
3674
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003675static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3676 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003677{
3678 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3679 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3680 unsigned int pin_ctl, item = 0;
3681
3682 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3683 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3684 if (pin_ctl & AC_PINCTL_OUT_EN) {
3685 if (pin_ctl & AC_PINCTL_HP_EN)
3686 item = 2;
3687 else
3688 item = 1;
3689 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3690 switch (pin_ctl & AC_PINCTL_VREFEN) {
3691 case AC_PINCTL_VREF_HIZ: item = 3; break;
3692 case AC_PINCTL_VREF_50: item = 4; break;
3693 case AC_PINCTL_VREF_GRD: item = 5; break;
3694 case AC_PINCTL_VREF_80: item = 6; break;
3695 case AC_PINCTL_VREF_100: item = 7; break;
3696 }
3697 }
3698 ucontrol->value.enumerated.item[0] = item;
3699 return 0;
3700}
3701
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003702static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3703 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003704{
3705 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3706 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3707 static unsigned int ctls[] = {
3708 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3709 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3710 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3711 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3712 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3713 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3714 };
3715 unsigned int old_ctl, new_ctl;
3716
3717 old_ctl = snd_hda_codec_read(codec, nid, 0,
3718 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3719 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3720 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003721 int val;
3722 snd_hda_codec_write_cache(codec, nid, 0,
3723 AC_VERB_SET_PIN_WIDGET_CONTROL,
3724 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003725 val = ucontrol->value.enumerated.item[0] >= 3 ?
3726 HDA_AMP_MUTE : 0;
3727 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3728 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003729 return 1;
3730 }
3731 return 0;
3732}
3733
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003734static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3735 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003736{
3737 static char *texts[] = {
3738 "Front", "Surround", "CLFE", "Side"
3739 };
3740 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3741 uinfo->count = 1;
3742 uinfo->value.enumerated.items = 4;
3743 if (uinfo->value.enumerated.item >= 4)
3744 uinfo->value.enumerated.item = 3;
3745 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3746 return 0;
3747}
3748
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003749static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3750 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003751{
3752 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3753 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3754 unsigned int sel;
3755
3756 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3757 ucontrol->value.enumerated.item[0] = sel & 3;
3758 return 0;
3759}
3760
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003761static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3762 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003763{
3764 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3765 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3766 unsigned int sel;
3767
3768 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3769 if (ucontrol->value.enumerated.item[0] != sel) {
3770 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003771 snd_hda_codec_write_cache(codec, nid, 0,
3772 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003773 return 1;
3774 }
3775 return 0;
3776}
3777
3778#define PIN_CTL_TEST(xname,nid) { \
3779 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3780 .name = xname, \
3781 .info = alc_test_pin_ctl_info, \
3782 .get = alc_test_pin_ctl_get, \
3783 .put = alc_test_pin_ctl_put, \
3784 .private_value = nid \
3785 }
3786
3787#define PIN_SRC_TEST(xname,nid) { \
3788 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3789 .name = xname, \
3790 .info = alc_test_pin_src_info, \
3791 .get = alc_test_pin_src_get, \
3792 .put = alc_test_pin_src_put, \
3793 .private_value = nid \
3794 }
3795
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003796static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003797 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3798 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3799 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3800 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003801 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3802 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3803 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3804 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003805 PIN_CTL_TEST("Front Pin Mode", 0x14),
3806 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3807 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3808 PIN_CTL_TEST("Side Pin Mode", 0x17),
3809 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3810 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3811 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3812 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3813 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3814 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3815 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3816 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3817 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3818 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3819 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3820 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3821 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3822 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3823 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3824 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3825 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3826 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003827 {
3828 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3829 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003830 .info = alc_ch_mode_info,
3831 .get = alc_ch_mode_get,
3832 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003833 },
3834 { } /* end */
3835};
3836
3837static struct hda_verb alc880_test_init_verbs[] = {
3838 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3843 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3844 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3845 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3846 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003847 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003848 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3849 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3850 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3851 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003852 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003853 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3854 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3855 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3856 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003857 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003858 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3859 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3860 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3861 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003862 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003863 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3864 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003865 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3866 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3867 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003868 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003869 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3870 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3871 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3872 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003873 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003874 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003875 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003876 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003877 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003878 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003879 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003880 /* Analog input/passthru */
3881 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3882 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3883 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3884 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3885 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003886 { }
3887};
3888#endif
3889
Linus Torvalds1da177e2005-04-16 15:20:36 -07003890/*
3891 */
3892
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003893static const char *alc880_models[ALC880_MODEL_LAST] = {
3894 [ALC880_3ST] = "3stack",
3895 [ALC880_TCL_S700] = "tcl",
3896 [ALC880_3ST_DIG] = "3stack-digout",
3897 [ALC880_CLEVO] = "clevo",
3898 [ALC880_5ST] = "5stack",
3899 [ALC880_5ST_DIG] = "5stack-digout",
3900 [ALC880_W810] = "w810",
3901 [ALC880_Z71V] = "z71v",
3902 [ALC880_6ST] = "6stack",
3903 [ALC880_6ST_DIG] = "6stack-digout",
3904 [ALC880_ASUS] = "asus",
3905 [ALC880_ASUS_W1V] = "asus-w1v",
3906 [ALC880_ASUS_DIG] = "asus-dig",
3907 [ALC880_ASUS_DIG2] = "asus-dig2",
3908 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003909 [ALC880_UNIWILL_P53] = "uniwill-p53",
3910 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003911 [ALC880_F1734] = "F1734",
3912 [ALC880_LG] = "lg",
3913 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003914 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003915#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003916 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003917#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003918 [ALC880_AUTO] = "auto",
3919};
3920
3921static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003922 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003923 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3924 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3925 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3926 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3927 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3928 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3929 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3930 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003931 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3932 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003933 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3934 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3935 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3936 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3937 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3938 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3939 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3940 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3941 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3942 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003943 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003944 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3945 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3946 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003947 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003948 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003949 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3950 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003951 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3952 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003953 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3954 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3955 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3956 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003957 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3958 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003959 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003960 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003961 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003962 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003963 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3964 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003965 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003966 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003967 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003968 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003969 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003970 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003971 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003972 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003973 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003974 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3975 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003976 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003977 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3978 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3979 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3980 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003981 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3982 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003983 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003984 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003985 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3986 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003987 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3988 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3989 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003990 /* default Intel */
3991 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003992 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3993 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003994 {}
3995};
3996
Takashi Iwai16ded522005-06-10 19:58:24 +02003997/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003998 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003999 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004000static struct alc_config_preset alc880_presets[] = {
4001 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004002 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004003 .init_verbs = { alc880_volume_init_verbs,
4004 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004005 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004006 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004007 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4008 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004009 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004010 .input_mux = &alc880_capture_source,
4011 },
4012 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004013 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004014 .init_verbs = { alc880_volume_init_verbs,
4015 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004016 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004017 .dac_nids = alc880_dac_nids,
4018 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004019 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4020 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004021 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004022 .input_mux = &alc880_capture_source,
4023 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004024 [ALC880_TCL_S700] = {
4025 .mixers = { alc880_tcl_s700_mixer },
4026 .init_verbs = { alc880_volume_init_verbs,
4027 alc880_pin_tcl_S700_init_verbs,
4028 alc880_gpio2_init_verbs },
4029 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4030 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004031 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4032 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004033 .hp_nid = 0x03,
4034 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4035 .channel_mode = alc880_2_jack_modes,
4036 .input_mux = &alc880_capture_source,
4037 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004038 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004039 .mixers = { alc880_three_stack_mixer,
4040 alc880_five_stack_mixer},
4041 .init_verbs = { alc880_volume_init_verbs,
4042 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004043 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4044 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004045 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4046 .channel_mode = alc880_fivestack_modes,
4047 .input_mux = &alc880_capture_source,
4048 },
4049 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004050 .mixers = { alc880_three_stack_mixer,
4051 alc880_five_stack_mixer },
4052 .init_verbs = { alc880_volume_init_verbs,
4053 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004054 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4055 .dac_nids = alc880_dac_nids,
4056 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004057 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4058 .channel_mode = alc880_fivestack_modes,
4059 .input_mux = &alc880_capture_source,
4060 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004061 [ALC880_6ST] = {
4062 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004063 .init_verbs = { alc880_volume_init_verbs,
4064 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004065 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4066 .dac_nids = alc880_6st_dac_nids,
4067 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4068 .channel_mode = alc880_sixstack_modes,
4069 .input_mux = &alc880_6stack_capture_source,
4070 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004071 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004072 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004073 .init_verbs = { alc880_volume_init_verbs,
4074 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004075 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4076 .dac_nids = alc880_6st_dac_nids,
4077 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004078 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4079 .channel_mode = alc880_sixstack_modes,
4080 .input_mux = &alc880_6stack_capture_source,
4081 },
4082 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004083 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004084 .init_verbs = { alc880_volume_init_verbs,
4085 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004086 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004087 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4088 .dac_nids = alc880_w810_dac_nids,
4089 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004090 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4091 .channel_mode = alc880_w810_modes,
4092 .input_mux = &alc880_capture_source,
4093 },
4094 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004095 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004096 .init_verbs = { alc880_volume_init_verbs,
4097 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004098 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4099 .dac_nids = alc880_z71v_dac_nids,
4100 .dig_out_nid = ALC880_DIGOUT_NID,
4101 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004102 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4103 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004104 .input_mux = &alc880_capture_source,
4105 },
4106 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004107 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004108 .init_verbs = { alc880_volume_init_verbs,
4109 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004110 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4111 .dac_nids = alc880_f1734_dac_nids,
4112 .hp_nid = 0x02,
4113 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4114 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004115 .input_mux = &alc880_f1734_capture_source,
4116 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004117 .setup = alc880_uniwill_p53_setup,
4118 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004119 },
4120 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004121 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004122 .init_verbs = { alc880_volume_init_verbs,
4123 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004124 alc880_gpio1_init_verbs },
4125 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4126 .dac_nids = alc880_asus_dac_nids,
4127 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4128 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004129 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004130 .input_mux = &alc880_capture_source,
4131 },
4132 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004133 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004134 .init_verbs = { alc880_volume_init_verbs,
4135 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004136 alc880_gpio1_init_verbs },
4137 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4138 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004139 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004140 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4141 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004142 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004143 .input_mux = &alc880_capture_source,
4144 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004145 [ALC880_ASUS_DIG2] = {
4146 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004147 .init_verbs = { alc880_volume_init_verbs,
4148 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004149 alc880_gpio2_init_verbs }, /* use GPIO2 */
4150 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4151 .dac_nids = alc880_asus_dac_nids,
4152 .dig_out_nid = ALC880_DIGOUT_NID,
4153 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4154 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004155 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004156 .input_mux = &alc880_capture_source,
4157 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004158 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004159 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004160 .init_verbs = { alc880_volume_init_verbs,
4161 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004162 alc880_gpio1_init_verbs },
4163 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4164 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004165 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004166 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4167 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004168 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004169 .input_mux = &alc880_capture_source,
4170 },
4171 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004172 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004173 .init_verbs = { alc880_volume_init_verbs,
4174 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004175 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4176 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004177 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004178 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4179 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004180 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004181 .input_mux = &alc880_capture_source,
4182 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004183 [ALC880_UNIWILL] = {
4184 .mixers = { alc880_uniwill_mixer },
4185 .init_verbs = { alc880_volume_init_verbs,
4186 alc880_uniwill_init_verbs },
4187 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4188 .dac_nids = alc880_asus_dac_nids,
4189 .dig_out_nid = ALC880_DIGOUT_NID,
4190 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4191 .channel_mode = alc880_threestack_modes,
4192 .need_dac_fix = 1,
4193 .input_mux = &alc880_capture_source,
4194 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004195 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004196 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004197 },
4198 [ALC880_UNIWILL_P53] = {
4199 .mixers = { alc880_uniwill_p53_mixer },
4200 .init_verbs = { alc880_volume_init_verbs,
4201 alc880_uniwill_p53_init_verbs },
4202 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4203 .dac_nids = alc880_asus_dac_nids,
4204 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004205 .channel_mode = alc880_threestack_modes,
4206 .input_mux = &alc880_capture_source,
4207 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004208 .setup = alc880_uniwill_p53_setup,
4209 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004210 },
4211 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004212 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004213 .init_verbs = { alc880_volume_init_verbs,
4214 alc880_uniwill_p53_init_verbs,
4215 alc880_beep_init_verbs },
4216 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4217 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004218 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004219 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4220 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004221 .input_mux = &alc880_capture_source,
4222 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004223 .setup = alc880_uniwill_p53_setup,
4224 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004225 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004226 [ALC880_CLEVO] = {
4227 .mixers = { alc880_three_stack_mixer },
4228 .init_verbs = { alc880_volume_init_verbs,
4229 alc880_pin_clevo_init_verbs },
4230 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4231 .dac_nids = alc880_dac_nids,
4232 .hp_nid = 0x03,
4233 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4234 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004235 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004236 .input_mux = &alc880_capture_source,
4237 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004238 [ALC880_LG] = {
4239 .mixers = { alc880_lg_mixer },
4240 .init_verbs = { alc880_volume_init_verbs,
4241 alc880_lg_init_verbs },
4242 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4243 .dac_nids = alc880_lg_dac_nids,
4244 .dig_out_nid = ALC880_DIGOUT_NID,
4245 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4246 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004247 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004248 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004249 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004250 .setup = alc880_lg_setup,
4251 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004252#ifdef CONFIG_SND_HDA_POWER_SAVE
4253 .loopbacks = alc880_lg_loopbacks,
4254#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004255 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004256 [ALC880_LG_LW] = {
4257 .mixers = { alc880_lg_lw_mixer },
4258 .init_verbs = { alc880_volume_init_verbs,
4259 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004260 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004261 .dac_nids = alc880_dac_nids,
4262 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004263 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4264 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004265 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004266 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004267 .setup = alc880_lg_lw_setup,
4268 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004269 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004270 [ALC880_MEDION_RIM] = {
4271 .mixers = { alc880_medion_rim_mixer },
4272 .init_verbs = { alc880_volume_init_verbs,
4273 alc880_medion_rim_init_verbs,
4274 alc_gpio2_init_verbs },
4275 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4276 .dac_nids = alc880_dac_nids,
4277 .dig_out_nid = ALC880_DIGOUT_NID,
4278 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4279 .channel_mode = alc880_2_jack_modes,
4280 .input_mux = &alc880_medion_rim_capture_source,
4281 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004282 .setup = alc880_medion_rim_setup,
4283 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004284 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004285#ifdef CONFIG_SND_DEBUG
4286 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004287 .mixers = { alc880_test_mixer },
4288 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004289 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4290 .dac_nids = alc880_test_dac_nids,
4291 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004292 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4293 .channel_mode = alc880_test_modes,
4294 .input_mux = &alc880_test_capture_source,
4295 },
4296#endif
4297};
4298
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004299/*
4300 * Automatic parse of I/O pins from the BIOS configuration
4301 */
4302
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004303enum {
4304 ALC_CTL_WIDGET_VOL,
4305 ALC_CTL_WIDGET_MUTE,
4306 ALC_CTL_BIND_MUTE,
4307};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004308static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004309 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4310 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004311 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004312};
4313
4314/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004315static int add_control(struct alc_spec *spec, int type, const char *name,
4316 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004317{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004318 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004319
Takashi Iwai603c4012008-07-30 15:01:44 +02004320 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4321 knew = snd_array_new(&spec->kctls);
4322 if (!knew)
4323 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004324 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004325 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004326 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004327 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004328 if (get_amp_nid_(val))
Takashi Iwai9c96fa52009-11-16 11:25:33 +01004329 knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004330 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004331 return 0;
4332}
4333
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004334static int add_control_with_pfx(struct alc_spec *spec, int type,
4335 const char *pfx, const char *dir,
4336 const char *sfx, unsigned long val)
4337{
4338 char name[32];
4339 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4340 return add_control(spec, type, name, val);
4341}
4342
4343#define add_pb_vol_ctrl(spec, type, pfx, val) \
4344 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4345#define add_pb_sw_ctrl(spec, type, pfx, val) \
4346 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4347
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004348#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4349#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4350#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4351#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004352#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4353#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4354#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4355#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4356#define ALC880_PIN_CD_NID 0x1c
4357
4358/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004359static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4360 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004361{
4362 hda_nid_t nid;
4363 int assigned[4];
4364 int i, j;
4365
4366 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004367 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004368
4369 /* check the pins hardwired to audio widget */
4370 for (i = 0; i < cfg->line_outs; i++) {
4371 nid = cfg->line_out_pins[i];
4372 if (alc880_is_fixed_pin(nid)) {
4373 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004374 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004375 assigned[idx] = 1;
4376 }
4377 }
4378 /* left pins can be connect to any audio widget */
4379 for (i = 0; i < cfg->line_outs; i++) {
4380 nid = cfg->line_out_pins[i];
4381 if (alc880_is_fixed_pin(nid))
4382 continue;
4383 /* search for an empty channel */
4384 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004385 if (!assigned[j]) {
4386 spec->multiout.dac_nids[i] =
4387 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004388 assigned[j] = 1;
4389 break;
4390 }
4391 }
4392 }
4393 spec->multiout.num_dacs = cfg->line_outs;
4394 return 0;
4395}
4396
4397/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004398static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4399 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004400{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004401 static const char *chname[4] = {
4402 "Front", "Surround", NULL /*CLFE*/, "Side"
4403 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004404 hda_nid_t nid;
4405 int i, err;
4406
4407 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004408 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004409 continue;
4410 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4411 if (i == 2) {
4412 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004413 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4414 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004415 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4416 HDA_OUTPUT));
4417 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004418 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004419 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4420 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004421 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4422 HDA_OUTPUT));
4423 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004424 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004425 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4426 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004427 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4428 HDA_INPUT));
4429 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004430 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004431 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4432 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004433 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4434 HDA_INPUT));
4435 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004436 return err;
4437 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004438 const char *pfx;
4439 if (cfg->line_outs == 1 &&
4440 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4441 pfx = "Speaker";
4442 else
4443 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004444 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004445 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4446 HDA_OUTPUT));
4447 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004448 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004449 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004450 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4451 HDA_INPUT));
4452 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004453 return err;
4454 }
4455 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004456 return 0;
4457}
4458
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004459/* add playback controls for speaker and HP outputs */
4460static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4461 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004462{
4463 hda_nid_t nid;
4464 int err;
4465
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004466 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004467 return 0;
4468
4469 if (alc880_is_fixed_pin(pin)) {
4470 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004471 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004472 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004473 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004474 else
4475 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004476 /* control HP volume/switch on the output mixer amp */
4477 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004478 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004479 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4480 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004481 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004482 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004483 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4484 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004485 return err;
4486 } else if (alc880_is_multi_pin(pin)) {
4487 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004488 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004489 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004490 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4491 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004492 return err;
4493 }
4494 return 0;
4495}
4496
4497/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004498static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4499 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004500 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004501{
Kailang Yangdf694da2005-12-05 19:42:22 +01004502 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004503
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004504 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004505 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4506 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004507 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004508 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004509 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4510 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004511 return err;
4512 return 0;
4513}
4514
Takashi Iwai05f5f472009-08-25 13:10:18 +02004515static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004516{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004517 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4518 return (pincap & AC_PINCAP_IN) != 0;
4519}
4520
4521/* create playback/capture controls for input pins */
4522static int alc_auto_create_input_ctls(struct hda_codec *codec,
4523 const struct auto_pin_cfg *cfg,
4524 hda_nid_t mixer,
4525 hda_nid_t cap1, hda_nid_t cap2)
4526{
4527 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004528 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004529 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004530
4531 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004532 hda_nid_t pin;
4533
4534 pin = cfg->input_pins[i];
4535 if (!alc_is_input_pin(codec, pin))
4536 continue;
4537
4538 if (mixer) {
4539 idx = get_connection_index(codec, mixer, pin);
4540 if (idx >= 0) {
4541 err = new_analog_input(spec, pin,
4542 auto_pin_cfg_labels[i],
4543 idx, mixer);
4544 if (err < 0)
4545 return err;
4546 }
4547 }
4548
4549 if (!cap1)
4550 continue;
4551 idx = get_connection_index(codec, cap1, pin);
4552 if (idx < 0 && cap2)
4553 idx = get_connection_index(codec, cap2, pin);
4554 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004555 imux->items[imux->num_items].label =
4556 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004557 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004558 imux->num_items++;
4559 }
4560 }
4561 return 0;
4562}
4563
Takashi Iwai05f5f472009-08-25 13:10:18 +02004564static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4565 const struct auto_pin_cfg *cfg)
4566{
4567 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4568}
4569
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004570static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4571 unsigned int pin_type)
4572{
4573 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4574 pin_type);
4575 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004576 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4577 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004578}
4579
Kailang Yangdf694da2005-12-05 19:42:22 +01004580static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4581 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004582 int dac_idx)
4583{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004584 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004585 /* need the manual connection? */
4586 if (alc880_is_multi_pin(nid)) {
4587 struct alc_spec *spec = codec->spec;
4588 int idx = alc880_multi_pin_idx(nid);
4589 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4590 AC_VERB_SET_CONNECT_SEL,
4591 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4592 }
4593}
4594
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004595static int get_pin_type(int line_out_type)
4596{
4597 if (line_out_type == AUTO_PIN_HP_OUT)
4598 return PIN_HP;
4599 else
4600 return PIN_OUT;
4601}
4602
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004603static void alc880_auto_init_multi_out(struct hda_codec *codec)
4604{
4605 struct alc_spec *spec = codec->spec;
4606 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004607
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004608 for (i = 0; i < spec->autocfg.line_outs; i++) {
4609 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004610 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4611 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004612 }
4613}
4614
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004615static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004616{
4617 struct alc_spec *spec = codec->spec;
4618 hda_nid_t pin;
4619
Takashi Iwai82bc9552006-03-21 11:24:42 +01004620 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004621 if (pin) /* connect to front */
4622 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004623 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004624 if (pin) /* connect to front */
4625 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4626}
4627
4628static void alc880_auto_init_analog_input(struct hda_codec *codec)
4629{
4630 struct alc_spec *spec = codec->spec;
4631 int i;
4632
4633 for (i = 0; i < AUTO_PIN_LAST; i++) {
4634 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004635 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004636 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004637 if (nid != ALC880_PIN_CD_NID &&
4638 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004639 snd_hda_codec_write(codec, nid, 0,
4640 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004641 AMP_OUT_MUTE);
4642 }
4643 }
4644}
4645
4646/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004647/* return 1 if successful, 0 if the proper config is not found,
4648 * or a negative error code
4649 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004650static int alc880_parse_auto_config(struct hda_codec *codec)
4651{
4652 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004653 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004654 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004655
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004656 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4657 alc880_ignore);
4658 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004659 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004660 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004661 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004662
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004663 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4664 if (err < 0)
4665 return err;
4666 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4667 if (err < 0)
4668 return err;
4669 err = alc880_auto_create_extra_out(spec,
4670 spec->autocfg.speaker_pins[0],
4671 "Speaker");
4672 if (err < 0)
4673 return err;
4674 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4675 "Headphone");
4676 if (err < 0)
4677 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004678 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004679 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004680 return err;
4681
4682 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4683
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004684 /* check multiple SPDIF-out (for recent codecs) */
4685 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4686 hda_nid_t dig_nid;
4687 err = snd_hda_get_connections(codec,
4688 spec->autocfg.dig_out_pins[i],
4689 &dig_nid, 1);
4690 if (err < 0)
4691 continue;
4692 if (!i)
4693 spec->multiout.dig_out_nid = dig_nid;
4694 else {
4695 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004696 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004697 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004698 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004699 }
4700 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004701 if (spec->autocfg.dig_in_pin)
4702 spec->dig_in_nid = ALC880_DIGIN_NID;
4703
Takashi Iwai603c4012008-07-30 15:01:44 +02004704 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004705 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004706
Takashi Iwaid88897e2008-10-31 15:01:37 +01004707 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004708
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004709 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004710 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004711
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004712 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4713
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004714 return 1;
4715}
4716
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004717/* additional initialization for auto-configuration model */
4718static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004719{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004720 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004721 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004722 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004723 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004724 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004725 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004726}
4727
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004728/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4729 * one of two digital mic pins, e.g. on ALC272
4730 */
4731static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004732{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004733 struct alc_spec *spec = codec->spec;
4734 int i;
4735
4736 for (i = 0; i < spec->num_adc_nids; i++) {
4737 hda_nid_t cap = spec->capsrc_nids ?
4738 spec->capsrc_nids[i] : spec->adc_nids[i];
4739 int iidx, eidx;
4740
4741 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4742 if (iidx < 0)
4743 continue;
4744 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4745 if (eidx < 0)
4746 continue;
4747 spec->int_mic.mux_idx = iidx;
4748 spec->ext_mic.mux_idx = eidx;
4749 if (spec->capsrc_nids)
4750 spec->capsrc_nids += i;
4751 spec->adc_nids += i;
4752 spec->num_adc_nids = 1;
4753 return;
4754 }
4755 snd_printd(KERN_INFO "hda_codec: %s: "
4756 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4757 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4758 spec->auto_mic = 0; /* disable auto-mic to be sure */
4759}
4760
4761static void set_capture_mixer(struct hda_codec *codec)
4762{
4763 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004764 static struct snd_kcontrol_new *caps[2][3] = {
4765 { alc_capture_mixer_nosrc1,
4766 alc_capture_mixer_nosrc2,
4767 alc_capture_mixer_nosrc3 },
4768 { alc_capture_mixer1,
4769 alc_capture_mixer2,
4770 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004771 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004772 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4773 int mux;
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004774 if (spec->auto_mic) {
4775 mux = 0;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004776 fixup_automic_adc(codec);
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004777 } else if (spec->input_mux && spec->input_mux->num_items > 1)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004778 mux = 1;
4779 else
4780 mux = 0;
4781 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4782 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004783}
4784
Takashi Iwai67d634c2009-11-16 15:35:59 +01004785#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004786#define set_beep_amp(spec, nid, idx, dir) \
4787 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01004788#else
4789#define set_beep_amp(spec, nid, idx, dir) /* NOP */
4790#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004791
4792/*
4793 * OK, here we have finally the patch for ALC880
4794 */
4795
Linus Torvalds1da177e2005-04-16 15:20:36 -07004796static int patch_alc880(struct hda_codec *codec)
4797{
4798 struct alc_spec *spec;
4799 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004800 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004801
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004802 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004803 if (spec == NULL)
4804 return -ENOMEM;
4805
4806 codec->spec = spec;
4807
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004808 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4809 alc880_models,
4810 alc880_cfg_tbl);
4811 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004812 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4813 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004814 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004815 }
4816
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004817 if (board_config == ALC880_AUTO) {
4818 /* automatic parse from the BIOS config */
4819 err = alc880_parse_auto_config(codec);
4820 if (err < 0) {
4821 alc_free(codec);
4822 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004823 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004824 printk(KERN_INFO
4825 "hda_codec: Cannot set up configuration "
4826 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004827 board_config = ALC880_3ST;
4828 }
4829 }
4830
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004831 err = snd_hda_attach_beep_device(codec, 0x1);
4832 if (err < 0) {
4833 alc_free(codec);
4834 return err;
4835 }
4836
Kailang Yangdf694da2005-12-05 19:42:22 +01004837 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004838 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004839
Linus Torvalds1da177e2005-04-16 15:20:36 -07004840 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4841 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004842 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004843
Linus Torvalds1da177e2005-04-16 15:20:36 -07004844 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4845 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4846
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004847 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004848 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004849 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004850 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004851 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004852 if (wcap != AC_WID_AUD_IN) {
4853 spec->adc_nids = alc880_adc_nids_alt;
4854 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004855 } else {
4856 spec->adc_nids = alc880_adc_nids;
4857 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004858 }
4859 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004860 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004861 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004862
Takashi Iwai2134ea42008-01-10 16:53:55 +01004863 spec->vmaster_nid = 0x0c;
4864
Linus Torvalds1da177e2005-04-16 15:20:36 -07004865 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004866 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004867 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004868#ifdef CONFIG_SND_HDA_POWER_SAVE
4869 if (!spec->loopback.amplist)
4870 spec->loopback.amplist = alc880_loopbacks;
4871#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004872 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004873
4874 return 0;
4875}
4876
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004877
Linus Torvalds1da177e2005-04-16 15:20:36 -07004878/*
4879 * ALC260 support
4880 */
4881
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004882static hda_nid_t alc260_dac_nids[1] = {
4883 /* front */
4884 0x02,
4885};
4886
4887static hda_nid_t alc260_adc_nids[1] = {
4888 /* ADC0 */
4889 0x04,
4890};
4891
Kailang Yangdf694da2005-12-05 19:42:22 +01004892static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004893 /* ADC1 */
4894 0x05,
4895};
4896
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004897/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4898 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4899 */
4900static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004901 /* ADC0, ADC1 */
4902 0x04, 0x05
4903};
4904
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004905#define ALC260_DIGOUT_NID 0x03
4906#define ALC260_DIGIN_NID 0x06
4907
4908static struct hda_input_mux alc260_capture_source = {
4909 .num_items = 4,
4910 .items = {
4911 { "Mic", 0x0 },
4912 { "Front Mic", 0x1 },
4913 { "Line", 0x2 },
4914 { "CD", 0x4 },
4915 },
4916};
4917
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004918/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004919 * headphone jack and the internal CD lines since these are the only pins at
4920 * which audio can appear. For flexibility, also allow the option of
4921 * recording the mixer output on the second ADC (ADC0 doesn't have a
4922 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004923 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004924static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4925 {
4926 .num_items = 3,
4927 .items = {
4928 { "Mic/Line", 0x0 },
4929 { "CD", 0x4 },
4930 { "Headphone", 0x2 },
4931 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004932 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004933 {
4934 .num_items = 4,
4935 .items = {
4936 { "Mic/Line", 0x0 },
4937 { "CD", 0x4 },
4938 { "Headphone", 0x2 },
4939 { "Mixer", 0x5 },
4940 },
4941 },
4942
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004943};
4944
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004945/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4946 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004947 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004948static struct hda_input_mux alc260_acer_capture_sources[2] = {
4949 {
4950 .num_items = 4,
4951 .items = {
4952 { "Mic", 0x0 },
4953 { "Line", 0x2 },
4954 { "CD", 0x4 },
4955 { "Headphone", 0x5 },
4956 },
4957 },
4958 {
4959 .num_items = 5,
4960 .items = {
4961 { "Mic", 0x0 },
4962 { "Line", 0x2 },
4963 { "CD", 0x4 },
4964 { "Headphone", 0x6 },
4965 { "Mixer", 0x5 },
4966 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004967 },
4968};
Michael Schwingencc959482009-02-22 18:58:45 +01004969
4970/* Maxdata Favorit 100XS */
4971static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4972 {
4973 .num_items = 2,
4974 .items = {
4975 { "Line/Mic", 0x0 },
4976 { "CD", 0x4 },
4977 },
4978 },
4979 {
4980 .num_items = 3,
4981 .items = {
4982 { "Line/Mic", 0x0 },
4983 { "CD", 0x4 },
4984 { "Mixer", 0x5 },
4985 },
4986 },
4987};
4988
Linus Torvalds1da177e2005-04-16 15:20:36 -07004989/*
4990 * This is just place-holder, so there's something for alc_build_pcms to look
4991 * at when it calculates the maximum number of channels. ALC260 has no mixer
4992 * element which allows changing the channel mode, so the verb list is
4993 * never used.
4994 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004995static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004996 { 2, NULL },
4997};
4998
Kailang Yangdf694da2005-12-05 19:42:22 +01004999
5000/* Mixer combinations
5001 *
5002 * basic: base_output + input + pc_beep + capture
5003 * HP: base_output + input + capture_alt
5004 * HP_3013: hp_3013 + input + capture
5005 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005006 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005007 */
5008
5009static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005010 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005011 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005012 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5013 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5014 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5015 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5016 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005017};
Kailang Yangdf694da2005-12-05 19:42:22 +01005018
5019static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005020 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5021 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5022 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5023 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5025 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5026 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5027 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005028 { } /* end */
5029};
5030
Takashi Iwaibec15c32008-01-28 18:16:30 +01005031/* update HP, line and mono out pins according to the master switch */
5032static void alc260_hp_master_update(struct hda_codec *codec,
5033 hda_nid_t hp, hda_nid_t line,
5034 hda_nid_t mono)
5035{
5036 struct alc_spec *spec = codec->spec;
5037 unsigned int val = spec->master_sw ? PIN_HP : 0;
5038 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005039 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005040 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005041 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005042 val);
5043 /* mono (speaker) depending on the HP jack sense */
5044 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005045 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005046 val);
5047}
5048
5049static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5050 struct snd_ctl_elem_value *ucontrol)
5051{
5052 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5053 struct alc_spec *spec = codec->spec;
5054 *ucontrol->value.integer.value = spec->master_sw;
5055 return 0;
5056}
5057
5058static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5059 struct snd_ctl_elem_value *ucontrol)
5060{
5061 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5062 struct alc_spec *spec = codec->spec;
5063 int val = !!*ucontrol->value.integer.value;
5064 hda_nid_t hp, line, mono;
5065
5066 if (val == spec->master_sw)
5067 return 0;
5068 spec->master_sw = val;
5069 hp = (kcontrol->private_value >> 16) & 0xff;
5070 line = (kcontrol->private_value >> 8) & 0xff;
5071 mono = kcontrol->private_value & 0xff;
5072 alc260_hp_master_update(codec, hp, line, mono);
5073 return 1;
5074}
5075
5076static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5077 {
5078 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5079 .name = "Master Playback Switch",
5080 .info = snd_ctl_boolean_mono_info,
5081 .get = alc260_hp_master_sw_get,
5082 .put = alc260_hp_master_sw_put,
5083 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5084 },
5085 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5086 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5087 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5088 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5089 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5090 HDA_OUTPUT),
5091 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5092 { } /* end */
5093};
5094
5095static struct hda_verb alc260_hp_unsol_verbs[] = {
5096 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5097 {},
5098};
5099
5100static void alc260_hp_automute(struct hda_codec *codec)
5101{
5102 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005103
Wu Fengguang864f92b2009-11-18 12:38:02 +08005104 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005105 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5106}
5107
5108static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5109{
5110 if ((res >> 26) == ALC880_HP_EVENT)
5111 alc260_hp_automute(codec);
5112}
5113
Kailang Yangdf694da2005-12-05 19:42:22 +01005114static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005115 {
5116 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5117 .name = "Master Playback Switch",
5118 .info = snd_ctl_boolean_mono_info,
5119 .get = alc260_hp_master_sw_get,
5120 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005121 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005122 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005123 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5124 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5125 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5126 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5127 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5128 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005129 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5130 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005131 { } /* end */
5132};
5133
Kailang Yang3f878302008-08-26 13:02:23 +02005134static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5135 .ops = &snd_hda_bind_vol,
5136 .values = {
5137 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5138 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5139 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5140 0
5141 },
5142};
5143
5144static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5145 .ops = &snd_hda_bind_sw,
5146 .values = {
5147 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5148 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5149 0
5150 },
5151};
5152
5153static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5154 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5155 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5156 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5157 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5158 { } /* end */
5159};
5160
Takashi Iwaibec15c32008-01-28 18:16:30 +01005161static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5162 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5163 {},
5164};
5165
5166static void alc260_hp_3013_automute(struct hda_codec *codec)
5167{
5168 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005169
Wu Fengguang864f92b2009-11-18 12:38:02 +08005170 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005171 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005172}
5173
5174static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5175 unsigned int res)
5176{
5177 if ((res >> 26) == ALC880_HP_EVENT)
5178 alc260_hp_3013_automute(codec);
5179}
5180
Kailang Yang3f878302008-08-26 13:02:23 +02005181static void alc260_hp_3012_automute(struct hda_codec *codec)
5182{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005183 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005184
Kailang Yang3f878302008-08-26 13:02:23 +02005185 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5186 bits);
5187 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5188 bits);
5189 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5190 bits);
5191}
5192
5193static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5194 unsigned int res)
5195{
5196 if ((res >> 26) == ALC880_HP_EVENT)
5197 alc260_hp_3012_automute(codec);
5198}
5199
5200/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005201 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5202 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005203static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005204 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005205 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005206 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005207 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5208 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5209 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5210 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005211 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005212 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5213 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005214 { } /* end */
5215};
5216
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005217/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5218 * versions of the ALC260 don't act on requests to enable mic bias from NID
5219 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5220 * datasheet doesn't mention this restriction. At this stage it's not clear
5221 * whether this behaviour is intentional or is a hardware bug in chip
5222 * revisions available in early 2006. Therefore for now allow the
5223 * "Headphone Jack Mode" control to span all choices, but if it turns out
5224 * that the lack of mic bias for this NID is intentional we could change the
5225 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5226 *
5227 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5228 * don't appear to make the mic bias available from the "line" jack, even
5229 * though the NID used for this jack (0x14) can supply it. The theory is
5230 * that perhaps Acer have included blocking capacitors between the ALC260
5231 * and the output jack. If this turns out to be the case for all such
5232 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5233 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005234 *
5235 * The C20x Tablet series have a mono internal speaker which is controlled
5236 * via the chip's Mono sum widget and pin complex, so include the necessary
5237 * controls for such models. On models without a "mono speaker" the control
5238 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005239 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005240static struct snd_kcontrol_new alc260_acer_mixer[] = {
5241 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5242 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005243 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005244 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005245 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005246 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005247 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005248 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5249 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5250 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5251 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5252 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5253 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5254 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5255 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005256 { } /* end */
5257};
5258
Michael Schwingencc959482009-02-22 18:58:45 +01005259/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5260 */
5261static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5262 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5263 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5264 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5265 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5266 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5267 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5268 { } /* end */
5269};
5270
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005271/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5272 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5273 */
5274static struct snd_kcontrol_new alc260_will_mixer[] = {
5275 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5276 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5277 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5278 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5279 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5280 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5281 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5282 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5283 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5284 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005285 { } /* end */
5286};
5287
5288/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5289 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5290 */
5291static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5292 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5293 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5294 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5295 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5296 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5297 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5298 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5299 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5300 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5301 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5302 { } /* end */
5303};
5304
Kailang Yangdf694da2005-12-05 19:42:22 +01005305/*
5306 * initialization verbs
5307 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005308static struct hda_verb alc260_init_verbs[] = {
5309 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005310 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005311 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005312 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005313 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005314 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005315 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005316 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005317 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005318 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005319 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005320 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005321 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005322 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005323 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005324 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005325 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005326 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5327 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005328 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005329 /* set connection select to line in (default select for this ADC) */
5330 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005331 /* mute capture amp left and right */
5332 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5333 /* set connection select to line in (default select for this ADC) */
5334 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005335 /* set vol=0 Line-Out mixer amp left and right */
5336 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5337 /* unmute pin widget amp left and right (no gain on this amp) */
5338 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5339 /* set vol=0 HP mixer amp left and right */
5340 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5341 /* unmute pin widget amp left and right (no gain on this amp) */
5342 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5343 /* set vol=0 Mono mixer amp left and right */
5344 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5345 /* unmute pin widget amp left and right (no gain on this amp) */
5346 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5347 /* unmute LINE-2 out pin */
5348 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005349 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5350 * Line In 2 = 0x03
5351 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005352 /* mute analog inputs */
5353 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5354 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5355 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5356 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5357 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005358 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005359 /* mute Front out path */
5360 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5361 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5362 /* mute Headphone out path */
5363 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5364 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5365 /* mute Mono out path */
5366 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5367 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005368 { }
5369};
5370
Takashi Iwai474167d2006-05-17 17:17:43 +02005371#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005372static struct hda_verb alc260_hp_init_verbs[] = {
5373 /* Headphone and output */
5374 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5375 /* mono output */
5376 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5377 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5378 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5379 /* Mic2 (front panel) pin widget for input and vref at 80% */
5380 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5381 /* Line In pin widget for input */
5382 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5383 /* Line-2 pin widget for output */
5384 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5385 /* CD pin widget for input */
5386 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5387 /* unmute amp left and right */
5388 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5389 /* set connection select to line in (default select for this ADC) */
5390 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5391 /* unmute Line-Out mixer amp left and right (volume = 0) */
5392 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5393 /* mute pin widget amp left and right (no gain on this amp) */
5394 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5395 /* unmute HP mixer amp left and right (volume = 0) */
5396 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5397 /* mute pin widget amp left and right (no gain on this amp) */
5398 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005399 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5400 * Line In 2 = 0x03
5401 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005402 /* mute analog inputs */
5403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5405 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5406 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5407 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005408 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5409 /* Unmute Front out path */
5410 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5411 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5412 /* Unmute Headphone out path */
5413 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5414 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5415 /* Unmute Mono out path */
5416 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5417 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5418 { }
5419};
Takashi Iwai474167d2006-05-17 17:17:43 +02005420#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005421
5422static struct hda_verb alc260_hp_3013_init_verbs[] = {
5423 /* Line out and output */
5424 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5425 /* mono output */
5426 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5427 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5428 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5429 /* Mic2 (front panel) pin widget for input and vref at 80% */
5430 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5431 /* Line In pin widget for input */
5432 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5433 /* Headphone pin widget for output */
5434 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5435 /* CD pin widget for input */
5436 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5437 /* unmute amp left and right */
5438 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5439 /* set connection select to line in (default select for this ADC) */
5440 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5441 /* unmute Line-Out mixer amp left and right (volume = 0) */
5442 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5443 /* mute pin widget amp left and right (no gain on this amp) */
5444 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5445 /* unmute HP mixer amp left and right (volume = 0) */
5446 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5447 /* mute pin widget amp left and right (no gain on this amp) */
5448 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005449 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5450 * Line In 2 = 0x03
5451 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005452 /* mute analog inputs */
5453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5455 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5456 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5457 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005458 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5459 /* Unmute Front out path */
5460 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5461 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5462 /* Unmute Headphone out path */
5463 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5464 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5465 /* Unmute Mono out path */
5466 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5467 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5468 { }
5469};
5470
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005471/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005472 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5473 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005474 */
5475static struct hda_verb alc260_fujitsu_init_verbs[] = {
5476 /* Disable all GPIOs */
5477 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5478 /* Internal speaker is connected to headphone pin */
5479 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5480 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5481 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005482 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5483 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5484 /* Ensure all other unused pins are disabled and muted. */
5485 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5486 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005487 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005488 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005489 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005490 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5491 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5492 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005493
Jonathan Woithef7ace402006-02-28 11:46:14 +01005494 /* Disable digital (SPDIF) pins */
5495 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5496 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005497
Kailang Yangea1fb292008-08-26 12:58:38 +02005498 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005499 * when acting as an output.
5500 */
5501 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5502
5503 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005504 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5505 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5506 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5507 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5508 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5509 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5510 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5511 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5512 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005513
Jonathan Woithef7ace402006-02-28 11:46:14 +01005514 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5515 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5516 /* Unmute Line1 pin widget output buffer since it starts as an output.
5517 * If the pin mode is changed by the user the pin mode control will
5518 * take care of enabling the pin's input/output buffers as needed.
5519 * Therefore there's no need to enable the input buffer at this
5520 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005521 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005522 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005523 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005524 * mixer ctrl)
5525 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005526 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005527
Jonathan Woithef7ace402006-02-28 11:46:14 +01005528 /* Mute capture amp left and right */
5529 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005530 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005531 * in (on mic1 pin)
5532 */
5533 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005534
Jonathan Woithef7ace402006-02-28 11:46:14 +01005535 /* Do the same for the second ADC: mute capture input amp and
5536 * set ADC connection to line in (on mic1 pin)
5537 */
5538 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5539 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005540
Jonathan Woithef7ace402006-02-28 11:46:14 +01005541 /* Mute all inputs to mixer widget (even unconnected ones) */
5542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005550
5551 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005552};
5553
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005554/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5555 * similar laptops (adapted from Fujitsu init verbs).
5556 */
5557static struct hda_verb alc260_acer_init_verbs[] = {
5558 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5559 * the headphone jack. Turn this on and rely on the standard mute
5560 * methods whenever the user wants to turn these outputs off.
5561 */
5562 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5563 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5564 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5565 /* Internal speaker/Headphone jack is connected to Line-out pin */
5566 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5567 /* Internal microphone/Mic jack is connected to Mic1 pin */
5568 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5569 /* Line In jack is connected to Line1 pin */
5570 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005571 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5572 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005573 /* Ensure all other unused pins are disabled and muted. */
5574 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5575 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005576 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5577 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5578 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5579 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5580 /* Disable digital (SPDIF) pins */
5581 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5582 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5583
Kailang Yangea1fb292008-08-26 12:58:38 +02005584 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005585 * bus when acting as outputs.
5586 */
5587 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5588 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5589
5590 /* Start with output sum widgets muted and their output gains at min */
5591 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5592 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5593 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5594 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5595 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5596 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5597 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5598 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5599 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5600
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005601 /* Unmute Line-out pin widget amp left and right
5602 * (no equiv mixer ctrl)
5603 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005604 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005605 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5606 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005607 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5608 * inputs. If the pin mode is changed by the user the pin mode control
5609 * will take care of enabling the pin's input/output buffers as needed.
5610 * Therefore there's no need to enable the input buffer at this
5611 * stage.
5612 */
5613 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5614 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5615
5616 /* Mute capture amp left and right */
5617 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5618 /* Set ADC connection select to match default mixer setting - mic
5619 * (on mic1 pin)
5620 */
5621 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5622
5623 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005624 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005625 */
5626 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005627 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005628
5629 /* Mute all inputs to mixer widget (even unconnected ones) */
5630 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5633 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5634 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5635 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5636 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5637 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5638
5639 { }
5640};
5641
Michael Schwingencc959482009-02-22 18:58:45 +01005642/* Initialisation sequence for Maxdata Favorit 100XS
5643 * (adapted from Acer init verbs).
5644 */
5645static struct hda_verb alc260_favorit100_init_verbs[] = {
5646 /* GPIO 0 enables the output jack.
5647 * Turn this on and rely on the standard mute
5648 * methods whenever the user wants to turn these outputs off.
5649 */
5650 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5651 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5652 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5653 /* Line/Mic input jack is connected to Mic1 pin */
5654 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5655 /* Ensure all other unused pins are disabled and muted. */
5656 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5657 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5658 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5659 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5660 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5661 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5662 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5663 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5664 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5665 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5666 /* Disable digital (SPDIF) pins */
5667 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5668 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5669
5670 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5671 * bus when acting as outputs.
5672 */
5673 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5674 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5675
5676 /* Start with output sum widgets muted and their output gains at min */
5677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5678 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5679 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5680 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5681 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5682 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5683 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5684 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5685 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5686
5687 /* Unmute Line-out pin widget amp left and right
5688 * (no equiv mixer ctrl)
5689 */
5690 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5691 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5692 * inputs. If the pin mode is changed by the user the pin mode control
5693 * will take care of enabling the pin's input/output buffers as needed.
5694 * Therefore there's no need to enable the input buffer at this
5695 * stage.
5696 */
5697 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5698
5699 /* Mute capture amp left and right */
5700 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5701 /* Set ADC connection select to match default mixer setting - mic
5702 * (on mic1 pin)
5703 */
5704 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5705
5706 /* Do similar with the second ADC: mute capture input amp and
5707 * set ADC connection to mic to match ALSA's default state.
5708 */
5709 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5710 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5711
5712 /* Mute all inputs to mixer widget (even unconnected ones) */
5713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5714 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5715 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5717 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5718 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5719 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5720 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5721
5722 { }
5723};
5724
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005725static struct hda_verb alc260_will_verbs[] = {
5726 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5727 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5728 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5729 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5730 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5731 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5732 {}
5733};
5734
5735static struct hda_verb alc260_replacer_672v_verbs[] = {
5736 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5737 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5738 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5739
5740 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5741 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5742 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5743
5744 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5745 {}
5746};
5747
5748/* toggle speaker-output according to the hp-jack state */
5749static void alc260_replacer_672v_automute(struct hda_codec *codec)
5750{
5751 unsigned int present;
5752
5753 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08005754 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005755 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005756 snd_hda_codec_write_cache(codec, 0x01, 0,
5757 AC_VERB_SET_GPIO_DATA, 1);
5758 snd_hda_codec_write_cache(codec, 0x0f, 0,
5759 AC_VERB_SET_PIN_WIDGET_CONTROL,
5760 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005761 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005762 snd_hda_codec_write_cache(codec, 0x01, 0,
5763 AC_VERB_SET_GPIO_DATA, 0);
5764 snd_hda_codec_write_cache(codec, 0x0f, 0,
5765 AC_VERB_SET_PIN_WIDGET_CONTROL,
5766 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005767 }
5768}
5769
5770static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5771 unsigned int res)
5772{
5773 if ((res >> 26) == ALC880_HP_EVENT)
5774 alc260_replacer_672v_automute(codec);
5775}
5776
Kailang Yang3f878302008-08-26 13:02:23 +02005777static struct hda_verb alc260_hp_dc7600_verbs[] = {
5778 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5779 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5780 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5781 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5782 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5783 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5784 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5785 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5786 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5787 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5788 {}
5789};
5790
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005791/* Test configuration for debugging, modelled after the ALC880 test
5792 * configuration.
5793 */
5794#ifdef CONFIG_SND_DEBUG
5795static hda_nid_t alc260_test_dac_nids[1] = {
5796 0x02,
5797};
5798static hda_nid_t alc260_test_adc_nids[2] = {
5799 0x04, 0x05,
5800};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005801/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005802 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005803 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005804 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005805static struct hda_input_mux alc260_test_capture_sources[2] = {
5806 {
5807 .num_items = 7,
5808 .items = {
5809 { "MIC1 pin", 0x0 },
5810 { "MIC2 pin", 0x1 },
5811 { "LINE1 pin", 0x2 },
5812 { "LINE2 pin", 0x3 },
5813 { "CD pin", 0x4 },
5814 { "LINE-OUT pin", 0x5 },
5815 { "HP-OUT pin", 0x6 },
5816 },
5817 },
5818 {
5819 .num_items = 8,
5820 .items = {
5821 { "MIC1 pin", 0x0 },
5822 { "MIC2 pin", 0x1 },
5823 { "LINE1 pin", 0x2 },
5824 { "LINE2 pin", 0x3 },
5825 { "CD pin", 0x4 },
5826 { "Mixer", 0x5 },
5827 { "LINE-OUT pin", 0x6 },
5828 { "HP-OUT pin", 0x7 },
5829 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005830 },
5831};
5832static struct snd_kcontrol_new alc260_test_mixer[] = {
5833 /* Output driver widgets */
5834 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5835 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5836 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5837 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5838 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5839 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5840
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005841 /* Modes for retasking pin widgets
5842 * Note: the ALC260 doesn't seem to act on requests to enable mic
5843 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5844 * mention this restriction. At this stage it's not clear whether
5845 * this behaviour is intentional or is a hardware bug in chip
5846 * revisions available at least up until early 2006. Therefore for
5847 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5848 * choices, but if it turns out that the lack of mic bias for these
5849 * NIDs is intentional we could change their modes from
5850 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5851 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005852 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5853 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5854 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5855 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5856 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5857 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5858
5859 /* Loopback mixer controls */
5860 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5861 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5862 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5863 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5864 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5865 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5866 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5867 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5868 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5869 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005870 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5871 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5872 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5873 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005874
5875 /* Controls for GPIO pins, assuming they are configured as outputs */
5876 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5877 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5878 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5879 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5880
Jonathan Woithe92621f12006-02-28 11:47:47 +01005881 /* Switches to allow the digital IO pins to be enabled. The datasheet
5882 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005883 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005884 */
5885 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5886 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5887
Jonathan Woithef8225f62008-01-08 12:16:54 +01005888 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5889 * this output to turn on an external amplifier.
5890 */
5891 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5892 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5893
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005894 { } /* end */
5895};
5896static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005897 /* Enable all GPIOs as outputs with an initial value of 0 */
5898 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5899 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5900 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5901
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005902 /* Enable retasking pins as output, initially without power amp */
5903 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5904 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5905 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5906 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5907 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5908 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5909
Jonathan Woithe92621f12006-02-28 11:47:47 +01005910 /* Disable digital (SPDIF) pins initially, but users can enable
5911 * them via a mixer switch. In the case of SPDIF-out, this initverb
5912 * payload also sets the generation to 0, output to be in "consumer"
5913 * PCM format, copyright asserted, no pre-emphasis and no validity
5914 * control.
5915 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005916 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5917 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5918
Kailang Yangea1fb292008-08-26 12:58:38 +02005919 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005920 * OUT1 sum bus when acting as an output.
5921 */
5922 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5923 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5924 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5925 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5926
5927 /* Start with output sum widgets muted and their output gains at min */
5928 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5929 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5930 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5931 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5932 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5933 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5934 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5935 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5936 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5937
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005938 /* Unmute retasking pin widget output buffers since the default
5939 * state appears to be output. As the pin mode is changed by the
5940 * user the pin mode control will take care of enabling the pin's
5941 * input/output buffers as needed.
5942 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005943 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5944 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5945 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5946 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5947 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5948 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5949 /* Also unmute the mono-out pin widget */
5950 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5951
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005952 /* Mute capture amp left and right */
5953 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005954 /* Set ADC connection select to match default mixer setting (mic1
5955 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005956 */
5957 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5958
5959 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005960 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005961 */
5962 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5963 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5964
5965 /* Mute all inputs to mixer widget (even unconnected ones) */
5966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5967 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5969 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5972 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5974
5975 { }
5976};
5977#endif
5978
Takashi Iwai63300792008-01-24 15:31:36 +01005979#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5980#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005981
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005982#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5983#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5984
Kailang Yangdf694da2005-12-05 19:42:22 +01005985/*
5986 * for BIOS auto-configuration
5987 */
5988
5989static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005990 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005991{
5992 hda_nid_t nid_vol;
5993 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01005994 int err;
5995
5996 if (nid >= 0x0f && nid < 0x11) {
5997 nid_vol = nid - 0x7;
5998 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5999 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6000 } else if (nid == 0x11) {
6001 nid_vol = nid - 0x7;
6002 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6003 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6004 } else if (nid >= 0x12 && nid <= 0x15) {
6005 nid_vol = 0x08;
6006 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6007 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6008 } else
6009 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006010
Takashi Iwai863b4512008-10-21 17:01:47 +02006011 if (!(*vol_bits & (1 << nid_vol))) {
6012 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006013 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006014 if (err < 0)
6015 return err;
6016 *vol_bits |= (1 << nid_vol);
6017 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006018 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006019 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006020 return err;
6021 return 1;
6022}
6023
6024/* add playback controls from the parsed DAC table */
6025static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6026 const struct auto_pin_cfg *cfg)
6027{
6028 hda_nid_t nid;
6029 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006030 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006031
6032 spec->multiout.num_dacs = 1;
6033 spec->multiout.dac_nids = spec->private_dac_nids;
6034 spec->multiout.dac_nids[0] = 0x02;
6035
6036 nid = cfg->line_out_pins[0];
6037 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006038 const char *pfx;
6039 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6040 pfx = "Master";
6041 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6042 pfx = "Speaker";
6043 else
6044 pfx = "Front";
6045 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006046 if (err < 0)
6047 return err;
6048 }
6049
Takashi Iwai82bc9552006-03-21 11:24:42 +01006050 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006051 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006052 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006053 if (err < 0)
6054 return err;
6055 }
6056
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006057 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006058 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006059 err = alc260_add_playback_controls(spec, nid, "Headphone",
6060 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006061 if (err < 0)
6062 return err;
6063 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006064 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006065}
6066
6067/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006068static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006069 const struct auto_pin_cfg *cfg)
6070{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006071 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006072}
6073
6074static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6075 hda_nid_t nid, int pin_type,
6076 int sel_idx)
6077{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006078 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006079 /* need the manual connection? */
6080 if (nid >= 0x12) {
6081 int idx = nid - 0x12;
6082 snd_hda_codec_write(codec, idx + 0x0b, 0,
6083 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006084 }
6085}
6086
6087static void alc260_auto_init_multi_out(struct hda_codec *codec)
6088{
6089 struct alc_spec *spec = codec->spec;
6090 hda_nid_t nid;
6091
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006092 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006093 if (nid) {
6094 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6095 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6096 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006097
Takashi Iwai82bc9552006-03-21 11:24:42 +01006098 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006099 if (nid)
6100 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6101
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006102 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006103 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006104 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006105}
Kailang Yangdf694da2005-12-05 19:42:22 +01006106
6107#define ALC260_PIN_CD_NID 0x16
6108static void alc260_auto_init_analog_input(struct hda_codec *codec)
6109{
6110 struct alc_spec *spec = codec->spec;
6111 int i;
6112
6113 for (i = 0; i < AUTO_PIN_LAST; i++) {
6114 hda_nid_t nid = spec->autocfg.input_pins[i];
6115 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006116 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006117 if (nid != ALC260_PIN_CD_NID &&
6118 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006119 snd_hda_codec_write(codec, nid, 0,
6120 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006121 AMP_OUT_MUTE);
6122 }
6123 }
6124}
6125
6126/*
6127 * generic initialization of ADC, input mixers and output mixers
6128 */
6129static struct hda_verb alc260_volume_init_verbs[] = {
6130 /*
6131 * Unmute ADC0-1 and set the default input to mic-in
6132 */
6133 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6134 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6135 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6136 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006137
Kailang Yangdf694da2005-12-05 19:42:22 +01006138 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6139 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006140 * Note: PASD motherboards uses the Line In 2 as the input for
6141 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006142 */
6143 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006144 /* mute analog inputs */
6145 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6146 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006150
6151 /*
6152 * Set up output mixers (0x08 - 0x0a)
6153 */
6154 /* set vol=0 to output mixers */
6155 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6156 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6157 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6158 /* set up input amps for analog loopback */
6159 /* Amp Indices: DAC = 0, mixer = 1 */
6160 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6161 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6162 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6163 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6164 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6165 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006166
Kailang Yangdf694da2005-12-05 19:42:22 +01006167 { }
6168};
6169
6170static int alc260_parse_auto_config(struct hda_codec *codec)
6171{
6172 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006173 int err;
6174 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6175
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006176 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6177 alc260_ignore);
6178 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006179 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006180 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6181 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006182 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006183 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006184 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006185 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006186 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006187 return err;
6188
6189 spec->multiout.max_channels = 2;
6190
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006191 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006192 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006193 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006194 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006195
Takashi Iwaid88897e2008-10-31 15:01:37 +01006196 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006197
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006198 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006199 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006200
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006201 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6202
Kailang Yangdf694da2005-12-05 19:42:22 +01006203 return 1;
6204}
6205
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006206/* additional initialization for auto-configuration model */
6207static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006208{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006209 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006210 alc260_auto_init_multi_out(codec);
6211 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006212 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006213 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006214}
6215
Takashi Iwaicb53c622007-08-10 17:21:45 +02006216#ifdef CONFIG_SND_HDA_POWER_SAVE
6217static struct hda_amp_list alc260_loopbacks[] = {
6218 { 0x07, HDA_INPUT, 0 },
6219 { 0x07, HDA_INPUT, 1 },
6220 { 0x07, HDA_INPUT, 2 },
6221 { 0x07, HDA_INPUT, 3 },
6222 { 0x07, HDA_INPUT, 4 },
6223 { } /* end */
6224};
6225#endif
6226
Kailang Yangdf694da2005-12-05 19:42:22 +01006227/*
6228 * ALC260 configurations
6229 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006230static const char *alc260_models[ALC260_MODEL_LAST] = {
6231 [ALC260_BASIC] = "basic",
6232 [ALC260_HP] = "hp",
6233 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006234 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006235 [ALC260_FUJITSU_S702X] = "fujitsu",
6236 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006237 [ALC260_WILL] = "will",
6238 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006239 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006240#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006241 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006242#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006243 [ALC260_AUTO] = "auto",
6244};
6245
6246static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006247 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006248 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006249 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006250 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006251 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006252 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006253 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006254 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006255 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6256 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6257 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6258 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6259 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6260 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6261 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6262 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6263 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006264 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006265 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006266 {}
6267};
6268
Kailang Yangdf694da2005-12-05 19:42:22 +01006269static struct alc_config_preset alc260_presets[] = {
6270 [ALC260_BASIC] = {
6271 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006272 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006273 .init_verbs = { alc260_init_verbs },
6274 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6275 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006276 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006277 .adc_nids = alc260_adc_nids,
6278 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6279 .channel_mode = alc260_modes,
6280 .input_mux = &alc260_capture_source,
6281 },
6282 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006283 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006284 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006285 .init_verbs = { alc260_init_verbs,
6286 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006287 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6288 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006289 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6290 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006291 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6292 .channel_mode = alc260_modes,
6293 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006294 .unsol_event = alc260_hp_unsol_event,
6295 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006296 },
Kailang Yang3f878302008-08-26 13:02:23 +02006297 [ALC260_HP_DC7600] = {
6298 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006299 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006300 .init_verbs = { alc260_init_verbs,
6301 alc260_hp_dc7600_verbs },
6302 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6303 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006304 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6305 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006306 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6307 .channel_mode = alc260_modes,
6308 .input_mux = &alc260_capture_source,
6309 .unsol_event = alc260_hp_3012_unsol_event,
6310 .init_hook = alc260_hp_3012_automute,
6311 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006312 [ALC260_HP_3013] = {
6313 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006314 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006315 .init_verbs = { alc260_hp_3013_init_verbs,
6316 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006317 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6318 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006319 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6320 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006321 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6322 .channel_mode = alc260_modes,
6323 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006324 .unsol_event = alc260_hp_3013_unsol_event,
6325 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006326 },
6327 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006328 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006329 .init_verbs = { alc260_fujitsu_init_verbs },
6330 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6331 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006332 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6333 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006334 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6335 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006336 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6337 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006338 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006339 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006340 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006341 .init_verbs = { alc260_acer_init_verbs },
6342 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6343 .dac_nids = alc260_dac_nids,
6344 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6345 .adc_nids = alc260_dual_adc_nids,
6346 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6347 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006348 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6349 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006350 },
Michael Schwingencc959482009-02-22 18:58:45 +01006351 [ALC260_FAVORIT100] = {
6352 .mixers = { alc260_favorit100_mixer },
6353 .init_verbs = { alc260_favorit100_init_verbs },
6354 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6355 .dac_nids = alc260_dac_nids,
6356 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6357 .adc_nids = alc260_dual_adc_nids,
6358 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6359 .channel_mode = alc260_modes,
6360 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6361 .input_mux = alc260_favorit100_capture_sources,
6362 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006363 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006364 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006365 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6366 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6367 .dac_nids = alc260_dac_nids,
6368 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6369 .adc_nids = alc260_adc_nids,
6370 .dig_out_nid = ALC260_DIGOUT_NID,
6371 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6372 .channel_mode = alc260_modes,
6373 .input_mux = &alc260_capture_source,
6374 },
6375 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006376 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006377 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6378 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6379 .dac_nids = alc260_dac_nids,
6380 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6381 .adc_nids = alc260_adc_nids,
6382 .dig_out_nid = ALC260_DIGOUT_NID,
6383 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6384 .channel_mode = alc260_modes,
6385 .input_mux = &alc260_capture_source,
6386 .unsol_event = alc260_replacer_672v_unsol_event,
6387 .init_hook = alc260_replacer_672v_automute,
6388 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006389#ifdef CONFIG_SND_DEBUG
6390 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006391 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006392 .init_verbs = { alc260_test_init_verbs },
6393 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6394 .dac_nids = alc260_test_dac_nids,
6395 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6396 .adc_nids = alc260_test_adc_nids,
6397 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6398 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006399 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6400 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006401 },
6402#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006403};
6404
Linus Torvalds1da177e2005-04-16 15:20:36 -07006405static int patch_alc260(struct hda_codec *codec)
6406{
6407 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006408 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006409
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006410 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006411 if (spec == NULL)
6412 return -ENOMEM;
6413
6414 codec->spec = spec;
6415
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006416 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6417 alc260_models,
6418 alc260_cfg_tbl);
6419 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006420 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006421 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006422 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006423 }
6424
Kailang Yangdf694da2005-12-05 19:42:22 +01006425 if (board_config == ALC260_AUTO) {
6426 /* automatic parse from the BIOS config */
6427 err = alc260_parse_auto_config(codec);
6428 if (err < 0) {
6429 alc_free(codec);
6430 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006431 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006432 printk(KERN_INFO
6433 "hda_codec: Cannot set up configuration "
6434 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006435 board_config = ALC260_BASIC;
6436 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006437 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006438
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006439 err = snd_hda_attach_beep_device(codec, 0x1);
6440 if (err < 0) {
6441 alc_free(codec);
6442 return err;
6443 }
6444
Kailang Yangdf694da2005-12-05 19:42:22 +01006445 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006446 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006447
Linus Torvalds1da177e2005-04-16 15:20:36 -07006448 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6449 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6450
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006451 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6452 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6453
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006454 if (!spec->adc_nids && spec->input_mux) {
6455 /* check whether NID 0x04 is valid */
6456 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006457 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006458 /* get type */
6459 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6460 spec->adc_nids = alc260_adc_nids_alt;
6461 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6462 } else {
6463 spec->adc_nids = alc260_adc_nids;
6464 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6465 }
6466 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006467 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006468 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006469
Takashi Iwai2134ea42008-01-10 16:53:55 +01006470 spec->vmaster_nid = 0x08;
6471
Linus Torvalds1da177e2005-04-16 15:20:36 -07006472 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006473 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006474 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006475#ifdef CONFIG_SND_HDA_POWER_SAVE
6476 if (!spec->loopback.amplist)
6477 spec->loopback.amplist = alc260_loopbacks;
6478#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006479 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006480
6481 return 0;
6482}
6483
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006484
Linus Torvalds1da177e2005-04-16 15:20:36 -07006485/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006486 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006487 *
6488 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6489 * configuration. Each pin widget can choose any input DACs and a mixer.
6490 * Each ADC is connected from a mixer of all inputs. This makes possible
6491 * 6-channel independent captures.
6492 *
6493 * In addition, an independent DAC for the multi-playback (not used in this
6494 * driver yet).
6495 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006496#define ALC882_DIGOUT_NID 0x06
6497#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006498#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6499#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6500#define ALC1200_DIGOUT_NID 0x10
6501
Linus Torvalds1da177e2005-04-16 15:20:36 -07006502
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006503static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006504 { 8, NULL }
6505};
6506
Takashi Iwai4953550a2009-06-30 15:28:30 +02006507/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006508static hda_nid_t alc882_dac_nids[4] = {
6509 /* front, rear, clfe, rear_surr */
6510 0x02, 0x03, 0x04, 0x05
6511};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006512#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006513
Takashi Iwai4953550a2009-06-30 15:28:30 +02006514/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006515#define alc882_adc_nids alc880_adc_nids
6516#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006517#define alc883_adc_nids alc882_adc_nids_alt
6518static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6519static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6520#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006521
Takashi Iwaie1406342008-02-11 18:32:32 +01006522static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6523static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006524#define alc883_capsrc_nids alc882_capsrc_nids_alt
6525static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6526#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006527
Linus Torvalds1da177e2005-04-16 15:20:36 -07006528/* input MUX */
6529/* FIXME: should be a matrix-type input source selection */
6530
6531static struct hda_input_mux alc882_capture_source = {
6532 .num_items = 4,
6533 .items = {
6534 { "Mic", 0x0 },
6535 { "Front Mic", 0x1 },
6536 { "Line", 0x2 },
6537 { "CD", 0x4 },
6538 },
6539};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006540
Takashi Iwai4953550a2009-06-30 15:28:30 +02006541#define alc883_capture_source alc882_capture_source
6542
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006543static struct hda_input_mux alc889_capture_source = {
6544 .num_items = 3,
6545 .items = {
6546 { "Front Mic", 0x0 },
6547 { "Mic", 0x3 },
6548 { "Line", 0x2 },
6549 },
6550};
6551
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006552static struct hda_input_mux mb5_capture_source = {
6553 .num_items = 3,
6554 .items = {
6555 { "Mic", 0x1 },
6556 { "Line", 0x2 },
6557 { "CD", 0x4 },
6558 },
6559};
6560
Takashi Iwai4953550a2009-06-30 15:28:30 +02006561static struct hda_input_mux alc883_3stack_6ch_intel = {
6562 .num_items = 4,
6563 .items = {
6564 { "Mic", 0x1 },
6565 { "Front Mic", 0x0 },
6566 { "Line", 0x2 },
6567 { "CD", 0x4 },
6568 },
6569};
6570
6571static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6572 .num_items = 2,
6573 .items = {
6574 { "Mic", 0x1 },
6575 { "Line", 0x2 },
6576 },
6577};
6578
6579static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6580 .num_items = 4,
6581 .items = {
6582 { "Mic", 0x0 },
6583 { "iMic", 0x1 },
6584 { "Line", 0x2 },
6585 { "CD", 0x4 },
6586 },
6587};
6588
6589static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6590 .num_items = 2,
6591 .items = {
6592 { "Mic", 0x0 },
6593 { "Int Mic", 0x1 },
6594 },
6595};
6596
6597static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6598 .num_items = 3,
6599 .items = {
6600 { "Mic", 0x0 },
6601 { "Front Mic", 0x1 },
6602 { "Line", 0x4 },
6603 },
6604};
6605
6606static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6607 .num_items = 2,
6608 .items = {
6609 { "Mic", 0x0 },
6610 { "Line", 0x2 },
6611 },
6612};
6613
6614static struct hda_input_mux alc889A_mb31_capture_source = {
6615 .num_items = 2,
6616 .items = {
6617 { "Mic", 0x0 },
6618 /* Front Mic (0x01) unused */
6619 { "Line", 0x2 },
6620 /* Line 2 (0x03) unused */
6621 /* CD (0x04) unsused? */
6622 },
6623};
6624
6625/*
6626 * 2ch mode
6627 */
6628static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6629 { 2, NULL }
6630};
6631
Kailang Yangdf694da2005-12-05 19:42:22 +01006632/*
Kailang Yang272a5272007-05-14 11:00:38 +02006633 * 2ch mode
6634 */
6635static struct hda_verb alc882_3ST_ch2_init[] = {
6636 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6637 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6638 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6639 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6640 { } /* end */
6641};
6642
6643/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006644 * 4ch mode
6645 */
6646static struct hda_verb alc882_3ST_ch4_init[] = {
6647 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6648 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6649 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6650 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6651 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6652 { } /* end */
6653};
6654
6655/*
Kailang Yang272a5272007-05-14 11:00:38 +02006656 * 6ch mode
6657 */
6658static struct hda_verb alc882_3ST_ch6_init[] = {
6659 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6660 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6661 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6662 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6663 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6664 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6665 { } /* end */
6666};
6667
Takashi Iwai4953550a2009-06-30 15:28:30 +02006668static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006669 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006670 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006671 { 6, alc882_3ST_ch6_init },
6672};
6673
Takashi Iwai4953550a2009-06-30 15:28:30 +02006674#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6675
Kailang Yang272a5272007-05-14 11:00:38 +02006676/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306677 * 2ch mode
6678 */
6679static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6680 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6681 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6682 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6683 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6684 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6685 { } /* end */
6686};
6687
6688/*
6689 * 4ch mode
6690 */
6691static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6692 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6693 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6694 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6695 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6696 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6697 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6698 { } /* end */
6699};
6700
6701/*
6702 * 6ch mode
6703 */
6704static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6705 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6706 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6707 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6708 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6709 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6710 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6711 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6712 { } /* end */
6713};
6714
6715static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6716 { 2, alc883_3ST_ch2_clevo_init },
6717 { 4, alc883_3ST_ch4_clevo_init },
6718 { 6, alc883_3ST_ch6_clevo_init },
6719};
6720
6721
6722/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006723 * 6ch mode
6724 */
6725static struct hda_verb alc882_sixstack_ch6_init[] = {
6726 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6727 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6728 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6729 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6730 { } /* end */
6731};
6732
6733/*
6734 * 8ch mode
6735 */
6736static struct hda_verb alc882_sixstack_ch8_init[] = {
6737 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6738 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6739 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6740 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6741 { } /* end */
6742};
6743
6744static struct hda_channel_mode alc882_sixstack_modes[2] = {
6745 { 6, alc882_sixstack_ch6_init },
6746 { 8, alc882_sixstack_ch8_init },
6747};
6748
Takashi Iwai87350ad2007-08-16 18:19:38 +02006749/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006750 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006751 */
6752
6753/*
6754 * 2ch mode
6755 */
6756static struct hda_verb alc885_mbp_ch2_init[] = {
6757 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6758 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6759 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6760 { } /* end */
6761};
6762
6763/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006764 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006765 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006766static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006767 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6768 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6769 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6770 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6771 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6772 { } /* end */
6773};
6774
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006775static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006776 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006777 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006778};
6779
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006780/*
6781 * 2ch
6782 * Speakers/Woofer/HP = Front
6783 * LineIn = Input
6784 */
6785static struct hda_verb alc885_mb5_ch2_init[] = {
6786 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6787 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6788 { } /* end */
6789};
6790
6791/*
6792 * 6ch mode
6793 * Speakers/HP = Front
6794 * Woofer = LFE
6795 * LineIn = Surround
6796 */
6797static struct hda_verb alc885_mb5_ch6_init[] = {
6798 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6800 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6801 { } /* end */
6802};
6803
6804static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6805 { 2, alc885_mb5_ch2_init },
6806 { 6, alc885_mb5_ch6_init },
6807};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006808
Takashi Iwai4953550a2009-06-30 15:28:30 +02006809
6810/*
6811 * 2ch mode
6812 */
6813static struct hda_verb alc883_4ST_ch2_init[] = {
6814 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6815 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6816 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6817 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6818 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6819 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6820 { } /* end */
6821};
6822
6823/*
6824 * 4ch mode
6825 */
6826static struct hda_verb alc883_4ST_ch4_init[] = {
6827 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6828 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6829 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6830 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6831 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6832 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6833 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6834 { } /* end */
6835};
6836
6837/*
6838 * 6ch mode
6839 */
6840static struct hda_verb alc883_4ST_ch6_init[] = {
6841 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6842 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6843 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6844 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6845 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6846 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6847 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6848 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6849 { } /* end */
6850};
6851
6852/*
6853 * 8ch mode
6854 */
6855static struct hda_verb alc883_4ST_ch8_init[] = {
6856 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6857 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6858 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6859 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6860 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6861 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6862 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6863 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6864 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6865 { } /* end */
6866};
6867
6868static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6869 { 2, alc883_4ST_ch2_init },
6870 { 4, alc883_4ST_ch4_init },
6871 { 6, alc883_4ST_ch6_init },
6872 { 8, alc883_4ST_ch8_init },
6873};
6874
6875
6876/*
6877 * 2ch mode
6878 */
6879static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6880 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6881 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6882 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6883 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6884 { } /* end */
6885};
6886
6887/*
6888 * 4ch mode
6889 */
6890static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6891 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6892 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6893 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6894 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6895 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6896 { } /* end */
6897};
6898
6899/*
6900 * 6ch mode
6901 */
6902static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6903 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6904 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6905 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6906 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6907 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6908 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6909 { } /* end */
6910};
6911
6912static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6913 { 2, alc883_3ST_ch2_intel_init },
6914 { 4, alc883_3ST_ch4_intel_init },
6915 { 6, alc883_3ST_ch6_intel_init },
6916};
6917
6918/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006919 * 2ch mode
6920 */
6921static struct hda_verb alc889_ch2_intel_init[] = {
6922 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6923 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6924 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6925 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6926 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6927 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6928 { } /* end */
6929};
6930
6931/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006932 * 6ch mode
6933 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006934static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006935 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6936 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6937 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6938 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6939 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006940 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6941 { } /* end */
6942};
6943
6944/*
6945 * 8ch mode
6946 */
6947static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006948 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6949 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6950 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6951 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6952 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006953 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6954 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006955 { } /* end */
6956};
6957
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006958static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6959 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006960 { 6, alc889_ch6_intel_init },
6961 { 8, alc889_ch8_intel_init },
6962};
6963
6964/*
6965 * 6ch mode
6966 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006967static struct hda_verb alc883_sixstack_ch6_init[] = {
6968 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6969 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6970 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6971 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6972 { } /* end */
6973};
6974
6975/*
6976 * 8ch mode
6977 */
6978static struct hda_verb alc883_sixstack_ch8_init[] = {
6979 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6980 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6981 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6982 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6983 { } /* end */
6984};
6985
6986static struct hda_channel_mode alc883_sixstack_modes[2] = {
6987 { 6, alc883_sixstack_ch6_init },
6988 { 8, alc883_sixstack_ch8_init },
6989};
6990
6991
Linus Torvalds1da177e2005-04-16 15:20:36 -07006992/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6993 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6994 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006995static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006996 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006997 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006998 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006999 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007000 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7001 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007002 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7003 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007004 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007005 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7007 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7008 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7009 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7010 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007012 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007013 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7014 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007015 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007016 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007017 { } /* end */
7018};
7019
Takashi Iwai87350ad2007-08-16 18:19:38 +02007020static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007021 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7022 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7023 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7024 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7025 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007026 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7027 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007028 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7029 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007030 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007031 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7032 { } /* end */
7033};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007034
7035static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007036 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7037 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7038 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7039 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7040 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7041 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7042 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7043 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007044 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7045 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7046 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7047 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7048 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7049 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7050 { } /* end */
7051};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007052
Kailang Yangbdd148a2007-05-08 15:19:08 +02007053static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7054 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7055 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7056 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7057 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7058 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7059 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7060 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7061 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7062 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007063 { } /* end */
7064};
7065
Kailang Yang272a5272007-05-14 11:00:38 +02007066static struct snd_kcontrol_new alc882_targa_mixer[] = {
7067 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7068 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7069 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7070 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7071 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7072 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7073 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7074 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7075 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007076 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007077 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7078 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007079 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007080 { } /* end */
7081};
7082
7083/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7084 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7085 */
7086static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7087 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7088 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7089 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7090 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7091 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7092 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7093 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7094 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7095 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7096 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7097 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7098 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007099 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007100 { } /* end */
7101};
7102
Takashi Iwai914759b2007-09-06 14:52:04 +02007103static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7104 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7105 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7106 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7107 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7108 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7109 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7110 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7112 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007114 { } /* end */
7115};
7116
Kailang Yangdf694da2005-12-05 19:42:22 +01007117static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7118 {
7119 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7120 .name = "Channel Mode",
7121 .info = alc_ch_mode_info,
7122 .get = alc_ch_mode_get,
7123 .put = alc_ch_mode_put,
7124 },
7125 { } /* end */
7126};
7127
Takashi Iwai4953550a2009-06-30 15:28:30 +02007128static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007129 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007130 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7131 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7132 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007133 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007134 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7135 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7136 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007137 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007138 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7139 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7140 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007141 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007142 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7143 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7144 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007145
Takashi Iwaicb638122009-07-03 10:56:10 +02007146 /* mute analog input loopbacks */
7147 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7149 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7151 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7152
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007153 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007154 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007155 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007156 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007157 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007158 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007159 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007160 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007161 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007162 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007163 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007164 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007165 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007166 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007167 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007168 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007169 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007170 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007171 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7172 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007173 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007174 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7175 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007176 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007177 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7178 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7179 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7180 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7181 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007182 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007183 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007184
7185 /* FIXME: use matrix-type input source selection */
7186 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007187 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007188 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7189 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7190 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7191 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007192 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007193 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7194 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007197 /* ADC2: mute amp left and right */
7198 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007199 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007200 /* ADC3: mute amp left and right */
7201 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007202 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007203
7204 { }
7205};
7206
Takashi Iwai4953550a2009-06-30 15:28:30 +02007207static struct hda_verb alc882_adc1_init_verbs[] = {
7208 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7212 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7213 /* ADC1: mute amp left and right */
7214 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7215 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7216 { }
7217};
7218
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007219static struct hda_verb alc882_eapd_verbs[] = {
7220 /* change to EAPD mode */
7221 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007222 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007223 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007224};
7225
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007226static struct hda_verb alc889_eapd_verbs[] = {
7227 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7228 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7229 { }
7230};
7231
Wu Fengguang6732bd02009-07-30 09:19:14 +02007232static struct hda_verb alc_hp15_unsol_verbs[] = {
7233 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7234 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7235 {}
7236};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007237
7238static struct hda_verb alc885_init_verbs[] = {
7239 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7240 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7241 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7243 /* Rear mixer */
7244 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7245 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7246 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7247 /* CLFE mixer */
7248 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7249 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7250 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7251 /* Side mixer */
7252 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7253 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7254 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7255
7256 /* mute analog input loopbacks */
7257 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7258 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7260
7261 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007263 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7264 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7265 /* Front Pin: output 0 (0x0c) */
7266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7267 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7268 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7269 /* Rear Pin: output 1 (0x0d) */
7270 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7271 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7272 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7273 /* CLFE Pin: output 2 (0x0e) */
7274 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7275 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7276 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7277 /* Side Pin: output 3 (0x0f) */
7278 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7279 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7280 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7281 /* Mic (rear) pin: input vref at 80% */
7282 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7283 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7284 /* Front Mic pin: input vref at 80% */
7285 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7286 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7287 /* Line In pin: input */
7288 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7289 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7290
7291 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7292 /* Input mixer1 */
7293 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7294 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7295 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7296 /* Input mixer2 */
7297 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7299 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7300 /* Input mixer3 */
7301 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7304 /* ADC2: mute amp left and right */
7305 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7306 /* ADC3: mute amp left and right */
7307 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7308
7309 { }
7310};
7311
7312static struct hda_verb alc885_init_input_verbs[] = {
7313 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7314 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7315 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7316 { }
7317};
7318
7319
7320/* Unmute Selector 24h and set the default input to front mic */
7321static struct hda_verb alc889_init_input_verbs[] = {
7322 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7323 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7324 { }
7325};
7326
7327
Takashi Iwai4953550a2009-06-30 15:28:30 +02007328#define alc883_init_verbs alc882_base_init_verbs
7329
Tobin Davis9102cd12006-12-15 10:02:12 +01007330/* Mac Pro test */
7331static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7332 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7333 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7334 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7335 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7336 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007337 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007338 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7339 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007340 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007341 { } /* end */
7342};
7343
7344static struct hda_verb alc882_macpro_init_verbs[] = {
7345 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7348 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7349 /* Front Pin: output 0 (0x0c) */
7350 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7351 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7352 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7353 /* Front Mic pin: input vref at 80% */
7354 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7355 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7356 /* Speaker: output */
7357 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7358 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7359 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7360 /* Headphone output (output 0 - 0x0c) */
7361 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7362 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7363 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7364
7365 /* FIXME: use matrix-type input source selection */
7366 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7367 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7368 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7369 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7370 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7371 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7372 /* Input mixer2 */
7373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7376 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7377 /* Input mixer3 */
7378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7380 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7381 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7382 /* ADC1: mute amp left and right */
7383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7384 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7385 /* ADC2: mute amp left and right */
7386 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7387 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7388 /* ADC3: mute amp left and right */
7389 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7390 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7391
7392 { }
7393};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007394
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007395/* Macbook 5,1 */
7396static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007397 /* DACs */
7398 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7399 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7400 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7401 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007402 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7405 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007406 /* Surround mixer */
7407 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7408 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7409 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7410 /* LFE mixer */
7411 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7412 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7414 /* HP mixer */
7415 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7416 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7417 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7418 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007419 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7420 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007421 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7422 /* LFE Pin (0x0e) */
7423 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7424 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7425 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7426 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007427 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7428 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007429 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007430 /* Front Mic pin: input vref at 80% */
7431 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7432 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7433 /* Line In pin */
7434 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7435 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7436
7437 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7441 { }
7442};
7443
Takashi Iwai87350ad2007-08-16 18:19:38 +02007444/* Macbook Pro rev3 */
7445static struct hda_verb alc885_mbp3_init_verbs[] = {
7446 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7447 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7448 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7449 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7450 /* Rear mixer */
7451 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7452 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7453 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007454 /* HP mixer */
7455 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7456 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7457 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007458 /* Front Pin: output 0 (0x0c) */
7459 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7460 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7461 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007462 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007463 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007464 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7465 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007466 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7467 /* Mic (rear) pin: input vref at 80% */
7468 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7469 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7470 /* Front Mic pin: input vref at 80% */
7471 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7472 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7473 /* Line In pin: use output 1 when in LineOut mode */
7474 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7475 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7476 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7477
7478 /* FIXME: use matrix-type input source selection */
7479 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7480 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7481 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7482 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7483 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7484 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7485 /* Input mixer2 */
7486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7487 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7488 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7489 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7490 /* Input mixer3 */
7491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7495 /* ADC1: mute amp left and right */
7496 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7497 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7498 /* ADC2: mute amp left and right */
7499 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7500 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7501 /* ADC3: mute amp left and right */
7502 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7503 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7504
7505 { }
7506};
7507
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007508/* iMac 24 mixer. */
7509static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7510 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7511 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7512 { } /* end */
7513};
7514
7515/* iMac 24 init verbs. */
7516static struct hda_verb alc885_imac24_init_verbs[] = {
7517 /* Internal speakers: output 0 (0x0c) */
7518 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7519 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7520 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7521 /* Internal speakers: output 0 (0x0c) */
7522 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7523 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7524 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7525 /* Headphone: output 0 (0x0c) */
7526 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7527 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7528 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7529 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7530 /* Front Mic: input vref at 80% */
7531 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7532 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7533 { }
7534};
7535
7536/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007537static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007538{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007539 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007540
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007541 spec->autocfg.hp_pins[0] = 0x14;
7542 spec->autocfg.speaker_pins[0] = 0x18;
7543 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007544}
7545
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007546static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007547{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007548 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007549
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007550 spec->autocfg.hp_pins[0] = 0x15;
7551 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007552}
7553
7554
Kailang Yang272a5272007-05-14 11:00:38 +02007555static struct hda_verb alc882_targa_verbs[] = {
7556 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7557 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7558
7559 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7560 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007561
Kailang Yang272a5272007-05-14 11:00:38 +02007562 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7563 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7564 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7565
7566 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007567 { } /* end */
7568};
7569
7570/* toggle speaker-output according to the hp-jack state */
7571static void alc882_targa_automute(struct hda_codec *codec)
7572{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007573 struct alc_spec *spec = codec->spec;
7574 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007575 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007576 spec->jack_present ? 1 : 3);
7577}
7578
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007579static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007580{
7581 struct alc_spec *spec = codec->spec;
7582
7583 spec->autocfg.hp_pins[0] = 0x14;
7584 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007585}
7586
7587static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7588{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007589 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007590 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007591}
7592
7593static struct hda_verb alc882_asus_a7j_verbs[] = {
7594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7596
7597 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7598 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7599 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007600
Kailang Yang272a5272007-05-14 11:00:38 +02007601 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7602 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7603 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7604
7605 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7606 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7607 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7608 { } /* end */
7609};
7610
Takashi Iwai914759b2007-09-06 14:52:04 +02007611static struct hda_verb alc882_asus_a7m_verbs[] = {
7612 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7613 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7614
7615 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7616 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7617 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007618
Takashi Iwai914759b2007-09-06 14:52:04 +02007619 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7620 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7621 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7622
7623 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7624 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7625 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7626 { } /* end */
7627};
7628
Tobin Davis9102cd12006-12-15 10:02:12 +01007629static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7630{
7631 unsigned int gpiostate, gpiomask, gpiodir;
7632
7633 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7634 AC_VERB_GET_GPIO_DATA, 0);
7635
7636 if (!muted)
7637 gpiostate |= (1 << pin);
7638 else
7639 gpiostate &= ~(1 << pin);
7640
7641 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7642 AC_VERB_GET_GPIO_MASK, 0);
7643 gpiomask |= (1 << pin);
7644
7645 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7646 AC_VERB_GET_GPIO_DIRECTION, 0);
7647 gpiodir |= (1 << pin);
7648
7649
7650 snd_hda_codec_write(codec, codec->afg, 0,
7651 AC_VERB_SET_GPIO_MASK, gpiomask);
7652 snd_hda_codec_write(codec, codec->afg, 0,
7653 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7654
7655 msleep(1);
7656
7657 snd_hda_codec_write(codec, codec->afg, 0,
7658 AC_VERB_SET_GPIO_DATA, gpiostate);
7659}
7660
Takashi Iwai7debbe52007-08-16 15:01:03 +02007661/* set up GPIO at initialization */
7662static void alc885_macpro_init_hook(struct hda_codec *codec)
7663{
7664 alc882_gpio_mute(codec, 0, 0);
7665 alc882_gpio_mute(codec, 1, 0);
7666}
7667
7668/* set up GPIO and update auto-muting at initialization */
7669static void alc885_imac24_init_hook(struct hda_codec *codec)
7670{
7671 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007672 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007673}
7674
Kailang Yangdf694da2005-12-05 19:42:22 +01007675/*
7676 * generic initialization of ADC, input mixers and output mixers
7677 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007678static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007679 /*
7680 * Unmute ADC0-2 and set the default input to mic-in
7681 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007682 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7683 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7684 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7685 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7686
Takashi Iwaicb53c622007-08-10 17:21:45 +02007687 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007688 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007689 * Note: PASD motherboards uses the Line In 2 as the input for
7690 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007691 */
7692 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007693 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7697 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007698
7699 /*
7700 * Set up output mixers (0x0c - 0x0f)
7701 */
7702 /* set vol=0 to output mixers */
7703 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7704 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7705 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7706 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7707 /* set up input amps for analog loopback */
7708 /* Amp Indices: DAC = 0, mixer = 1 */
7709 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7710 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7711 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7712 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7713 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7714 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7715 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7716 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7717 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7718 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7719
7720 /* FIXME: use matrix-type input source selection */
7721 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007722 /* Input mixer2 */
7723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7725 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7726 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7727 /* Input mixer3 */
7728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7731 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7732
7733 { }
7734};
7735
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007736/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7737static struct hda_verb alc889A_mb31_ch2_init[] = {
7738 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7739 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7740 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7741 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7742 { } /* end */
7743};
7744
7745/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7746static struct hda_verb alc889A_mb31_ch4_init[] = {
7747 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7748 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7749 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7750 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7751 { } /* end */
7752};
7753
7754/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7755static struct hda_verb alc889A_mb31_ch5_init[] = {
7756 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7757 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7758 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7759 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7760 { } /* end */
7761};
7762
7763/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7764static struct hda_verb alc889A_mb31_ch6_init[] = {
7765 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7766 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7767 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7768 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7769 { } /* end */
7770};
7771
7772static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7773 { 2, alc889A_mb31_ch2_init },
7774 { 4, alc889A_mb31_ch4_init },
7775 { 5, alc889A_mb31_ch5_init },
7776 { 6, alc889A_mb31_ch6_init },
7777};
7778
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007779static struct hda_verb alc883_medion_eapd_verbs[] = {
7780 /* eanable EAPD on medion laptop */
7781 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7782 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7783 { }
7784};
7785
Takashi Iwai4953550a2009-06-30 15:28:30 +02007786#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007787
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007788static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7789 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7790 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7791 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7792 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7793 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7794 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7795 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7797 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7799 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7800 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7801 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007802 { } /* end */
7803};
7804
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007805static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007806 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7807 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7808 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7809 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7811 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7813 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7814 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7815 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007816 { } /* end */
7817};
7818
Jiang zhefb97dc62008-03-06 11:07:11 +01007819static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7820 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7821 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7822 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7823 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7825 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7826 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7827 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7828 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7829 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007830 { } /* end */
7831};
7832
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007833static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7834 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7835 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7836 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7837 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7838 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7839 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7840 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7841 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007842 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007843 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7844 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007845 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007846 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007847 { } /* end */
7848};
7849
7850static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7851 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7852 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7853 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7854 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7855 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7856 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7857 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7858 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7860 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7861 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7862 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7863 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007865 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007866 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7867 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007868 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007869 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007870 { } /* end */
7871};
7872
Jiang zhe17bba1b2008-06-04 12:11:07 +02007873static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7874 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7875 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7876 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7877 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7878 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7879 HDA_OUTPUT),
7880 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7881 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7882 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7883 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7884 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7885 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7886 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7887 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7889 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7890 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7891 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7892 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7893 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007894 { } /* end */
7895};
7896
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007897static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7898 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7899 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7900 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7901 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7902 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7903 HDA_OUTPUT),
7904 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7905 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7906 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7907 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7908 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7909 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7910 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7911 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7913 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7914 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7915 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7916 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7917 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7918 { } /* end */
7919};
7920
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007921static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007922 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007923 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007924 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007925 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007926 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7927 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007928 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7929 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007936 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7938 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007939 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007940 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007941 { } /* end */
7942};
7943
Sasha Alexandrc2592492009-06-16 14:52:54 -04007944static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007945 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007946 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007947 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007948 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007949 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7950 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7951 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7952 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7953 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7954 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7955 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7956 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7957 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7958 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007960 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007961 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007962 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007963};
Kailang Yangccc656c2006-10-17 12:32:26 +02007964
Sasha Alexandrc2592492009-06-16 14:52:54 -04007965static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007966 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007967 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02007969 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007970 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7971 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007973 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007974 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007975 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7976 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7977 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007978 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007979};
Kailang Yangccc656c2006-10-17 12:32:26 +02007980
Takashi Iwaib99dba32009-09-17 18:23:00 +02007981static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
7982 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7983 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7984 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7985 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7986 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7987 { } /* end */
7988};
7989
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007990static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7992 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007993 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7994 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007995 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7997 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007999 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008000};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008001
Kailang Yang272a5272007-05-14 11:00:38 +02008002static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8003 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8004 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8006 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8007 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8008 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8009 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8010 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8011 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008012 { } /* end */
8013};
8014
8015static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8016 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8017 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8018 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8019 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8020 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8021 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8022 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8023 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8024 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008025 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008026};
Kailang Yang272a5272007-05-14 11:00:38 +02008027
Tobin Davis2880a862007-08-07 11:50:26 +02008028static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008029 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8030 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008031 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008032 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8033 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008034 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8035 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8036 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008037 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008038};
Tobin Davis2880a862007-08-07 11:50:26 +02008039
Tony Vroond2fd4b02009-06-21 00:40:10 +01008040static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8041 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8042 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8043 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8044 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008045 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8046 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008047 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8048 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8049 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8050 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8051 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8052 { } /* end */
8053};
8054
Kailang Yange2757d52008-08-26 13:17:46 +02008055static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8056 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8057 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8058 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8059 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8060 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8061 0x0d, 1, 0x0, HDA_OUTPUT),
8062 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8063 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8064 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8065 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8066 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008067 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8068 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8069 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8070 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8071 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8072 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8074 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8075 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8076 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008077 { } /* end */
8078};
8079
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008080static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8081 /* Output mixers */
8082 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8083 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8084 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8085 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8086 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8087 HDA_OUTPUT),
8088 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8089 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8090 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8091 /* Output switches */
8092 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8093 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8094 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8095 /* Boost mixers */
8096 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8097 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8098 /* Input mixers */
8099 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8100 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8101 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8102 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8103 { } /* end */
8104};
8105
Guido Günther3e1647c2009-06-05 00:47:26 +02008106static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8107 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8108 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8109 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8111 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8113 { } /* end */
8114};
8115
Kailang Yange2757d52008-08-26 13:17:46 +02008116static struct hda_bind_ctls alc883_bind_cap_vol = {
8117 .ops = &snd_hda_bind_vol,
8118 .values = {
8119 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8120 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8121 0
8122 },
8123};
8124
8125static struct hda_bind_ctls alc883_bind_cap_switch = {
8126 .ops = &snd_hda_bind_sw,
8127 .values = {
8128 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8129 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8130 0
8131 },
8132};
8133
8134static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8135 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8136 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8137 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8138 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8139 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8141 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8142 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008143 { } /* end */
8144};
8145
8146static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008147 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8148 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8149 {
8150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8151 /* .name = "Capture Source", */
8152 .name = "Input Source",
8153 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008154 .info = alc_mux_enum_info,
8155 .get = alc_mux_enum_get,
8156 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008157 },
8158 { } /* end */
8159};
8160
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008161static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8162 {
8163 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8164 .name = "Channel Mode",
8165 .info = alc_ch_mode_info,
8166 .get = alc_ch_mode_get,
8167 .put = alc_ch_mode_put,
8168 },
8169 { } /* end */
8170};
8171
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008172/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008173static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008174{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008175 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008176
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008177 spec->autocfg.hp_pins[0] = 0x15;
8178 spec->autocfg.speaker_pins[0] = 0x14;
8179 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008180}
8181
8182/* auto-toggle front mic */
8183/*
8184static void alc883_mitac_mic_automute(struct hda_codec *codec)
8185{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008186 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008187
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008188 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8189}
8190*/
8191
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008192static struct hda_verb alc883_mitac_verbs[] = {
8193 /* HP */
8194 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8195 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8196 /* Subwoofer */
8197 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8198 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8199
8200 /* enable unsolicited event */
8201 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8202 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8203
8204 { } /* end */
8205};
8206
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308207static struct hda_verb alc883_clevo_m540r_verbs[] = {
8208 /* HP */
8209 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8210 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8211 /* Int speaker */
8212 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8213
8214 /* enable unsolicited event */
8215 /*
8216 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8217 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8218 */
8219
8220 { } /* end */
8221};
8222
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008223static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008224 /* HP */
8225 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8226 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8227 /* Int speaker */
8228 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8229 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8230
8231 /* enable unsolicited event */
8232 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008233 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008234
8235 { } /* end */
8236};
8237
Jiang zhefb97dc62008-03-06 11:07:11 +01008238static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8239 /* HP */
8240 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8241 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8242 /* Subwoofer */
8243 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8244 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8245
8246 /* enable unsolicited event */
8247 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8248
8249 { } /* end */
8250};
8251
Sasha Alexandrc2592492009-06-16 14:52:54 -04008252static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008253 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8254 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8255
8256 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8257 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008258
David Heidelberger64a8be72009-06-08 16:15:18 +02008259/* Connect Line-Out side jack (SPDIF) to Side */
8260 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8261 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8262 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8263/* Connect Mic jack to CLFE */
8264 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8265 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8266 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8267/* Connect Line-in jack to Surround */
8268 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8269 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8270 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8271/* Connect HP out jack to Front */
8272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8273 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8274 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008275
8276 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008277
8278 { } /* end */
8279};
8280
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008281static struct hda_verb alc883_lenovo_101e_verbs[] = {
8282 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8283 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8284 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8285 { } /* end */
8286};
8287
Kailang Yang272a5272007-05-14 11:00:38 +02008288static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8289 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8290 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8291 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8292 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8293 { } /* end */
8294};
8295
8296static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8297 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8298 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8299 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8300 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8301 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8302 { } /* end */
8303};
8304
Kailang Yang189609a2007-08-20 11:31:23 +02008305static struct hda_verb alc883_haier_w66_verbs[] = {
8306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8308
8309 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8310
8311 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8312 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8313 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8314 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8315 { } /* end */
8316};
8317
Kailang Yange2757d52008-08-26 13:17:46 +02008318static struct hda_verb alc888_lenovo_sky_verbs[] = {
8319 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8320 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8321 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8322 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8323 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8324 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8325 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8326 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8327 { } /* end */
8328};
8329
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008330static struct hda_verb alc888_6st_dell_verbs[] = {
8331 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8332 { }
8333};
8334
Guido Günther3e1647c2009-06-05 00:47:26 +02008335static struct hda_verb alc883_vaiott_verbs[] = {
8336 /* HP */
8337 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8338 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8339
8340 /* enable unsolicited event */
8341 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8342
8343 { } /* end */
8344};
8345
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008346static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008347{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008348 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008349
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008350 spec->autocfg.hp_pins[0] = 0x1b;
8351 spec->autocfg.speaker_pins[0] = 0x14;
8352 spec->autocfg.speaker_pins[1] = 0x16;
8353 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008354}
8355
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008356static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008357 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008358 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8359 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008360 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008361 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008362};
8363
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008364/*
8365 * 2ch mode
8366 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008367static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008368 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8369 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8370 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8371 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008372 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008373};
8374
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008375/*
8376 * 4ch mode
8377 */
8378static struct hda_verb alc888_3st_hp_4ch_init[] = {
8379 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8380 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8381 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8382 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8383 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8384 { } /* end */
8385};
8386
8387/*
8388 * 6ch mode
8389 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008390static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008391 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8392 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008393 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008394 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8395 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008396 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8397 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008398};
8399
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008400static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008401 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008402 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008403 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008404};
8405
Kailang Yang272a5272007-05-14 11:00:38 +02008406/* toggle front-jack and RCA according to the hp-jack state */
8407static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8408{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008409 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008410
Takashi Iwai47fd8302007-08-10 17:11:07 +02008411 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8412 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8413 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8414 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008415}
8416
8417/* toggle RCA according to the front-jack state */
8418static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8419{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008420 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008421
Takashi Iwai47fd8302007-08-10 17:11:07 +02008422 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8423 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008424}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008425
Kailang Yang272a5272007-05-14 11:00:38 +02008426static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8427 unsigned int res)
8428{
8429 if ((res >> 26) == ALC880_HP_EVENT)
8430 alc888_lenovo_ms7195_front_automute(codec);
8431 if ((res >> 26) == ALC880_FRONT_EVENT)
8432 alc888_lenovo_ms7195_rca_automute(codec);
8433}
8434
8435static struct hda_verb alc883_medion_md2_verbs[] = {
8436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8437 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8438
8439 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8440
8441 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8442 { } /* end */
8443};
8444
8445/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008446static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008447{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008448 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008449
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008450 spec->autocfg.hp_pins[0] = 0x14;
8451 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008452}
8453
Kailang Yangccc656c2006-10-17 12:32:26 +02008454/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008455#define alc883_targa_init_hook alc882_targa_init_hook
8456#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008457
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008458static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8459{
8460 unsigned int present;
8461
Takashi Iwaid56757a2009-11-18 08:00:14 +01008462 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008463 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8464 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8465}
8466
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008467static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008468{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008469 struct alc_spec *spec = codec->spec;
8470
8471 spec->autocfg.hp_pins[0] = 0x15;
8472 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008473}
8474
8475static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8476{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008477 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008478 alc883_clevo_m720_mic_automute(codec);
8479}
8480
8481static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008482 unsigned int res)
8483{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008484 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008485 case ALC880_MIC_EVENT:
8486 alc883_clevo_m720_mic_automute(codec);
8487 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008488 default:
8489 alc_automute_amp_unsol_event(codec, res);
8490 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008491 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008492}
8493
Jiang zhefb97dc62008-03-06 11:07:11 +01008494/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008495static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008496{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008497 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008498
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008499 spec->autocfg.hp_pins[0] = 0x14;
8500 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008501}
8502
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008503static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008504{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008505 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008506
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008507 spec->autocfg.hp_pins[0] = 0x1b;
8508 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008509}
8510
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008511static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8512{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008513 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008514
Takashi Iwai47fd8302007-08-10 17:11:07 +02008515 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8516 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008517}
8518
8519static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8520{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008521 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008522
Takashi Iwai47fd8302007-08-10 17:11:07 +02008523 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8524 HDA_AMP_MUTE, bits);
8525 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8526 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008527}
8528
8529static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8530 unsigned int res)
8531{
8532 if ((res >> 26) == ALC880_HP_EVENT)
8533 alc883_lenovo_101e_all_automute(codec);
8534 if ((res >> 26) == ALC880_FRONT_EVENT)
8535 alc883_lenovo_101e_ispeaker_automute(codec);
8536}
8537
Takashi Iwai676a9b52007-08-16 15:23:35 +02008538/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008539static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008540{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008541 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008542
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008543 spec->autocfg.hp_pins[0] = 0x14;
8544 spec->autocfg.speaker_pins[0] = 0x15;
8545 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008546}
8547
Kailang Yangd1a991a2007-08-15 16:21:59 +02008548static struct hda_verb alc883_acer_eapd_verbs[] = {
8549 /* HP Pin: output 0 (0x0c) */
8550 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8551 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8552 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8553 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008554 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8555 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008556 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008557 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8558 /* eanable EAPD on medion laptop */
8559 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8560 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008561 /* enable unsolicited event */
8562 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008563 { }
8564};
8565
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008566static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8567 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8568 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8569 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8570 { } /* end */
8571};
8572
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008573static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008574{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008575 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008576
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008577 spec->autocfg.hp_pins[0] = 0x1b;
8578 spec->autocfg.speaker_pins[0] = 0x14;
8579 spec->autocfg.speaker_pins[1] = 0x15;
8580 spec->autocfg.speaker_pins[2] = 0x16;
8581 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008582}
8583
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008584static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008585{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008586 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008587
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008588 spec->autocfg.hp_pins[0] = 0x1b;
8589 spec->autocfg.speaker_pins[0] = 0x14;
8590 spec->autocfg.speaker_pins[1] = 0x15;
8591 spec->autocfg.speaker_pins[2] = 0x16;
8592 spec->autocfg.speaker_pins[3] = 0x17;
8593 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008594}
8595
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008596static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008597{
8598 struct alc_spec *spec = codec->spec;
8599
8600 spec->autocfg.hp_pins[0] = 0x15;
8601 spec->autocfg.speaker_pins[0] = 0x14;
8602 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008603}
8604
Kailang Yange2757d52008-08-26 13:17:46 +02008605static struct hda_verb alc888_asus_m90v_verbs[] = {
8606 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8607 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8608 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8609 /* enable unsolicited event */
8610 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8611 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8612 { } /* end */
8613};
8614
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008615static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008616{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008617 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008618
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008619 spec->autocfg.hp_pins[0] = 0x1b;
8620 spec->autocfg.speaker_pins[0] = 0x14;
8621 spec->autocfg.speaker_pins[1] = 0x15;
8622 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008623 spec->ext_mic.pin = 0x18;
8624 spec->int_mic.pin = 0x19;
8625 spec->ext_mic.mux_idx = 0;
8626 spec->int_mic.mux_idx = 1;
8627 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008628}
8629
8630static struct hda_verb alc888_asus_eee1601_verbs[] = {
8631 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8632 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8633 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8634 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8635 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8636 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8637 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8638 /* enable unsolicited event */
8639 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8640 { } /* end */
8641};
8642
Kailang Yange2757d52008-08-26 13:17:46 +02008643static void alc883_eee1601_inithook(struct hda_codec *codec)
8644{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008645 struct alc_spec *spec = codec->spec;
8646
8647 spec->autocfg.hp_pins[0] = 0x14;
8648 spec->autocfg.speaker_pins[0] = 0x1b;
8649 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008650}
8651
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008652static struct hda_verb alc889A_mb31_verbs[] = {
8653 /* Init rear pin (used as headphone output) */
8654 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8655 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8656 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8657 /* Init line pin (used as output in 4ch and 6ch mode) */
8658 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8659 /* Init line 2 pin (used as headphone out by default) */
8660 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8661 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8662 { } /* end */
8663};
8664
8665/* Mute speakers according to the headphone jack state */
8666static void alc889A_mb31_automute(struct hda_codec *codec)
8667{
8668 unsigned int present;
8669
8670 /* Mute only in 2ch or 4ch mode */
8671 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8672 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08008673 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008674 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8675 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8676 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8677 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8678 }
8679}
8680
8681static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8682{
8683 if ((res >> 26) == ALC880_HP_EVENT)
8684 alc889A_mb31_automute(codec);
8685}
8686
Takashi Iwai4953550a2009-06-30 15:28:30 +02008687
Takashi Iwaicb53c622007-08-10 17:21:45 +02008688#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008689#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008690#endif
8691
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008692/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008693#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8694#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8695#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8696#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8697
8698static hda_nid_t alc883_slave_dig_outs[] = {
8699 ALC1200_DIGOUT_NID, 0,
8700};
8701
8702static hda_nid_t alc1200_slave_dig_outs[] = {
8703 ALC883_DIGOUT_NID, 0,
8704};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008705
8706/*
8707 * configuration and preset
8708 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008709static const char *alc882_models[ALC882_MODEL_LAST] = {
8710 [ALC882_3ST_DIG] = "3stack-dig",
8711 [ALC882_6ST_DIG] = "6stack-dig",
8712 [ALC882_ARIMA] = "arima",
8713 [ALC882_W2JC] = "w2jc",
8714 [ALC882_TARGA] = "targa",
8715 [ALC882_ASUS_A7J] = "asus-a7j",
8716 [ALC882_ASUS_A7M] = "asus-a7m",
8717 [ALC885_MACPRO] = "macpro",
8718 [ALC885_MB5] = "mb5",
8719 [ALC885_MBP3] = "mbp3",
8720 [ALC885_IMAC24] = "imac24",
8721 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008722 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8723 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008724 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008725 [ALC883_TARGA_DIG] = "targa-dig",
8726 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008727 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008728 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008729 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008730 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008731 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008732 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008733 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008734 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008735 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008736 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008737 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008738 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8739 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008740 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008741 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008742 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008743 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008744 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308745 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008746 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008747 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008748 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008749 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008750 [ALC889A_INTEL] = "intel-alc889a",
8751 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008752 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008753 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008754 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008755 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008756};
8757
Takashi Iwai4953550a2009-06-30 15:28:30 +02008758static struct snd_pci_quirk alc882_cfg_tbl[] = {
8759 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8760
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008761 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008762 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008763 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008764 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8765 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008766 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008767 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8768 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008769 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01008770 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008771 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8772 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008773 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8774 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008775 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8776 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008777 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008778 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008779 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008780 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008781 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8782 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008783 /* default Acer -- disabled as it causes more problems.
8784 * model=auto should work fine now
8785 */
8786 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008787
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008788 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008789
Tobin Davisfebe3372007-06-12 11:27:46 +02008790 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008791 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8792 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008793 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008794 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008795 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008796
8797 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8798 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8799 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008800 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008801 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8802 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8803 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008804 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008805 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008806 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008807 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008808
8809 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008810 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008811 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008812 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008813 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8814 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008815 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008816 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008817 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8818
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008819 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8820 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8821 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008822 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Jiang zhe4383fae2008-04-14 12:58:57 +02008823 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008824 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008825 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008826 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008827 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8828 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8829 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8830 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8831 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8832 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008833 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008834 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8835 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8836 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008837 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008838 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8839 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008840 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008841 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008842 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008843 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008844 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008845 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008846 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008847 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008848
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008849 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008850 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8851 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308852 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008853 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008854 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008855 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008856 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008857 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008858 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008859 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008860 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008861 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008862 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008863 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8864 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008865 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008866 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008867 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008868 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008869 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008870
Jiang zhe17bba1b2008-06-04 12:11:07 +02008871 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8872 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008873 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008874 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8875 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8876 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008877 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008878
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008879 {}
8880};
8881
Takashi Iwai4953550a2009-06-30 15:28:30 +02008882/* codec SSID table for Intel Mac */
8883static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8884 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8885 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8886 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8887 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8888 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8889 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8890 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8891 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8892 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8893 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8894 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05008895 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
8896 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02008897 */
8898 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05008899 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008900 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008901};
8902
Takashi Iwai4953550a2009-06-30 15:28:30 +02008903static struct alc_config_preset alc882_presets[] = {
8904 [ALC882_3ST_DIG] = {
8905 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008906 .init_verbs = { alc882_base_init_verbs,
8907 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008908 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8909 .dac_nids = alc882_dac_nids,
8910 .dig_out_nid = ALC882_DIGOUT_NID,
8911 .dig_in_nid = ALC882_DIGIN_NID,
8912 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8913 .channel_mode = alc882_ch_modes,
8914 .need_dac_fix = 1,
8915 .input_mux = &alc882_capture_source,
8916 },
8917 [ALC882_6ST_DIG] = {
8918 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008919 .init_verbs = { alc882_base_init_verbs,
8920 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008921 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8922 .dac_nids = alc882_dac_nids,
8923 .dig_out_nid = ALC882_DIGOUT_NID,
8924 .dig_in_nid = ALC882_DIGIN_NID,
8925 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8926 .channel_mode = alc882_sixstack_modes,
8927 .input_mux = &alc882_capture_source,
8928 },
8929 [ALC882_ARIMA] = {
8930 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008931 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8932 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008933 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8934 .dac_nids = alc882_dac_nids,
8935 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8936 .channel_mode = alc882_sixstack_modes,
8937 .input_mux = &alc882_capture_source,
8938 },
8939 [ALC882_W2JC] = {
8940 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008941 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8942 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008943 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8944 .dac_nids = alc882_dac_nids,
8945 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8946 .channel_mode = alc880_threestack_modes,
8947 .need_dac_fix = 1,
8948 .input_mux = &alc882_capture_source,
8949 .dig_out_nid = ALC882_DIGOUT_NID,
8950 },
8951 [ALC885_MBP3] = {
8952 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8953 .init_verbs = { alc885_mbp3_init_verbs,
8954 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02008955 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008956 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02008957 .hp_nid = 0x04,
8958 .channel_mode = alc885_mbp_4ch_modes,
8959 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008960 .input_mux = &alc882_capture_source,
8961 .dig_out_nid = ALC882_DIGOUT_NID,
8962 .dig_in_nid = ALC882_DIGIN_NID,
8963 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008964 .setup = alc885_mbp3_setup,
8965 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008966 },
8967 [ALC885_MB5] = {
8968 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8969 .init_verbs = { alc885_mb5_init_verbs,
8970 alc880_gpio1_init_verbs },
8971 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8972 .dac_nids = alc882_dac_nids,
8973 .channel_mode = alc885_mb5_6ch_modes,
8974 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8975 .input_mux = &mb5_capture_source,
8976 .dig_out_nid = ALC882_DIGOUT_NID,
8977 .dig_in_nid = ALC882_DIGIN_NID,
8978 },
8979 [ALC885_MACPRO] = {
8980 .mixers = { alc882_macpro_mixer },
8981 .init_verbs = { alc882_macpro_init_verbs },
8982 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8983 .dac_nids = alc882_dac_nids,
8984 .dig_out_nid = ALC882_DIGOUT_NID,
8985 .dig_in_nid = ALC882_DIGIN_NID,
8986 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8987 .channel_mode = alc882_ch_modes,
8988 .input_mux = &alc882_capture_source,
8989 .init_hook = alc885_macpro_init_hook,
8990 },
8991 [ALC885_IMAC24] = {
8992 .mixers = { alc885_imac24_mixer },
8993 .init_verbs = { alc885_imac24_init_verbs },
8994 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8995 .dac_nids = alc882_dac_nids,
8996 .dig_out_nid = ALC882_DIGOUT_NID,
8997 .dig_in_nid = ALC882_DIGIN_NID,
8998 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8999 .channel_mode = alc882_ch_modes,
9000 .input_mux = &alc882_capture_source,
9001 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009002 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009003 .init_hook = alc885_imac24_init_hook,
9004 },
9005 [ALC882_TARGA] = {
9006 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009007 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009008 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009009 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9010 .dac_nids = alc882_dac_nids,
9011 .dig_out_nid = ALC882_DIGOUT_NID,
9012 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9013 .adc_nids = alc882_adc_nids,
9014 .capsrc_nids = alc882_capsrc_nids,
9015 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9016 .channel_mode = alc882_3ST_6ch_modes,
9017 .need_dac_fix = 1,
9018 .input_mux = &alc882_capture_source,
9019 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009020 .setup = alc882_targa_setup,
9021 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009022 },
9023 [ALC882_ASUS_A7J] = {
9024 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009025 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9026 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009027 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9028 .dac_nids = alc882_dac_nids,
9029 .dig_out_nid = ALC882_DIGOUT_NID,
9030 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9031 .adc_nids = alc882_adc_nids,
9032 .capsrc_nids = alc882_capsrc_nids,
9033 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9034 .channel_mode = alc882_3ST_6ch_modes,
9035 .need_dac_fix = 1,
9036 .input_mux = &alc882_capture_source,
9037 },
9038 [ALC882_ASUS_A7M] = {
9039 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009040 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9041 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009042 alc882_asus_a7m_verbs },
9043 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9044 .dac_nids = alc882_dac_nids,
9045 .dig_out_nid = ALC882_DIGOUT_NID,
9046 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9047 .channel_mode = alc880_threestack_modes,
9048 .need_dac_fix = 1,
9049 .input_mux = &alc882_capture_source,
9050 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009051 [ALC883_3ST_2ch_DIG] = {
9052 .mixers = { alc883_3ST_2ch_mixer },
9053 .init_verbs = { alc883_init_verbs },
9054 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9055 .dac_nids = alc883_dac_nids,
9056 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009057 .dig_in_nid = ALC883_DIGIN_NID,
9058 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9059 .channel_mode = alc883_3ST_2ch_modes,
9060 .input_mux = &alc883_capture_source,
9061 },
9062 [ALC883_3ST_6ch_DIG] = {
9063 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9064 .init_verbs = { alc883_init_verbs },
9065 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9066 .dac_nids = alc883_dac_nids,
9067 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009068 .dig_in_nid = ALC883_DIGIN_NID,
9069 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9070 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009071 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009072 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009073 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009074 [ALC883_3ST_6ch] = {
9075 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9076 .init_verbs = { alc883_init_verbs },
9077 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9078 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009079 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9080 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009081 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009082 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009083 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009084 [ALC883_3ST_6ch_INTEL] = {
9085 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9086 .init_verbs = { alc883_init_verbs },
9087 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9088 .dac_nids = alc883_dac_nids,
9089 .dig_out_nid = ALC883_DIGOUT_NID,
9090 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009091 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009092 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9093 .channel_mode = alc883_3ST_6ch_intel_modes,
9094 .need_dac_fix = 1,
9095 .input_mux = &alc883_3stack_6ch_intel,
9096 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009097 [ALC889A_INTEL] = {
9098 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009099 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9100 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009101 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9102 .dac_nids = alc883_dac_nids,
9103 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9104 .adc_nids = alc889_adc_nids,
9105 .dig_out_nid = ALC883_DIGOUT_NID,
9106 .dig_in_nid = ALC883_DIGIN_NID,
9107 .slave_dig_outs = alc883_slave_dig_outs,
9108 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9109 .channel_mode = alc889_8ch_intel_modes,
9110 .capsrc_nids = alc889_capsrc_nids,
9111 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009112 .setup = alc889_automute_setup,
9113 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009114 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009115 .need_dac_fix = 1,
9116 },
9117 [ALC889_INTEL] = {
9118 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9119 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009120 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009121 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9122 .dac_nids = alc883_dac_nids,
9123 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9124 .adc_nids = alc889_adc_nids,
9125 .dig_out_nid = ALC883_DIGOUT_NID,
9126 .dig_in_nid = ALC883_DIGIN_NID,
9127 .slave_dig_outs = alc883_slave_dig_outs,
9128 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9129 .channel_mode = alc889_8ch_intel_modes,
9130 .capsrc_nids = alc889_capsrc_nids,
9131 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009132 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009133 .init_hook = alc889_intel_init_hook,
9134 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009135 .need_dac_fix = 1,
9136 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009137 [ALC883_6ST_DIG] = {
9138 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9139 .init_verbs = { alc883_init_verbs },
9140 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9141 .dac_nids = alc883_dac_nids,
9142 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009143 .dig_in_nid = ALC883_DIGIN_NID,
9144 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9145 .channel_mode = alc883_sixstack_modes,
9146 .input_mux = &alc883_capture_source,
9147 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009148 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009149 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009150 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9151 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009152 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9153 .dac_nids = alc883_dac_nids,
9154 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009155 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9156 .channel_mode = alc883_3ST_6ch_modes,
9157 .need_dac_fix = 1,
9158 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009159 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009160 .setup = alc882_targa_setup,
9161 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009162 },
9163 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009164 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009165 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9166 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009167 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9168 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009169 .adc_nids = alc883_adc_nids_alt,
9170 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009171 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009172 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9173 .channel_mode = alc883_3ST_2ch_modes,
9174 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009175 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009176 .setup = alc882_targa_setup,
9177 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009178 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009179 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009180 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9181 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009182 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009183 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009184 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9185 .dac_nids = alc883_dac_nids,
9186 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9187 .adc_nids = alc883_adc_nids_rev,
9188 .capsrc_nids = alc883_capsrc_nids_rev,
9189 .dig_out_nid = ALC883_DIGOUT_NID,
9190 .dig_in_nid = ALC883_DIGIN_NID,
9191 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9192 .channel_mode = alc883_4ST_8ch_modes,
9193 .need_dac_fix = 1,
9194 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009195 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009196 .setup = alc882_targa_setup,
9197 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009198 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009199 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009200 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009201 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9202 * and the headphone jack. Turn this on and rely on the
9203 * standard mute methods whenever the user wants to turn
9204 * these outputs off.
9205 */
9206 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9207 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9208 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009209 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9210 .channel_mode = alc883_3ST_2ch_modes,
9211 .input_mux = &alc883_capture_source,
9212 },
Tobin Davis2880a862007-08-07 11:50:26 +02009213 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009214 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009215 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009216 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9217 .dac_nids = alc883_dac_nids,
9218 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009219 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9220 .channel_mode = alc883_3ST_2ch_modes,
9221 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009222 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009223 .setup = alc883_acer_aspire_setup,
9224 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009225 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009226 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009227 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009228 alc883_chmode_mixer },
9229 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9230 alc888_acer_aspire_4930g_verbs },
9231 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9232 .dac_nids = alc883_dac_nids,
9233 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9234 .adc_nids = alc883_adc_nids_rev,
9235 .capsrc_nids = alc883_capsrc_nids_rev,
9236 .dig_out_nid = ALC883_DIGOUT_NID,
9237 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9238 .channel_mode = alc883_3ST_6ch_modes,
9239 .need_dac_fix = 1,
9240 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009241 ARRAY_SIZE(alc888_2_capture_sources),
9242 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009243 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009244 .setup = alc888_acer_aspire_4930g_setup,
9245 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009246 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009247 [ALC888_ACER_ASPIRE_6530G] = {
9248 .mixers = { alc888_acer_aspire_6530_mixer },
9249 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9250 alc888_acer_aspire_6530g_verbs },
9251 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9252 .dac_nids = alc883_dac_nids,
9253 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9254 .adc_nids = alc883_adc_nids_rev,
9255 .capsrc_nids = alc883_capsrc_nids_rev,
9256 .dig_out_nid = ALC883_DIGOUT_NID,
9257 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9258 .channel_mode = alc883_3ST_2ch_modes,
9259 .num_mux_defs =
9260 ARRAY_SIZE(alc888_2_capture_sources),
9261 .input_mux = alc888_acer_aspire_6530_sources,
9262 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009263 .setup = alc888_acer_aspire_6530g_setup,
9264 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009265 },
Hector Martin3b315d72009-06-02 10:54:19 +02009266 [ALC888_ACER_ASPIRE_8930G] = {
9267 .mixers = { alc888_base_mixer,
9268 alc883_chmode_mixer },
9269 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009270 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009271 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9272 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009273 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9274 .adc_nids = alc889_adc_nids,
9275 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009276 .dig_out_nid = ALC883_DIGOUT_NID,
9277 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9278 .channel_mode = alc883_3ST_6ch_modes,
9279 .need_dac_fix = 1,
9280 .const_channel_count = 6,
9281 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009282 ARRAY_SIZE(alc889_capture_sources),
9283 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009284 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009285 .setup = alc889_acer_aspire_8930g_setup,
9286 .init_hook = alc_automute_amp,
Hector Martin3b315d72009-06-02 10:54:19 +02009287 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009288 [ALC888_ACER_ASPIRE_7730G] = {
9289 .mixers = { alc883_3ST_6ch_mixer,
9290 alc883_chmode_mixer },
9291 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9292 alc888_acer_aspire_7730G_verbs },
9293 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9294 .dac_nids = alc883_dac_nids,
9295 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9296 .adc_nids = alc883_adc_nids_rev,
9297 .capsrc_nids = alc883_capsrc_nids_rev,
9298 .dig_out_nid = ALC883_DIGOUT_NID,
9299 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9300 .channel_mode = alc883_3ST_6ch_modes,
9301 .need_dac_fix = 1,
9302 .const_channel_count = 6,
9303 .input_mux = &alc883_capture_source,
9304 .unsol_event = alc_automute_amp_unsol_event,
9305 .setup = alc888_acer_aspire_6530g_setup,
9306 .init_hook = alc_automute_amp,
9307 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009308 [ALC883_MEDION] = {
9309 .mixers = { alc883_fivestack_mixer,
9310 alc883_chmode_mixer },
9311 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009312 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009313 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9314 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009315 .adc_nids = alc883_adc_nids_alt,
9316 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009317 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9318 .channel_mode = alc883_sixstack_modes,
9319 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009320 },
Kailang Yang272a5272007-05-14 11:00:38 +02009321 [ALC883_MEDION_MD2] = {
9322 .mixers = { alc883_medion_md2_mixer},
9323 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9324 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9325 .dac_nids = alc883_dac_nids,
9326 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009327 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9328 .channel_mode = alc883_3ST_2ch_modes,
9329 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009330 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009331 .setup = alc883_medion_md2_setup,
9332 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009333 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009334 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009335 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009336 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9337 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9338 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009339 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9340 .channel_mode = alc883_3ST_2ch_modes,
9341 .input_mux = &alc883_capture_source,
9342 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309343 [ALC883_CLEVO_M540R] = {
9344 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9345 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9346 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9347 .dac_nids = alc883_dac_nids,
9348 .dig_out_nid = ALC883_DIGOUT_NID,
9349 .dig_in_nid = ALC883_DIGIN_NID,
9350 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9351 .channel_mode = alc883_3ST_6ch_clevo_modes,
9352 .need_dac_fix = 1,
9353 .input_mux = &alc883_capture_source,
9354 /* This machine has the hardware HP auto-muting, thus
9355 * we need no software mute via unsol event
9356 */
9357 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009358 [ALC883_CLEVO_M720] = {
9359 .mixers = { alc883_clevo_m720_mixer },
9360 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009361 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9362 .dac_nids = alc883_dac_nids,
9363 .dig_out_nid = ALC883_DIGOUT_NID,
9364 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9365 .channel_mode = alc883_3ST_2ch_modes,
9366 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009367 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009368 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009369 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009370 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009371 [ALC883_LENOVO_101E_2ch] = {
9372 .mixers = { alc883_lenovo_101e_2ch_mixer},
9373 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9374 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9375 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009376 .adc_nids = alc883_adc_nids_alt,
9377 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009378 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9379 .channel_mode = alc883_3ST_2ch_modes,
9380 .input_mux = &alc883_lenovo_101e_capture_source,
9381 .unsol_event = alc883_lenovo_101e_unsol_event,
9382 .init_hook = alc883_lenovo_101e_all_automute,
9383 },
Kailang Yang272a5272007-05-14 11:00:38 +02009384 [ALC883_LENOVO_NB0763] = {
9385 .mixers = { alc883_lenovo_nb0763_mixer },
9386 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9387 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9388 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009389 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9390 .channel_mode = alc883_3ST_2ch_modes,
9391 .need_dac_fix = 1,
9392 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009393 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009394 .setup = alc883_medion_md2_setup,
9395 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009396 },
9397 [ALC888_LENOVO_MS7195_DIG] = {
9398 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9399 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9400 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9401 .dac_nids = alc883_dac_nids,
9402 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009403 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9404 .channel_mode = alc883_3ST_6ch_modes,
9405 .need_dac_fix = 1,
9406 .input_mux = &alc883_capture_source,
9407 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9408 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009409 },
9410 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009411 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009412 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9413 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9414 .dac_nids = alc883_dac_nids,
9415 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009416 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9417 .channel_mode = alc883_3ST_2ch_modes,
9418 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009419 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009420 .setup = alc883_haier_w66_setup,
9421 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009422 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009423 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009424 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009425 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009426 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9427 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009428 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9429 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009430 .need_dac_fix = 1,
9431 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009432 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009433 .setup = alc888_3st_hp_setup,
9434 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009435 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009436 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009437 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009438 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9439 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9440 .dac_nids = alc883_dac_nids,
9441 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009442 .dig_in_nid = ALC883_DIGIN_NID,
9443 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9444 .channel_mode = alc883_sixstack_modes,
9445 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009446 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009447 .setup = alc888_6st_dell_setup,
9448 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009449 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009450 [ALC883_MITAC] = {
9451 .mixers = { alc883_mitac_mixer },
9452 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9453 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9454 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009455 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9456 .channel_mode = alc883_3ST_2ch_modes,
9457 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009458 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009459 .setup = alc883_mitac_setup,
9460 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009461 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009462 [ALC883_FUJITSU_PI2515] = {
9463 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9464 .init_verbs = { alc883_init_verbs,
9465 alc883_2ch_fujitsu_pi2515_verbs},
9466 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9467 .dac_nids = alc883_dac_nids,
9468 .dig_out_nid = ALC883_DIGOUT_NID,
9469 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9470 .channel_mode = alc883_3ST_2ch_modes,
9471 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009472 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009473 .setup = alc883_2ch_fujitsu_pi2515_setup,
9474 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009475 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009476 [ALC888_FUJITSU_XA3530] = {
9477 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9478 .init_verbs = { alc883_init_verbs,
9479 alc888_fujitsu_xa3530_verbs },
9480 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9481 .dac_nids = alc883_dac_nids,
9482 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9483 .adc_nids = alc883_adc_nids_rev,
9484 .capsrc_nids = alc883_capsrc_nids_rev,
9485 .dig_out_nid = ALC883_DIGOUT_NID,
9486 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9487 .channel_mode = alc888_4ST_8ch_intel_modes,
9488 .num_mux_defs =
9489 ARRAY_SIZE(alc888_2_capture_sources),
9490 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009491 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009492 .setup = alc888_fujitsu_xa3530_setup,
9493 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009494 },
Kailang Yange2757d52008-08-26 13:17:46 +02009495 [ALC888_LENOVO_SKY] = {
9496 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9497 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9498 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9499 .dac_nids = alc883_dac_nids,
9500 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009501 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9502 .channel_mode = alc883_sixstack_modes,
9503 .need_dac_fix = 1,
9504 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009505 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009506 .setup = alc888_lenovo_sky_setup,
9507 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009508 },
9509 [ALC888_ASUS_M90V] = {
9510 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9511 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9512 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9513 .dac_nids = alc883_dac_nids,
9514 .dig_out_nid = ALC883_DIGOUT_NID,
9515 .dig_in_nid = ALC883_DIGIN_NID,
9516 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9517 .channel_mode = alc883_3ST_6ch_modes,
9518 .need_dac_fix = 1,
9519 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009520 .unsol_event = alc_sku_unsol_event,
9521 .setup = alc883_mode2_setup,
9522 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009523 },
9524 [ALC888_ASUS_EEE1601] = {
9525 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009526 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009527 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9528 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9529 .dac_nids = alc883_dac_nids,
9530 .dig_out_nid = ALC883_DIGOUT_NID,
9531 .dig_in_nid = ALC883_DIGIN_NID,
9532 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9533 .channel_mode = alc883_3ST_2ch_modes,
9534 .need_dac_fix = 1,
9535 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009536 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009537 .init_hook = alc883_eee1601_inithook,
9538 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009539 [ALC1200_ASUS_P5Q] = {
9540 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9541 .init_verbs = { alc883_init_verbs },
9542 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9543 .dac_nids = alc883_dac_nids,
9544 .dig_out_nid = ALC1200_DIGOUT_NID,
9545 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009546 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009547 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9548 .channel_mode = alc883_sixstack_modes,
9549 .input_mux = &alc883_capture_source,
9550 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009551 [ALC889A_MB31] = {
9552 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9553 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9554 alc880_gpio1_init_verbs },
9555 .adc_nids = alc883_adc_nids,
9556 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9557 .dac_nids = alc883_dac_nids,
9558 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9559 .channel_mode = alc889A_mb31_6ch_modes,
9560 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9561 .input_mux = &alc889A_mb31_capture_source,
9562 .dig_out_nid = ALC883_DIGOUT_NID,
9563 .unsol_event = alc889A_mb31_unsol_event,
9564 .init_hook = alc889A_mb31_automute,
9565 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009566 [ALC883_SONY_VAIO_TT] = {
9567 .mixers = { alc883_vaiott_mixer },
9568 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9569 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9570 .dac_nids = alc883_dac_nids,
9571 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9572 .channel_mode = alc883_3ST_2ch_modes,
9573 .input_mux = &alc883_capture_source,
9574 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009575 .setup = alc883_vaiott_setup,
9576 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009577 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009578};
9579
9580
9581/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009582 * Pin config fixes
9583 */
9584enum {
9585 PINFIX_ABIT_AW9D_MAX
9586};
9587
9588static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9589 { 0x15, 0x01080104 }, /* side */
9590 { 0x16, 0x01011012 }, /* rear */
9591 { 0x17, 0x01016011 }, /* clfe */
9592 { }
9593};
9594
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009595static const struct alc_fixup alc882_fixups[] = {
9596 [PINFIX_ABIT_AW9D_MAX] = {
9597 .pins = alc882_abit_aw9d_pinfix
9598 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009599};
9600
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009601static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009602 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9603 {}
9604};
9605
9606/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009607 * BIOS auto configuration
9608 */
Takashi Iwai05f5f472009-08-25 13:10:18 +02009609static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9610 const struct auto_pin_cfg *cfg)
9611{
9612 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9613}
9614
Takashi Iwai4953550a2009-06-30 15:28:30 +02009615static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009616 hda_nid_t nid, int pin_type,
9617 int dac_idx)
9618{
9619 /* set as output */
9620 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009621 int idx;
9622
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009623 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009624 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9625 idx = 4;
9626 else
9627 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009628 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9629
9630}
9631
Takashi Iwai4953550a2009-06-30 15:28:30 +02009632static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009633{
9634 struct alc_spec *spec = codec->spec;
9635 int i;
9636
9637 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009638 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009639 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009640 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009641 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009642 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009643 }
9644}
9645
Takashi Iwai4953550a2009-06-30 15:28:30 +02009646static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009647{
9648 struct alc_spec *spec = codec->spec;
9649 hda_nid_t pin;
9650
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009651 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009652 if (pin) /* connect to front */
9653 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009654 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009655 pin = spec->autocfg.speaker_pins[0];
9656 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009657 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009658}
9659
Takashi Iwai4953550a2009-06-30 15:28:30 +02009660static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009661{
9662 struct alc_spec *spec = codec->spec;
9663 int i;
9664
9665 for (i = 0; i < AUTO_PIN_LAST; i++) {
9666 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009667 if (!nid)
9668 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009669 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009670 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9671 snd_hda_codec_write(codec, nid, 0,
9672 AC_VERB_SET_AMP_GAIN_MUTE,
9673 AMP_OUT_MUTE);
9674 }
9675}
9676
9677static void alc882_auto_init_input_src(struct hda_codec *codec)
9678{
9679 struct alc_spec *spec = codec->spec;
9680 int c;
9681
9682 for (c = 0; c < spec->num_adc_nids; c++) {
9683 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9684 hda_nid_t nid = spec->capsrc_nids[c];
9685 unsigned int mux_idx;
9686 const struct hda_input_mux *imux;
9687 int conns, mute, idx, item;
9688
9689 conns = snd_hda_get_connections(codec, nid, conn_list,
9690 ARRAY_SIZE(conn_list));
9691 if (conns < 0)
9692 continue;
9693 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9694 imux = &spec->input_mux[mux_idx];
9695 for (idx = 0; idx < conns; idx++) {
9696 /* if the current connection is the selected one,
9697 * unmute it as default - otherwise mute it
9698 */
9699 mute = AMP_IN_MUTE(idx);
9700 for (item = 0; item < imux->num_items; item++) {
9701 if (imux->items[item].index == idx) {
9702 if (spec->cur_mux[c] == item)
9703 mute = AMP_IN_UNMUTE(idx);
9704 break;
9705 }
9706 }
9707 /* check if we have a selector or mixer
9708 * we could check for the widget type instead, but
9709 * just check for Amp-In presence (in case of mixer
9710 * without amp-in there is something wrong, this
9711 * function shouldn't be used or capsrc nid is wrong)
9712 */
9713 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009714 snd_hda_codec_write(codec, nid, 0,
9715 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009716 mute);
9717 else if (mute != AMP_IN_MUTE(idx))
9718 snd_hda_codec_write(codec, nid, 0,
9719 AC_VERB_SET_CONNECT_SEL,
9720 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009721 }
9722 }
9723}
9724
Takashi Iwai4953550a2009-06-30 15:28:30 +02009725/* add mic boosts if needed */
9726static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009727{
9728 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009729 int err;
9730 hda_nid_t nid;
9731
9732 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9733 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9734 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9735 "Mic Boost",
9736 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9737 if (err < 0)
9738 return err;
9739 }
9740 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9741 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9742 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9743 "Front Mic Boost",
9744 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9745 if (err < 0)
9746 return err;
9747 }
9748 return 0;
9749}
9750
9751/* almost identical with ALC880 parser... */
9752static int alc882_parse_auto_config(struct hda_codec *codec)
9753{
9754 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009755 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9756 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009757
Takashi Iwai05f5f472009-08-25 13:10:18 +02009758 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9759 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009760 if (err < 0)
9761 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009762 if (!spec->autocfg.line_outs)
9763 return 0; /* can't find valid BIOS pin config */
9764
9765 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9766 if (err < 0)
9767 return err;
9768 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9769 if (err < 0)
9770 return err;
9771 err = alc880_auto_create_extra_out(spec,
9772 spec->autocfg.speaker_pins[0],
9773 "Speaker");
9774 if (err < 0)
9775 return err;
9776 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9777 "Headphone");
9778 if (err < 0)
9779 return err;
9780 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9781 if (err < 0)
9782 return err;
9783
9784 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9785
9786 /* check multiple SPDIF-out (for recent codecs) */
9787 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9788 hda_nid_t dig_nid;
9789 err = snd_hda_get_connections(codec,
9790 spec->autocfg.dig_out_pins[i],
9791 &dig_nid, 1);
9792 if (err < 0)
9793 continue;
9794 if (!i)
9795 spec->multiout.dig_out_nid = dig_nid;
9796 else {
9797 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01009798 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +02009799 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01009800 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009801 }
9802 }
9803 if (spec->autocfg.dig_in_pin)
9804 spec->dig_in_nid = ALC880_DIGIN_NID;
9805
9806 if (spec->kctls.list)
9807 add_mixer(spec, spec->kctls.list);
9808
9809 add_verb(spec, alc883_auto_init_verbs);
9810 /* if ADC 0x07 is available, initialize it, too */
9811 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9812 add_verb(spec, alc882_adc1_init_verbs);
9813
9814 spec->num_mux_defs = 1;
9815 spec->input_mux = &spec->private_imux[0];
9816
9817 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +02009818
9819 err = alc_auto_add_mic_boost(codec);
9820 if (err < 0)
9821 return err;
9822
Takashi Iwai776e1842007-08-29 15:07:11 +02009823 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009824}
9825
9826/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009827static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009828{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009829 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009830 alc882_auto_init_multi_out(codec);
9831 alc882_auto_init_hp_out(codec);
9832 alc882_auto_init_analog_input(codec);
9833 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009834 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009835 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009836}
9837
Takashi Iwai4953550a2009-06-30 15:28:30 +02009838static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009839{
9840 struct alc_spec *spec;
9841 int err, board_config;
9842
9843 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9844 if (spec == NULL)
9845 return -ENOMEM;
9846
9847 codec->spec = spec;
9848
Takashi Iwai4953550a2009-06-30 15:28:30 +02009849 switch (codec->vendor_id) {
9850 case 0x10ec0882:
9851 case 0x10ec0885:
9852 break;
9853 default:
9854 /* ALC883 and variants */
9855 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9856 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009857 }
9858
Takashi Iwai4953550a2009-06-30 15:28:30 +02009859 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9860 alc882_models,
9861 alc882_cfg_tbl);
9862
9863 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9864 board_config = snd_hda_check_board_codec_sid_config(codec,
9865 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9866
9867 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009868 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009869 codec->chip_name);
9870 board_config = ALC882_AUTO;
9871 }
9872
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02009873 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009874
9875 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009876 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009877 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009878 if (err < 0) {
9879 alc_free(codec);
9880 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009881 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009882 printk(KERN_INFO
9883 "hda_codec: Cannot set up configuration "
9884 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +02009885 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009886 }
9887 }
9888
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009889 err = snd_hda_attach_beep_device(codec, 0x1);
9890 if (err < 0) {
9891 alc_free(codec);
9892 return err;
9893 }
9894
Takashi Iwai4953550a2009-06-30 15:28:30 +02009895 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02009896 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009897
Takashi Iwai4953550a2009-06-30 15:28:30 +02009898 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9899 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9900 /* FIXME: setup DAC5 */
9901 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9902 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9903
9904 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9905 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9906
9907 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009908 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009909
9910 if (!spec->adc_nids && spec->input_mux) {
9911 int i;
9912 spec->num_adc_nids = 0;
9913 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9914 hda_nid_t cap;
9915 hda_nid_t nid = alc882_adc_nids[i];
9916 unsigned int wcap = get_wcaps(codec, nid);
9917 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02009918 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009919 if (wcap != AC_WID_AUD_IN)
9920 continue;
9921 spec->private_adc_nids[spec->num_adc_nids] = nid;
9922 err = snd_hda_get_connections(codec, nid, &cap, 1);
9923 if (err < 0)
9924 continue;
9925 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9926 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009927 }
Takashi Iwai4953550a2009-06-30 15:28:30 +02009928 spec->adc_nids = spec->private_adc_nids;
9929 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009930 }
9931
Takashi Iwaib59bdf32009-08-11 09:47:30 +02009932 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009933 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009934
Takashi Iwai2134ea42008-01-10 16:53:55 +01009935 spec->vmaster_nid = 0x0c;
9936
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009937 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009938 if (board_config == ALC882_AUTO)
9939 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009940#ifdef CONFIG_SND_HDA_POWER_SAVE
9941 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009942 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009943#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009944 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009945
9946 return 0;
9947}
9948
Takashi Iwai4953550a2009-06-30 15:28:30 +02009949
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009950/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009951 * ALC262 support
9952 */
9953
9954#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9955#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9956
9957#define alc262_dac_nids alc260_dac_nids
9958#define alc262_adc_nids alc882_adc_nids
9959#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009960#define alc262_capsrc_nids alc882_capsrc_nids
9961#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009962
9963#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009964#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009965
Kailang Yang4e555fe2008-08-26 13:05:55 +02009966static hda_nid_t alc262_dmic_adc_nids[1] = {
9967 /* ADC0 */
9968 0x09
9969};
9970
9971static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9972
Kailang Yangdf694da2005-12-05 19:42:22 +01009973static struct snd_kcontrol_new alc262_base_mixer[] = {
9974 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9975 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9976 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9977 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9978 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9979 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9980 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9981 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009982 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009983 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9984 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009985 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009986 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9988 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9989 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009990 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009991};
9992
Takashi Iwaice875f02008-01-28 18:17:43 +01009993/* update HP, line and mono-out pins according to the master switch */
9994static void alc262_hp_master_update(struct hda_codec *codec)
9995{
9996 struct alc_spec *spec = codec->spec;
9997 int val = spec->master_sw;
9998
9999 /* HP & line-out */
10000 snd_hda_codec_write_cache(codec, 0x1b, 0,
10001 AC_VERB_SET_PIN_WIDGET_CONTROL,
10002 val ? PIN_HP : 0);
10003 snd_hda_codec_write_cache(codec, 0x15, 0,
10004 AC_VERB_SET_PIN_WIDGET_CONTROL,
10005 val ? PIN_HP : 0);
10006 /* mono (speaker) depending on the HP jack sense */
10007 val = val && !spec->jack_present;
10008 snd_hda_codec_write_cache(codec, 0x16, 0,
10009 AC_VERB_SET_PIN_WIDGET_CONTROL,
10010 val ? PIN_OUT : 0);
10011}
10012
10013static void alc262_hp_bpc_automute(struct hda_codec *codec)
10014{
10015 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010016
10017 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010018 alc262_hp_master_update(codec);
10019}
10020
10021static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10022{
10023 if ((res >> 26) != ALC880_HP_EVENT)
10024 return;
10025 alc262_hp_bpc_automute(codec);
10026}
10027
10028static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10029{
10030 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010031
10032 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010033 alc262_hp_master_update(codec);
10034}
10035
10036static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10037 unsigned int res)
10038{
10039 if ((res >> 26) != ALC880_HP_EVENT)
10040 return;
10041 alc262_hp_wildwest_automute(codec);
10042}
10043
Takashi Iwaib72519b2009-05-08 14:31:55 +020010044#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010045
10046static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10047 struct snd_ctl_elem_value *ucontrol)
10048{
10049 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10050 struct alc_spec *spec = codec->spec;
10051 int val = !!*ucontrol->value.integer.value;
10052
10053 if (val == spec->master_sw)
10054 return 0;
10055 spec->master_sw = val;
10056 alc262_hp_master_update(codec);
10057 return 1;
10058}
10059
Takashi Iwaib72519b2009-05-08 14:31:55 +020010060#define ALC262_HP_MASTER_SWITCH \
10061 { \
10062 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10063 .name = "Master Playback Switch", \
10064 .info = snd_ctl_boolean_mono_info, \
10065 .get = alc262_hp_master_sw_get, \
10066 .put = alc262_hp_master_sw_put, \
10067 }
10068
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010069static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010070 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010071 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10072 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10073 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010074 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10075 HDA_OUTPUT),
10076 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10077 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010078 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10079 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010080 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010081 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10082 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010083 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010084 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10085 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10086 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10087 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010088 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10089 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10090 { } /* end */
10091};
10092
Kailang Yangcd7509a2007-01-26 18:33:17 +010010093static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010094 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010095 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10096 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10097 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10098 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010099 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10100 HDA_OUTPUT),
10101 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10102 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010103 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10104 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010105 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010106 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10107 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010110 { } /* end */
10111};
10112
10113static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10114 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10115 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010116 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010117 { } /* end */
10118};
10119
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010120/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010121static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010122{
10123 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010124
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010125 spec->autocfg.hp_pins[0] = 0x15;
10126 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010127}
10128
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010129static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010130 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10131 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010132 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10133 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10136 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10137 { } /* end */
10138};
10139
10140static struct hda_verb alc262_hp_t5735_verbs[] = {
10141 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10142 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10143
10144 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10145 { }
10146};
10147
Kailang Yang8c427222008-01-10 13:03:59 +010010148static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010149 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10150 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010151 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10152 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010153 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10154 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10155 { } /* end */
10156};
10157
10158static struct hda_verb alc262_hp_rp5700_verbs[] = {
10159 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10160 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10161 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10162 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10163 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10164 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10165 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10166 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10167 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10168 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10169 {}
10170};
10171
10172static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10173 .num_items = 1,
10174 .items = {
10175 { "Line", 0x1 },
10176 },
10177};
10178
Takashi Iwai42171c12009-05-08 14:11:43 +020010179/* bind hp and internal speaker mute (with plug check) as master switch */
10180static void alc262_hippo_master_update(struct hda_codec *codec)
10181{
10182 struct alc_spec *spec = codec->spec;
10183 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10184 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10185 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10186 unsigned int mute;
10187
10188 /* HP */
10189 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10190 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10191 HDA_AMP_MUTE, mute);
10192 /* mute internal speaker per jack sense */
10193 if (spec->jack_present)
10194 mute = HDA_AMP_MUTE;
10195 if (line_nid)
10196 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10197 HDA_AMP_MUTE, mute);
10198 if (speaker_nid && speaker_nid != line_nid)
10199 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10200 HDA_AMP_MUTE, mute);
10201}
10202
10203#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10204
10205static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10206 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010207{
10208 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010209 struct alc_spec *spec = codec->spec;
10210 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010211
Takashi Iwai42171c12009-05-08 14:11:43 +020010212 if (val == spec->master_sw)
10213 return 0;
10214 spec->master_sw = val;
10215 alc262_hippo_master_update(codec);
10216 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010217}
Takashi Iwai5b319542007-07-26 11:49:22 +020010218
Takashi Iwai42171c12009-05-08 14:11:43 +020010219#define ALC262_HIPPO_MASTER_SWITCH \
10220 { \
10221 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10222 .name = "Master Playback Switch", \
10223 .info = snd_ctl_boolean_mono_info, \
10224 .get = alc262_hippo_master_sw_get, \
10225 .put = alc262_hippo_master_sw_put, \
10226 }
10227
10228static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10229 ALC262_HIPPO_MASTER_SWITCH,
10230 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10231 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10232 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10233 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10234 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10235 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10236 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10237 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10238 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10239 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10240 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10241 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10242 { } /* end */
10243};
10244
10245static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10246 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10247 ALC262_HIPPO_MASTER_SWITCH,
10248 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10249 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10250 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10251 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10252 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10253 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10254 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10255 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10256 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10257 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10258 { } /* end */
10259};
10260
10261/* mute/unmute internal speaker according to the hp jack and mute state */
10262static void alc262_hippo_automute(struct hda_codec *codec)
10263{
10264 struct alc_spec *spec = codec->spec;
10265 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010266
Wu Fengguang864f92b2009-11-18 12:38:02 +080010267 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010268 alc262_hippo_master_update(codec);
10269}
10270
10271static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10272{
10273 if ((res >> 26) != ALC880_HP_EVENT)
10274 return;
10275 alc262_hippo_automute(codec);
10276}
10277
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010278static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010279{
10280 struct alc_spec *spec = codec->spec;
10281
10282 spec->autocfg.hp_pins[0] = 0x15;
10283 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010284}
10285
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010286static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010287{
10288 struct alc_spec *spec = codec->spec;
10289
10290 spec->autocfg.hp_pins[0] = 0x1b;
10291 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010292}
10293
10294
Kailang Yang272a5272007-05-14 11:00:38 +020010295static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010296 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010297 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010298 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10299 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10300 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10301 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10302 { } /* end */
10303};
10304
Kailang Yang83c34212007-07-05 11:43:05 +020010305static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010306 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10307 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010308 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10309 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10310 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10311 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10312 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10313 { } /* end */
10314};
Kailang Yang272a5272007-05-14 11:00:38 +020010315
Tony Vroonba340e82009-02-02 19:01:30 +000010316static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10317 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10318 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10319 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10320 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10321 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10322 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10323 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10324 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10325 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10326 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10327 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10328 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10329 { } /* end */
10330};
10331
10332static struct hda_verb alc262_tyan_verbs[] = {
10333 /* Headphone automute */
10334 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10335 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10337
10338 /* P11 AUX_IN, white 4-pin connector */
10339 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10340 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10341 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10342 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10343
10344 {}
10345};
10346
10347/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010348static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010349{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010350 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010351
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010352 spec->autocfg.hp_pins[0] = 0x1b;
10353 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010354}
10355
Tony Vroonba340e82009-02-02 19:01:30 +000010356
Kailang Yangdf694da2005-12-05 19:42:22 +010010357#define alc262_capture_mixer alc882_capture_mixer
10358#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10359
10360/*
10361 * generic initialization of ADC, input mixers and output mixers
10362 */
10363static struct hda_verb alc262_init_verbs[] = {
10364 /*
10365 * Unmute ADC0-2 and set the default input to mic-in
10366 */
10367 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10368 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10369 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10370 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10371 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10372 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10373
Takashi Iwaicb53c622007-08-10 17:21:45 +020010374 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010375 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010376 * Note: PASD motherboards uses the Line In 2 as the input for
10377 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010378 */
10379 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010380 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10381 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10382 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10383 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10384 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010385
10386 /*
10387 * Set up output mixers (0x0c - 0x0e)
10388 */
10389 /* set vol=0 to output mixers */
10390 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10391 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10392 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10393 /* set up input amps for analog loopback */
10394 /* Amp Indices: DAC = 0, mixer = 1 */
10395 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10396 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10397 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10398 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10399 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10400 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10401
10402 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10403 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10404 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10405 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10406 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10407 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10408
10409 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10410 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10411 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10412 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10413 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010414
Kailang Yangdf694da2005-12-05 19:42:22 +010010415 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10416 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010417
Kailang Yangdf694da2005-12-05 19:42:22 +010010418 /* FIXME: use matrix-type input source selection */
10419 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10420 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10421 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10422 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10423 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10424 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10425 /* Input mixer2 */
10426 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10427 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10428 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10429 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10430 /* Input mixer3 */
10431 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10432 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10433 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010434 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010435
10436 { }
10437};
10438
Kailang Yang4e555fe2008-08-26 13:05:55 +020010439static struct hda_verb alc262_eapd_verbs[] = {
10440 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10441 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10442 { }
10443};
10444
Kailang Yangccc656c2006-10-17 12:32:26 +020010445static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10446 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10447 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10448 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10449
10450 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10451 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10452 {}
10453};
10454
Kailang Yang272a5272007-05-14 11:00:38 +020010455static struct hda_verb alc262_sony_unsol_verbs[] = {
10456 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10457 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10458 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10459
10460 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010462 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010463};
10464
Kailang Yang4e555fe2008-08-26 13:05:55 +020010465static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10466 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10467 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10468 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10469 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10470 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010471 { } /* end */
10472};
10473
10474static struct hda_verb alc262_toshiba_s06_verbs[] = {
10475 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10476 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10478 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10479 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10480 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10481 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10482 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10483 {}
10484};
10485
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010486static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010487{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010488 struct alc_spec *spec = codec->spec;
10489
10490 spec->autocfg.hp_pins[0] = 0x15;
10491 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010492 spec->ext_mic.pin = 0x18;
10493 spec->ext_mic.mux_idx = 0;
10494 spec->int_mic.pin = 0x12;
10495 spec->int_mic.mux_idx = 9;
10496 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010497}
10498
Takashi Iwai834be882006-03-01 14:16:17 +010010499/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010500 * nec model
10501 * 0x15 = headphone
10502 * 0x16 = internal speaker
10503 * 0x18 = external mic
10504 */
10505
10506static struct snd_kcontrol_new alc262_nec_mixer[] = {
10507 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10508 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10509
10510 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10511 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10512 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10513
10514 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10515 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10516 { } /* end */
10517};
10518
10519static struct hda_verb alc262_nec_verbs[] = {
10520 /* Unmute Speaker */
10521 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10522
10523 /* Headphone */
10524 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10525 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10526
10527 /* External mic to headphone */
10528 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10529 /* External mic to speaker */
10530 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10531 {}
10532};
10533
10534/*
Takashi Iwai834be882006-03-01 14:16:17 +010010535 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010536 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10537 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010538 */
10539
10540#define ALC_HP_EVENT 0x37
10541
10542static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10543 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10544 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010545 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10546 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010547 {}
10548};
10549
Jiang zhe0e31daf2008-03-20 12:12:39 +010010550static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10551 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10552 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10553 {}
10554};
10555
Takashi Iwai834be882006-03-01 14:16:17 +010010556static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010557 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010558 .items = {
10559 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010560 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010561 { "CD", 0x4 },
10562 },
10563};
10564
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010565static struct hda_input_mux alc262_HP_capture_source = {
10566 .num_items = 5,
10567 .items = {
10568 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010569 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010570 { "Line", 0x2 },
10571 { "CD", 0x4 },
10572 { "AUX IN", 0x6 },
10573 },
10574};
10575
zhejiangaccbe492007-08-31 12:36:05 +020010576static struct hda_input_mux alc262_HP_D7000_capture_source = {
10577 .num_items = 4,
10578 .items = {
10579 { "Mic", 0x0 },
10580 { "Front Mic", 0x2 },
10581 { "Line", 0x1 },
10582 { "CD", 0x4 },
10583 },
10584};
10585
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010586/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010587static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10588{
10589 struct alc_spec *spec = codec->spec;
10590 unsigned int mute;
10591
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010592 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010593 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
10594 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010010595 spec->sense_updated = 1;
10596 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010597 /* unmute internal speaker only if both HPs are unplugged and
10598 * master switch is on
10599 */
10600 if (spec->jack_present)
10601 mute = HDA_AMP_MUTE;
10602 else
Takashi Iwai834be882006-03-01 14:16:17 +010010603 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010604 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10605 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010606}
10607
10608/* unsolicited event for HP jack sensing */
10609static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10610 unsigned int res)
10611{
10612 if ((res >> 26) != ALC_HP_EVENT)
10613 return;
10614 alc262_fujitsu_automute(codec, 1);
10615}
10616
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010617static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10618{
10619 alc262_fujitsu_automute(codec, 1);
10620}
10621
Takashi Iwai834be882006-03-01 14:16:17 +010010622/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010623static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10624 .ops = &snd_hda_bind_vol,
10625 .values = {
10626 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10627 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10628 0
10629 },
10630};
Takashi Iwai834be882006-03-01 14:16:17 +010010631
Jiang zhe0e31daf2008-03-20 12:12:39 +010010632/* mute/unmute internal speaker according to the hp jack and mute state */
10633static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10634{
10635 struct alc_spec *spec = codec->spec;
10636 unsigned int mute;
10637
10638 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010639 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010640 spec->sense_updated = 1;
10641 }
10642 if (spec->jack_present) {
10643 /* mute internal speaker */
10644 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10645 HDA_AMP_MUTE, HDA_AMP_MUTE);
10646 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10647 HDA_AMP_MUTE, HDA_AMP_MUTE);
10648 } else {
10649 /* unmute internal speaker if necessary */
10650 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10651 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10652 HDA_AMP_MUTE, mute);
10653 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10654 HDA_AMP_MUTE, mute);
10655 }
10656}
10657
10658/* unsolicited event for HP jack sensing */
10659static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10660 unsigned int res)
10661{
10662 if ((res >> 26) != ALC_HP_EVENT)
10663 return;
10664 alc262_lenovo_3000_automute(codec, 1);
10665}
10666
Takashi Iwai8de56b72009-07-24 16:51:47 +020010667static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10668 int dir, int idx, long *valp)
10669{
10670 int i, change = 0;
10671
10672 for (i = 0; i < 2; i++, valp++)
10673 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10674 HDA_AMP_MUTE,
10675 *valp ? 0 : HDA_AMP_MUTE);
10676 return change;
10677}
10678
Takashi Iwai834be882006-03-01 14:16:17 +010010679/* bind hp and internal speaker mute (with plug check) */
10680static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10681 struct snd_ctl_elem_value *ucontrol)
10682{
10683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10684 long *valp = ucontrol->value.integer.value;
10685 int change;
10686
Takashi Iwai8de56b72009-07-24 16:51:47 +020010687 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10688 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010689 if (change)
10690 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010691 return change;
10692}
10693
10694static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010695 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010696 {
10697 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10698 .name = "Master Playback Switch",
10699 .info = snd_hda_mixer_amp_switch_info,
10700 .get = snd_hda_mixer_amp_switch_get,
10701 .put = alc262_fujitsu_master_sw_put,
10702 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10703 },
10704 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10705 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10706 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010709 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10710 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10711 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010712 { } /* end */
10713};
10714
Jiang zhe0e31daf2008-03-20 12:12:39 +010010715/* bind hp and internal speaker mute (with plug check) */
10716static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10717 struct snd_ctl_elem_value *ucontrol)
10718{
10719 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10720 long *valp = ucontrol->value.integer.value;
10721 int change;
10722
Takashi Iwai8de56b72009-07-24 16:51:47 +020010723 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010724 if (change)
10725 alc262_lenovo_3000_automute(codec, 0);
10726 return change;
10727}
10728
10729static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10730 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10731 {
10732 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10733 .name = "Master Playback Switch",
10734 .info = snd_hda_mixer_amp_switch_info,
10735 .get = snd_hda_mixer_amp_switch_get,
10736 .put = alc262_lenovo_3000_master_sw_put,
10737 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10738 },
10739 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10740 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10741 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10744 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10745 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10746 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10747 { } /* end */
10748};
10749
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010750static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10751 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010752 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010753 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10754 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10755 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10756 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10757 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10758 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10759 { } /* end */
10760};
10761
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010762/* additional init verbs for Benq laptops */
10763static struct hda_verb alc262_EAPD_verbs[] = {
10764 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10765 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10766 {}
10767};
10768
Kailang Yang83c34212007-07-05 11:43:05 +020010769static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10770 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10771 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10772
10773 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10774 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10775 {}
10776};
10777
Tobin Davisf651b502007-10-26 12:40:47 +020010778/* Samsung Q1 Ultra Vista model setup */
10779static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010780 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10781 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010782 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10783 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10784 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010785 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010786 { } /* end */
10787};
10788
10789static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010790 /* output mixer */
10791 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10792 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10793 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10794 /* speaker */
10795 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10796 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10797 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10798 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10799 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010800 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010801 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10802 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10803 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10804 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10805 /* internal mic */
10806 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10807 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10808 /* ADC, choose mic */
10809 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10810 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10811 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10812 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10813 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10814 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10815 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10816 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10817 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10818 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010819 {}
10820};
10821
Tobin Davisf651b502007-10-26 12:40:47 +020010822/* mute/unmute internal speaker according to the hp jack and mute state */
10823static void alc262_ultra_automute(struct hda_codec *codec)
10824{
10825 struct alc_spec *spec = codec->spec;
10826 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010827
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010828 mute = 0;
10829 /* auto-mute only when HP is used as HP */
10830 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080010831 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010832 if (spec->jack_present)
10833 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010834 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010835 /* mute/unmute internal speaker */
10836 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10837 HDA_AMP_MUTE, mute);
10838 /* mute/unmute HP */
10839 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10840 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010841}
10842
10843/* unsolicited event for HP jack sensing */
10844static void alc262_ultra_unsol_event(struct hda_codec *codec,
10845 unsigned int res)
10846{
10847 if ((res >> 26) != ALC880_HP_EVENT)
10848 return;
10849 alc262_ultra_automute(codec);
10850}
10851
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010852static struct hda_input_mux alc262_ultra_capture_source = {
10853 .num_items = 2,
10854 .items = {
10855 { "Mic", 0x1 },
10856 { "Headphone", 0x7 },
10857 },
10858};
10859
10860static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10861 struct snd_ctl_elem_value *ucontrol)
10862{
10863 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10864 struct alc_spec *spec = codec->spec;
10865 int ret;
10866
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010867 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010868 if (!ret)
10869 return 0;
10870 /* reprogram the HP pin as mic or HP according to the input source */
10871 snd_hda_codec_write_cache(codec, 0x15, 0,
10872 AC_VERB_SET_PIN_WIDGET_CONTROL,
10873 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10874 alc262_ultra_automute(codec); /* mute/unmute HP */
10875 return ret;
10876}
10877
10878static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10879 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10880 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10881 {
10882 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10883 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010884 .info = alc_mux_enum_info,
10885 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010886 .put = alc262_ultra_mux_enum_put,
10887 },
10888 { } /* end */
10889};
10890
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010891/* We use two mixers depending on the output pin; 0x16 is a mono output
10892 * and thus it's bound with a different mixer.
10893 * This function returns which mixer amp should be used.
10894 */
10895static int alc262_check_volbit(hda_nid_t nid)
10896{
10897 if (!nid)
10898 return 0;
10899 else if (nid == 0x16)
10900 return 2;
10901 else
10902 return 1;
10903}
10904
10905static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
10906 const char *pfx, int *vbits)
10907{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010908 unsigned long val;
10909 int vbit;
10910
10911 vbit = alc262_check_volbit(nid);
10912 if (!vbit)
10913 return 0;
10914 if (*vbits & vbit) /* a volume control for this mixer already there */
10915 return 0;
10916 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010917 if (vbit == 2)
10918 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
10919 else
10920 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020010921 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010922}
10923
10924static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
10925 const char *pfx)
10926{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010927 unsigned long val;
10928
10929 if (!nid)
10930 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010931 if (nid == 0x16)
10932 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
10933 else
10934 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020010935 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010936}
10937
Kailang Yangdf694da2005-12-05 19:42:22 +010010938/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010939static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10940 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010941{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010942 const char *pfx;
10943 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010010944 int err;
10945
10946 spec->multiout.num_dacs = 1; /* only use one dac */
10947 spec->multiout.dac_nids = spec->private_dac_nids;
10948 spec->multiout.dac_nids[0] = 2;
10949
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010950 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
10951 pfx = "Master";
10952 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
10953 pfx = "Speaker";
10954 else
10955 pfx = "Front";
10956 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
10957 if (err < 0)
10958 return err;
10959 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
10960 if (err < 0)
10961 return err;
10962 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
10963 if (err < 0)
10964 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010010965
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010966 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
10967 alc262_check_volbit(cfg->speaker_pins[0]) |
10968 alc262_check_volbit(cfg->hp_pins[0]);
10969 if (vbits == 1 || vbits == 2)
10970 pfx = "Master"; /* only one mixer is used */
10971 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
10972 pfx = "Speaker";
10973 else
10974 pfx = "Front";
10975 vbits = 0;
10976 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
10977 if (err < 0)
10978 return err;
10979 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
10980 &vbits);
10981 if (err < 0)
10982 return err;
10983 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
10984 &vbits);
10985 if (err < 0)
10986 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010987 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010988}
10989
Takashi Iwai05f5f472009-08-25 13:10:18 +020010990#define alc262_auto_create_input_ctls \
10991 alc880_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010992
10993/*
10994 * generic initialization of ADC, input mixers and output mixers
10995 */
10996static struct hda_verb alc262_volume_init_verbs[] = {
10997 /*
10998 * Unmute ADC0-2 and set the default input to mic-in
10999 */
11000 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11001 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11002 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11003 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11004 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11005 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11006
Takashi Iwaicb53c622007-08-10 17:21:45 +020011007 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011008 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011009 * Note: PASD motherboards uses the Line In 2 as the input for
11010 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011011 */
11012 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011013 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11014 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11015 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11017 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011018
11019 /*
11020 * Set up output mixers (0x0c - 0x0f)
11021 */
11022 /* set vol=0 to output mixers */
11023 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11024 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11025 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011026
Kailang Yangdf694da2005-12-05 19:42:22 +010011027 /* set up input amps for analog loopback */
11028 /* Amp Indices: DAC = 0, mixer = 1 */
11029 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11030 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11031 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11032 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11033 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11034 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11035
11036 /* FIXME: use matrix-type input source selection */
11037 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11038 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11039 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11040 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11041 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11042 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11043 /* Input mixer2 */
11044 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11045 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11046 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11047 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11048 /* Input mixer3 */
11049 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11050 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11051 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11052 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11053
11054 { }
11055};
11056
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011057static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11058 /*
11059 * Unmute ADC0-2 and set the default input to mic-in
11060 */
11061 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11062 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11063 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11064 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11065 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11066 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11067
Takashi Iwaicb53c622007-08-10 17:21:45 +020011068 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011069 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011070 * Note: PASD motherboards uses the Line In 2 as the input for
11071 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011072 */
11073 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11075 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11076 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11077 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11078 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11079 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11080 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011081
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011082 /*
11083 * Set up output mixers (0x0c - 0x0e)
11084 */
11085 /* set vol=0 to output mixers */
11086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11087 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11088 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11089
11090 /* set up input amps for analog loopback */
11091 /* Amp Indices: DAC = 0, mixer = 1 */
11092 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11093 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11094 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11095 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11096 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11097 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11098
Takashi Iwaice875f02008-01-28 18:17:43 +010011099 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011100 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11101 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11102
11103 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11104 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11105
11106 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11107 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11108
11109 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11110 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11111 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11112 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11113 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11114
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011115 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011116 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11117 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011118 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011119 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11120 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11121
11122
11123 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011124 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11125 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011126 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011127 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11128 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11129 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11130 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11131 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11132 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11133 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11134 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011135 /* Input mixer2 */
11136 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011137 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11138 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11139 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11140 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11141 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11142 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11143 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11144 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011145 /* Input mixer3 */
11146 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011147 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11148 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11149 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11150 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11151 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11152 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11153 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11154 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011155
Takashi Iwaice875f02008-01-28 18:17:43 +010011156 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11157
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011158 { }
11159};
11160
Kailang Yangcd7509a2007-01-26 18:33:17 +010011161static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11162 /*
11163 * Unmute ADC0-2 and set the default input to mic-in
11164 */
11165 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11166 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11167 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11168 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11169 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11170 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11171
Takashi Iwaicb53c622007-08-10 17:21:45 +020011172 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011173 * mixer widget
11174 * Note: PASD motherboards uses the Line In 2 as the input for front
11175 * panel mic (mic 2)
11176 */
11177 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011178 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11179 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11180 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11181 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11182 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11183 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11184 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11185 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011186 /*
11187 * Set up output mixers (0x0c - 0x0e)
11188 */
11189 /* set vol=0 to output mixers */
11190 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11191 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11192 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11193
11194 /* set up input amps for analog loopback */
11195 /* Amp Indices: DAC = 0, mixer = 1 */
11196 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11197 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11198 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11199 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11200 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11201 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11202
11203
11204 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11205 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11206 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11207 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11208 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11209 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11210 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11211
11212 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11213 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11214
11215 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11216 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11217
11218 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11219 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11220 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11221 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11222 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11223 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11224
11225 /* FIXME: use matrix-type input source selection */
11226 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11227 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11228 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11231 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11232 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11233 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11234 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11235 /* Input mixer2 */
11236 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11237 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11238 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11239 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11240 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11241 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11242 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11243 /* Input mixer3 */
11244 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11245 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11246 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11247 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11248 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11249 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11250 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11251
Takashi Iwaice875f02008-01-28 18:17:43 +010011252 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11253
Kailang Yangcd7509a2007-01-26 18:33:17 +010011254 { }
11255};
11256
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011257static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11258
11259 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11260 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11261 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11262
11263 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11264 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11265 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11266 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11267
11268 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11269 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11270 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11271 {}
11272};
11273
11274
Takashi Iwaicb53c622007-08-10 17:21:45 +020011275#ifdef CONFIG_SND_HDA_POWER_SAVE
11276#define alc262_loopbacks alc880_loopbacks
11277#endif
11278
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011279/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011280#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11281#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11282#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11283#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11284
11285/*
11286 * BIOS auto configuration
11287 */
11288static int alc262_parse_auto_config(struct hda_codec *codec)
11289{
11290 struct alc_spec *spec = codec->spec;
11291 int err;
11292 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11293
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011294 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11295 alc262_ignore);
11296 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011297 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011298 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011299 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011300 spec->multiout.max_channels = 2;
11301 spec->no_analog = 1;
11302 goto dig_only;
11303 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011304 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011305 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011306 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11307 if (err < 0)
11308 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011309 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011310 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011311 return err;
11312
11313 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11314
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011315 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011316 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011317 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011318 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011319 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011320 if (spec->autocfg.dig_in_pin)
11321 spec->dig_in_nid = ALC262_DIGIN_NID;
11322
Takashi Iwai603c4012008-07-30 15:01:44 +020011323 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011324 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011325
Takashi Iwaid88897e2008-10-31 15:01:37 +010011326 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011327 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011328 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011329
Takashi Iwai776e1842007-08-29 15:07:11 +020011330 err = alc_auto_add_mic_boost(codec);
11331 if (err < 0)
11332 return err;
11333
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011334 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11335
Kailang Yangdf694da2005-12-05 19:42:22 +010011336 return 1;
11337}
11338
11339#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11340#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11341#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011342#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011343
11344
11345/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011346static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011347{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011348 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011349 alc262_auto_init_multi_out(codec);
11350 alc262_auto_init_hp_out(codec);
11351 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011352 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011353 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011354 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011355}
11356
11357/*
11358 * configuration and preset
11359 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011360static const char *alc262_models[ALC262_MODEL_LAST] = {
11361 [ALC262_BASIC] = "basic",
11362 [ALC262_HIPPO] = "hippo",
11363 [ALC262_HIPPO_1] = "hippo_1",
11364 [ALC262_FUJITSU] = "fujitsu",
11365 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011366 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011367 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011368 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011369 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011370 [ALC262_BENQ_T31] = "benq-t31",
11371 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011372 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011373 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011374 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011375 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011376 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011377 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011378 [ALC262_AUTO] = "auto",
11379};
11380
11381static struct snd_pci_quirk alc262_cfg_tbl[] = {
11382 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011383 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011384 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11385 ALC262_HP_BPC),
11386 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11387 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011388 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11389 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011390 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011391 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011392 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011393 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011394 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011395 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011396 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011397 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011398 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11399 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11400 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011401 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11402 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011403 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011404 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011405 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011406 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011407 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011408 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011409 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011410 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011411#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011412 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11413 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011414#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011415 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011416 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011417 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011418 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011419 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011420 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011421 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11422 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011423 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011424 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011425 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011426 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011427 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011428 {}
11429};
11430
11431static struct alc_config_preset alc262_presets[] = {
11432 [ALC262_BASIC] = {
11433 .mixers = { alc262_base_mixer },
11434 .init_verbs = { alc262_init_verbs },
11435 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11436 .dac_nids = alc262_dac_nids,
11437 .hp_nid = 0x03,
11438 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11439 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011440 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011441 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011442 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011443 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011444 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011445 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11446 .dac_nids = alc262_dac_nids,
11447 .hp_nid = 0x03,
11448 .dig_out_nid = ALC262_DIGOUT_NID,
11449 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11450 .channel_mode = alc262_modes,
11451 .input_mux = &alc262_capture_source,
11452 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011453 .setup = alc262_hippo_setup,
11454 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011455 },
11456 [ALC262_HIPPO_1] = {
11457 .mixers = { alc262_hippo1_mixer },
11458 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11459 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11460 .dac_nids = alc262_dac_nids,
11461 .hp_nid = 0x02,
11462 .dig_out_nid = ALC262_DIGOUT_NID,
11463 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11464 .channel_mode = alc262_modes,
11465 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011466 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011467 .setup = alc262_hippo1_setup,
11468 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011469 },
Takashi Iwai834be882006-03-01 14:16:17 +010011470 [ALC262_FUJITSU] = {
11471 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011472 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11473 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011474 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11475 .dac_nids = alc262_dac_nids,
11476 .hp_nid = 0x03,
11477 .dig_out_nid = ALC262_DIGOUT_NID,
11478 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11479 .channel_mode = alc262_modes,
11480 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011481 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011482 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011483 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011484 [ALC262_HP_BPC] = {
11485 .mixers = { alc262_HP_BPC_mixer },
11486 .init_verbs = { alc262_HP_BPC_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,
11492 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011493 .unsol_event = alc262_hp_bpc_unsol_event,
11494 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011495 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011496 [ALC262_HP_BPC_D7000_WF] = {
11497 .mixers = { alc262_HP_BPC_WildWest_mixer },
11498 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11499 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11500 .dac_nids = alc262_dac_nids,
11501 .hp_nid = 0x03,
11502 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11503 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011504 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011505 .unsol_event = alc262_hp_wildwest_unsol_event,
11506 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011507 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011508 [ALC262_HP_BPC_D7000_WL] = {
11509 .mixers = { alc262_HP_BPC_WildWest_mixer,
11510 alc262_HP_BPC_WildWest_option_mixer },
11511 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11512 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11513 .dac_nids = alc262_dac_nids,
11514 .hp_nid = 0x03,
11515 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11516 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011517 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011518 .unsol_event = alc262_hp_wildwest_unsol_event,
11519 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011520 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011521 [ALC262_HP_TC_T5735] = {
11522 .mixers = { alc262_hp_t5735_mixer },
11523 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11524 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11525 .dac_nids = alc262_dac_nids,
11526 .hp_nid = 0x03,
11527 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11528 .channel_mode = alc262_modes,
11529 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011530 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011531 .setup = alc262_hp_t5735_setup,
11532 .init_hook = alc_automute_amp,
Kailang Yang8c427222008-01-10 13:03:59 +010011533 },
11534 [ALC262_HP_RP5700] = {
11535 .mixers = { alc262_hp_rp5700_mixer },
11536 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11537 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11538 .dac_nids = alc262_dac_nids,
11539 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11540 .channel_mode = alc262_modes,
11541 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011542 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011543 [ALC262_BENQ_ED8] = {
11544 .mixers = { alc262_base_mixer },
11545 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11546 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11547 .dac_nids = alc262_dac_nids,
11548 .hp_nid = 0x03,
11549 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11550 .channel_mode = alc262_modes,
11551 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011552 },
Kailang Yang272a5272007-05-14 11:00:38 +020011553 [ALC262_SONY_ASSAMD] = {
11554 .mixers = { alc262_sony_mixer },
11555 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11556 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11557 .dac_nids = alc262_dac_nids,
11558 .hp_nid = 0x02,
11559 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11560 .channel_mode = alc262_modes,
11561 .input_mux = &alc262_capture_source,
11562 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011563 .setup = alc262_hippo_setup,
11564 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011565 },
11566 [ALC262_BENQ_T31] = {
11567 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011568 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11569 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011570 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11571 .dac_nids = alc262_dac_nids,
11572 .hp_nid = 0x03,
11573 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11574 .channel_mode = alc262_modes,
11575 .input_mux = &alc262_capture_source,
11576 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011577 .setup = alc262_hippo_setup,
11578 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011579 },
Tobin Davisf651b502007-10-26 12:40:47 +020011580 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011581 .mixers = { alc262_ultra_mixer },
11582 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011583 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011584 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11585 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011586 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11587 .channel_mode = alc262_modes,
11588 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011589 .adc_nids = alc262_adc_nids, /* ADC0 */
11590 .capsrc_nids = alc262_capsrc_nids,
11591 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011592 .unsol_event = alc262_ultra_unsol_event,
11593 .init_hook = alc262_ultra_automute,
11594 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011595 [ALC262_LENOVO_3000] = {
11596 .mixers = { alc262_lenovo_3000_mixer },
11597 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11598 alc262_lenovo_3000_unsol_verbs },
11599 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11600 .dac_nids = alc262_dac_nids,
11601 .hp_nid = 0x03,
11602 .dig_out_nid = ALC262_DIGOUT_NID,
11603 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11604 .channel_mode = alc262_modes,
11605 .input_mux = &alc262_fujitsu_capture_source,
11606 .unsol_event = alc262_lenovo_3000_unsol_event,
11607 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011608 [ALC262_NEC] = {
11609 .mixers = { alc262_nec_mixer },
11610 .init_verbs = { alc262_nec_verbs },
11611 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11612 .dac_nids = alc262_dac_nids,
11613 .hp_nid = 0x03,
11614 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11615 .channel_mode = alc262_modes,
11616 .input_mux = &alc262_capture_source,
11617 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011618 [ALC262_TOSHIBA_S06] = {
11619 .mixers = { alc262_toshiba_s06_mixer },
11620 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11621 alc262_eapd_verbs },
11622 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11623 .capsrc_nids = alc262_dmic_capsrc_nids,
11624 .dac_nids = alc262_dac_nids,
11625 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011626 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011627 .dig_out_nid = ALC262_DIGOUT_NID,
11628 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11629 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011630 .unsol_event = alc_sku_unsol_event,
11631 .setup = alc262_toshiba_s06_setup,
11632 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011633 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011634 [ALC262_TOSHIBA_RX1] = {
11635 .mixers = { alc262_toshiba_rx1_mixer },
11636 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11637 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11638 .dac_nids = alc262_dac_nids,
11639 .hp_nid = 0x03,
11640 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11641 .channel_mode = alc262_modes,
11642 .input_mux = &alc262_capture_source,
11643 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011644 .setup = alc262_hippo_setup,
11645 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011646 },
Tony Vroonba340e82009-02-02 19:01:30 +000011647 [ALC262_TYAN] = {
11648 .mixers = { alc262_tyan_mixer },
11649 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11650 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11651 .dac_nids = alc262_dac_nids,
11652 .hp_nid = 0x02,
11653 .dig_out_nid = ALC262_DIGOUT_NID,
11654 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11655 .channel_mode = alc262_modes,
11656 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011657 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011658 .setup = alc262_tyan_setup,
11659 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011660 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011661};
11662
11663static int patch_alc262(struct hda_codec *codec)
11664{
11665 struct alc_spec *spec;
11666 int board_config;
11667 int err;
11668
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011669 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011670 if (spec == NULL)
11671 return -ENOMEM;
11672
11673 codec->spec = spec;
11674#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011675 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11676 * under-run
11677 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011678 {
11679 int tmp;
11680 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11681 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11682 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11683 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11684 }
11685#endif
11686
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011687 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11688
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011689 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11690 alc262_models,
11691 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011692
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011693 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011694 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11695 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011696 board_config = ALC262_AUTO;
11697 }
11698
11699 if (board_config == ALC262_AUTO) {
11700 /* automatic parse from the BIOS config */
11701 err = alc262_parse_auto_config(codec);
11702 if (err < 0) {
11703 alc_free(codec);
11704 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011705 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011706 printk(KERN_INFO
11707 "hda_codec: Cannot set up configuration "
11708 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011709 board_config = ALC262_BASIC;
11710 }
11711 }
11712
Takashi Iwai07eba612009-02-19 08:06:35 +010011713 if (!spec->no_analog) {
11714 err = snd_hda_attach_beep_device(codec, 0x1);
11715 if (err < 0) {
11716 alc_free(codec);
11717 return err;
11718 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011719 }
11720
Kailang Yangdf694da2005-12-05 19:42:22 +010011721 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011722 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011723
Kailang Yangdf694da2005-12-05 19:42:22 +010011724 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11725 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011726
Kailang Yangdf694da2005-12-05 19:42:22 +010011727 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11728 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11729
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011730 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011731 int i;
11732 /* check whether the digital-mic has to be supported */
11733 for (i = 0; i < spec->input_mux->num_items; i++) {
11734 if (spec->input_mux->items[i].index >= 9)
11735 break;
11736 }
11737 if (i < spec->input_mux->num_items) {
11738 /* use only ADC0 */
11739 spec->adc_nids = alc262_dmic_adc_nids;
11740 spec->num_adc_nids = 1;
11741 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011742 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011743 /* all analog inputs */
11744 /* check whether NID 0x07 is valid */
11745 unsigned int wcap = get_wcaps(codec, 0x07);
11746
11747 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011748 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011749 if (wcap != AC_WID_AUD_IN) {
11750 spec->adc_nids = alc262_adc_nids_alt;
11751 spec->num_adc_nids =
11752 ARRAY_SIZE(alc262_adc_nids_alt);
11753 spec->capsrc_nids = alc262_capsrc_nids_alt;
11754 } else {
11755 spec->adc_nids = alc262_adc_nids;
11756 spec->num_adc_nids =
11757 ARRAY_SIZE(alc262_adc_nids);
11758 spec->capsrc_nids = alc262_capsrc_nids;
11759 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011760 }
11761 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011762 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011763 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011764 if (!spec->no_analog)
11765 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011766
Takashi Iwai2134ea42008-01-10 16:53:55 +010011767 spec->vmaster_nid = 0x0c;
11768
Kailang Yangdf694da2005-12-05 19:42:22 +010011769 codec->patch_ops = alc_patch_ops;
11770 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011771 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011772#ifdef CONFIG_SND_HDA_POWER_SAVE
11773 if (!spec->loopback.amplist)
11774 spec->loopback.amplist = alc262_loopbacks;
11775#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011776 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011777
Kailang Yangdf694da2005-12-05 19:42:22 +010011778 return 0;
11779}
11780
Kailang Yangdf694da2005-12-05 19:42:22 +010011781/*
Kailang Yanga361d842007-06-05 12:30:55 +020011782 * ALC268 channel source setting (2 channel)
11783 */
11784#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11785#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011786
Kailang Yanga361d842007-06-05 12:30:55 +020011787static hda_nid_t alc268_dac_nids[2] = {
11788 /* front, hp */
11789 0x02, 0x03
11790};
11791
11792static hda_nid_t alc268_adc_nids[2] = {
11793 /* ADC0-1 */
11794 0x08, 0x07
11795};
11796
11797static hda_nid_t alc268_adc_nids_alt[1] = {
11798 /* ADC0 */
11799 0x08
11800};
11801
Takashi Iwaie1406342008-02-11 18:32:32 +010011802static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11803
Kailang Yanga361d842007-06-05 12:30:55 +020011804static struct snd_kcontrol_new alc268_base_mixer[] = {
11805 /* output mixer control */
11806 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11807 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11808 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11809 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011810 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11811 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11812 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011813 { }
11814};
11815
Takashi Iwai42171c12009-05-08 14:11:43 +020011816static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11817 /* output mixer control */
11818 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11819 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11820 ALC262_HIPPO_MASTER_SWITCH,
11821 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11822 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11823 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11824 { }
11825};
11826
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011827/* bind Beep switches of both NID 0x0f and 0x10 */
11828static struct hda_bind_ctls alc268_bind_beep_sw = {
11829 .ops = &snd_hda_bind_sw,
11830 .values = {
11831 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11832 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11833 0
11834 },
11835};
11836
11837static struct snd_kcontrol_new alc268_beep_mixer[] = {
11838 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11839 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11840 { }
11841};
11842
Kailang Yangd1a991a2007-08-15 16:21:59 +020011843static struct hda_verb alc268_eapd_verbs[] = {
11844 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11845 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11846 { }
11847};
11848
Takashi Iwaid2738092007-08-16 14:59:45 +020011849/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011850static struct hda_verb alc268_toshiba_verbs[] = {
11851 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11852 { } /* end */
11853};
11854
11855/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011856/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011857static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11858 .ops = &snd_hda_bind_vol,
11859 .values = {
11860 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11861 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11862 0
11863 },
11864};
11865
Takashi Iwai889c4392007-08-23 18:56:52 +020011866/* mute/unmute internal speaker according to the hp jack and mute state */
11867static void alc268_acer_automute(struct hda_codec *codec, int force)
11868{
11869 struct alc_spec *spec = codec->spec;
11870 unsigned int mute;
11871
11872 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011873 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020011874 spec->sense_updated = 1;
11875 }
11876 if (spec->jack_present)
11877 mute = HDA_AMP_MUTE; /* mute internal speaker */
11878 else /* unmute internal speaker if necessary */
11879 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11880 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11881 HDA_AMP_MUTE, mute);
11882}
11883
11884
11885/* bind hp and internal speaker mute (with plug check) */
11886static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11887 struct snd_ctl_elem_value *ucontrol)
11888{
11889 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11890 long *valp = ucontrol->value.integer.value;
11891 int change;
11892
Takashi Iwai8de56b72009-07-24 16:51:47 +020011893 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020011894 if (change)
11895 alc268_acer_automute(codec, 0);
11896 return change;
11897}
Takashi Iwaid2738092007-08-16 14:59:45 +020011898
Kailang Yang8ef355d2008-08-26 13:10:22 +020011899static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11900 /* output mixer control */
11901 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11902 {
11903 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11904 .name = "Master Playback Switch",
11905 .info = snd_hda_mixer_amp_switch_info,
11906 .get = snd_hda_mixer_amp_switch_get,
11907 .put = alc268_acer_master_sw_put,
11908 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11909 },
11910 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11911 { }
11912};
11913
Takashi Iwaid2738092007-08-16 14:59:45 +020011914static struct snd_kcontrol_new alc268_acer_mixer[] = {
11915 /* output mixer control */
11916 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11917 {
11918 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11919 .name = "Master Playback Switch",
11920 .info = snd_hda_mixer_amp_switch_info,
11921 .get = snd_hda_mixer_amp_switch_get,
11922 .put = alc268_acer_master_sw_put,
11923 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11924 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011925 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11926 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11927 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011928 { }
11929};
11930
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011931static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11932 /* output mixer control */
11933 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11934 {
11935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11936 .name = "Master Playback Switch",
11937 .info = snd_hda_mixer_amp_switch_info,
11938 .get = snd_hda_mixer_amp_switch_get,
11939 .put = alc268_acer_master_sw_put,
11940 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11941 },
11942 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11943 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11944 { }
11945};
11946
Kailang Yang8ef355d2008-08-26 13:10:22 +020011947static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11948 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11949 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11950 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11951 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11952 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11953 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11954 { }
11955};
11956
Takashi Iwaid2738092007-08-16 14:59:45 +020011957static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011958 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11959 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011960 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11961 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011962 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11963 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011964 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11965 { }
11966};
11967
11968/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011969#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011970#define alc268_toshiba_setup alc262_hippo_setup
11971#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020011972
11973static void alc268_acer_unsol_event(struct hda_codec *codec,
11974 unsigned int res)
11975{
Takashi Iwai889c4392007-08-23 18:56:52 +020011976 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011977 return;
11978 alc268_acer_automute(codec, 1);
11979}
11980
Takashi Iwai889c4392007-08-23 18:56:52 +020011981static void alc268_acer_init_hook(struct hda_codec *codec)
11982{
11983 alc268_acer_automute(codec, 1);
11984}
11985
Kailang Yang8ef355d2008-08-26 13:10:22 +020011986/* toggle speaker-output according to the hp-jack state */
11987static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11988{
11989 unsigned int present;
11990 unsigned char bits;
11991
Wu Fengguang864f92b2009-11-18 12:38:02 +080011992 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang8ef355d2008-08-26 13:10:22 +020011993 bits = present ? AMP_IN_MUTE(0) : 0;
11994 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11995 AMP_IN_MUTE(0), bits);
11996 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11997 AMP_IN_MUTE(0), bits);
11998}
11999
Kailang Yang8ef355d2008-08-26 13:10:22 +020012000static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12001 unsigned int res)
12002{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012003 switch (res >> 26) {
12004 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012005 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012006 break;
12007 case ALC880_MIC_EVENT:
12008 alc_mic_automute(codec);
12009 break;
12010 }
12011}
12012
12013static void alc268_acer_lc_setup(struct hda_codec *codec)
12014{
12015 struct alc_spec *spec = codec->spec;
12016 spec->ext_mic.pin = 0x18;
12017 spec->ext_mic.mux_idx = 0;
12018 spec->int_mic.pin = 0x12;
12019 spec->int_mic.mux_idx = 6;
12020 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012021}
12022
12023static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12024{
12025 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012026 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012027}
12028
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012029static struct snd_kcontrol_new alc268_dell_mixer[] = {
12030 /* output mixer control */
12031 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12032 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12033 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12034 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12035 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12036 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12037 { }
12038};
12039
12040static struct hda_verb alc268_dell_verbs[] = {
12041 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12042 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12043 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012044 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012045 { }
12046};
12047
12048/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012049static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012050{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012051 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012052
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012053 spec->autocfg.hp_pins[0] = 0x15;
12054 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012055 spec->ext_mic.pin = 0x18;
12056 spec->ext_mic.mux_idx = 0;
12057 spec->int_mic.pin = 0x19;
12058 spec->int_mic.mux_idx = 1;
12059 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012060}
12061
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012062static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12063 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12064 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12065 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12066 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12067 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12068 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12069 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12070 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12071 { }
12072};
12073
12074static struct hda_verb alc267_quanta_il1_verbs[] = {
12075 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12076 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12077 { }
12078};
12079
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012080static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012081{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012082 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012083 spec->autocfg.hp_pins[0] = 0x15;
12084 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012085 spec->ext_mic.pin = 0x18;
12086 spec->ext_mic.mux_idx = 0;
12087 spec->int_mic.pin = 0x19;
12088 spec->int_mic.mux_idx = 1;
12089 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012090}
12091
Kailang Yanga361d842007-06-05 12:30:55 +020012092/*
12093 * generic initialization of ADC, input mixers and output mixers
12094 */
12095static struct hda_verb alc268_base_init_verbs[] = {
12096 /* Unmute DAC0-1 and set vol = 0 */
12097 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012098 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012099
12100 /*
12101 * Set up output mixers (0x0c - 0x0e)
12102 */
12103 /* set vol=0 to output mixers */
12104 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012105 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12106
12107 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12108 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12109
12110 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12111 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12112 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12113 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12114 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12115 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12116 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12117 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12118
12119 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12120 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12121 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12122 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012123 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012124
12125 /* set PCBEEP vol = 0, mute connections */
12126 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12127 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12128 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012129
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012130 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012131
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012132 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12133 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12134 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12135 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012136
Kailang Yanga361d842007-06-05 12:30:55 +020012137 { }
12138};
12139
12140/*
12141 * generic initialization of ADC, input mixers and output mixers
12142 */
12143static struct hda_verb alc268_volume_init_verbs[] = {
12144 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012145 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12146 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012147
12148 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12149 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12150 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12151 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12152 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12153
Kailang Yanga361d842007-06-05 12:30:55 +020012154 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012155 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12156 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12157
12158 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012159 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012160
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012161 /* set PCBEEP vol = 0, mute connections */
12162 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12163 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12164 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012165
12166 { }
12167};
12168
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012169static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12170 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12171 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12172 { } /* end */
12173};
12174
Kailang Yanga361d842007-06-05 12:30:55 +020012175static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12176 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12177 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012178 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012179 { } /* end */
12180};
12181
12182static struct snd_kcontrol_new alc268_capture_mixer[] = {
12183 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12184 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12185 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12186 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012187 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012188 { } /* end */
12189};
12190
12191static struct hda_input_mux alc268_capture_source = {
12192 .num_items = 4,
12193 .items = {
12194 { "Mic", 0x0 },
12195 { "Front Mic", 0x1 },
12196 { "Line", 0x2 },
12197 { "CD", 0x3 },
12198 },
12199};
12200
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012201static struct hda_input_mux alc268_acer_capture_source = {
12202 .num_items = 3,
12203 .items = {
12204 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012205 { "Internal Mic", 0x1 },
12206 { "Line", 0x2 },
12207 },
12208};
12209
12210static struct hda_input_mux alc268_acer_dmic_capture_source = {
12211 .num_items = 3,
12212 .items = {
12213 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012214 { "Internal Mic", 0x6 },
12215 { "Line", 0x2 },
12216 },
12217};
12218
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012219#ifdef CONFIG_SND_DEBUG
12220static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012221 /* Volume widgets */
12222 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12223 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12224 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12225 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12226 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12227 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12228 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12229 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12230 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12231 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12232 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12233 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12234 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012235 /* The below appears problematic on some hardwares */
12236 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012237 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12238 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12239 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12240 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12241
12242 /* Modes for retasking pin widgets */
12243 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12244 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12245 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12246 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12247
12248 /* Controls for GPIO pins, assuming they are configured as outputs */
12249 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12250 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12251 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12252 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12253
12254 /* Switches to allow the digital SPDIF output pin to be enabled.
12255 * The ALC268 does not have an SPDIF input.
12256 */
12257 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12258
12259 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12260 * this output to turn on an external amplifier.
12261 */
12262 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12263 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12264
12265 { } /* end */
12266};
12267#endif
12268
Kailang Yanga361d842007-06-05 12:30:55 +020012269/* create input playback/capture controls for the given pin */
12270static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12271 const char *ctlname, int idx)
12272{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012273 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012274 int err;
12275
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012276 switch (nid) {
12277 case 0x14:
12278 case 0x16:
12279 dac = 0x02;
12280 break;
12281 case 0x15:
12282 dac = 0x03;
12283 break;
12284 default:
12285 return 0;
12286 }
12287 if (spec->multiout.dac_nids[0] != dac &&
12288 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012289 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012290 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012291 HDA_OUTPUT));
12292 if (err < 0)
12293 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012294 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12295 }
12296
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012297 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012298 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012299 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012300 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012301 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012302 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012303 if (err < 0)
12304 return err;
12305 return 0;
12306}
12307
12308/* add playback controls from the parsed DAC table */
12309static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12310 const struct auto_pin_cfg *cfg)
12311{
12312 hda_nid_t nid;
12313 int err;
12314
Kailang Yanga361d842007-06-05 12:30:55 +020012315 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012316
12317 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012318 if (nid) {
12319 const char *name;
12320 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12321 name = "Speaker";
12322 else
12323 name = "Front";
12324 err = alc268_new_analog_output(spec, nid, name, 0);
12325 if (err < 0)
12326 return err;
12327 }
Kailang Yanga361d842007-06-05 12:30:55 +020012328
12329 nid = cfg->speaker_pins[0];
12330 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012331 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012332 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12333 if (err < 0)
12334 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012335 } else {
12336 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12337 if (err < 0)
12338 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012339 }
12340 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012341 if (nid) {
12342 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12343 if (err < 0)
12344 return err;
12345 }
Kailang Yanga361d842007-06-05 12:30:55 +020012346
12347 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12348 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012349 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012350 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012351 if (err < 0)
12352 return err;
12353 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012354 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012355}
12356
12357/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012358static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012359 const struct auto_pin_cfg *cfg)
12360{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012361 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012362}
12363
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012364static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12365 hda_nid_t nid, int pin_type)
12366{
12367 int idx;
12368
12369 alc_set_pin_output(codec, nid, pin_type);
12370 if (nid == 0x14 || nid == 0x16)
12371 idx = 0;
12372 else
12373 idx = 1;
12374 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12375}
12376
12377static void alc268_auto_init_multi_out(struct hda_codec *codec)
12378{
12379 struct alc_spec *spec = codec->spec;
12380 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12381 if (nid) {
12382 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12383 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12384 }
12385}
12386
12387static void alc268_auto_init_hp_out(struct hda_codec *codec)
12388{
12389 struct alc_spec *spec = codec->spec;
12390 hda_nid_t pin;
12391
12392 pin = spec->autocfg.hp_pins[0];
12393 if (pin)
12394 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12395 pin = spec->autocfg.speaker_pins[0];
12396 if (pin)
12397 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12398}
12399
Kailang Yanga361d842007-06-05 12:30:55 +020012400static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12401{
12402 struct alc_spec *spec = codec->spec;
12403 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12404 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12405 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12406 unsigned int dac_vol1, dac_vol2;
12407
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012408 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012409 snd_hda_codec_write(codec, speaker_nid, 0,
12410 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012411 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012412 snd_hda_codec_write(codec, 0x0f, 0,
12413 AC_VERB_SET_AMP_GAIN_MUTE,
12414 AMP_IN_UNMUTE(1));
12415 snd_hda_codec_write(codec, 0x10, 0,
12416 AC_VERB_SET_AMP_GAIN_MUTE,
12417 AMP_IN_UNMUTE(1));
12418 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012419 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012420 snd_hda_codec_write(codec, 0x0f, 0,
12421 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12422 snd_hda_codec_write(codec, 0x10, 0,
12423 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12424 }
12425
12426 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012427 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012428 dac_vol2 = AMP_OUT_ZERO;
12429 else if (line_nid == 0x15)
12430 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012431 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012432 dac_vol2 = AMP_OUT_ZERO;
12433 else if (hp_nid == 0x15)
12434 dac_vol1 = AMP_OUT_ZERO;
12435 if (line_nid != 0x16 || hp_nid != 0x16 ||
12436 spec->autocfg.line_out_pins[1] != 0x16 ||
12437 spec->autocfg.line_out_pins[2] != 0x16)
12438 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12439
12440 snd_hda_codec_write(codec, 0x02, 0,
12441 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12442 snd_hda_codec_write(codec, 0x03, 0,
12443 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12444}
12445
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012446/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012447#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12448#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012449#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012450#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12451
12452/*
12453 * BIOS auto configuration
12454 */
12455static int alc268_parse_auto_config(struct hda_codec *codec)
12456{
12457 struct alc_spec *spec = codec->spec;
12458 int err;
12459 static hda_nid_t alc268_ignore[] = { 0 };
12460
12461 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12462 alc268_ignore);
12463 if (err < 0)
12464 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012465 if (!spec->autocfg.line_outs) {
12466 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12467 spec->multiout.max_channels = 2;
12468 spec->no_analog = 1;
12469 goto dig_only;
12470 }
Kailang Yanga361d842007-06-05 12:30:55 +020012471 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012472 }
Kailang Yanga361d842007-06-05 12:30:55 +020012473 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12474 if (err < 0)
12475 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012476 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012477 if (err < 0)
12478 return err;
12479
12480 spec->multiout.max_channels = 2;
12481
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012482 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012483 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012484 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012485 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012486 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12487 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012488 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012489 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012490
Takashi Iwai892981f2009-03-02 08:04:35 +010012491 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012492 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012493
Takashi Iwaid88897e2008-10-31 15:01:37 +010012494 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012495 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012496 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012497
Takashi Iwai776e1842007-08-29 15:07:11 +020012498 err = alc_auto_add_mic_boost(codec);
12499 if (err < 0)
12500 return err;
12501
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012502 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12503
Kailang Yanga361d842007-06-05 12:30:55 +020012504 return 1;
12505}
12506
Kailang Yanga361d842007-06-05 12:30:55 +020012507#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12508
12509/* init callback for auto-configuration model -- overriding the default init */
12510static void alc268_auto_init(struct hda_codec *codec)
12511{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012512 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012513 alc268_auto_init_multi_out(codec);
12514 alc268_auto_init_hp_out(codec);
12515 alc268_auto_init_mono_speaker_out(codec);
12516 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012517 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012518 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012519}
12520
12521/*
12522 * configuration and preset
12523 */
12524static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012525 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012526 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012527 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012528 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012529 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012530 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012531 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012532 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012533#ifdef CONFIG_SND_DEBUG
12534 [ALC268_TEST] = "test",
12535#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012536 [ALC268_AUTO] = "auto",
12537};
12538
12539static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012540 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012541 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012542 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012543 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012544 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012545 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12546 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012547 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050012548 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
12549 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020012550 /* almost compatible with toshiba but with optional digital outs;
12551 * auto-probing seems working fine
12552 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012553 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020012554 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020012555 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012556 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012557 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012558 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012559 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012560 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012561 {}
12562};
12563
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012564/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12565static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12566 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12567 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12568 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12569 ALC268_TOSHIBA),
12570 {}
12571};
12572
Kailang Yanga361d842007-06-05 12:30:55 +020012573static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012574 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012575 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12576 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012577 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12578 alc267_quanta_il1_verbs },
12579 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12580 .dac_nids = alc268_dac_nids,
12581 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12582 .adc_nids = alc268_adc_nids_alt,
12583 .hp_nid = 0x03,
12584 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12585 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012586 .unsol_event = alc_sku_unsol_event,
12587 .setup = alc267_quanta_il1_setup,
12588 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012589 },
Kailang Yanga361d842007-06-05 12:30:55 +020012590 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012591 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12592 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012593 .init_verbs = { alc268_base_init_verbs },
12594 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12595 .dac_nids = alc268_dac_nids,
12596 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12597 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012598 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012599 .hp_nid = 0x03,
12600 .dig_out_nid = ALC268_DIGOUT_NID,
12601 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12602 .channel_mode = alc268_modes,
12603 .input_mux = &alc268_capture_source,
12604 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012605 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012606 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012607 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012608 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12609 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012610 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12611 .dac_nids = alc268_dac_nids,
12612 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12613 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012614 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012615 .hp_nid = 0x03,
12616 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12617 .channel_mode = alc268_modes,
12618 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012619 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012620 .setup = alc268_toshiba_setup,
12621 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012622 },
12623 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020012624 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012625 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012626 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12627 alc268_acer_verbs },
12628 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12629 .dac_nids = alc268_dac_nids,
12630 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12631 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012632 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012633 .hp_nid = 0x02,
12634 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12635 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012636 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012637 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012638 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012639 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012640 [ALC268_ACER_DMIC] = {
12641 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12642 alc268_beep_mixer },
12643 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12644 alc268_acer_verbs },
12645 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12646 .dac_nids = alc268_dac_nids,
12647 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12648 .adc_nids = alc268_adc_nids_alt,
12649 .capsrc_nids = alc268_capsrc_nids,
12650 .hp_nid = 0x02,
12651 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12652 .channel_mode = alc268_modes,
12653 .input_mux = &alc268_acer_dmic_capture_source,
12654 .unsol_event = alc268_acer_unsol_event,
12655 .init_hook = alc268_acer_init_hook,
12656 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012657 [ALC268_ACER_ASPIRE_ONE] = {
12658 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012659 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012660 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012661 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12662 alc268_acer_aspire_one_verbs },
12663 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12664 .dac_nids = alc268_dac_nids,
12665 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12666 .adc_nids = alc268_adc_nids_alt,
12667 .capsrc_nids = alc268_capsrc_nids,
12668 .hp_nid = 0x03,
12669 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12670 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012671 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012672 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012673 .init_hook = alc268_acer_lc_init_hook,
12674 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012675 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012676 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12677 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012678 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12679 alc268_dell_verbs },
12680 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12681 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012682 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12683 .adc_nids = alc268_adc_nids_alt,
12684 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012685 .hp_nid = 0x02,
12686 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12687 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012688 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012689 .setup = alc268_dell_setup,
12690 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012691 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012692 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012693 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12694 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012695 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12696 alc268_toshiba_verbs },
12697 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12698 .dac_nids = alc268_dac_nids,
12699 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12700 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012701 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012702 .hp_nid = 0x03,
12703 .dig_out_nid = ALC268_DIGOUT_NID,
12704 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12705 .channel_mode = alc268_modes,
12706 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012707 .setup = alc268_toshiba_setup,
12708 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012709 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012710#ifdef CONFIG_SND_DEBUG
12711 [ALC268_TEST] = {
12712 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12713 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12714 alc268_volume_init_verbs },
12715 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12716 .dac_nids = alc268_dac_nids,
12717 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12718 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012719 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012720 .hp_nid = 0x03,
12721 .dig_out_nid = ALC268_DIGOUT_NID,
12722 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12723 .channel_mode = alc268_modes,
12724 .input_mux = &alc268_capture_source,
12725 },
12726#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012727};
12728
12729static int patch_alc268(struct hda_codec *codec)
12730{
12731 struct alc_spec *spec;
12732 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012733 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012734
12735 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12736 if (spec == NULL)
12737 return -ENOMEM;
12738
12739 codec->spec = spec;
12740
12741 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12742 alc268_models,
12743 alc268_cfg_tbl);
12744
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012745 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12746 board_config = snd_hda_check_board_codec_sid_config(codec,
12747 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12748
Kailang Yanga361d842007-06-05 12:30:55 +020012749 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012750 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12751 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012752 board_config = ALC268_AUTO;
12753 }
12754
12755 if (board_config == ALC268_AUTO) {
12756 /* automatic parse from the BIOS config */
12757 err = alc268_parse_auto_config(codec);
12758 if (err < 0) {
12759 alc_free(codec);
12760 return err;
12761 } else if (!err) {
12762 printk(KERN_INFO
12763 "hda_codec: Cannot set up configuration "
12764 "from BIOS. Using base mode...\n");
12765 board_config = ALC268_3ST;
12766 }
12767 }
12768
12769 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012770 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020012771
Kailang Yanga361d842007-06-05 12:30:55 +020012772 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12773 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012774 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012775
Kailang Yanga361d842007-06-05 12:30:55 +020012776 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12777
Takashi Iwai22971e32009-02-10 11:56:44 +010012778 has_beep = 0;
12779 for (i = 0; i < spec->num_mixers; i++) {
12780 if (spec->mixers[i] == alc268_beep_mixer) {
12781 has_beep = 1;
12782 break;
12783 }
12784 }
12785
12786 if (has_beep) {
12787 err = snd_hda_attach_beep_device(codec, 0x1);
12788 if (err < 0) {
12789 alc_free(codec);
12790 return err;
12791 }
12792 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12793 /* override the amp caps for beep generator */
12794 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012795 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12796 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12797 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12798 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012799 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012800
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012801 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012802 /* check whether NID 0x07 is valid */
12803 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012804 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012805
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020012806 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012807 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012808 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012809 if (spec->auto_mic ||
12810 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012811 spec->adc_nids = alc268_adc_nids_alt;
12812 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020012813 if (spec->auto_mic)
12814 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012815 if (spec->auto_mic || spec->input_mux->num_items == 1)
12816 add_mixer(spec, alc268_capture_nosrc_mixer);
12817 else
12818 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012819 } else {
12820 spec->adc_nids = alc268_adc_nids;
12821 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012822 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012823 }
Takashi Iwai85860c02008-02-19 15:00:15 +010012824 /* set default input source */
12825 for (i = 0; i < spec->num_adc_nids; i++)
12826 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12827 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012828 i < spec->num_mux_defs ?
12829 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010012830 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012831 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012832
12833 spec->vmaster_nid = 0x02;
12834
Kailang Yanga361d842007-06-05 12:30:55 +020012835 codec->patch_ops = alc_patch_ops;
12836 if (board_config == ALC268_AUTO)
12837 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012838
Takashi Iwaidaead532008-11-28 12:55:36 +010012839 codec->proc_widget_hook = print_realtek_coef;
12840
Kailang Yanga361d842007-06-05 12:30:55 +020012841 return 0;
12842}
12843
12844/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012845 * ALC269 channel source setting (2 channel)
12846 */
12847#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12848
12849#define alc269_dac_nids alc260_dac_nids
12850
12851static hda_nid_t alc269_adc_nids[1] = {
12852 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012853 0x08,
12854};
12855
Takashi Iwaie01bf502008-08-21 16:25:07 +020012856static hda_nid_t alc269_capsrc_nids[1] = {
12857 0x23,
12858};
12859
12860/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12861 * not a mux!
12862 */
12863
Kailang Yangf6a92242007-12-13 16:52:54 +010012864#define alc269_modes alc260_modes
12865#define alc269_capture_source alc880_lg_lw_capture_source
12866
12867static struct snd_kcontrol_new alc269_base_mixer[] = {
12868 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12869 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12870 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12871 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12872 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12873 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12874 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12875 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12876 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12877 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12878 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12879 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12880 { } /* end */
12881};
12882
Kailang Yang60db6b52008-08-26 13:13:00 +020012883static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12884 /* output mixer control */
12885 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12886 {
12887 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12888 .name = "Master Playback Switch",
12889 .info = snd_hda_mixer_amp_switch_info,
12890 .get = snd_hda_mixer_amp_switch_get,
12891 .put = alc268_acer_master_sw_put,
12892 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12893 },
12894 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12895 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12896 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12897 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12898 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12899 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012900 { }
12901};
12902
Tony Vroon64154832008-11-06 15:08:49 +000012903static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12904 /* output mixer control */
12905 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12906 {
12907 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12908 .name = "Master Playback Switch",
12909 .info = snd_hda_mixer_amp_switch_info,
12910 .get = snd_hda_mixer_amp_switch_get,
12911 .put = alc268_acer_master_sw_put,
12912 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12913 },
12914 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12915 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12916 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12917 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12918 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12919 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12920 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12921 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12922 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012923 { }
12924};
12925
Kailang Yangf53281e2008-07-18 12:36:43 +020012926static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012927 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012928 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012929 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012930 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012931 { } /* end */
12932};
12933
Kailang Yangf6a92242007-12-13 16:52:54 +010012934/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012935static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12936 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12937 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012938 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12939 { } /* end */
12940};
12941
12942/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012943#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012944
Kailang Yang60db6b52008-08-26 13:13:00 +020012945static struct hda_verb alc269_quanta_fl1_verbs[] = {
12946 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12947 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12948 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12949 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12950 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12951 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12952 { }
12953};
12954
Tony Vroon64154832008-11-06 15:08:49 +000012955static struct hda_verb alc269_lifebook_verbs[] = {
12956 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12957 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12958 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12959 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12960 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12961 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12962 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12963 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12964 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12965 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12966 { }
12967};
12968
Kailang Yang60db6b52008-08-26 13:13:00 +020012969/* toggle speaker-output according to the hp-jack state */
12970static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12971{
12972 unsigned int present;
12973 unsigned char bits;
12974
Wu Fengguang864f92b2009-11-18 12:38:02 +080012975 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020012976 bits = present ? AMP_IN_MUTE(0) : 0;
12977 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12978 AMP_IN_MUTE(0), bits);
12979 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12980 AMP_IN_MUTE(0), bits);
12981
12982 snd_hda_codec_write(codec, 0x20, 0,
12983 AC_VERB_SET_COEF_INDEX, 0x0c);
12984 snd_hda_codec_write(codec, 0x20, 0,
12985 AC_VERB_SET_PROC_COEF, 0x680);
12986
12987 snd_hda_codec_write(codec, 0x20, 0,
12988 AC_VERB_SET_COEF_INDEX, 0x0c);
12989 snd_hda_codec_write(codec, 0x20, 0,
12990 AC_VERB_SET_PROC_COEF, 0x480);
12991}
12992
Tony Vroon64154832008-11-06 15:08:49 +000012993/* toggle speaker-output according to the hp-jacks state */
12994static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12995{
12996 unsigned int present;
12997 unsigned char bits;
12998
12999 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013000 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013001
13002 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013003 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013004
13005 bits = present ? AMP_IN_MUTE(0) : 0;
13006 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13007 AMP_IN_MUTE(0), bits);
13008 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13009 AMP_IN_MUTE(0), bits);
13010
13011 snd_hda_codec_write(codec, 0x20, 0,
13012 AC_VERB_SET_COEF_INDEX, 0x0c);
13013 snd_hda_codec_write(codec, 0x20, 0,
13014 AC_VERB_SET_PROC_COEF, 0x680);
13015
13016 snd_hda_codec_write(codec, 0x20, 0,
13017 AC_VERB_SET_COEF_INDEX, 0x0c);
13018 snd_hda_codec_write(codec, 0x20, 0,
13019 AC_VERB_SET_PROC_COEF, 0x480);
13020}
13021
Tony Vroon64154832008-11-06 15:08:49 +000013022static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13023{
13024 unsigned int present_laptop;
13025 unsigned int present_dock;
13026
Wu Fengguang864f92b2009-11-18 12:38:02 +080013027 present_laptop = snd_hda_jack_detect(codec, 0x18);
13028 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013029
13030 /* Laptop mic port overrides dock mic port, design decision */
13031 if (present_dock)
13032 snd_hda_codec_write(codec, 0x23, 0,
13033 AC_VERB_SET_CONNECT_SEL, 0x3);
13034 if (present_laptop)
13035 snd_hda_codec_write(codec, 0x23, 0,
13036 AC_VERB_SET_CONNECT_SEL, 0x0);
13037 if (!present_dock && !present_laptop)
13038 snd_hda_codec_write(codec, 0x23, 0,
13039 AC_VERB_SET_CONNECT_SEL, 0x1);
13040}
13041
Kailang Yang60db6b52008-08-26 13:13:00 +020013042static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13043 unsigned int res)
13044{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013045 switch (res >> 26) {
13046 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013047 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013048 break;
13049 case ALC880_MIC_EVENT:
13050 alc_mic_automute(codec);
13051 break;
13052 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013053}
13054
Tony Vroon64154832008-11-06 15:08:49 +000013055static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13056 unsigned int res)
13057{
13058 if ((res >> 26) == ALC880_HP_EVENT)
13059 alc269_lifebook_speaker_automute(codec);
13060 if ((res >> 26) == ALC880_MIC_EVENT)
13061 alc269_lifebook_mic_autoswitch(codec);
13062}
13063
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013064static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13065{
13066 struct alc_spec *spec = codec->spec;
13067 spec->ext_mic.pin = 0x18;
13068 spec->ext_mic.mux_idx = 0;
13069 spec->int_mic.pin = 0x19;
13070 spec->int_mic.mux_idx = 1;
13071 spec->auto_mic = 1;
13072}
13073
Kailang Yang60db6b52008-08-26 13:13:00 +020013074static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13075{
13076 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013077 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013078}
13079
Tony Vroon64154832008-11-06 15:08:49 +000013080static void alc269_lifebook_init_hook(struct hda_codec *codec)
13081{
13082 alc269_lifebook_speaker_automute(codec);
13083 alc269_lifebook_mic_autoswitch(codec);
13084}
13085
Kailang Yang60db6b52008-08-26 13:13:00 +020013086static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13087 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13088 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13089 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13090 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13091 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13092 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13093 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13094 {}
13095};
13096
13097static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13098 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13099 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13100 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13101 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13102 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13103 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13104 {}
13105};
13106
13107/* toggle speaker-output according to the hp-jack state */
13108static void alc269_speaker_automute(struct hda_codec *codec)
13109{
13110 unsigned int present;
13111 unsigned char bits;
13112
Wu Fengguang864f92b2009-11-18 12:38:02 +080013113 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020013114 bits = present ? AMP_IN_MUTE(0) : 0;
13115 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13116 AMP_IN_MUTE(0), bits);
13117 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13118 AMP_IN_MUTE(0), bits);
13119}
13120
Kailang Yang60db6b52008-08-26 13:13:00 +020013121/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013122static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013123 unsigned int res)
13124{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013125 switch (res >> 26) {
13126 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013127 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013128 break;
13129 case ALC880_MIC_EVENT:
13130 alc_mic_automute(codec);
13131 break;
13132 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013133}
13134
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013135static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13136{
13137 struct alc_spec *spec = codec->spec;
13138 spec->ext_mic.pin = 0x18;
13139 spec->ext_mic.mux_idx = 0;
13140 spec->int_mic.pin = 0x12;
13141 spec->int_mic.mux_idx = 5;
13142 spec->auto_mic = 1;
13143}
13144
13145static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13146{
13147 struct alc_spec *spec = codec->spec;
13148 spec->ext_mic.pin = 0x18;
13149 spec->ext_mic.mux_idx = 0;
13150 spec->int_mic.pin = 0x19;
13151 spec->int_mic.mux_idx = 1;
13152 spec->auto_mic = 1;
13153}
13154
13155static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013156{
13157 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013158 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013159}
13160
Kailang Yangf6a92242007-12-13 16:52:54 +010013161/*
13162 * generic initialization of ADC, input mixers and output mixers
13163 */
13164static struct hda_verb alc269_init_verbs[] = {
13165 /*
13166 * Unmute ADC0 and set the default input to mic-in
13167 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013168 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013169
13170 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13171 * analog-loopback mixer widget
13172 * Note: PASD motherboards uses the Line In 2 as the input for
13173 * front panel mic (mic 2)
13174 */
13175 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13176 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13177 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13178 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13179 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13180 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13181
13182 /*
13183 * Set up output mixers (0x0c - 0x0e)
13184 */
13185 /* set vol=0 to output mixers */
13186 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13187 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13188
13189 /* set up input amps for analog loopback */
13190 /* Amp Indices: DAC = 0, mixer = 1 */
13191 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13192 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13193 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13194 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13195 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13196 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13197
13198 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13199 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13200 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13201 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13202 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13203 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13204 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13205
13206 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13207 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13208 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13209 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13210 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13211 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13212 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13213
13214 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13215 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13216
13217 /* FIXME: use matrix-type input source selection */
13218 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13219 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013220 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13221 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013222 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13223 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13224
13225 /* set EAPD */
13226 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13227 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13228 { }
13229};
13230
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013231#define alc269_auto_create_multi_out_ctls \
13232 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013233#define alc269_auto_create_input_ctls \
13234 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013235
13236#ifdef CONFIG_SND_HDA_POWER_SAVE
13237#define alc269_loopbacks alc880_loopbacks
13238#endif
13239
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013240/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013241#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13242#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13243#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13244#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13245
Takashi Iwaif03d3112009-03-05 14:18:16 +010013246static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13247 .substreams = 1,
13248 .channels_min = 2,
13249 .channels_max = 8,
13250 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13251 /* NID is set in alc_build_pcms */
13252 .ops = {
13253 .open = alc880_playback_pcm_open,
13254 .prepare = alc880_playback_pcm_prepare,
13255 .cleanup = alc880_playback_pcm_cleanup
13256 },
13257};
13258
13259static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13260 .substreams = 1,
13261 .channels_min = 2,
13262 .channels_max = 2,
13263 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13264 /* NID is set in alc_build_pcms */
13265};
13266
Kailang Yangf6a92242007-12-13 16:52:54 +010013267/*
13268 * BIOS auto configuration
13269 */
13270static int alc269_parse_auto_config(struct hda_codec *codec)
13271{
13272 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013273 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013274 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13275
13276 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13277 alc269_ignore);
13278 if (err < 0)
13279 return err;
13280
13281 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13282 if (err < 0)
13283 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013284 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013285 if (err < 0)
13286 return err;
13287
13288 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13289
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013290 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013291 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13292
Takashi Iwai603c4012008-07-30 15:01:44 +020013293 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013294 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013295
Takashi Iwaid88897e2008-10-31 15:01:37 +010013296 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013297 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013298 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013299 /* set default input source */
13300 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13301 0, AC_VERB_SET_CONNECT_SEL,
13302 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013303
13304 err = alc_auto_add_mic_boost(codec);
13305 if (err < 0)
13306 return err;
13307
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013308 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013309 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013310
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013311 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13312
Kailang Yangf6a92242007-12-13 16:52:54 +010013313 return 1;
13314}
13315
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013316#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13317#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013318#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13319
13320
13321/* init callback for auto-configuration model -- overriding the default init */
13322static void alc269_auto_init(struct hda_codec *codec)
13323{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013324 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013325 alc269_auto_init_multi_out(codec);
13326 alc269_auto_init_hp_out(codec);
13327 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013328 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013329 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013330}
13331
13332/*
13333 * configuration and preset
13334 */
13335static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013336 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013337 [ALC269_QUANTA_FL1] = "quanta",
13338 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013339 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013340 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013341 [ALC269_LIFEBOOK] = "lifebook",
13342 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013343};
13344
13345static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013346 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013347 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13348 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013349 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13350 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13351 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13352 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13353 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13354 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013355 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13356 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013357 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13358 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013359 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013360 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013361 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013362 {}
13363};
13364
13365static struct alc_config_preset alc269_presets[] = {
13366 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013367 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013368 .init_verbs = { alc269_init_verbs },
13369 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13370 .dac_nids = alc269_dac_nids,
13371 .hp_nid = 0x03,
13372 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13373 .channel_mode = alc269_modes,
13374 .input_mux = &alc269_capture_source,
13375 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013376 [ALC269_QUANTA_FL1] = {
13377 .mixers = { alc269_quanta_fl1_mixer },
13378 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13379 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13380 .dac_nids = alc269_dac_nids,
13381 .hp_nid = 0x03,
13382 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13383 .channel_mode = alc269_modes,
13384 .input_mux = &alc269_capture_source,
13385 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013386 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013387 .init_hook = alc269_quanta_fl1_init_hook,
13388 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013389 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013390 .mixers = { alc269_eeepc_mixer },
13391 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013392 .init_verbs = { alc269_init_verbs,
13393 alc269_eeepc_amic_init_verbs },
13394 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13395 .dac_nids = alc269_dac_nids,
13396 .hp_nid = 0x03,
13397 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13398 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013399 .unsol_event = alc269_eeepc_unsol_event,
13400 .setup = alc269_eeepc_amic_setup,
13401 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013402 },
13403 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013404 .mixers = { alc269_eeepc_mixer },
13405 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013406 .init_verbs = { alc269_init_verbs,
13407 alc269_eeepc_dmic_init_verbs },
13408 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13409 .dac_nids = alc269_dac_nids,
13410 .hp_nid = 0x03,
13411 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13412 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013413 .unsol_event = alc269_eeepc_unsol_event,
13414 .setup = alc269_eeepc_dmic_setup,
13415 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013416 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013417 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013418 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013419 .cap_mixer = alc269_epc_capture_mixer,
13420 .init_verbs = { alc269_init_verbs,
13421 alc269_eeepc_dmic_init_verbs },
13422 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13423 .dac_nids = alc269_dac_nids,
13424 .hp_nid = 0x03,
13425 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13426 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013427 .unsol_event = alc269_eeepc_unsol_event,
13428 .setup = alc269_eeepc_dmic_setup,
13429 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013430 },
Tony Vroon64154832008-11-06 15:08:49 +000013431 [ALC269_LIFEBOOK] = {
13432 .mixers = { alc269_lifebook_mixer },
13433 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13434 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13435 .dac_nids = alc269_dac_nids,
13436 .hp_nid = 0x03,
13437 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13438 .channel_mode = alc269_modes,
13439 .input_mux = &alc269_capture_source,
13440 .unsol_event = alc269_lifebook_unsol_event,
13441 .init_hook = alc269_lifebook_init_hook,
13442 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013443};
13444
13445static int patch_alc269(struct hda_codec *codec)
13446{
13447 struct alc_spec *spec;
13448 int board_config;
13449 int err;
13450
13451 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13452 if (spec == NULL)
13453 return -ENOMEM;
13454
13455 codec->spec = spec;
13456
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013457 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13458
Kailang Yang274693f2009-12-03 10:07:50 +010013459 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
13460 kfree(codec->chip_name);
13461 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013462 if (!codec->chip_name) {
13463 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010013464 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010013465 }
Kailang Yang274693f2009-12-03 10:07:50 +010013466 }
13467
Kailang Yangf6a92242007-12-13 16:52:54 +010013468 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13469 alc269_models,
13470 alc269_cfg_tbl);
13471
13472 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013473 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13474 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013475 board_config = ALC269_AUTO;
13476 }
13477
13478 if (board_config == ALC269_AUTO) {
13479 /* automatic parse from the BIOS config */
13480 err = alc269_parse_auto_config(codec);
13481 if (err < 0) {
13482 alc_free(codec);
13483 return err;
13484 } else if (!err) {
13485 printk(KERN_INFO
13486 "hda_codec: Cannot set up configuration "
13487 "from BIOS. Using base mode...\n");
13488 board_config = ALC269_BASIC;
13489 }
13490 }
13491
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013492 err = snd_hda_attach_beep_device(codec, 0x1);
13493 if (err < 0) {
13494 alc_free(codec);
13495 return err;
13496 }
13497
Kailang Yangf6a92242007-12-13 16:52:54 +010013498 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013499 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013500
Takashi Iwaif03d3112009-03-05 14:18:16 +010013501 if (codec->subsystem_id == 0x17aa3bf8) {
13502 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13503 * fix the sample rate of analog I/O to 44.1kHz
13504 */
13505 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13506 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13507 } else {
13508 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13509 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13510 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013511 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13512 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13513
13514 spec->adc_nids = alc269_adc_nids;
13515 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013516 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013517 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013518 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013519 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013520
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013521 spec->vmaster_nid = 0x02;
13522
Kailang Yangf6a92242007-12-13 16:52:54 +010013523 codec->patch_ops = alc_patch_ops;
13524 if (board_config == ALC269_AUTO)
13525 spec->init_hook = alc269_auto_init;
13526#ifdef CONFIG_SND_HDA_POWER_SAVE
13527 if (!spec->loopback.amplist)
13528 spec->loopback.amplist = alc269_loopbacks;
13529#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013530 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013531
13532 return 0;
13533}
13534
13535/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013536 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13537 */
13538
13539/*
13540 * set the path ways for 2 channel output
13541 * need to set the codec line out and mic 1 pin widgets to inputs
13542 */
13543static struct hda_verb alc861_threestack_ch2_init[] = {
13544 /* set pin widget 1Ah (line in) for input */
13545 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013546 /* set pin widget 18h (mic1/2) for input, for mic also enable
13547 * the vref
13548 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013549 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13550
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013551 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13552#if 0
13553 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13554 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13555#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013556 { } /* end */
13557};
13558/*
13559 * 6ch mode
13560 * need to set the codec line out and mic 1 pin widgets to outputs
13561 */
13562static struct hda_verb alc861_threestack_ch6_init[] = {
13563 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13564 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13565 /* set pin widget 18h (mic1) for output (CLFE)*/
13566 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13567
13568 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013569 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013570
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013571 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13572#if 0
13573 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13574 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13575#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013576 { } /* end */
13577};
13578
13579static struct hda_channel_mode alc861_threestack_modes[2] = {
13580 { 2, alc861_threestack_ch2_init },
13581 { 6, alc861_threestack_ch6_init },
13582};
Takashi Iwai22309c32006-08-09 16:57:28 +020013583/* Set mic1 as input and unmute the mixer */
13584static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13585 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13586 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13587 { } /* end */
13588};
13589/* Set mic1 as output and mute mixer */
13590static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13591 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13592 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13593 { } /* end */
13594};
13595
13596static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13597 { 2, alc861_uniwill_m31_ch2_init },
13598 { 4, alc861_uniwill_m31_ch4_init },
13599};
Kailang Yangdf694da2005-12-05 19:42:22 +010013600
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013601/* Set mic1 and line-in as input and unmute the mixer */
13602static struct hda_verb alc861_asus_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 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013608 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13609
13610 { 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
13615 { } /* end */
13616};
13617/* Set mic1 nad line-in as output and mute mixer */
13618static struct hda_verb alc861_asus_ch6_init[] = {
13619 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13620 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13621 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13622 /* set pin widget 18h (mic1) for output (CLFE)*/
13623 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13624 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13625 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13626 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13627
13628 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13629#if 0
13630 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13631 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13632#endif
13633 { } /* end */
13634};
13635
13636static struct hda_channel_mode alc861_asus_modes[2] = {
13637 { 2, alc861_asus_ch2_init },
13638 { 6, alc861_asus_ch6_init },
13639};
13640
Kailang Yangdf694da2005-12-05 19:42:22 +010013641/* patch-ALC861 */
13642
13643static struct snd_kcontrol_new alc861_base_mixer[] = {
13644 /* output mixer control */
13645 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13646 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13647 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13648 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13649 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13650
13651 /*Input mixer control */
13652 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13653 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13654 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13655 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13656 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13657 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13658 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13659 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13660 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13661 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013662
Kailang Yangdf694da2005-12-05 19:42:22 +010013663 { } /* end */
13664};
13665
13666static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13667 /* output mixer control */
13668 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13669 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13670 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13671 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13672 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13673
13674 /* Input mixer control */
13675 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13676 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13677 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13678 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13679 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13680 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13682 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13683 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13684 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013685
Kailang Yangdf694da2005-12-05 19:42:22 +010013686 {
13687 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13688 .name = "Channel Mode",
13689 .info = alc_ch_mode_info,
13690 .get = alc_ch_mode_get,
13691 .put = alc_ch_mode_put,
13692 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13693 },
13694 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013695};
13696
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013697static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013698 /* output mixer control */
13699 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13700 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13701 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013702
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013703 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013704};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013705
Takashi Iwai22309c32006-08-09 16:57:28 +020013706static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13707 /* output mixer control */
13708 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13709 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13710 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13711 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13712 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13713
13714 /* Input mixer control */
13715 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13716 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13717 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13718 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13719 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13720 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13721 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13722 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13723 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13724 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013725
Takashi Iwai22309c32006-08-09 16:57:28 +020013726 {
13727 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13728 .name = "Channel Mode",
13729 .info = alc_ch_mode_info,
13730 .get = alc_ch_mode_get,
13731 .put = alc_ch_mode_put,
13732 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13733 },
13734 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013735};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013736
13737static struct snd_kcontrol_new alc861_asus_mixer[] = {
13738 /* output mixer control */
13739 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13740 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13741 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13742 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13743 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13744
13745 /* Input mixer control */
13746 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13747 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13748 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13749 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13750 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13751 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13752 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13753 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13754 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013755 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13756
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013757 {
13758 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13759 .name = "Channel Mode",
13760 .info = alc_ch_mode_info,
13761 .get = alc_ch_mode_get,
13762 .put = alc_ch_mode_put,
13763 .private_value = ARRAY_SIZE(alc861_asus_modes),
13764 },
13765 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013766};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013767
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013768/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013769static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013770 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13771 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013772 { }
13773};
13774
Kailang Yangdf694da2005-12-05 19:42:22 +010013775/*
13776 * generic initialization of ADC, input mixers and output mixers
13777 */
13778static struct hda_verb alc861_base_init_verbs[] = {
13779 /*
13780 * Unmute ADC0 and set the default input to mic-in
13781 */
13782 /* port-A for surround (rear panel) */
13783 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13784 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13785 /* port-B for mic-in (rear panel) with vref */
13786 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13787 /* port-C for line-in (rear panel) */
13788 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13789 /* port-D for Front */
13790 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13791 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13792 /* port-E for HP out (front panel) */
13793 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13794 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013795 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013796 /* port-F for mic-in (front panel) with vref */
13797 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13798 /* port-G for CLFE (rear panel) */
13799 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13800 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13801 /* port-H for side (rear panel) */
13802 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13803 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13804 /* CD-in */
13805 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13806 /* route front mic to ADC1*/
13807 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13808 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013809
Kailang Yangdf694da2005-12-05 19:42:22 +010013810 /* Unmute DAC0~3 & spdif out*/
13811 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13812 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13813 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13814 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13815 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013816
Kailang Yangdf694da2005-12-05 19:42:22 +010013817 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13818 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13819 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13820 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13821 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013822
Kailang Yangdf694da2005-12-05 19:42:22 +010013823 /* Unmute Stereo Mixer 15 */
13824 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13825 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13826 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013827 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013828
13829 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13830 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13831 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13832 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13833 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13834 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13835 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13836 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013837 /* hp used DAC 3 (Front) */
13838 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013839 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13840
13841 { }
13842};
13843
13844static struct hda_verb alc861_threestack_init_verbs[] = {
13845 /*
13846 * Unmute ADC0 and set the default input to mic-in
13847 */
13848 /* port-A for surround (rear panel) */
13849 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13850 /* port-B for mic-in (rear panel) with vref */
13851 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13852 /* port-C for line-in (rear panel) */
13853 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13854 /* port-D for Front */
13855 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13856 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13857 /* port-E for HP out (front panel) */
13858 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13859 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013860 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013861 /* port-F for mic-in (front panel) with vref */
13862 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13863 /* port-G for CLFE (rear panel) */
13864 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13865 /* port-H for side (rear panel) */
13866 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13867 /* CD-in */
13868 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13869 /* route front mic to ADC1*/
13870 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13871 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13872 /* Unmute DAC0~3 & spdif out*/
13873 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13874 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13875 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13876 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13877 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013878
Kailang Yangdf694da2005-12-05 19:42:22 +010013879 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13880 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13881 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13882 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13883 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013884
Kailang Yangdf694da2005-12-05 19:42:22 +010013885 /* Unmute Stereo Mixer 15 */
13886 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13887 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13888 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013889 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013890
13891 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13892 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13893 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13894 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13895 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13896 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13897 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13898 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013899 /* hp used DAC 3 (Front) */
13900 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013901 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13902 { }
13903};
Takashi Iwai22309c32006-08-09 16:57:28 +020013904
13905static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13906 /*
13907 * Unmute ADC0 and set the default input to mic-in
13908 */
13909 /* port-A for surround (rear panel) */
13910 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13911 /* port-B for mic-in (rear panel) with vref */
13912 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13913 /* port-C for line-in (rear panel) */
13914 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13915 /* port-D for Front */
13916 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13917 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13918 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013919 /* this has to be set to VREF80 */
13920 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013921 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013922 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013923 /* port-F for mic-in (front panel) with vref */
13924 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13925 /* port-G for CLFE (rear panel) */
13926 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13927 /* port-H for side (rear panel) */
13928 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13929 /* CD-in */
13930 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13931 /* route front mic to ADC1*/
13932 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13933 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13934 /* Unmute DAC0~3 & spdif out*/
13935 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13936 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13937 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13938 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013940
Takashi Iwai22309c32006-08-09 16:57:28 +020013941 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13942 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13943 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13944 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13945 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013946
Takashi Iwai22309c32006-08-09 16:57:28 +020013947 /* Unmute Stereo Mixer 15 */
13948 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13949 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13950 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013951 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013952
13953 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13954 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13955 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13956 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13957 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13958 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13959 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13960 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013961 /* hp used DAC 3 (Front) */
13962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013963 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13964 { }
13965};
13966
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013967static struct hda_verb alc861_asus_init_verbs[] = {
13968 /*
13969 * Unmute ADC0 and set the default input to mic-in
13970 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013971 /* port-A for surround (rear panel)
13972 * according to codec#0 this is the HP jack
13973 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013974 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13975 /* route front PCM to HP */
13976 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13977 /* port-B for mic-in (rear panel) with vref */
13978 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13979 /* port-C for line-in (rear panel) */
13980 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13981 /* port-D for Front */
13982 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13983 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13984 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013985 /* this has to be set to VREF80 */
13986 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013987 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013988 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013989 /* port-F for mic-in (front panel) with vref */
13990 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13991 /* port-G for CLFE (rear panel) */
13992 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13993 /* port-H for side (rear panel) */
13994 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13995 /* CD-in */
13996 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13997 /* route front mic to ADC1*/
13998 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13999 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14000 /* Unmute DAC0~3 & spdif out*/
14001 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14002 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14003 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14004 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14005 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14006 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14007 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14008 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14009 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14010 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014011
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014012 /* Unmute Stereo Mixer 15 */
14013 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14014 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14015 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014016 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014017
14018 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14019 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14020 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14021 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14022 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14023 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14024 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14025 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014026 /* hp used DAC 3 (Front) */
14027 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014028 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14029 { }
14030};
14031
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014032/* additional init verbs for ASUS laptops */
14033static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14034 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14035 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14036 { }
14037};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014038
Kailang Yangdf694da2005-12-05 19:42:22 +010014039/*
14040 * generic initialization of ADC, input mixers and output mixers
14041 */
14042static struct hda_verb alc861_auto_init_verbs[] = {
14043 /*
14044 * Unmute ADC0 and set the default input to mic-in
14045 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014046 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014047 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014048
Kailang Yangdf694da2005-12-05 19:42:22 +010014049 /* Unmute DAC0~3 & spdif out*/
14050 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14051 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14052 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14053 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14054 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014055
Kailang Yangdf694da2005-12-05 19:42:22 +010014056 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14057 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14058 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14059 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14060 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014061
Kailang Yangdf694da2005-12-05 19:42:22 +010014062 /* Unmute Stereo Mixer 15 */
14063 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14064 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14065 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14067
Takashi Iwai1c209302009-07-22 15:17:45 +020014068 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14069 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14070 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14071 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14072 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14073 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14074 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14075 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014076
14077 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14078 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014079 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14080 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014081 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14082 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014083 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14084 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014085
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014086 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014087
14088 { }
14089};
14090
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014091static struct hda_verb alc861_toshiba_init_verbs[] = {
14092 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014093
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014094 { }
14095};
14096
14097/* toggle speaker-output according to the hp-jack state */
14098static void alc861_toshiba_automute(struct hda_codec *codec)
14099{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014100 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014101
Takashi Iwai47fd8302007-08-10 17:11:07 +020014102 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14103 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14104 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14105 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014106}
14107
14108static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14109 unsigned int res)
14110{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014111 if ((res >> 26) == ALC880_HP_EVENT)
14112 alc861_toshiba_automute(codec);
14113}
14114
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014115/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014116#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14117#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14118#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14119#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14120
14121
14122#define ALC861_DIGOUT_NID 0x07
14123
14124static struct hda_channel_mode alc861_8ch_modes[1] = {
14125 { 8, NULL }
14126};
14127
14128static hda_nid_t alc861_dac_nids[4] = {
14129 /* front, surround, clfe, side */
14130 0x03, 0x06, 0x05, 0x04
14131};
14132
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014133static hda_nid_t alc660_dac_nids[3] = {
14134 /* front, clfe, surround */
14135 0x03, 0x05, 0x06
14136};
14137
Kailang Yangdf694da2005-12-05 19:42:22 +010014138static hda_nid_t alc861_adc_nids[1] = {
14139 /* ADC0-2 */
14140 0x08,
14141};
14142
14143static struct hda_input_mux alc861_capture_source = {
14144 .num_items = 5,
14145 .items = {
14146 { "Mic", 0x0 },
14147 { "Front Mic", 0x3 },
14148 { "Line", 0x1 },
14149 { "CD", 0x4 },
14150 { "Mixer", 0x5 },
14151 },
14152};
14153
Takashi Iwai1c209302009-07-22 15:17:45 +020014154static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14155{
14156 struct alc_spec *spec = codec->spec;
14157 hda_nid_t mix, srcs[5];
14158 int i, j, num;
14159
14160 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14161 return 0;
14162 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14163 if (num < 0)
14164 return 0;
14165 for (i = 0; i < num; i++) {
14166 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014167 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014168 if (type != AC_WID_AUD_OUT)
14169 continue;
14170 for (j = 0; j < spec->multiout.num_dacs; j++)
14171 if (spec->multiout.dac_nids[j] == srcs[i])
14172 break;
14173 if (j >= spec->multiout.num_dacs)
14174 return srcs[i];
14175 }
14176 return 0;
14177}
14178
Kailang Yangdf694da2005-12-05 19:42:22 +010014179/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014180static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014181 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014182{
Takashi Iwai1c209302009-07-22 15:17:45 +020014183 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014184 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014185 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014186
14187 spec->multiout.dac_nids = spec->private_dac_nids;
14188 for (i = 0; i < cfg->line_outs; i++) {
14189 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014190 dac = alc861_look_for_dac(codec, nid);
14191 if (!dac)
14192 continue;
14193 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014194 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014195 return 0;
14196}
14197
Takashi Iwai1c209302009-07-22 15:17:45 +020014198static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14199 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014200{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014201 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014202 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14203}
14204
14205/* add playback controls from the parsed DAC table */
14206static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14207 const struct auto_pin_cfg *cfg)
14208{
14209 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014210 static const char *chname[4] = {
14211 "Front", "Surround", NULL /*CLFE*/, "Side"
14212 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014213 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014214 int i, err;
14215
14216 if (cfg->line_outs == 1) {
14217 const char *pfx = NULL;
14218 if (!cfg->hp_outs)
14219 pfx = "Master";
14220 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14221 pfx = "Speaker";
14222 if (pfx) {
14223 nid = spec->multiout.dac_nids[0];
14224 return alc861_create_out_sw(codec, pfx, nid, 3);
14225 }
14226 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014227
14228 for (i = 0; i < cfg->line_outs; i++) {
14229 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014230 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014231 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014232 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014233 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014234 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014235 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014236 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014237 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014238 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014239 return err;
14240 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014241 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014242 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014243 return err;
14244 }
14245 }
14246 return 0;
14247}
14248
Takashi Iwai1c209302009-07-22 15:17:45 +020014249static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014250{
Takashi Iwai1c209302009-07-22 15:17:45 +020014251 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014252 int err;
14253 hda_nid_t nid;
14254
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014255 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014256 return 0;
14257
14258 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014259 nid = alc861_look_for_dac(codec, pin);
14260 if (nid) {
14261 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14262 if (err < 0)
14263 return err;
14264 spec->multiout.hp_nid = nid;
14265 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014266 }
14267 return 0;
14268}
14269
14270/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014271static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014272 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014273{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014274 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014275}
14276
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014277static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14278 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014279 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014280{
Takashi Iwai1c209302009-07-22 15:17:45 +020014281 hda_nid_t mix, srcs[5];
14282 int i, num;
14283
Jacek Luczak564c5be2008-05-03 18:41:23 +020014284 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14285 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014286 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014287 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014288 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14289 return;
14290 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14291 if (num < 0)
14292 return;
14293 for (i = 0; i < num; i++) {
14294 unsigned int mute;
14295 if (srcs[i] == dac || srcs[i] == 0x15)
14296 mute = AMP_IN_UNMUTE(i);
14297 else
14298 mute = AMP_IN_MUTE(i);
14299 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14300 mute);
14301 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014302}
14303
14304static void alc861_auto_init_multi_out(struct hda_codec *codec)
14305{
14306 struct alc_spec *spec = codec->spec;
14307 int i;
14308
14309 for (i = 0; i < spec->autocfg.line_outs; i++) {
14310 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014311 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014312 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014313 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014314 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014315 }
14316}
14317
14318static void alc861_auto_init_hp_out(struct hda_codec *codec)
14319{
14320 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014321
Takashi Iwai15870f02009-10-05 08:25:13 +020014322 if (spec->autocfg.hp_outs)
14323 alc861_auto_set_output_and_unmute(codec,
14324 spec->autocfg.hp_pins[0],
14325 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014326 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014327 if (spec->autocfg.speaker_outs)
14328 alc861_auto_set_output_and_unmute(codec,
14329 spec->autocfg.speaker_pins[0],
14330 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014331 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014332}
14333
14334static void alc861_auto_init_analog_input(struct hda_codec *codec)
14335{
14336 struct alc_spec *spec = codec->spec;
14337 int i;
14338
14339 for (i = 0; i < AUTO_PIN_LAST; i++) {
14340 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014341 if (nid >= 0x0c && nid <= 0x11)
14342 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014343 }
14344}
14345
14346/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014347/* return 1 if successful, 0 if the proper config is not found,
14348 * or a negative error code
14349 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014350static int alc861_parse_auto_config(struct hda_codec *codec)
14351{
14352 struct alc_spec *spec = codec->spec;
14353 int err;
14354 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14355
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014356 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14357 alc861_ignore);
14358 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014359 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014360 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014361 return 0; /* can't find valid BIOS pin config */
14362
Takashi Iwai1c209302009-07-22 15:17:45 +020014363 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014364 if (err < 0)
14365 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014366 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014367 if (err < 0)
14368 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014369 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014370 if (err < 0)
14371 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014372 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014373 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014374 return err;
14375
14376 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14377
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014378 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014379 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14380
Takashi Iwai603c4012008-07-30 15:01:44 +020014381 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014382 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014383
Takashi Iwaid88897e2008-10-31 15:01:37 +010014384 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014385
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014386 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014387 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014388
14389 spec->adc_nids = alc861_adc_nids;
14390 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014391 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014392
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014393 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14394
Kailang Yangdf694da2005-12-05 19:42:22 +010014395 return 1;
14396}
14397
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014398/* additional initialization for auto-configuration model */
14399static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014400{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014401 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014402 alc861_auto_init_multi_out(codec);
14403 alc861_auto_init_hp_out(codec);
14404 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014405 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014406 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014407}
14408
Takashi Iwaicb53c622007-08-10 17:21:45 +020014409#ifdef CONFIG_SND_HDA_POWER_SAVE
14410static struct hda_amp_list alc861_loopbacks[] = {
14411 { 0x15, HDA_INPUT, 0 },
14412 { 0x15, HDA_INPUT, 1 },
14413 { 0x15, HDA_INPUT, 2 },
14414 { 0x15, HDA_INPUT, 3 },
14415 { } /* end */
14416};
14417#endif
14418
Kailang Yangdf694da2005-12-05 19:42:22 +010014419
14420/*
14421 * configuration and preset
14422 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014423static const char *alc861_models[ALC861_MODEL_LAST] = {
14424 [ALC861_3ST] = "3stack",
14425 [ALC660_3ST] = "3stack-660",
14426 [ALC861_3ST_DIG] = "3stack-dig",
14427 [ALC861_6ST_DIG] = "6stack-dig",
14428 [ALC861_UNIWILL_M31] = "uniwill-m31",
14429 [ALC861_TOSHIBA] = "toshiba",
14430 [ALC861_ASUS] = "asus",
14431 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14432 [ALC861_AUTO] = "auto",
14433};
14434
14435static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014436 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014437 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14438 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14439 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014440 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014441 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014442 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014443 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14444 * Any other models that need this preset?
14445 */
14446 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014447 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14448 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014449 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14450 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14451 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14452 /* FIXME: the below seems conflict */
14453 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14454 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14455 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014456 {}
14457};
14458
14459static struct alc_config_preset alc861_presets[] = {
14460 [ALC861_3ST] = {
14461 .mixers = { alc861_3ST_mixer },
14462 .init_verbs = { alc861_threestack_init_verbs },
14463 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14464 .dac_nids = alc861_dac_nids,
14465 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14466 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014467 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014468 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14469 .adc_nids = alc861_adc_nids,
14470 .input_mux = &alc861_capture_source,
14471 },
14472 [ALC861_3ST_DIG] = {
14473 .mixers = { alc861_base_mixer },
14474 .init_verbs = { alc861_threestack_init_verbs },
14475 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14476 .dac_nids = alc861_dac_nids,
14477 .dig_out_nid = ALC861_DIGOUT_NID,
14478 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14479 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014480 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014481 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14482 .adc_nids = alc861_adc_nids,
14483 .input_mux = &alc861_capture_source,
14484 },
14485 [ALC861_6ST_DIG] = {
14486 .mixers = { alc861_base_mixer },
14487 .init_verbs = { alc861_base_init_verbs },
14488 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14489 .dac_nids = alc861_dac_nids,
14490 .dig_out_nid = ALC861_DIGOUT_NID,
14491 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14492 .channel_mode = alc861_8ch_modes,
14493 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14494 .adc_nids = alc861_adc_nids,
14495 .input_mux = &alc861_capture_source,
14496 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014497 [ALC660_3ST] = {
14498 .mixers = { alc861_3ST_mixer },
14499 .init_verbs = { alc861_threestack_init_verbs },
14500 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14501 .dac_nids = alc660_dac_nids,
14502 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14503 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014504 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014505 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14506 .adc_nids = alc861_adc_nids,
14507 .input_mux = &alc861_capture_source,
14508 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014509 [ALC861_UNIWILL_M31] = {
14510 .mixers = { alc861_uniwill_m31_mixer },
14511 .init_verbs = { alc861_uniwill_m31_init_verbs },
14512 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14513 .dac_nids = alc861_dac_nids,
14514 .dig_out_nid = ALC861_DIGOUT_NID,
14515 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14516 .channel_mode = alc861_uniwill_m31_modes,
14517 .need_dac_fix = 1,
14518 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14519 .adc_nids = alc861_adc_nids,
14520 .input_mux = &alc861_capture_source,
14521 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014522 [ALC861_TOSHIBA] = {
14523 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014524 .init_verbs = { alc861_base_init_verbs,
14525 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014526 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14527 .dac_nids = alc861_dac_nids,
14528 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14529 .channel_mode = alc883_3ST_2ch_modes,
14530 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14531 .adc_nids = alc861_adc_nids,
14532 .input_mux = &alc861_capture_source,
14533 .unsol_event = alc861_toshiba_unsol_event,
14534 .init_hook = alc861_toshiba_automute,
14535 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014536 [ALC861_ASUS] = {
14537 .mixers = { alc861_asus_mixer },
14538 .init_verbs = { alc861_asus_init_verbs },
14539 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14540 .dac_nids = alc861_dac_nids,
14541 .dig_out_nid = ALC861_DIGOUT_NID,
14542 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14543 .channel_mode = alc861_asus_modes,
14544 .need_dac_fix = 1,
14545 .hp_nid = 0x06,
14546 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14547 .adc_nids = alc861_adc_nids,
14548 .input_mux = &alc861_capture_source,
14549 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014550 [ALC861_ASUS_LAPTOP] = {
14551 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14552 .init_verbs = { alc861_asus_init_verbs,
14553 alc861_asus_laptop_init_verbs },
14554 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14555 .dac_nids = alc861_dac_nids,
14556 .dig_out_nid = ALC861_DIGOUT_NID,
14557 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14558 .channel_mode = alc883_3ST_2ch_modes,
14559 .need_dac_fix = 1,
14560 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14561 .adc_nids = alc861_adc_nids,
14562 .input_mux = &alc861_capture_source,
14563 },
14564};
Kailang Yangdf694da2005-12-05 19:42:22 +010014565
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014566/* Pin config fixes */
14567enum {
14568 PINFIX_FSC_AMILO_PI1505,
14569};
14570
14571static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
14572 { 0x0b, 0x0221101f }, /* HP */
14573 { 0x0f, 0x90170310 }, /* speaker */
14574 { }
14575};
14576
14577static const struct alc_fixup alc861_fixups[] = {
14578 [PINFIX_FSC_AMILO_PI1505] = {
14579 .pins = alc861_fsc_amilo_pi1505_pinfix
14580 },
14581};
14582
14583static struct snd_pci_quirk alc861_fixup_tbl[] = {
14584 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
14585 {}
14586};
Kailang Yangdf694da2005-12-05 19:42:22 +010014587
14588static int patch_alc861(struct hda_codec *codec)
14589{
14590 struct alc_spec *spec;
14591 int board_config;
14592 int err;
14593
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014594 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014595 if (spec == NULL)
14596 return -ENOMEM;
14597
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014598 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014599
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014600 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14601 alc861_models,
14602 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014603
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014604 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014605 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14606 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014607 board_config = ALC861_AUTO;
14608 }
14609
Takashi Iwaicfc9b062009-12-01 12:19:37 +010014610 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
14611
Kailang Yangdf694da2005-12-05 19:42:22 +010014612 if (board_config == ALC861_AUTO) {
14613 /* automatic parse from the BIOS config */
14614 err = alc861_parse_auto_config(codec);
14615 if (err < 0) {
14616 alc_free(codec);
14617 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014618 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014619 printk(KERN_INFO
14620 "hda_codec: Cannot set up configuration "
14621 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014622 board_config = ALC861_3ST_DIG;
14623 }
14624 }
14625
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014626 err = snd_hda_attach_beep_device(codec, 0x23);
14627 if (err < 0) {
14628 alc_free(codec);
14629 return err;
14630 }
14631
Kailang Yangdf694da2005-12-05 19:42:22 +010014632 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014633 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014634
Kailang Yangdf694da2005-12-05 19:42:22 +010014635 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14636 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14637
Kailang Yangdf694da2005-12-05 19:42:22 +010014638 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14639 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14640
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014641 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14642
Takashi Iwai2134ea42008-01-10 16:53:55 +010014643 spec->vmaster_nid = 0x03;
14644
Kailang Yangdf694da2005-12-05 19:42:22 +010014645 codec->patch_ops = alc_patch_ops;
14646 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014647 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014648#ifdef CONFIG_SND_HDA_POWER_SAVE
14649 if (!spec->loopback.amplist)
14650 spec->loopback.amplist = alc861_loopbacks;
14651#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014652 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014653
Kailang Yangdf694da2005-12-05 19:42:22 +010014654 return 0;
14655}
14656
14657/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014658 * ALC861-VD support
14659 *
14660 * Based on ALC882
14661 *
14662 * In addition, an independent DAC
14663 */
14664#define ALC861VD_DIGOUT_NID 0x06
14665
14666static hda_nid_t alc861vd_dac_nids[4] = {
14667 /* front, surr, clfe, side surr */
14668 0x02, 0x03, 0x04, 0x05
14669};
14670
14671/* dac_nids for ALC660vd are in a different order - according to
14672 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014673 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014674 * of ALC660vd codecs, but for now there is only 3stack mixer
14675 * - and it is the same as in 861vd.
14676 * adc_nids in ALC660vd are (is) the same as in 861vd
14677 */
14678static hda_nid_t alc660vd_dac_nids[3] = {
14679 /* front, rear, clfe, rear_surr */
14680 0x02, 0x04, 0x03
14681};
14682
14683static hda_nid_t alc861vd_adc_nids[1] = {
14684 /* ADC0 */
14685 0x09,
14686};
14687
Takashi Iwaie1406342008-02-11 18:32:32 +010014688static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14689
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014690/* input MUX */
14691/* FIXME: should be a matrix-type input source selection */
14692static struct hda_input_mux alc861vd_capture_source = {
14693 .num_items = 4,
14694 .items = {
14695 { "Mic", 0x0 },
14696 { "Front Mic", 0x1 },
14697 { "Line", 0x2 },
14698 { "CD", 0x4 },
14699 },
14700};
14701
Kailang Yang272a5272007-05-14 11:00:38 +020014702static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014703 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014704 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014705 { "Ext Mic", 0x0 },
14706 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014707 },
14708};
14709
Kailang Yangd1a991a2007-08-15 16:21:59 +020014710static struct hda_input_mux alc861vd_hp_capture_source = {
14711 .num_items = 2,
14712 .items = {
14713 { "Front Mic", 0x0 },
14714 { "ATAPI Mic", 0x1 },
14715 },
14716};
14717
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014718/*
14719 * 2ch mode
14720 */
14721static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14722 { 2, NULL }
14723};
14724
14725/*
14726 * 6ch mode
14727 */
14728static struct hda_verb alc861vd_6stack_ch6_init[] = {
14729 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14730 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14731 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14732 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14733 { } /* end */
14734};
14735
14736/*
14737 * 8ch mode
14738 */
14739static struct hda_verb alc861vd_6stack_ch8_init[] = {
14740 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14741 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14742 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14743 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14744 { } /* end */
14745};
14746
14747static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14748 { 6, alc861vd_6stack_ch6_init },
14749 { 8, alc861vd_6stack_ch8_init },
14750};
14751
14752static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14753 {
14754 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14755 .name = "Channel Mode",
14756 .info = alc_ch_mode_info,
14757 .get = alc_ch_mode_get,
14758 .put = alc_ch_mode_put,
14759 },
14760 { } /* end */
14761};
14762
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014763/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14764 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14765 */
14766static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14767 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14768 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14769
14770 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14771 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14772
14773 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14774 HDA_OUTPUT),
14775 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14776 HDA_OUTPUT),
14777 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14778 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14779
14780 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14781 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14782
14783 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14784
14785 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14786 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14787 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14788
14789 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14790 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14791 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14792
14793 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14794 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14795
14796 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14797 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14798
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014799 { } /* end */
14800};
14801
14802static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14803 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14804 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14805
14806 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14807
14808 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14811
14812 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14813 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14814 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14815
14816 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14817 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14818
14819 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14820 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14821
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014822 { } /* end */
14823};
14824
Kailang Yangbdd148a2007-05-08 15:19:08 +020014825static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14826 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14827 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14828 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14829
14830 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14831
14832 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14835
14836 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14837 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14838 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14839
14840 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14841 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14842
14843 { } /* end */
14844};
14845
Tobin Davisb419f342008-03-07 11:57:51 +010014846/* Pin assignment: Speaker=0x14, HP = 0x15,
14847 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014848 */
14849static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014850 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14851 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014852 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14853 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014854 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14855 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14856 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14857 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14858 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14859 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014860 { } /* end */
14861};
14862
Kailang Yangd1a991a2007-08-15 16:21:59 +020014863/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14864 * Front Mic=0x18, ATAPI Mic = 0x19,
14865 */
14866static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14867 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14868 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14869 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14870 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14871 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14872 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14873 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14874 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014875
Kailang Yangd1a991a2007-08-15 16:21:59 +020014876 { } /* end */
14877};
14878
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014879/*
14880 * generic initialization of ADC, input mixers and output mixers
14881 */
14882static struct hda_verb alc861vd_volume_init_verbs[] = {
14883 /*
14884 * Unmute ADC0 and set the default input to mic-in
14885 */
14886 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14887 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14888
14889 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14890 * the analog-loopback mixer widget
14891 */
14892 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014893 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14894 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14895 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14896 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014898
14899 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014900 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014904
14905 /*
14906 * Set up output mixers (0x02 - 0x05)
14907 */
14908 /* set vol=0 to output mixers */
14909 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14910 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14911 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14912 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14913
14914 /* set up input amps for analog loopback */
14915 /* Amp Indices: DAC = 0, mixer = 1 */
14916 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14918 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14919 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14920 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14921 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14922 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14923 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14924
14925 { }
14926};
14927
14928/*
14929 * 3-stack pin configuration:
14930 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14931 */
14932static struct hda_verb alc861vd_3stack_init_verbs[] = {
14933 /*
14934 * Set pin mode and muting
14935 */
14936 /* set front pin widgets 0x14 for output */
14937 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14938 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14939 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14940
14941 /* Mic (rear) pin: input vref at 80% */
14942 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14943 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14944 /* Front Mic pin: input vref at 80% */
14945 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14946 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14947 /* Line In pin: input */
14948 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14949 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14950 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14951 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14952 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14953 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14954 /* CD pin widget for input */
14955 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14956
14957 { }
14958};
14959
14960/*
14961 * 6-stack pin configuration:
14962 */
14963static struct hda_verb alc861vd_6stack_init_verbs[] = {
14964 /*
14965 * Set pin mode and muting
14966 */
14967 /* set front pin widgets 0x14 for output */
14968 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14969 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14970 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14971
14972 /* Rear Pin: output 1 (0x0d) */
14973 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14974 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14975 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14976 /* CLFE Pin: output 2 (0x0e) */
14977 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14978 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14979 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14980 /* Side Pin: output 3 (0x0f) */
14981 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14982 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14983 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14984
14985 /* Mic (rear) pin: input vref at 80% */
14986 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14987 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14988 /* Front Mic pin: input vref at 80% */
14989 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14990 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14991 /* Line In pin: input */
14992 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14993 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14994 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14995 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14996 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14997 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14998 /* CD pin widget for input */
14999 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15000
15001 { }
15002};
15003
Kailang Yangbdd148a2007-05-08 15:19:08 +020015004static struct hda_verb alc861vd_eapd_verbs[] = {
15005 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15006 { }
15007};
15008
Kailang Yangf9423e72008-05-27 12:32:25 +020015009static struct hda_verb alc660vd_eapd_verbs[] = {
15010 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15011 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15012 { }
15013};
15014
Kailang Yangbdd148a2007-05-08 15:19:08 +020015015static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15016 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15017 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15018 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15019 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015020 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015021 {}
15022};
15023
Kailang Yangbdd148a2007-05-08 15:19:08 +020015024static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15025{
15026 unsigned int present;
15027 unsigned char bits;
15028
Wu Fengguang864f92b2009-11-18 12:38:02 +080015029 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015030 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015031
Takashi Iwai47fd8302007-08-10 17:11:07 +020015032 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15033 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015034}
15035
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015036static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015037{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015038 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015039 spec->autocfg.hp_pins[0] = 0x1b;
15040 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015041}
15042
15043static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15044{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015045 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015046 alc861vd_lenovo_mic_automute(codec);
15047}
15048
15049static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15050 unsigned int res)
15051{
15052 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015053 case ALC880_MIC_EVENT:
15054 alc861vd_lenovo_mic_automute(codec);
15055 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015056 default:
15057 alc_automute_amp_unsol_event(codec, res);
15058 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015059 }
15060}
15061
Kailang Yang272a5272007-05-14 11:00:38 +020015062static struct hda_verb alc861vd_dallas_verbs[] = {
15063 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15064 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15065 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15066 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15067
15068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15069 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15070 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15071 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15072 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15073 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15074 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15075 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015076
Kailang Yang272a5272007-05-14 11:00:38 +020015077 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15078 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15079 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15080 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15081 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15082 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15083 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15084 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15085
15086 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15087 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15088 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15089 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15090 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15091 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15092 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15093 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15094
15095 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15096 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15099
15100 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015101 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015102 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15103
15104 { } /* end */
15105};
15106
15107/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015108static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015109{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015110 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015111
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015112 spec->autocfg.hp_pins[0] = 0x15;
15113 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015114}
15115
Takashi Iwaicb53c622007-08-10 17:21:45 +020015116#ifdef CONFIG_SND_HDA_POWER_SAVE
15117#define alc861vd_loopbacks alc880_loopbacks
15118#endif
15119
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015120/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015121#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15122#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15123#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15124#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15125
15126/*
15127 * configuration and preset
15128 */
15129static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15130 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015131 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015132 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015133 [ALC861VD_3ST] = "3stack",
15134 [ALC861VD_3ST_DIG] = "3stack-digout",
15135 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015136 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015137 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015138 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015139 [ALC861VD_AUTO] = "auto",
15140};
15141
15142static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015143 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15144 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015145 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015146 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015147 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015148 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015149 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015150 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015151 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015152 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015153 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015154 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015155 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015156 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015157 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015158 {}
15159};
15160
15161static struct alc_config_preset alc861vd_presets[] = {
15162 [ALC660VD_3ST] = {
15163 .mixers = { alc861vd_3st_mixer },
15164 .init_verbs = { alc861vd_volume_init_verbs,
15165 alc861vd_3stack_init_verbs },
15166 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15167 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015168 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15169 .channel_mode = alc861vd_3stack_2ch_modes,
15170 .input_mux = &alc861vd_capture_source,
15171 },
Mike Crash6963f842007-06-25 12:12:51 +020015172 [ALC660VD_3ST_DIG] = {
15173 .mixers = { alc861vd_3st_mixer },
15174 .init_verbs = { alc861vd_volume_init_verbs,
15175 alc861vd_3stack_init_verbs },
15176 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15177 .dac_nids = alc660vd_dac_nids,
15178 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015179 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15180 .channel_mode = alc861vd_3stack_2ch_modes,
15181 .input_mux = &alc861vd_capture_source,
15182 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015183 [ALC861VD_3ST] = {
15184 .mixers = { alc861vd_3st_mixer },
15185 .init_verbs = { alc861vd_volume_init_verbs,
15186 alc861vd_3stack_init_verbs },
15187 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15188 .dac_nids = alc861vd_dac_nids,
15189 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15190 .channel_mode = alc861vd_3stack_2ch_modes,
15191 .input_mux = &alc861vd_capture_source,
15192 },
15193 [ALC861VD_3ST_DIG] = {
15194 .mixers = { alc861vd_3st_mixer },
15195 .init_verbs = { alc861vd_volume_init_verbs,
15196 alc861vd_3stack_init_verbs },
15197 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15198 .dac_nids = alc861vd_dac_nids,
15199 .dig_out_nid = ALC861VD_DIGOUT_NID,
15200 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15201 .channel_mode = alc861vd_3stack_2ch_modes,
15202 .input_mux = &alc861vd_capture_source,
15203 },
15204 [ALC861VD_6ST_DIG] = {
15205 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15206 .init_verbs = { alc861vd_volume_init_verbs,
15207 alc861vd_6stack_init_verbs },
15208 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15209 .dac_nids = alc861vd_dac_nids,
15210 .dig_out_nid = ALC861VD_DIGOUT_NID,
15211 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15212 .channel_mode = alc861vd_6stack_modes,
15213 .input_mux = &alc861vd_capture_source,
15214 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015215 [ALC861VD_LENOVO] = {
15216 .mixers = { alc861vd_lenovo_mixer },
15217 .init_verbs = { alc861vd_volume_init_verbs,
15218 alc861vd_3stack_init_verbs,
15219 alc861vd_eapd_verbs,
15220 alc861vd_lenovo_unsol_verbs },
15221 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15222 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015223 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15224 .channel_mode = alc861vd_3stack_2ch_modes,
15225 .input_mux = &alc861vd_capture_source,
15226 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015227 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015228 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015229 },
Kailang Yang272a5272007-05-14 11:00:38 +020015230 [ALC861VD_DALLAS] = {
15231 .mixers = { alc861vd_dallas_mixer },
15232 .init_verbs = { alc861vd_dallas_verbs },
15233 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15234 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015235 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15236 .channel_mode = alc861vd_3stack_2ch_modes,
15237 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015238 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015239 .setup = alc861vd_dallas_setup,
15240 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015241 },
15242 [ALC861VD_HP] = {
15243 .mixers = { alc861vd_hp_mixer },
15244 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15245 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15246 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015247 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015248 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15249 .channel_mode = alc861vd_3stack_2ch_modes,
15250 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015251 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015252 .setup = alc861vd_dallas_setup,
15253 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015254 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015255 [ALC660VD_ASUS_V1S] = {
15256 .mixers = { alc861vd_lenovo_mixer },
15257 .init_verbs = { alc861vd_volume_init_verbs,
15258 alc861vd_3stack_init_verbs,
15259 alc861vd_eapd_verbs,
15260 alc861vd_lenovo_unsol_verbs },
15261 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15262 .dac_nids = alc660vd_dac_nids,
15263 .dig_out_nid = ALC861VD_DIGOUT_NID,
15264 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15265 .channel_mode = alc861vd_3stack_2ch_modes,
15266 .input_mux = &alc861vd_capture_source,
15267 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015268 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015269 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015270 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015271};
15272
15273/*
15274 * BIOS auto configuration
15275 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015276static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15277 const struct auto_pin_cfg *cfg)
15278{
15279 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15280}
15281
15282
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015283static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15284 hda_nid_t nid, int pin_type, int dac_idx)
15285{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015286 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015287}
15288
15289static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15290{
15291 struct alc_spec *spec = codec->spec;
15292 int i;
15293
15294 for (i = 0; i <= HDA_SIDE; i++) {
15295 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015296 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015297 if (nid)
15298 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015299 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015300 }
15301}
15302
15303
15304static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15305{
15306 struct alc_spec *spec = codec->spec;
15307 hda_nid_t pin;
15308
15309 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015310 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015311 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015312 pin = spec->autocfg.speaker_pins[0];
15313 if (pin)
15314 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015315}
15316
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015317#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15318
15319static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15320{
15321 struct alc_spec *spec = codec->spec;
15322 int i;
15323
15324 for (i = 0; i < AUTO_PIN_LAST; i++) {
15325 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015326 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015327 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015328 if (nid != ALC861VD_PIN_CD_NID &&
15329 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015330 snd_hda_codec_write(codec, nid, 0,
15331 AC_VERB_SET_AMP_GAIN_MUTE,
15332 AMP_OUT_MUTE);
15333 }
15334 }
15335}
15336
Takashi Iwaif511b012008-08-15 16:46:42 +020015337#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15338
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015339#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15340#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15341
15342/* add playback controls from the parsed DAC table */
15343/* Based on ALC880 version. But ALC861VD has separate,
15344 * different NIDs for mute/unmute switch and volume control */
15345static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15346 const struct auto_pin_cfg *cfg)
15347{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015348 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15349 hda_nid_t nid_v, nid_s;
15350 int i, err;
15351
15352 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015353 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015354 continue;
15355 nid_v = alc861vd_idx_to_mixer_vol(
15356 alc880_dac_to_idx(
15357 spec->multiout.dac_nids[i]));
15358 nid_s = alc861vd_idx_to_mixer_switch(
15359 alc880_dac_to_idx(
15360 spec->multiout.dac_nids[i]));
15361
15362 if (i == 2) {
15363 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015364 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15365 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015366 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15367 HDA_OUTPUT));
15368 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015369 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015370 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15371 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015372 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15373 HDA_OUTPUT));
15374 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015375 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015376 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15377 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015378 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15379 HDA_INPUT));
15380 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015381 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015382 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15383 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015384 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15385 HDA_INPUT));
15386 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015387 return err;
15388 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015389 const char *pfx;
15390 if (cfg->line_outs == 1 &&
15391 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15392 if (!cfg->hp_pins)
15393 pfx = "Speaker";
15394 else
15395 pfx = "PCM";
15396 } else
15397 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015398 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015399 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15400 HDA_OUTPUT));
15401 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015402 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015403 if (cfg->line_outs == 1 &&
15404 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15405 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015406 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015407 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015408 HDA_INPUT));
15409 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015410 return err;
15411 }
15412 }
15413 return 0;
15414}
15415
15416/* add playback controls for speaker and HP outputs */
15417/* Based on ALC880 version. But ALC861VD has separate,
15418 * different NIDs for mute/unmute switch and volume control */
15419static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15420 hda_nid_t pin, const char *pfx)
15421{
15422 hda_nid_t nid_v, nid_s;
15423 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015424
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015425 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015426 return 0;
15427
15428 if (alc880_is_fixed_pin(pin)) {
15429 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15430 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015431 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015432 spec->multiout.hp_nid = nid_v;
15433 else
15434 spec->multiout.extra_out_nid[0] = nid_v;
15435 /* control HP volume/switch on the output mixer amp */
15436 nid_v = alc861vd_idx_to_mixer_vol(
15437 alc880_fixed_pin_idx(pin));
15438 nid_s = alc861vd_idx_to_mixer_switch(
15439 alc880_fixed_pin_idx(pin));
15440
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015441 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015442 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15443 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015444 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015445 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015446 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15447 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015448 return err;
15449 } else if (alc880_is_multi_pin(pin)) {
15450 /* set manual connection */
15451 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015452 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015453 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15454 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015455 return err;
15456 }
15457 return 0;
15458}
15459
15460/* parse the BIOS configuration and set up the alc_spec
15461 * return 1 if successful, 0 if the proper config is not found,
15462 * or a negative error code
15463 * Based on ALC880 version - had to change it to override
15464 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15465static int alc861vd_parse_auto_config(struct hda_codec *codec)
15466{
15467 struct alc_spec *spec = codec->spec;
15468 int err;
15469 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15470
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015471 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15472 alc861vd_ignore);
15473 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015474 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015475 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015476 return 0; /* can't find valid BIOS pin config */
15477
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015478 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15479 if (err < 0)
15480 return err;
15481 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15482 if (err < 0)
15483 return err;
15484 err = alc861vd_auto_create_extra_out(spec,
15485 spec->autocfg.speaker_pins[0],
15486 "Speaker");
15487 if (err < 0)
15488 return err;
15489 err = alc861vd_auto_create_extra_out(spec,
15490 spec->autocfg.hp_pins[0],
15491 "Headphone");
15492 if (err < 0)
15493 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015494 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015495 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015496 return err;
15497
15498 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15499
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015500 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015501 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15502
Takashi Iwai603c4012008-07-30 15:01:44 +020015503 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015504 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015505
Takashi Iwaid88897e2008-10-31 15:01:37 +010015506 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015507
15508 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015509 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015510
Takashi Iwai776e1842007-08-29 15:07:11 +020015511 err = alc_auto_add_mic_boost(codec);
15512 if (err < 0)
15513 return err;
15514
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015515 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15516
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015517 return 1;
15518}
15519
15520/* additional initialization for auto-configuration model */
15521static void alc861vd_auto_init(struct hda_codec *codec)
15522{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015523 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015524 alc861vd_auto_init_multi_out(codec);
15525 alc861vd_auto_init_hp_out(codec);
15526 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015527 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015528 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015529 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015530}
15531
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015532enum {
15533 ALC660VD_FIX_ASUS_GPIO1
15534};
15535
15536/* reset GPIO1 */
15537static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
15538 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
15539 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
15540 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
15541 { }
15542};
15543
15544static const struct alc_fixup alc861vd_fixups[] = {
15545 [ALC660VD_FIX_ASUS_GPIO1] = {
15546 .verbs = alc660vd_fix_asus_gpio1_verbs,
15547 },
15548};
15549
15550static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
15551 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
15552 {}
15553};
15554
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015555static int patch_alc861vd(struct hda_codec *codec)
15556{
15557 struct alc_spec *spec;
15558 int err, board_config;
15559
15560 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15561 if (spec == NULL)
15562 return -ENOMEM;
15563
15564 codec->spec = spec;
15565
15566 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15567 alc861vd_models,
15568 alc861vd_cfg_tbl);
15569
15570 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015571 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15572 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015573 board_config = ALC861VD_AUTO;
15574 }
15575
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015576 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
15577
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015578 if (board_config == ALC861VD_AUTO) {
15579 /* automatic parse from the BIOS config */
15580 err = alc861vd_parse_auto_config(codec);
15581 if (err < 0) {
15582 alc_free(codec);
15583 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015584 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015585 printk(KERN_INFO
15586 "hda_codec: Cannot set up configuration "
15587 "from BIOS. Using base mode...\n");
15588 board_config = ALC861VD_3ST;
15589 }
15590 }
15591
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015592 err = snd_hda_attach_beep_device(codec, 0x23);
15593 if (err < 0) {
15594 alc_free(codec);
15595 return err;
15596 }
15597
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015598 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015599 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015600
Kailang Yang2f893282008-05-27 12:14:47 +020015601 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015602 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015603 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015604 }
15605
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015606 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15607 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15608
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015609 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15610 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15611
Takashi Iwaidd704692009-08-11 08:45:11 +020015612 if (!spec->adc_nids) {
15613 spec->adc_nids = alc861vd_adc_nids;
15614 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15615 }
15616 if (!spec->capsrc_nids)
15617 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015618
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015619 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015620 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015621
Takashi Iwai2134ea42008-01-10 16:53:55 +010015622 spec->vmaster_nid = 0x02;
15623
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015624 codec->patch_ops = alc_patch_ops;
15625
15626 if (board_config == ALC861VD_AUTO)
15627 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015628#ifdef CONFIG_SND_HDA_POWER_SAVE
15629 if (!spec->loopback.amplist)
15630 spec->loopback.amplist = alc861vd_loopbacks;
15631#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015632 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015633
15634 return 0;
15635}
15636
15637/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015638 * ALC662 support
15639 *
15640 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15641 * configuration. Each pin widget can choose any input DACs and a mixer.
15642 * Each ADC is connected from a mixer of all inputs. This makes possible
15643 * 6-channel independent captures.
15644 *
15645 * In addition, an independent DAC for the multi-playback (not used in this
15646 * driver yet).
15647 */
15648#define ALC662_DIGOUT_NID 0x06
15649#define ALC662_DIGIN_NID 0x0a
15650
15651static hda_nid_t alc662_dac_nids[4] = {
15652 /* front, rear, clfe, rear_surr */
15653 0x02, 0x03, 0x04
15654};
15655
Kailang Yang622e84c2009-04-21 07:39:04 +020015656static hda_nid_t alc272_dac_nids[2] = {
15657 0x02, 0x03
15658};
15659
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015660static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015661 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015662 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015663};
Takashi Iwaie1406342008-02-11 18:32:32 +010015664
Kailang Yang622e84c2009-04-21 07:39:04 +020015665static hda_nid_t alc272_adc_nids[1] = {
15666 /* ADC1-2 */
15667 0x08,
15668};
15669
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015670static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015671static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15672
Takashi Iwaie1406342008-02-11 18:32:32 +010015673
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015674/* input MUX */
15675/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015676static struct hda_input_mux alc662_capture_source = {
15677 .num_items = 4,
15678 .items = {
15679 { "Mic", 0x0 },
15680 { "Front Mic", 0x1 },
15681 { "Line", 0x2 },
15682 { "CD", 0x4 },
15683 },
15684};
15685
15686static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15687 .num_items = 2,
15688 .items = {
15689 { "Mic", 0x1 },
15690 { "Line", 0x2 },
15691 },
15692};
Kailang Yang291702f2007-10-16 14:28:03 +020015693
Kailang Yang6dda9f42008-05-27 12:05:31 +020015694static struct hda_input_mux alc663_capture_source = {
15695 .num_items = 3,
15696 .items = {
15697 { "Mic", 0x0 },
15698 { "Front Mic", 0x1 },
15699 { "Line", 0x2 },
15700 },
15701};
15702
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015703#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015704static struct hda_input_mux alc272_nc10_capture_source = {
15705 .num_items = 16,
15706 .items = {
15707 { "Autoselect Mic", 0x0 },
15708 { "Internal Mic", 0x1 },
15709 { "In-0x02", 0x2 },
15710 { "In-0x03", 0x3 },
15711 { "In-0x04", 0x4 },
15712 { "In-0x05", 0x5 },
15713 { "In-0x06", 0x6 },
15714 { "In-0x07", 0x7 },
15715 { "In-0x08", 0x8 },
15716 { "In-0x09", 0x9 },
15717 { "In-0x0a", 0x0a },
15718 { "In-0x0b", 0x0b },
15719 { "In-0x0c", 0x0c },
15720 { "In-0x0d", 0x0d },
15721 { "In-0x0e", 0x0e },
15722 { "In-0x0f", 0x0f },
15723 },
15724};
15725#endif
15726
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015727/*
15728 * 2ch mode
15729 */
15730static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15731 { 2, NULL }
15732};
15733
15734/*
15735 * 2ch mode
15736 */
15737static struct hda_verb alc662_3ST_ch2_init[] = {
15738 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15739 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15740 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15741 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15742 { } /* end */
15743};
15744
15745/*
15746 * 6ch mode
15747 */
15748static struct hda_verb alc662_3ST_ch6_init[] = {
15749 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15750 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15751 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15752 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15753 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15754 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15755 { } /* end */
15756};
15757
15758static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15759 { 2, alc662_3ST_ch2_init },
15760 { 6, alc662_3ST_ch6_init },
15761};
15762
15763/*
15764 * 2ch mode
15765 */
15766static struct hda_verb alc662_sixstack_ch6_init[] = {
15767 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15768 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15769 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15770 { } /* end */
15771};
15772
15773/*
15774 * 6ch mode
15775 */
15776static struct hda_verb alc662_sixstack_ch8_init[] = {
15777 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15778 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15779 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15780 { } /* end */
15781};
15782
15783static struct hda_channel_mode alc662_5stack_modes[2] = {
15784 { 2, alc662_sixstack_ch6_init },
15785 { 6, alc662_sixstack_ch8_init },
15786};
15787
15788/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15789 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15790 */
15791
15792static struct snd_kcontrol_new alc662_base_mixer[] = {
15793 /* output mixer control */
15794 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015795 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015796 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015797 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015798 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15799 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015800 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15801 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015802 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15803
15804 /*Input mixer control */
15805 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15806 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15807 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15808 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15809 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15810 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15811 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15812 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015813 { } /* end */
15814};
15815
15816static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15817 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015818 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015819 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15820 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15821 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15822 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15823 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15825 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15826 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15827 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015828 { } /* end */
15829};
15830
15831static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15832 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015833 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015834 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015835 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015836 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15837 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015838 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15839 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015840 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15841 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15842 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15843 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15844 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15845 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15847 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15848 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015849 { } /* end */
15850};
15851
15852static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15853 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15854 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015855 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15856 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015857 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15858 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15859 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15860 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15861 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015862 { } /* end */
15863};
15864
Kailang Yang291702f2007-10-16 14:28:03 +020015865static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015866 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15867 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015868
15869 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15870 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15871 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15872
15873 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15874 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15875 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15876 { } /* end */
15877};
15878
Kailang Yang8c427222008-01-10 13:03:59 +010015879static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015880 ALC262_HIPPO_MASTER_SWITCH,
15881 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015882 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015883 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),
Kailang Yang8c427222008-01-10 13:03:59 +010015885 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15886 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15887 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15889 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15890 { } /* end */
15891};
15892
Kailang Yangf1d4e282008-08-26 14:03:29 +020015893static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15894 .ops = &snd_hda_bind_vol,
15895 .values = {
15896 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15897 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15898 0
15899 },
15900};
15901
15902static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15903 .ops = &snd_hda_bind_sw,
15904 .values = {
15905 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15906 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15907 0
15908 },
15909};
15910
Kailang Yang6dda9f42008-05-27 12:05:31 +020015911static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015912 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15913 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15914 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15915 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15916 { } /* end */
15917};
15918
15919static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15920 .ops = &snd_hda_bind_sw,
15921 .values = {
15922 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15923 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15924 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15925 0
15926 },
15927};
15928
15929static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15930 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15931 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15932 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15933 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15934 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15935 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15936
15937 { } /* end */
15938};
15939
15940static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15941 .ops = &snd_hda_bind_sw,
15942 .values = {
15943 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15944 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15945 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15946 0
15947 },
15948};
15949
15950static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15951 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15952 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15955 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15956 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15957 { } /* end */
15958};
15959
15960static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015961 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15962 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015963 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15964 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15965 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15966 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15967 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15968 { } /* end */
15969};
15970
15971static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15972 .ops = &snd_hda_bind_vol,
15973 .values = {
15974 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15975 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15976 0
15977 },
15978};
15979
15980static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15981 .ops = &snd_hda_bind_sw,
15982 .values = {
15983 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15984 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15985 0
15986 },
15987};
15988
15989static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15990 HDA_BIND_VOL("Master Playback Volume",
15991 &alc663_asus_two_bind_master_vol),
15992 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15993 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15996 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015997 { } /* end */
15998};
15999
16000static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16001 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16002 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16003 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16005 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16006 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016007 { } /* end */
16008};
16009
16010static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16011 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16012 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16013 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16014 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16015 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16016
16017 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16018 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16019 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16020 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16021 { } /* end */
16022};
16023
16024static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16025 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16026 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16027 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16028
16029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16030 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16031 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16032 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16033 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16034 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16035 { } /* end */
16036};
16037
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016038static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16039 {
16040 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16041 .name = "Channel Mode",
16042 .info = alc_ch_mode_info,
16043 .get = alc_ch_mode_get,
16044 .put = alc_ch_mode_put,
16045 },
16046 { } /* end */
16047};
16048
16049static struct hda_verb alc662_init_verbs[] = {
16050 /* ADC: mute amp left and right */
16051 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16052 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16053 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16054
Takashi Iwaicb53c622007-08-10 17:21:45 +020016055 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16056 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16057 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16058 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16059 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016060
Kailang Yangb60dd392007-09-20 12:50:29 +020016061 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16062 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16063 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16064 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16065 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16066 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016067
16068 /* Front Pin: output 0 (0x0c) */
16069 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16070 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16071
16072 /* Rear Pin: output 1 (0x0d) */
16073 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16074 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16075
16076 /* CLFE Pin: output 2 (0x0e) */
16077 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16078 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16079
16080 /* Mic (rear) pin: input vref at 80% */
16081 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16082 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16083 /* Front Mic pin: input vref at 80% */
16084 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16085 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16086 /* Line In pin: input */
16087 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16088 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16089 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16090 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16091 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16092 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16093 /* CD pin widget for input */
16094 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16095
16096 /* FIXME: use matrix-type input source selection */
16097 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16098 /* Input mixer */
16099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016101
16102 /* always trun on EAPD */
16103 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16104 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16105
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016106 { }
16107};
16108
16109static struct hda_verb alc662_sue_init_verbs[] = {
16110 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16111 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016112 {}
16113};
16114
16115static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16116 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16117 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16118 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016119};
16120
Kailang Yang8c427222008-01-10 13:03:59 +010016121/* Set Unsolicited Event*/
16122static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16123 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16124 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16125 {}
16126};
16127
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016128/*
16129 * generic initialization of ADC, input mixers and output mixers
16130 */
16131static struct hda_verb alc662_auto_init_verbs[] = {
16132 /*
16133 * Unmute ADC and set the default input to mic-in
16134 */
16135 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16136 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16137
16138 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16139 * mixer widget
16140 * Note: PASD motherboards uses the Line In 2 as the input for front
16141 * panel mic (mic 2)
16142 */
16143 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016144 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16145 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16146 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16147 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016149
16150 /*
16151 * Set up output mixers (0x0c - 0x0f)
16152 */
16153 /* set vol=0 to output mixers */
16154 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16155 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16156 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16157
16158 /* set up input amps for analog loopback */
16159 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016160 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16161 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16162 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16163 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16164 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16165 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016166
16167
16168 /* FIXME: use matrix-type input source selection */
16169 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16170 /* Input mixer */
16171 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016172 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016173 { }
16174};
16175
Takashi Iwai24fb9172008-09-02 14:48:20 +020016176/* additional verbs for ALC663 */
16177static struct hda_verb alc663_auto_init_verbs[] = {
16178 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16179 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16180 { }
16181};
16182
Kailang Yang6dda9f42008-05-27 12:05:31 +020016183static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016184 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16185 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016186 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16187 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016188 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16190 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016191 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16192 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16193 {}
16194};
16195
Kailang Yangf1d4e282008-08-26 14:03:29 +020016196static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16197 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16198 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16199 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16200 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16201 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16202 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16203 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16204 {}
16205};
16206
16207static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16208 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16209 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16210 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16211 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16212 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16213 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16214 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16215 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16216 {}
16217};
16218
16219static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16220 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16222 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16223 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16224 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16225 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16226 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16227 {}
16228};
16229
16230static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16231 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16232 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16233 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16234 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16237 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16238 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16239 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16240 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16241 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16242 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16243 {}
16244};
16245
16246static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16247 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16248 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16249 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16250 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16251 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16252 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16253 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16254 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16255 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16256 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16257 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16258 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16259 {}
16260};
16261
Kailang Yang6dda9f42008-05-27 12:05:31 +020016262static struct hda_verb alc663_g71v_init_verbs[] = {
16263 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16264 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16265 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16266
16267 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16268 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16269 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16270
16271 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16272 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16273 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16274 {}
16275};
16276
16277static struct hda_verb alc663_g50v_init_verbs[] = {
16278 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16279 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16280 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16281
16282 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16283 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16284 {}
16285};
16286
Kailang Yangf1d4e282008-08-26 14:03:29 +020016287static struct hda_verb alc662_ecs_init_verbs[] = {
16288 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16290 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16291 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16292 {}
16293};
16294
Kailang Yang622e84c2009-04-21 07:39:04 +020016295static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16296 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16297 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16298 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16299 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16300 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16301 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16302 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16305 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16306 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16307 {}
16308};
16309
16310static struct hda_verb alc272_dell_init_verbs[] = {
16311 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16312 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16313 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16314 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16315 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16316 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16317 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16318 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16319 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16320 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16321 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16322 {}
16323};
16324
Kailang Yangf1d4e282008-08-26 14:03:29 +020016325static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16326 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16327 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16328 { } /* end */
16329};
16330
Kailang Yang622e84c2009-04-21 07:39:04 +020016331static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16332 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16333 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16334 { } /* end */
16335};
16336
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016337static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16338{
16339 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016340 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016341
Wu Fengguang864f92b2009-11-18 12:38:02 +080016342 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016343 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016344
Takashi Iwai47fd8302007-08-10 17:11:07 +020016345 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16346 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016347}
16348
16349static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16350{
16351 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016352 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016353
Wu Fengguang864f92b2009-11-18 12:38:02 +080016354 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016355 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016356
Takashi Iwai47fd8302007-08-10 17:11:07 +020016357 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16358 HDA_AMP_MUTE, bits);
16359 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16360 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016361}
16362
16363static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16364 unsigned int res)
16365{
16366 if ((res >> 26) == ALC880_HP_EVENT)
16367 alc662_lenovo_101e_all_automute(codec);
16368 if ((res >> 26) == ALC880_FRONT_EVENT)
16369 alc662_lenovo_101e_ispeaker_automute(codec);
16370}
16371
Kailang Yang291702f2007-10-16 14:28:03 +020016372/* unsolicited event for HP jack sensing */
16373static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16374 unsigned int res)
16375{
Kailang Yang291702f2007-10-16 14:28:03 +020016376 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016377 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016378 else
16379 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016380}
16381
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016382static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016383{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016384 struct alc_spec *spec = codec->spec;
16385
16386 alc262_hippo1_setup(codec);
16387 spec->ext_mic.pin = 0x18;
16388 spec->ext_mic.mux_idx = 0;
16389 spec->int_mic.pin = 0x19;
16390 spec->int_mic.mux_idx = 1;
16391 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016392}
16393
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016394static void alc662_eeepc_inithook(struct hda_codec *codec)
16395{
16396 alc262_hippo_automute(codec);
16397 alc_mic_automute(codec);
16398}
16399
16400static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016401{
Takashi Iwai42171c12009-05-08 14:11:43 +020016402 struct alc_spec *spec = codec->spec;
16403
16404 spec->autocfg.hp_pins[0] = 0x14;
16405 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016406}
16407
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016408#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16409
Kailang Yang6dda9f42008-05-27 12:05:31 +020016410static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16411{
16412 unsigned int present;
16413 unsigned char bits;
16414
Wu Fengguang864f92b2009-11-18 12:38:02 +080016415 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016416 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016417 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16418 AMP_IN_MUTE(0), bits);
16419 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16420 AMP_IN_MUTE(0), bits);
16421}
16422
16423static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16424{
16425 unsigned int present;
16426 unsigned char bits;
16427
Wu Fengguang864f92b2009-11-18 12:38:02 +080016428 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016429 bits = present ? HDA_AMP_MUTE : 0;
16430 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16431 AMP_IN_MUTE(0), bits);
16432 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16433 AMP_IN_MUTE(0), bits);
16434 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16435 AMP_IN_MUTE(0), bits);
16436 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16437 AMP_IN_MUTE(0), bits);
16438}
16439
16440static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16441{
16442 unsigned int present;
16443 unsigned char bits;
16444
Wu Fengguang864f92b2009-11-18 12:38:02 +080016445 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016446 bits = present ? HDA_AMP_MUTE : 0;
16447 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16448 AMP_IN_MUTE(0), bits);
16449 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16450 AMP_IN_MUTE(0), bits);
16451 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16452 AMP_IN_MUTE(0), bits);
16453 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16454 AMP_IN_MUTE(0), bits);
16455}
16456
16457static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16458{
16459 unsigned int present;
16460 unsigned char bits;
16461
Wu Fengguang864f92b2009-11-18 12:38:02 +080016462 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016463 bits = present ? 0 : PIN_OUT;
16464 snd_hda_codec_write(codec, 0x14, 0,
16465 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16466}
16467
16468static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16469{
16470 unsigned int present1, present2;
16471
Wu Fengguang864f92b2009-11-18 12:38:02 +080016472 present1 = snd_hda_jack_detect(codec, 0x21);
16473 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016474
16475 if (present1 || present2) {
16476 snd_hda_codec_write_cache(codec, 0x14, 0,
16477 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16478 } else {
16479 snd_hda_codec_write_cache(codec, 0x14, 0,
16480 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16481 }
16482}
16483
16484static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16485{
16486 unsigned int present1, present2;
16487
Wu Fengguang864f92b2009-11-18 12:38:02 +080016488 present1 = snd_hda_jack_detect(codec, 0x1b);
16489 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016490
16491 if (present1 || present2) {
16492 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16493 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16494 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16495 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16496 } else {
16497 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16498 AMP_IN_MUTE(0), 0);
16499 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16500 AMP_IN_MUTE(0), 0);
16501 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016502}
16503
Kailang Yang6dda9f42008-05-27 12:05:31 +020016504static void alc663_m51va_unsol_event(struct hda_codec *codec,
16505 unsigned int res)
16506{
16507 switch (res >> 26) {
16508 case ALC880_HP_EVENT:
16509 alc663_m51va_speaker_automute(codec);
16510 break;
16511 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016512 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016513 break;
16514 }
16515}
16516
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016517static void alc663_m51va_setup(struct hda_codec *codec)
16518{
16519 struct alc_spec *spec = codec->spec;
16520 spec->ext_mic.pin = 0x18;
16521 spec->ext_mic.mux_idx = 0;
16522 spec->int_mic.pin = 0x12;
16523 spec->int_mic.mux_idx = 1;
16524 spec->auto_mic = 1;
16525}
16526
Kailang Yang6dda9f42008-05-27 12:05:31 +020016527static void alc663_m51va_inithook(struct hda_codec *codec)
16528{
16529 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016530 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016531}
16532
Kailang Yangf1d4e282008-08-26 14:03:29 +020016533/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016534#define alc663_mode1_unsol_event alc663_m51va_unsol_event
16535#define alc663_mode1_setup alc663_m51va_setup
16536#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016537
Kailang Yangf1d4e282008-08-26 14:03:29 +020016538/* ***************** Mode2 ******************************/
16539static void alc662_mode2_unsol_event(struct hda_codec *codec,
16540 unsigned int res)
16541{
16542 switch (res >> 26) {
16543 case ALC880_HP_EVENT:
16544 alc662_f5z_speaker_automute(codec);
16545 break;
16546 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016547 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016548 break;
16549 }
16550}
16551
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016552#define alc662_mode2_setup alc663_m51va_setup
16553
Kailang Yangf1d4e282008-08-26 14:03:29 +020016554static void alc662_mode2_inithook(struct hda_codec *codec)
16555{
16556 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016557 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016558}
16559/* ***************** Mode3 ******************************/
16560static void alc663_mode3_unsol_event(struct hda_codec *codec,
16561 unsigned int res)
16562{
16563 switch (res >> 26) {
16564 case ALC880_HP_EVENT:
16565 alc663_two_hp_m1_speaker_automute(codec);
16566 break;
16567 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016568 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016569 break;
16570 }
16571}
16572
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016573#define alc663_mode3_setup alc663_m51va_setup
16574
Kailang Yangf1d4e282008-08-26 14:03:29 +020016575static void alc663_mode3_inithook(struct hda_codec *codec)
16576{
16577 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016578 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016579}
16580/* ***************** Mode4 ******************************/
16581static void alc663_mode4_unsol_event(struct hda_codec *codec,
16582 unsigned int res)
16583{
16584 switch (res >> 26) {
16585 case ALC880_HP_EVENT:
16586 alc663_21jd_two_speaker_automute(codec);
16587 break;
16588 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016589 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016590 break;
16591 }
16592}
16593
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016594#define alc663_mode4_setup alc663_m51va_setup
16595
Kailang Yangf1d4e282008-08-26 14:03:29 +020016596static void alc663_mode4_inithook(struct hda_codec *codec)
16597{
16598 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016599 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016600}
16601/* ***************** Mode5 ******************************/
16602static void alc663_mode5_unsol_event(struct hda_codec *codec,
16603 unsigned int res)
16604{
16605 switch (res >> 26) {
16606 case ALC880_HP_EVENT:
16607 alc663_15jd_two_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 alc663_mode5_setup alc663_m51va_setup
16616
Kailang Yangf1d4e282008-08-26 14:03:29 +020016617static void alc663_mode5_inithook(struct hda_codec *codec)
16618{
16619 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016620 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016621}
16622/* ***************** Mode6 ******************************/
16623static void alc663_mode6_unsol_event(struct hda_codec *codec,
16624 unsigned int res)
16625{
16626 switch (res >> 26) {
16627 case ALC880_HP_EVENT:
16628 alc663_two_hp_m2_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_mode6_setup alc663_m51va_setup
16637
Kailang Yangf1d4e282008-08-26 14:03:29 +020016638static void alc663_mode6_inithook(struct hda_codec *codec)
16639{
16640 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016641 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016642}
16643
Kailang Yang6dda9f42008-05-27 12:05:31 +020016644static void alc663_g71v_hp_automute(struct hda_codec *codec)
16645{
16646 unsigned int present;
16647 unsigned char bits;
16648
Wu Fengguang864f92b2009-11-18 12:38:02 +080016649 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016650 bits = present ? HDA_AMP_MUTE : 0;
16651 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16652 HDA_AMP_MUTE, bits);
16653 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16654 HDA_AMP_MUTE, bits);
16655}
16656
16657static void alc663_g71v_front_automute(struct hda_codec *codec)
16658{
16659 unsigned int present;
16660 unsigned char bits;
16661
Wu Fengguang864f92b2009-11-18 12:38:02 +080016662 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016663 bits = present ? HDA_AMP_MUTE : 0;
16664 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16665 HDA_AMP_MUTE, bits);
16666}
16667
16668static void alc663_g71v_unsol_event(struct hda_codec *codec,
16669 unsigned int res)
16670{
16671 switch (res >> 26) {
16672 case ALC880_HP_EVENT:
16673 alc663_g71v_hp_automute(codec);
16674 break;
16675 case ALC880_FRONT_EVENT:
16676 alc663_g71v_front_automute(codec);
16677 break;
16678 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016679 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016680 break;
16681 }
16682}
16683
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016684#define alc663_g71v_setup alc663_m51va_setup
16685
Kailang Yang6dda9f42008-05-27 12:05:31 +020016686static void alc663_g71v_inithook(struct hda_codec *codec)
16687{
16688 alc663_g71v_front_automute(codec);
16689 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016690 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016691}
16692
16693static void alc663_g50v_unsol_event(struct hda_codec *codec,
16694 unsigned int res)
16695{
16696 switch (res >> 26) {
16697 case ALC880_HP_EVENT:
16698 alc663_m51va_speaker_automute(codec);
16699 break;
16700 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016701 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016702 break;
16703 }
16704}
16705
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016706#define alc663_g50v_setup alc663_m51va_setup
16707
Kailang Yang6dda9f42008-05-27 12:05:31 +020016708static void alc663_g50v_inithook(struct hda_codec *codec)
16709{
16710 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016711 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016712}
16713
Kailang Yangf1d4e282008-08-26 14:03:29 +020016714static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16715 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016716 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016717
16718 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16719 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16720 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16721
16722 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16723 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16724 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16725 { } /* end */
16726};
16727
Chris Pockelé9541ba12009-05-12 08:08:53 +020016728static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16729 /* Master Playback automatically created from Speaker and Headphone */
16730 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16731 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16732 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16733 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16734
16735 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16736 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16737 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16738
16739 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16740 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16741 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16742 { } /* end */
16743};
16744
Takashi Iwaicb53c622007-08-10 17:21:45 +020016745#ifdef CONFIG_SND_HDA_POWER_SAVE
16746#define alc662_loopbacks alc880_loopbacks
16747#endif
16748
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016749
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016750/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016751#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16752#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16753#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16754#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16755
16756/*
16757 * configuration and preset
16758 */
16759static const char *alc662_models[ALC662_MODEL_LAST] = {
16760 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16761 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16762 [ALC662_3ST_6ch] = "3stack-6ch",
16763 [ALC662_5ST_DIG] = "6stack-dig",
16764 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016765 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016766 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016767 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016768 [ALC663_ASUS_M51VA] = "m51va",
16769 [ALC663_ASUS_G71V] = "g71v",
16770 [ALC663_ASUS_H13] = "h13",
16771 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016772 [ALC663_ASUS_MODE1] = "asus-mode1",
16773 [ALC662_ASUS_MODE2] = "asus-mode2",
16774 [ALC663_ASUS_MODE3] = "asus-mode3",
16775 [ALC663_ASUS_MODE4] = "asus-mode4",
16776 [ALC663_ASUS_MODE5] = "asus-mode5",
16777 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016778 [ALC272_DELL] = "dell",
16779 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016780 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016781 [ALC662_AUTO] = "auto",
16782};
16783
16784static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016785 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016786 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16787 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016788 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16789 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16790 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16791 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16792 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16793 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16794 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16795 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16796 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16797 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16798 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16799 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016800 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16801 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16802 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016803 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16804 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16805 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16806 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016807 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016808 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16809 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016810 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016811 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16812 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16813 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016814 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16815 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16816 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016817 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16818 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16819 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016820 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016821 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16822 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016823 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016824 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016825 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016826 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16827 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16828 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016829 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016830 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16831 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016832 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016833 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016834 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016835 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016836 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16837 ALC662_3ST_6ch_DIG),
Manoj Iyer3db6c032009-09-22 18:33:29 -050016838 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB200", ALC663_ASUS_MODE4),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016839 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016840 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16841 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016842 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016843 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016844 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016845 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016846 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016847 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16848 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016849 {}
16850};
16851
16852static struct alc_config_preset alc662_presets[] = {
16853 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016854 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016855 .init_verbs = { alc662_init_verbs },
16856 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16857 .dac_nids = alc662_dac_nids,
16858 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016859 .dig_in_nid = ALC662_DIGIN_NID,
16860 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16861 .channel_mode = alc662_3ST_2ch_modes,
16862 .input_mux = &alc662_capture_source,
16863 },
16864 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016865 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016866 .init_verbs = { alc662_init_verbs },
16867 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16868 .dac_nids = alc662_dac_nids,
16869 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016870 .dig_in_nid = ALC662_DIGIN_NID,
16871 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16872 .channel_mode = alc662_3ST_6ch_modes,
16873 .need_dac_fix = 1,
16874 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016875 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016876 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016877 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016878 .init_verbs = { alc662_init_verbs },
16879 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16880 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016881 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16882 .channel_mode = alc662_3ST_6ch_modes,
16883 .need_dac_fix = 1,
16884 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016885 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016886 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016887 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016888 .init_verbs = { alc662_init_verbs },
16889 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16890 .dac_nids = alc662_dac_nids,
16891 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016892 .dig_in_nid = ALC662_DIGIN_NID,
16893 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16894 .channel_mode = alc662_5stack_modes,
16895 .input_mux = &alc662_capture_source,
16896 },
16897 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016898 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016899 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16900 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16901 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016902 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16903 .channel_mode = alc662_3ST_2ch_modes,
16904 .input_mux = &alc662_lenovo_101e_capture_source,
16905 .unsol_event = alc662_lenovo_101e_unsol_event,
16906 .init_hook = alc662_lenovo_101e_all_automute,
16907 },
Kailang Yang291702f2007-10-16 14:28:03 +020016908 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016909 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016910 .init_verbs = { alc662_init_verbs,
16911 alc662_eeepc_sue_init_verbs },
16912 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16913 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016914 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16915 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020016916 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016917 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020016918 .init_hook = alc662_eeepc_inithook,
16919 },
Kailang Yang8c427222008-01-10 13:03:59 +010016920 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016921 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016922 alc662_chmode_mixer },
16923 .init_verbs = { alc662_init_verbs,
16924 alc662_eeepc_ep20_sue_init_verbs },
16925 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16926 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016927 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16928 .channel_mode = alc662_3ST_6ch_modes,
16929 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016930 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016931 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010016932 .init_hook = alc662_eeepc_ep20_inithook,
16933 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016934 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016935 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016936 .init_verbs = { alc662_init_verbs,
16937 alc662_ecs_init_verbs },
16938 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16939 .dac_nids = alc662_dac_nids,
16940 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16941 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016942 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016943 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016944 .init_hook = alc662_eeepc_inithook,
16945 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016946 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016947 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016948 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16949 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16950 .dac_nids = alc662_dac_nids,
16951 .dig_out_nid = ALC662_DIGOUT_NID,
16952 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16953 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016954 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016955 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016956 .init_hook = alc663_m51va_inithook,
16957 },
16958 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016959 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016960 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16961 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16962 .dac_nids = alc662_dac_nids,
16963 .dig_out_nid = ALC662_DIGOUT_NID,
16964 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16965 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016966 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016967 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016968 .init_hook = alc663_g71v_inithook,
16969 },
16970 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016971 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016972 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16973 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16974 .dac_nids = alc662_dac_nids,
16975 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16976 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016977 .unsol_event = alc663_m51va_unsol_event,
16978 .init_hook = alc663_m51va_inithook,
16979 },
16980 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016981 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016982 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16983 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16984 .dac_nids = alc662_dac_nids,
16985 .dig_out_nid = ALC662_DIGOUT_NID,
16986 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16987 .channel_mode = alc662_3ST_6ch_modes,
16988 .input_mux = &alc663_capture_source,
16989 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016990 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016991 .init_hook = alc663_g50v_inithook,
16992 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016993 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016994 .mixers = { alc663_m51va_mixer },
16995 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016996 .init_verbs = { alc662_init_verbs,
16997 alc663_21jd_amic_init_verbs },
16998 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16999 .hp_nid = 0x03,
17000 .dac_nids = alc662_dac_nids,
17001 .dig_out_nid = ALC662_DIGOUT_NID,
17002 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17003 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017004 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017005 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017006 .init_hook = alc663_mode1_inithook,
17007 },
17008 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017009 .mixers = { alc662_1bjd_mixer },
17010 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017011 .init_verbs = { alc662_init_verbs,
17012 alc662_1bjd_amic_init_verbs },
17013 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17014 .dac_nids = alc662_dac_nids,
17015 .dig_out_nid = ALC662_DIGOUT_NID,
17016 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17017 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017018 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017019 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017020 .init_hook = alc662_mode2_inithook,
17021 },
17022 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017023 .mixers = { alc663_two_hp_m1_mixer },
17024 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017025 .init_verbs = { alc662_init_verbs,
17026 alc663_two_hp_amic_m1_init_verbs },
17027 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17028 .hp_nid = 0x03,
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 Yangf1d4e282008-08-26 14:03:29 +020017033 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017034 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017035 .init_hook = alc663_mode3_inithook,
17036 },
17037 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017038 .mixers = { alc663_asus_21jd_clfe_mixer },
17039 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017040 .init_verbs = { alc662_init_verbs,
17041 alc663_21jd_amic_init_verbs},
17042 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17043 .hp_nid = 0x03,
17044 .dac_nids = alc662_dac_nids,
17045 .dig_out_nid = ALC662_DIGOUT_NID,
17046 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17047 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017048 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017049 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017050 .init_hook = alc663_mode4_inithook,
17051 },
17052 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017053 .mixers = { alc663_asus_15jd_clfe_mixer },
17054 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017055 .init_verbs = { alc662_init_verbs,
17056 alc663_15jd_amic_init_verbs },
17057 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17058 .hp_nid = 0x03,
17059 .dac_nids = alc662_dac_nids,
17060 .dig_out_nid = ALC662_DIGOUT_NID,
17061 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17062 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017063 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017064 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017065 .init_hook = alc663_mode5_inithook,
17066 },
17067 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017068 .mixers = { alc663_two_hp_m2_mixer },
17069 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017070 .init_verbs = { alc662_init_verbs,
17071 alc663_two_hp_amic_m2_init_verbs },
17072 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17073 .hp_nid = 0x03,
17074 .dac_nids = alc662_dac_nids,
17075 .dig_out_nid = ALC662_DIGOUT_NID,
17076 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17077 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017078 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017079 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017080 .init_hook = alc663_mode6_inithook,
17081 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017082 [ALC272_DELL] = {
17083 .mixers = { alc663_m51va_mixer },
17084 .cap_mixer = alc272_auto_capture_mixer,
17085 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17086 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17087 .dac_nids = alc662_dac_nids,
17088 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17089 .adc_nids = alc272_adc_nids,
17090 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17091 .capsrc_nids = alc272_capsrc_nids,
17092 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017093 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017094 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017095 .init_hook = alc663_m51va_inithook,
17096 },
17097 [ALC272_DELL_ZM1] = {
17098 .mixers = { alc663_m51va_mixer },
17099 .cap_mixer = alc662_auto_capture_mixer,
17100 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17101 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17102 .dac_nids = alc662_dac_nids,
17103 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17104 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017105 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017106 .capsrc_nids = alc662_capsrc_nids,
17107 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017108 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017109 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017110 .init_hook = alc663_m51va_inithook,
17111 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017112 [ALC272_SAMSUNG_NC10] = {
17113 .mixers = { alc272_nc10_mixer },
17114 .init_verbs = { alc662_init_verbs,
17115 alc663_21jd_amic_init_verbs },
17116 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17117 .dac_nids = alc272_dac_nids,
17118 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17119 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017120 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017121 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017122 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017123 .init_hook = alc663_mode4_inithook,
17124 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017125};
17126
17127
17128/*
17129 * BIOS auto configuration
17130 */
17131
Takashi Iwai7085ec12009-10-02 09:03:58 +020017132/* convert from MIX nid to DAC */
17133static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17134{
17135 if (nid == 0x0f)
17136 return 0x02;
17137 else if (nid >= 0x0c && nid <= 0x0e)
17138 return nid - 0x0c + 0x02;
17139 else
17140 return 0;
17141}
17142
17143/* get MIX nid connected to the given pin targeted to DAC */
17144static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17145 hda_nid_t dac)
17146{
17147 hda_nid_t mix[4];
17148 int i, num;
17149
17150 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17151 for (i = 0; i < num; i++) {
17152 if (alc662_mix_to_dac(mix[i]) == dac)
17153 return mix[i];
17154 }
17155 return 0;
17156}
17157
17158/* look for an empty DAC slot */
17159static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17160{
17161 struct alc_spec *spec = codec->spec;
17162 hda_nid_t srcs[5];
17163 int i, j, num;
17164
17165 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17166 if (num < 0)
17167 return 0;
17168 for (i = 0; i < num; i++) {
17169 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17170 if (!nid)
17171 continue;
17172 for (j = 0; j < spec->multiout.num_dacs; j++)
17173 if (spec->multiout.dac_nids[j] == nid)
17174 break;
17175 if (j >= spec->multiout.num_dacs)
17176 return nid;
17177 }
17178 return 0;
17179}
17180
17181/* fill in the dac_nids table from the parsed pin configuration */
17182static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
17183 const struct auto_pin_cfg *cfg)
17184{
17185 struct alc_spec *spec = codec->spec;
17186 int i;
17187 hda_nid_t dac;
17188
17189 spec->multiout.dac_nids = spec->private_dac_nids;
17190 for (i = 0; i < cfg->line_outs; i++) {
17191 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
17192 if (!dac)
17193 continue;
17194 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
17195 }
17196 return 0;
17197}
17198
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017199static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017200 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017201{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017202 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017203 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
17204}
17205
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017206static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017207 hda_nid_t nid, unsigned int chs)
17208{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017209 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017210 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
17211}
17212
17213#define alc662_add_stereo_vol(spec, pfx, nid) \
17214 alc662_add_vol_ctl(spec, pfx, nid, 3)
17215#define alc662_add_stereo_sw(spec, pfx, nid) \
17216 alc662_add_sw_ctl(spec, pfx, nid, 3)
17217
17218/* add playback controls from the parsed DAC table */
17219static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
17220 const struct auto_pin_cfg *cfg)
17221{
17222 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017223 static const char *chname[4] = {
17224 "Front", "Surround", NULL /*CLFE*/, "Side"
17225 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020017226 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017227 int i, err;
17228
17229 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017230 nid = spec->multiout.dac_nids[i];
17231 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017232 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017233 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
17234 if (!mix)
17235 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017236 if (i == 2) {
17237 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017238 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017239 if (err < 0)
17240 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017241 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017242 if (err < 0)
17243 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017244 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017245 if (err < 0)
17246 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017247 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017248 if (err < 0)
17249 return err;
17250 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017251 const char *pfx;
17252 if (cfg->line_outs == 1 &&
17253 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017254 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017255 pfx = "Speaker";
17256 else
17257 pfx = "PCM";
17258 } else
17259 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017260 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017261 if (err < 0)
17262 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020017263 if (cfg->line_outs == 1 &&
17264 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17265 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020017266 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017267 if (err < 0)
17268 return err;
17269 }
17270 }
17271 return 0;
17272}
17273
17274/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017275/* return DAC nid if any new DAC is assigned */
17276static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017277 const char *pfx)
17278{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017279 struct alc_spec *spec = codec->spec;
17280 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017281 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017282
17283 if (!pin)
17284 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017285 nid = alc662_look_for_dac(codec, pin);
17286 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020017287 /* the corresponding DAC is already occupied */
17288 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
17289 return 0; /* no way */
17290 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017291 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017292 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17293 }
17294
17295 mix = alc662_dac_to_mix(codec, pin, nid);
17296 if (!mix)
17297 return 0;
17298 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17299 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020017300 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017301 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17302 if (err < 0)
17303 return err;
17304 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017305}
17306
17307/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017308#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020017309 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017310
17311static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17312 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017313 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017314{
Takashi Iwai7085ec12009-10-02 09:03:58 +020017315 int i, num;
17316 hda_nid_t srcs[4];
17317
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017318 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017319 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020017320 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
17321 if (num <= 1)
17322 return;
17323 for (i = 0; i < num; i++) {
17324 if (alc662_mix_to_dac(srcs[i]) != dac)
17325 continue;
17326 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
17327 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017328 }
17329}
17330
17331static void alc662_auto_init_multi_out(struct hda_codec *codec)
17332{
17333 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017334 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017335 int i;
17336
17337 for (i = 0; i <= HDA_SIDE; i++) {
17338 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17339 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017340 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020017341 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017342 }
17343}
17344
17345static void alc662_auto_init_hp_out(struct hda_codec *codec)
17346{
17347 struct alc_spec *spec = codec->spec;
17348 hda_nid_t pin;
17349
17350 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020017351 if (pin)
17352 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
17353 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017354 pin = spec->autocfg.speaker_pins[0];
17355 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020017356 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
17357 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017358}
17359
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017360#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17361
17362static void alc662_auto_init_analog_input(struct hda_codec *codec)
17363{
17364 struct alc_spec *spec = codec->spec;
17365 int i;
17366
17367 for (i = 0; i < AUTO_PIN_LAST; i++) {
17368 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020017369 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017370 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017371 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017372 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017373 snd_hda_codec_write(codec, nid, 0,
17374 AC_VERB_SET_AMP_GAIN_MUTE,
17375 AMP_OUT_MUTE);
17376 }
17377 }
17378}
17379
Takashi Iwaif511b012008-08-15 16:46:42 +020017380#define alc662_auto_init_input_src alc882_auto_init_input_src
17381
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017382static int alc662_parse_auto_config(struct hda_codec *codec)
17383{
17384 struct alc_spec *spec = codec->spec;
17385 int err;
17386 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17387
17388 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17389 alc662_ignore);
17390 if (err < 0)
17391 return err;
17392 if (!spec->autocfg.line_outs)
17393 return 0; /* can't find valid BIOS pin config */
17394
Takashi Iwai7085ec12009-10-02 09:03:58 +020017395 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017396 if (err < 0)
17397 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017398 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017399 if (err < 0)
17400 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017401 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017402 spec->autocfg.speaker_pins[0],
17403 "Speaker");
17404 if (err < 0)
17405 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017406 if (err)
17407 spec->multiout.extra_out_nid[0] = err;
17408 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017409 "Headphone");
17410 if (err < 0)
17411 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020017412 if (err)
17413 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017414 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017415 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017416 return err;
17417
17418 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17419
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017420 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017421 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17422
Takashi Iwai603c4012008-07-30 15:01:44 +020017423 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017424 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017425
17426 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017427 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017428
Takashi Iwaid88897e2008-10-31 15:01:37 +010017429 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017430 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017431 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017432
17433 err = alc_auto_add_mic_boost(codec);
17434 if (err < 0)
17435 return err;
17436
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017437 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17438
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017439 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017440}
17441
17442/* additional initialization for auto-configuration model */
17443static void alc662_auto_init(struct hda_codec *codec)
17444{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017445 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017446 alc662_auto_init_multi_out(codec);
17447 alc662_auto_init_hp_out(codec);
17448 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017449 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017450 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017451 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017452}
17453
17454static int patch_alc662(struct hda_codec *codec)
17455{
17456 struct alc_spec *spec;
17457 int err, board_config;
17458
17459 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17460 if (!spec)
17461 return -ENOMEM;
17462
17463 codec->spec = spec;
17464
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017465 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17466
Kailang Yang274693f2009-12-03 10:07:50 +010017467 if (alc_read_coef_idx(codec, 0)==0x8020){
17468 kfree(codec->chip_name);
17469 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017470 if (!codec->chip_name) {
17471 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017472 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017473 }
Kailang Yang274693f2009-12-03 10:07:50 +010017474 }
17475
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017476 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17477 alc662_models,
17478 alc662_cfg_tbl);
17479 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017480 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17481 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017482 board_config = ALC662_AUTO;
17483 }
17484
17485 if (board_config == ALC662_AUTO) {
17486 /* automatic parse from the BIOS config */
17487 err = alc662_parse_auto_config(codec);
17488 if (err < 0) {
17489 alc_free(codec);
17490 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017491 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017492 printk(KERN_INFO
17493 "hda_codec: Cannot set up configuration "
17494 "from BIOS. Using base mode...\n");
17495 board_config = ALC662_3ST_2ch_DIG;
17496 }
17497 }
17498
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017499 err = snd_hda_attach_beep_device(codec, 0x1);
17500 if (err < 0) {
17501 alc_free(codec);
17502 return err;
17503 }
17504
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017505 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017506 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017507
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017508 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17509 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17510
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017511 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17512 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17513
Takashi Iwaidd704692009-08-11 08:45:11 +020017514 if (!spec->adc_nids) {
17515 spec->adc_nids = alc662_adc_nids;
17516 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17517 }
17518 if (!spec->capsrc_nids)
17519 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017520
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017521 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017522 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017523 if (codec->vendor_id == 0x10ec0662)
17524 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17525 else
17526 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017527
Takashi Iwai2134ea42008-01-10 16:53:55 +010017528 spec->vmaster_nid = 0x02;
17529
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017530 codec->patch_ops = alc_patch_ops;
17531 if (board_config == ALC662_AUTO)
17532 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017533#ifdef CONFIG_SND_HDA_POWER_SAVE
17534 if (!spec->loopback.amplist)
17535 spec->loopback.amplist = alc662_loopbacks;
17536#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017537 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017538
17539 return 0;
17540}
17541
Kailang Yang274693f2009-12-03 10:07:50 +010017542static int patch_alc888(struct hda_codec *codec)
17543{
17544 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
17545 kfree(codec->chip_name);
17546 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017547 if (!codec->chip_name) {
17548 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017549 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017550 }
17551 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017552 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010017553 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010017554}
17555
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017556/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017557 * patch entries
17558 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017559static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017560 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017561 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017562 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017563 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017564 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017565 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017566 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017567 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017568 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17569 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17570 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017571 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017572 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017573 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17574 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017575 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017576 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017577 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017578 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017579 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017580 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017581 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017582 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017583 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017584 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017585 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017586 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010017587 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017588 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010017589 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017590 {} /* terminator */
17591};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017592
17593MODULE_ALIAS("snd-hda-codec-id:10ec*");
17594
17595MODULE_LICENSE("GPL");
17596MODULE_DESCRIPTION("Realtek HD-audio codec");
17597
17598static struct hda_codec_preset_list realtek_list = {
17599 .preset = snd_hda_preset_realtek,
17600 .owner = THIS_MODULE,
17601};
17602
17603static int __init patch_realtek_init(void)
17604{
17605 return snd_hda_add_codec_preset(&realtek_list);
17606}
17607
17608static void __exit patch_realtek_exit(void)
17609{
17610 snd_hda_delete_codec_preset(&realtek_list);
17611}
17612
17613module_init(patch_realtek_init)
17614module_exit(patch_realtek_exit)