blob: 5156c4f14f8015f0c0a23d1947fee08f037b98fc [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 Woithe7cf51e42006-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 Woithe7cf51e42006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200134 ALC269_ASUS_EEEPC_P703,
135 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100136 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000137 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100138 ALC269_AUTO,
139 ALC269_MODEL_LAST /* last tag */
140};
141
Kailang Yangdf694da2005-12-05 19:42:22 +0100142/* ALC861 models */
143enum {
144 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200145 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 ALC861_3ST_DIG,
147 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200148 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200149 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200150 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100151 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100152 ALC861_AUTO,
153 ALC861_MODEL_LAST,
154};
155
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100156/* ALC861-VD models */
157enum {
158 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200159 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100160 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_3ST,
162 ALC861VD_3ST_DIG,
163 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200164 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200165 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200166 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100167 ALC861VD_AUTO,
168 ALC861VD_MODEL_LAST,
169};
170
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200171/* ALC662 models */
172enum {
173 ALC662_3ST_2ch_DIG,
174 ALC662_3ST_6ch_DIG,
175 ALC662_3ST_6ch,
176 ALC662_5ST_DIG,
177 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200178 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100179 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200180 ALC663_ASUS_M51VA,
181 ALC663_ASUS_G71V,
182 ALC663_ASUS_H13,
183 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200184 ALC662_ECS,
185 ALC663_ASUS_MODE1,
186 ALC662_ASUS_MODE2,
187 ALC663_ASUS_MODE3,
188 ALC663_ASUS_MODE4,
189 ALC663_ASUS_MODE5,
190 ALC663_ASUS_MODE6,
Kailang Yang622e84c2009-04-21 07:39:04 +0200191 ALC272_DELL,
192 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200193 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200194 ALC662_AUTO,
195 ALC662_MODEL_LAST,
196};
197
Kailang Yangdf694da2005-12-05 19:42:22 +0100198/* ALC882 models */
199enum {
200 ALC882_3ST_DIG,
201 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200202 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200203 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200204 ALC882_TARGA,
205 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200206 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100207 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200208 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200209 ALC885_MB5,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200210 ALC885_IMAC24,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200211 ALC883_3ST_2ch_DIG,
212 ALC883_3ST_6ch_DIG,
213 ALC883_3ST_6ch,
214 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200215 ALC883_TARGA_DIG,
216 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200217 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +0200218 ALC883_ACER,
Tobin 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,
Tobin Davisc07584c2006-10-13 12:32:16 +0200223 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200224 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100225 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200226 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200227 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200228 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200229 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200230 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200231 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100232 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100233 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100234 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100235 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800236 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200237 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200238 ALC889A_INTEL,
239 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200240 ALC888_ASUS_M90V,
241 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200242 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100243 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200244 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200245 ALC882_AUTO,
246 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200247};
248
Kailang Yangdf694da2005-12-05 19:42:22 +0100249/* for GPIO Poll */
250#define GPIO_MASK 0x03
251
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200252/* extra amp-initialization sequence types */
253enum {
254 ALC_INIT_NONE,
255 ALC_INIT_DEFAULT,
256 ALC_INIT_GPIO1,
257 ALC_INIT_GPIO2,
258 ALC_INIT_GPIO3,
259};
260
Takashi Iwai6c819492009-08-10 18:47:44 +0200261struct alc_mic_route {
262 hda_nid_t pin;
263 unsigned char mux_idx;
264 unsigned char amix_idx;
265};
266
267#define MUX_IDX_UNDEF ((unsigned char)-1)
268
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269struct alc_spec {
270 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100271 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100273 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100274 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275
Kailang Yangdf694da2005-12-05 19:42:22 +0100276 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200277 * don't forget NULL
278 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200279 */
280 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200282 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 struct hda_pcm_stream *stream_analog_playback;
284 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100285 struct hda_pcm_stream *stream_analog_alt_playback;
286 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200288 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 struct hda_pcm_stream *stream_digital_playback;
290 struct hda_pcm_stream *stream_digital_capture;
291
292 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200293 struct hda_multi_out multiout; /* playback set-up
294 * max_channels, dacs must be set
295 * dig_out_nid and hp_nid are optional
296 */
Takashi Iwai63300792008-01-24 15:31:36 +0100297 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100298 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100299 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
301 /* capture */
302 unsigned int num_adc_nids;
303 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100304 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200305 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
307 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200308 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 const struct hda_input_mux *input_mux;
310 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200311 struct alc_mic_route ext_mic;
312 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
314 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100315 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200317 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200318 int const_channel_count;
319 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
321 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100322 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200323
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200324 /* dynamic controls, init_verbs and input_mux */
325 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200326 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200327 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200328 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200329 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
330 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100331
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100332 /* hooks */
333 void (*init_hook)(struct hda_codec *codec);
334 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
335
Takashi Iwai834be882006-03-01 14:16:17 +0100336 /* for pin sensing */
337 unsigned int sense_updated: 1;
338 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100339 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200340 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200341
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100342 /* other flags */
343 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200344 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100345
Takashi Iwai2134ea42008-01-10 16:53:55 +0100346 /* for virtual master */
347 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200348#ifdef CONFIG_SND_HDA_POWER_SAVE
349 struct hda_loopback_check loopback;
350#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200351
352 /* for PLL fix */
353 hda_nid_t pll_nid;
354 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100355};
356
357/*
358 * configuration template - to be copied to the spec instance
359 */
360struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200361 struct snd_kcontrol_new *mixers[5]; /* should be identical size
362 * with spec
363 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100364 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100365 const struct hda_verb *init_verbs[5];
366 unsigned int num_dacs;
367 hda_nid_t *dac_nids;
368 hda_nid_t dig_out_nid; /* optional */
369 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800370 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100371 unsigned int num_adc_nids;
372 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100373 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100374 hda_nid_t dig_in_nid;
375 unsigned int num_channel_mode;
376 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200377 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200378 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200379 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100380 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100381 void (*unsol_event)(struct hda_codec *, unsigned int);
382 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200383#ifdef CONFIG_SND_HDA_POWER_SAVE
384 struct hda_amp_list *loopbacks;
385#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386};
387
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388
389/*
390 * input MUX handling
391 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200392static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
393 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394{
395 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
396 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200397 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
398 if (mux_idx >= spec->num_mux_defs)
399 mux_idx = 0;
400 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401}
402
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200403static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
404 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405{
406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
407 struct alc_spec *spec = codec->spec;
408 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
409
410 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
411 return 0;
412}
413
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200414static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
415 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416{
417 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
418 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100419 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100421 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100422 hda_nid_t nid = spec->capsrc_nids ?
423 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200424 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425
Takashi Iwaicd896c32008-11-18 12:36:33 +0100426 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
427 imux = &spec->input_mux[mux_idx];
428
Takashi Iwaia22d5432009-07-27 12:54:26 +0200429 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200430 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100431 /* Matrix-mixer style (e.g. ALC882) */
432 unsigned int *cur_val = &spec->cur_mux[adc_idx];
433 unsigned int i, idx;
434
435 idx = ucontrol->value.enumerated.item[0];
436 if (idx >= imux->num_items)
437 idx = imux->num_items - 1;
438 if (*cur_val == idx)
439 return 0;
440 for (i = 0; i < imux->num_items; i++) {
441 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
442 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
443 imux->items[i].index,
444 HDA_AMP_MUTE, v);
445 }
446 *cur_val = idx;
447 return 1;
448 } else {
449 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100450 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100451 &spec->cur_mux[adc_idx]);
452 }
453}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200454
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455/*
456 * channel mode setting
457 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200458static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
459 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
462 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100463 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
464 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465}
466
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200467static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
468 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469{
470 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
471 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100472 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200473 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200474 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475}
476
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200477static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479{
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200482 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
483 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200484 &spec->ext_channel_count);
485 if (err >= 0 && !spec->const_channel_count) {
486 spec->multiout.max_channels = spec->ext_channel_count;
487 if (spec->need_dac_fix)
488 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
489 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200490 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491}
492
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100494 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200495 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100496 * being part of a format specifier. Maximum allowed length of a value is
497 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100498 *
499 * Note: some retasking pin complexes seem to ignore requests for input
500 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
501 * are requested. Therefore order this list so that this behaviour will not
502 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200503 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
504 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200505 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100506static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100507 "Mic 50pc bias", "Mic 80pc bias",
508 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100509};
510static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100511 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512};
513/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200514 * in the pin being assumed to be exclusively an input or an output pin. In
515 * addition, "input" pins may or may not process the mic bias option
516 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
517 * accept requests for bias as of chip versions up to March 2006) and/or
518 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100519 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200520#define ALC_PIN_DIR_IN 0x00
521#define ALC_PIN_DIR_OUT 0x01
522#define ALC_PIN_DIR_INOUT 0x02
523#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
524#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100525
Kailang Yangea1fb292008-08-26 12:58:38 +0200526/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100527 * For each direction the minimum and maximum values are given.
528 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200529static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100530 { 0, 2 }, /* ALC_PIN_DIR_IN */
531 { 3, 4 }, /* ALC_PIN_DIR_OUT */
532 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200533 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
534 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100535};
536#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
537#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
538#define alc_pin_mode_n_items(_dir) \
539 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
540
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200541static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
542 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200543{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100544 unsigned int item_num = uinfo->value.enumerated.item;
545 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
546
547 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200548 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100549 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
550
551 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
552 item_num = alc_pin_mode_min(dir);
553 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200554 return 0;
555}
556
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200557static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
558 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200559{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100560 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200561 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
562 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200564 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200565 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
566 AC_VERB_GET_PIN_WIDGET_CONTROL,
567 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200568
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100569 /* Find enumerated value for current pinctl setting */
570 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200571 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100572 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200573 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100574 return 0;
575}
576
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200577static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
578 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100579{
580 signed int change;
581 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
582 hda_nid_t nid = kcontrol->private_value & 0xffff;
583 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
584 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200585 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
586 AC_VERB_GET_PIN_WIDGET_CONTROL,
587 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100588
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200589 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100590 val = alc_pin_mode_min(dir);
591
592 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100593 if (change) {
594 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200595 snd_hda_codec_write_cache(codec, nid, 0,
596 AC_VERB_SET_PIN_WIDGET_CONTROL,
597 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100598
Kailang Yangea1fb292008-08-26 12:58:38 +0200599 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100600 * for the requested pin mode. Enum values of 2 or less are
601 * input modes.
602 *
603 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200604 * reduces noise slightly (particularly on input) so we'll
605 * do it. However, having both input and output buffers
606 * enabled simultaneously doesn't seem to be problematic if
607 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100608 */
609 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200610 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
611 HDA_AMP_MUTE, HDA_AMP_MUTE);
612 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
613 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100614 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200615 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
616 HDA_AMP_MUTE, HDA_AMP_MUTE);
617 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
618 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100619 }
620 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200621 return change;
622}
623
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100624#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200625 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100626 .info = alc_pin_mode_info, \
627 .get = alc_pin_mode_get, \
628 .put = alc_pin_mode_put, \
629 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100630
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100631/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
632 * together using a mask with more than one bit set. This control is
633 * currently used only by the ALC260 test model. At this stage they are not
634 * needed for any "production" models.
635 */
636#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200637#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200638
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200639static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
640 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100641{
642 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
643 hda_nid_t nid = kcontrol->private_value & 0xffff;
644 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
645 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200646 unsigned int val = snd_hda_codec_read(codec, nid, 0,
647 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100648
649 *valp = (val & mask) != 0;
650 return 0;
651}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200652static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100654{
655 signed int change;
656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
657 hda_nid_t nid = kcontrol->private_value & 0xffff;
658 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
659 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200660 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
661 AC_VERB_GET_GPIO_DATA,
662 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100663
664 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200665 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
666 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100667 gpio_data &= ~mask;
668 else
669 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200670 snd_hda_codec_write_cache(codec, nid, 0,
671 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100672
673 return change;
674}
675#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
676 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
677 .info = alc_gpio_data_info, \
678 .get = alc_gpio_data_get, \
679 .put = alc_gpio_data_put, \
680 .private_value = nid | (mask<<16) }
681#endif /* CONFIG_SND_DEBUG */
682
Jonathan Woithe92621f12006-02-28 11:47:47 +0100683/* A switch control to allow the enabling of the digital IO pins on the
684 * ALC260. This is incredibly simplistic; the intention of this control is
685 * to provide something in the test model allowing digital outputs to be
686 * identified if present. If models are found which can utilise these
687 * outputs a more complete mixer control can be devised for those models if
688 * necessary.
689 */
690#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200691#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200692
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200693static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
694 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100695{
696 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
697 hda_nid_t nid = kcontrol->private_value & 0xffff;
698 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
699 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200700 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100701 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100702
703 *valp = (val & mask) != 0;
704 return 0;
705}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200706static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
707 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100708{
709 signed int change;
710 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
711 hda_nid_t nid = kcontrol->private_value & 0xffff;
712 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
713 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200714 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100715 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200716 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100717
718 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200719 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100720 if (val==0)
721 ctrl_data &= ~mask;
722 else
723 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200724 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
725 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100726
727 return change;
728}
729#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
730 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
731 .info = alc_spdif_ctrl_info, \
732 .get = alc_spdif_ctrl_get, \
733 .put = alc_spdif_ctrl_put, \
734 .private_value = nid | (mask<<16) }
735#endif /* CONFIG_SND_DEBUG */
736
Jonathan Woithef8225f62008-01-08 12:16:54 +0100737/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
738 * Again, this is only used in the ALC26x test models to help identify when
739 * the EAPD line must be asserted for features to work.
740 */
741#ifdef CONFIG_SND_DEBUG
742#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
743
744static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
745 struct snd_ctl_elem_value *ucontrol)
746{
747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
748 hda_nid_t nid = kcontrol->private_value & 0xffff;
749 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
750 long *valp = ucontrol->value.integer.value;
751 unsigned int val = snd_hda_codec_read(codec, nid, 0,
752 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
753
754 *valp = (val & mask) != 0;
755 return 0;
756}
757
758static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
759 struct snd_ctl_elem_value *ucontrol)
760{
761 int change;
762 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
763 hda_nid_t nid = kcontrol->private_value & 0xffff;
764 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
765 long val = *ucontrol->value.integer.value;
766 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
767 AC_VERB_GET_EAPD_BTLENABLE,
768 0x00);
769
770 /* Set/unset the masked control bit(s) as needed */
771 change = (!val ? 0 : mask) != (ctrl_data & mask);
772 if (!val)
773 ctrl_data &= ~mask;
774 else
775 ctrl_data |= mask;
776 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
777 ctrl_data);
778
779 return change;
780}
781
782#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
783 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
784 .info = alc_eapd_ctrl_info, \
785 .get = alc_eapd_ctrl_get, \
786 .put = alc_eapd_ctrl_put, \
787 .private_value = nid | (mask<<16) }
788#endif /* CONFIG_SND_DEBUG */
789
Kailang Yangdf694da2005-12-05 19:42:22 +0100790/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100791 * set up the input pin config (depending on the given auto-pin type)
792 */
793static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
794 int auto_pin_type)
795{
796 unsigned int val = PIN_IN;
797
798 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
799 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100800 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100801 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
802 if (pincap & AC_PINCAP_VREF_80)
803 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200804 else if (pincap & AC_PINCAP_VREF_50)
805 val = PIN_VREF50;
806 else if (pincap & AC_PINCAP_VREF_100)
807 val = PIN_VREF100;
808 else if (pincap & AC_PINCAP_VREF_GRD)
809 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100810 }
811 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
812}
813
814/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100815 */
816static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
817{
818 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
819 return;
820 spec->mixers[spec->num_mixers++] = mix;
821}
822
823static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
824{
825 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
826 return;
827 spec->init_verbs[spec->num_init_verbs++] = verb;
828}
829
Takashi Iwaidaead532008-11-28 12:55:36 +0100830#ifdef CONFIG_PROC_FS
831/*
832 * hook for proc
833 */
834static void print_realtek_coef(struct snd_info_buffer *buffer,
835 struct hda_codec *codec, hda_nid_t nid)
836{
837 int coeff;
838
839 if (nid != 0x20)
840 return;
841 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
842 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
843 coeff = snd_hda_codec_read(codec, nid, 0,
844 AC_VERB_GET_COEF_INDEX, 0);
845 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
846}
847#else
848#define print_realtek_coef NULL
849#endif
850
Takashi Iwaid88897e2008-10-31 15:01:37 +0100851/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100852 * set up from the preset table
853 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200854static void setup_preset(struct alc_spec *spec,
855 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100856{
857 int i;
858
859 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100860 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100861 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200862 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
863 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100864 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200865
Kailang Yangdf694da2005-12-05 19:42:22 +0100866 spec->channel_mode = preset->channel_mode;
867 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200868 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200869 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100870
Hector Martin3b315d72009-06-02 10:54:19 +0200871 if (preset->const_channel_count)
872 spec->multiout.max_channels = preset->const_channel_count;
873 else
874 spec->multiout.max_channels = spec->channel_mode[0].channels;
875 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100876
877 spec->multiout.num_dacs = preset->num_dacs;
878 spec->multiout.dac_nids = preset->dac_nids;
879 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800880 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100881 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200882
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200883 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200884 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200885 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100886 spec->input_mux = preset->input_mux;
887
888 spec->num_adc_nids = preset->num_adc_nids;
889 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100890 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100891 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100892
893 spec->unsol_event = preset->unsol_event;
894 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200895#ifdef CONFIG_SND_HDA_POWER_SAVE
896 spec->loopback.amplist = preset->loopbacks;
897#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100898}
899
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200900/* Enable GPIO mask and set output */
901static struct hda_verb alc_gpio1_init_verbs[] = {
902 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
903 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
904 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
905 { }
906};
907
908static struct hda_verb alc_gpio2_init_verbs[] = {
909 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
910 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
911 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
912 { }
913};
914
Kailang Yangbdd148a2007-05-08 15:19:08 +0200915static struct hda_verb alc_gpio3_init_verbs[] = {
916 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
917 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
918 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
919 { }
920};
921
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200922/*
923 * Fix hardware PLL issue
924 * On some codecs, the analog PLL gating control must be off while
925 * the default value is 1.
926 */
927static void alc_fix_pll(struct hda_codec *codec)
928{
929 struct alc_spec *spec = codec->spec;
930 unsigned int val;
931
932 if (!spec->pll_nid)
933 return;
934 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
935 spec->pll_coef_idx);
936 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
937 AC_VERB_GET_PROC_COEF, 0);
938 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
939 spec->pll_coef_idx);
940 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
941 val & ~(1 << spec->pll_coef_bit));
942}
943
944static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
945 unsigned int coef_idx, unsigned int coef_bit)
946{
947 struct alc_spec *spec = codec->spec;
948 spec->pll_nid = nid;
949 spec->pll_coef_idx = coef_idx;
950 spec->pll_coef_bit = coef_bit;
951 alc_fix_pll(codec);
952}
953
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200954static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200955{
956 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +0200957 unsigned int present, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200958 unsigned int nid = spec->autocfg.hp_pins[0];
959 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200960
Takashi Iwai261c2402009-06-25 08:13:40 +0200961 pincap = snd_hda_query_pin_caps(codec, nid);
962 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
963 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200964 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200965 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200966 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
967 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
968 nid = spec->autocfg.speaker_pins[i];
969 if (!nid)
970 break;
971 snd_hda_codec_write(codec, nid, 0,
972 AC_VERB_SET_PIN_WIDGET_CONTROL,
973 spec->jack_present ? 0 : PIN_OUT);
974 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200975}
976
Takashi Iwai6c819492009-08-10 18:47:44 +0200977static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
978 hda_nid_t nid)
979{
980 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
981 int i, nums;
982
983 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
984 for (i = 0; i < nums; i++)
985 if (conn[i] == nid)
986 return i;
987 return -1;
988}
989
Kailang Yang7fb0d782008-10-15 11:12:35 +0200990static void alc_mic_automute(struct hda_codec *codec)
991{
992 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +0200993 struct alc_mic_route *dead, *alive;
994 unsigned int present, type;
995 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200996
Takashi Iwaib59bdf32009-08-11 09:47:30 +0200997 if (!spec->auto_mic)
998 return;
Takashi Iwai6c819492009-08-10 18:47:44 +0200999 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1000 return;
1001 if (snd_BUG_ON(!spec->adc_nids))
1002 return;
1003
1004 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1005
1006 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
1007 AC_VERB_GET_PIN_SENSE, 0);
1008 present &= AC_PINSENSE_PRESENCE;
1009 if (present) {
1010 alive = &spec->ext_mic;
1011 dead = &spec->int_mic;
1012 } else {
1013 alive = &spec->int_mic;
1014 dead = &spec->ext_mic;
1015 }
1016
Takashi Iwai6c819492009-08-10 18:47:44 +02001017 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1018 if (type == AC_WID_AUD_MIX) {
1019 /* Matrix-mixer style (e.g. ALC882) */
1020 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1021 alive->mux_idx,
1022 HDA_AMP_MUTE, 0);
1023 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1024 dead->mux_idx,
1025 HDA_AMP_MUTE, HDA_AMP_MUTE);
1026 } else {
1027 /* MUX style (e.g. ALC880) */
1028 snd_hda_codec_write_cache(codec, cap_nid, 0,
1029 AC_VERB_SET_CONNECT_SEL,
1030 alive->mux_idx);
1031 }
1032
1033 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001034}
1035
Kailang Yangc9b58002007-10-16 14:30:01 +02001036/* unsolicited event for HP jack sensing */
1037static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1038{
1039 if (codec->vendor_id == 0x10ec0880)
1040 res >>= 28;
1041 else
1042 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001043 switch (res) {
1044 case ALC880_HP_EVENT:
1045 alc_automute_pin(codec);
1046 break;
1047 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001048 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001049 break;
1050 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001051}
1052
1053static void alc_inithook(struct hda_codec *codec)
1054{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001055 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001056 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001057}
1058
Kailang Yangf9423e72008-05-27 12:32:25 +02001059/* additional initialization for ALC888 variants */
1060static void alc888_coef_init(struct hda_codec *codec)
1061{
1062 unsigned int tmp;
1063
1064 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1065 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1066 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001067 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001068 /* alc888S-VC */
1069 snd_hda_codec_read(codec, 0x20, 0,
1070 AC_VERB_SET_PROC_COEF, 0x830);
1071 else
1072 /* alc888-VB */
1073 snd_hda_codec_read(codec, 0x20, 0,
1074 AC_VERB_SET_PROC_COEF, 0x3030);
1075}
1076
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001077static void alc889_coef_init(struct hda_codec *codec)
1078{
1079 unsigned int tmp;
1080
1081 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1082 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1083 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1084 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1085}
1086
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001087static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001088{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001089 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001090
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001091 switch (type) {
1092 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001093 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1094 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001095 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001096 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1097 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001098 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001099 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1100 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001101 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001102 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001103 case 0x10ec0260:
1104 snd_hda_codec_write(codec, 0x0f, 0,
1105 AC_VERB_SET_EAPD_BTLENABLE, 2);
1106 snd_hda_codec_write(codec, 0x10, 0,
1107 AC_VERB_SET_EAPD_BTLENABLE, 2);
1108 break;
1109 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001110 case 0x10ec0267:
1111 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001112 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001113 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001114 case 0x10ec0660:
1115 case 0x10ec0662:
1116 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001117 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001118 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001119 snd_hda_codec_write(codec, 0x14, 0,
1120 AC_VERB_SET_EAPD_BTLENABLE, 2);
1121 snd_hda_codec_write(codec, 0x15, 0,
1122 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001123 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001124 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001125 switch (codec->vendor_id) {
1126 case 0x10ec0260:
1127 snd_hda_codec_write(codec, 0x1a, 0,
1128 AC_VERB_SET_COEF_INDEX, 7);
1129 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1130 AC_VERB_GET_PROC_COEF, 0);
1131 snd_hda_codec_write(codec, 0x1a, 0,
1132 AC_VERB_SET_COEF_INDEX, 7);
1133 snd_hda_codec_write(codec, 0x1a, 0,
1134 AC_VERB_SET_PROC_COEF,
1135 tmp | 0x2010);
1136 break;
1137 case 0x10ec0262:
1138 case 0x10ec0880:
1139 case 0x10ec0882:
1140 case 0x10ec0883:
1141 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001142 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001143 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001144 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001145 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001146 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001147 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001148 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001149 case 0x10ec0267:
1150 case 0x10ec0268:
1151 snd_hda_codec_write(codec, 0x20, 0,
1152 AC_VERB_SET_COEF_INDEX, 7);
1153 tmp = snd_hda_codec_read(codec, 0x20, 0,
1154 AC_VERB_GET_PROC_COEF, 0);
1155 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001156 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001157 snd_hda_codec_write(codec, 0x20, 0,
1158 AC_VERB_SET_PROC_COEF,
1159 tmp | 0x3000);
1160 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001161 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001162 break;
1163 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001164}
Kailang Yangea1fb292008-08-26 12:58:38 +02001165
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001166static void alc_init_auto_hp(struct hda_codec *codec)
1167{
1168 struct alc_spec *spec = codec->spec;
1169
1170 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001171 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001172
Kailang Yangc9b58002007-10-16 14:30:01 +02001173 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001174 if (spec->autocfg.line_out_pins[0] &&
1175 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001176 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001177 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001178 else
1179 return;
1180 }
1181
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001182 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1183 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001184 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1185 AC_VERB_SET_UNSOLICITED_ENABLE,
1186 AC_USRSP_EN | ALC880_HP_EVENT);
1187 spec->unsol_event = alc_sku_unsol_event;
1188}
1189
Takashi Iwai6c819492009-08-10 18:47:44 +02001190static void alc_init_auto_mic(struct hda_codec *codec)
1191{
1192 struct alc_spec *spec = codec->spec;
1193 struct auto_pin_cfg *cfg = &spec->autocfg;
1194 hda_nid_t fixed, ext;
1195 int i;
1196
1197 /* there must be only two mic inputs exclusively */
1198 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1199 if (cfg->input_pins[i])
1200 return;
1201
1202 fixed = ext = 0;
1203 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1204 hda_nid_t nid = cfg->input_pins[i];
1205 unsigned int defcfg;
1206 if (!nid)
1207 return;
1208 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1209 switch (get_defcfg_connect(defcfg)) {
1210 case AC_JACK_PORT_FIXED:
1211 if (fixed)
1212 return; /* already occupied */
1213 fixed = nid;
1214 break;
1215 case AC_JACK_PORT_COMPLEX:
1216 if (ext)
1217 return; /* already occupied */
1218 ext = nid;
1219 break;
1220 default:
1221 return; /* invalid entry */
1222 }
1223 }
1224 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1225 return; /* no unsol support */
1226 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1227 ext, fixed);
1228 spec->ext_mic.pin = ext;
1229 spec->int_mic.pin = fixed;
1230 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1231 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1232 spec->auto_mic = 1;
1233 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1234 AC_VERB_SET_UNSOLICITED_ENABLE,
1235 AC_USRSP_EN | ALC880_MIC_EVENT);
1236 spec->unsol_event = alc_sku_unsol_event;
1237}
1238
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001239/* check subsystem ID and set up device-specific initialization;
1240 * return 1 if initialized, 0 if invalid SSID
1241 */
1242/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1243 * 31 ~ 16 : Manufacture ID
1244 * 15 ~ 8 : SKU ID
1245 * 7 ~ 0 : Assembly ID
1246 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1247 */
1248static int alc_subsystem_id(struct hda_codec *codec,
1249 hda_nid_t porta, hda_nid_t porte,
1250 hda_nid_t portd)
1251{
1252 unsigned int ass, tmp, i;
1253 unsigned nid;
1254 struct alc_spec *spec = codec->spec;
1255
1256 ass = codec->subsystem_id & 0xffff;
1257 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1258 goto do_sku;
1259
1260 /* invalid SSID, check the special NID pin defcfg instead */
1261 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001262 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001263 * 29~21 : reserve
1264 * 20 : PCBEEP input
1265 * 19~16 : Check sum (15:1)
1266 * 15~1 : Custom
1267 * 0 : override
1268 */
1269 nid = 0x1d;
1270 if (codec->vendor_id == 0x10ec0260)
1271 nid = 0x17;
1272 ass = snd_hda_codec_get_pincfg(codec, nid);
1273 snd_printd("realtek: No valid SSID, "
1274 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001275 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001276 if (!(ass & 1) && !(ass & 0x100000))
1277 return 0;
1278 if ((ass >> 30) != 1) /* no physical connection */
1279 return 0;
1280
1281 /* check sum */
1282 tmp = 0;
1283 for (i = 1; i < 16; i++) {
1284 if ((ass >> i) & 1)
1285 tmp++;
1286 }
1287 if (((ass >> 16) & 0xf) != tmp)
1288 return 0;
1289do_sku:
1290 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1291 ass & 0xffff, codec->vendor_id);
1292 /*
1293 * 0 : override
1294 * 1 : Swap Jack
1295 * 2 : 0 --> Desktop, 1 --> Laptop
1296 * 3~5 : External Amplifier control
1297 * 7~6 : Reserved
1298 */
1299 tmp = (ass & 0x38) >> 3; /* external Amp control */
1300 switch (tmp) {
1301 case 1:
1302 spec->init_amp = ALC_INIT_GPIO1;
1303 break;
1304 case 3:
1305 spec->init_amp = ALC_INIT_GPIO2;
1306 break;
1307 case 7:
1308 spec->init_amp = ALC_INIT_GPIO3;
1309 break;
1310 case 5:
1311 spec->init_amp = ALC_INIT_DEFAULT;
1312 break;
1313 }
1314
1315 /* is laptop or Desktop and enable the function "Mute internal speaker
1316 * when the external headphone out jack is plugged"
1317 */
1318 if (!(ass & 0x8000))
1319 return 1;
1320 /*
1321 * 10~8 : Jack location
1322 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1323 * 14~13: Resvered
1324 * 15 : 1 --> enable the function "Mute internal speaker
1325 * when the external headphone out jack is plugged"
1326 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001327 if (!spec->autocfg.hp_pins[0]) {
1328 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1329 if (tmp == 0)
1330 spec->autocfg.hp_pins[0] = porta;
1331 else if (tmp == 1)
1332 spec->autocfg.hp_pins[0] = porte;
1333 else if (tmp == 2)
1334 spec->autocfg.hp_pins[0] = portd;
1335 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001336 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001337 }
1338
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001339 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001340 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001341 return 1;
1342}
Kailang Yangea1fb292008-08-26 12:58:38 +02001343
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001344static void alc_ssid_check(struct hda_codec *codec,
1345 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1346{
1347 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1348 struct alc_spec *spec = codec->spec;
1349 snd_printd("realtek: "
1350 "Enable default setup for auto mode as fallback\n");
1351 spec->init_amp = ALC_INIT_DEFAULT;
1352 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001353 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001354 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001355}
1356
Takashi Iwai41e41f12005-06-08 14:48:49 +02001357/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001358 * Fix-up pin default configurations
1359 */
1360
1361struct alc_pincfg {
1362 hda_nid_t nid;
1363 u32 val;
1364};
1365
1366static void alc_fix_pincfg(struct hda_codec *codec,
1367 const struct snd_pci_quirk *quirk,
1368 const struct alc_pincfg **pinfix)
1369{
1370 const struct alc_pincfg *cfg;
1371
1372 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1373 if (!quirk)
1374 return;
1375
1376 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001377 for (; cfg->nid; cfg++)
1378 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001379}
1380
1381/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001382 * ALC888
1383 */
1384
1385/*
1386 * 2ch mode
1387 */
1388static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1389/* Mic-in jack as mic in */
1390 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1391 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1392/* Line-in jack as Line in */
1393 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1394 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1395/* Line-Out as Front */
1396 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1397 { } /* end */
1398};
1399
1400/*
1401 * 4ch mode
1402 */
1403static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1404/* Mic-in jack as mic in */
1405 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1406 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1407/* Line-in jack as Surround */
1408 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1409 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1410/* Line-Out as Front */
1411 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1412 { } /* end */
1413};
1414
1415/*
1416 * 6ch mode
1417 */
1418static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1419/* Mic-in jack as CLFE */
1420 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1421 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1422/* Line-in jack as Surround */
1423 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1424 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1425/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1426 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1427 { } /* end */
1428};
1429
1430/*
1431 * 8ch mode
1432 */
1433static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1434/* Mic-in jack as CLFE */
1435 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1436 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1437/* Line-in jack as Surround */
1438 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1439 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1440/* Line-Out as Side */
1441 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1442 { } /* end */
1443};
1444
1445static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1446 { 2, alc888_4ST_ch2_intel_init },
1447 { 4, alc888_4ST_ch4_intel_init },
1448 { 6, alc888_4ST_ch6_intel_init },
1449 { 8, alc888_4ST_ch8_intel_init },
1450};
1451
1452/*
1453 * ALC888 Fujitsu Siemens Amillo xa3530
1454 */
1455
1456static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1457/* Front Mic: set to PIN_IN (empty by default) */
1458 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1459/* Connect Internal HP to Front */
1460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1461 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1462 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1463/* Connect Bass HP to Front */
1464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1466 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1467/* Connect Line-Out side jack (SPDIF) to Side */
1468 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1469 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1470 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1471/* Connect Mic jack to CLFE */
1472 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1473 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1474 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1475/* Connect Line-in jack to Surround */
1476 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1477 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1478 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1479/* Connect HP out jack to Front */
1480 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1481 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1482 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1483/* Enable unsolicited event for HP jack and Line-out jack */
1484 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1485 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1486 {}
1487};
1488
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001489static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001490{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001491 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +02001492 unsigned int val, mute, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001493 hda_nid_t nid;
1494 int i;
1495
1496 spec->jack_present = 0;
1497 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1498 nid = spec->autocfg.hp_pins[i];
1499 if (!nid)
1500 break;
Takashi Iwai261c2402009-06-25 08:13:40 +02001501 pincap = snd_hda_query_pin_caps(codec, nid);
1502 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1503 snd_hda_codec_read(codec, nid, 0,
1504 AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001505 val = snd_hda_codec_read(codec, nid, 0,
1506 AC_VERB_GET_PIN_SENSE, 0);
1507 if (val & AC_PINSENSE_PRESENCE) {
1508 spec->jack_present = 1;
1509 break;
1510 }
1511 }
1512
1513 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001514 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001515 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1516 nid = spec->autocfg.speaker_pins[i];
1517 if (!nid)
1518 break;
1519 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1520 HDA_AMP_MUTE, mute);
1521 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001522}
1523
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001524static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1525 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001526{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001527 if (codec->vendor_id == 0x10ec0880)
1528 res >>= 28;
1529 else
1530 res >>= 26;
1531 if (res == ALC880_HP_EVENT)
1532 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001533}
1534
Wu Fengguang6732bd02009-07-30 09:19:14 +02001535static void alc889_automute_init(struct hda_codec *codec)
1536{
1537 struct alc_spec *spec = codec->spec;
1538
1539 spec->autocfg.hp_pins[0] = 0x15;
1540 spec->autocfg.speaker_pins[0] = 0x14;
1541 spec->autocfg.speaker_pins[1] = 0x16;
1542 spec->autocfg.speaker_pins[2] = 0x17;
1543 spec->autocfg.speaker_pins[3] = 0x19;
1544 spec->autocfg.speaker_pins[4] = 0x1a;
1545 alc_automute_amp(codec);
1546}
1547
1548static void alc889_intel_init_hook(struct hda_codec *codec)
1549{
1550 alc889_coef_init(codec);
1551 alc889_automute_init(codec);
1552}
1553
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001554static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1555{
1556 struct alc_spec *spec = codec->spec;
1557
1558 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1559 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1560 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1561 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1562 alc_automute_amp(codec);
1563}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001564
1565/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001566 * ALC888 Acer Aspire 4930G model
1567 */
1568
1569static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1570/* Front Mic: set to PIN_IN (empty by default) */
1571 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1572/* Unselect Front Mic by default in input mixer 3 */
1573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001574/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001575 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1576/* Connect Internal HP to front */
1577 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1578 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1579 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1580/* Connect HP out to front */
1581 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1582 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1583 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1584 { }
1585};
1586
Hector Martin3b315d72009-06-02 10:54:19 +02001587/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001588 * ALC888 Acer Aspire 6530G model
1589 */
1590
1591static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1592/* Bias voltage on for external mic port */
1593 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001594/* Front Mic: set to PIN_IN (empty by default) */
1595 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1596/* Unselect Front Mic by default in input mixer 3 */
1597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001598/* Enable unsolicited event for HP jack */
1599 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1600/* Enable speaker output */
1601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1602 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1603/* Enable headphone output */
1604 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1605 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1606 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1607 { }
1608};
1609
1610/*
Hector Martin018df412009-06-04 00:13:40 +02001611 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001612 */
1613
Hector Martin018df412009-06-04 00:13:40 +02001614static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001615/* Front Mic: set to PIN_IN (empty by default) */
1616 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1617/* Unselect Front Mic by default in input mixer 3 */
1618 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1619/* Enable unsolicited event for HP jack */
1620 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1621/* Connect Internal Front to Front */
1622 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1623 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1624 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1625/* Connect Internal Rear to Rear */
1626 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1627 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1628 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1629/* Connect Internal CLFE to CLFE */
1630 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1631 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1632 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1633/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001634 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001635 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1636 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1637/* Enable all DACs */
1638/* DAC DISABLE/MUTE 1? */
1639/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1640 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1641 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1642/* DAC DISABLE/MUTE 2? */
1643/* some bit here disables the other DACs. Init=0x4900 */
1644 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1645 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1646/* Enable amplifiers */
1647 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1648 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001649/* DMIC fix
1650 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1651 * which makes the stereo useless. However, either the mic or the ALC889
1652 * makes the signal become a difference/sum signal instead of standard
1653 * stereo, which is annoying. So instead we flip this bit which makes the
1654 * codec replicate the sum signal to both channels, turning it into a
1655 * normal mono mic.
1656 */
1657/* DMIC_CONTROL? Init value = 0x0001 */
1658 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1659 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001660 { }
1661};
1662
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001663static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001664 /* Front mic only available on one ADC */
1665 {
1666 .num_items = 4,
1667 .items = {
1668 { "Mic", 0x0 },
1669 { "Line", 0x2 },
1670 { "CD", 0x4 },
1671 { "Front Mic", 0xb },
1672 },
1673 },
1674 {
1675 .num_items = 3,
1676 .items = {
1677 { "Mic", 0x0 },
1678 { "Line", 0x2 },
1679 { "CD", 0x4 },
1680 },
1681 }
1682};
1683
Tony Vroond2fd4b02009-06-21 00:40:10 +01001684static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1685 /* Interal mic only available on one ADC */
1686 {
Tony Vroon684a8842009-06-26 09:27:50 +01001687 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001688 .items = {
1689 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001690 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001691 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001692 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001693 { "Int Mic", 0xb },
1694 },
1695 },
1696 {
Tony Vroon684a8842009-06-26 09:27:50 +01001697 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001698 .items = {
1699 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001700 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001701 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001702 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001703 },
1704 }
1705};
1706
Hector Martin018df412009-06-04 00:13:40 +02001707static struct hda_input_mux alc889_capture_sources[3] = {
1708 /* Digital mic only available on first "ADC" */
1709 {
1710 .num_items = 5,
1711 .items = {
1712 { "Mic", 0x0 },
1713 { "Line", 0x2 },
1714 { "CD", 0x4 },
1715 { "Front Mic", 0xb },
1716 { "Input Mix", 0xa },
1717 },
1718 },
1719 {
1720 .num_items = 4,
1721 .items = {
1722 { "Mic", 0x0 },
1723 { "Line", 0x2 },
1724 { "CD", 0x4 },
1725 { "Input Mix", 0xa },
1726 },
1727 },
1728 {
1729 .num_items = 4,
1730 .items = {
1731 { "Mic", 0x0 },
1732 { "Line", 0x2 },
1733 { "CD", 0x4 },
1734 { "Input Mix", 0xa },
1735 },
1736 }
1737};
1738
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001739static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001740 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1741 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1742 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1743 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1744 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1745 HDA_OUTPUT),
1746 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1747 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1748 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1749 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1750 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1751 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1752 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1753 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1754 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1756 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1757 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001758 { } /* end */
1759};
1760
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001761static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001762{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001763 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001764
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001765 spec->autocfg.hp_pins[0] = 0x15;
1766 spec->autocfg.speaker_pins[0] = 0x14;
1767 alc_automute_amp(codec);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001768}
1769
Emilio López320d5922009-06-25 08:18:44 +02001770static void alc888_acer_aspire_6530g_init_hook(struct hda_codec *codec)
1771{
1772 struct alc_spec *spec = codec->spec;
1773
1774 spec->autocfg.hp_pins[0] = 0x15;
1775 spec->autocfg.speaker_pins[0] = 0x14;
1776 spec->autocfg.speaker_pins[1] = 0x16;
1777 spec->autocfg.speaker_pins[2] = 0x17;
1778 alc_automute_amp(codec);
1779}
1780
Hector Martin018df412009-06-04 00:13:40 +02001781static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001782{
1783 struct alc_spec *spec = codec->spec;
1784
1785 spec->autocfg.hp_pins[0] = 0x15;
1786 spec->autocfg.speaker_pins[0] = 0x14;
1787 spec->autocfg.speaker_pins[1] = 0x16;
1788 spec->autocfg.speaker_pins[2] = 0x1b;
1789 alc_automute_amp(codec);
1790}
1791
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001792/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001793 * ALC880 3-stack model
1794 *
1795 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001796 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1797 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001798 */
1799
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001800static hda_nid_t alc880_dac_nids[4] = {
1801 /* front, rear, clfe, rear_surr */
1802 0x02, 0x05, 0x04, 0x03
1803};
1804
1805static hda_nid_t alc880_adc_nids[3] = {
1806 /* ADC0-2 */
1807 0x07, 0x08, 0x09,
1808};
1809
1810/* The datasheet says the node 0x07 is connected from inputs,
1811 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001812 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001813 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001814static hda_nid_t alc880_adc_nids_alt[2] = {
1815 /* ADC1-2 */
1816 0x08, 0x09,
1817};
1818
1819#define ALC880_DIGOUT_NID 0x06
1820#define ALC880_DIGIN_NID 0x0a
1821
1822static struct hda_input_mux alc880_capture_source = {
1823 .num_items = 4,
1824 .items = {
1825 { "Mic", 0x0 },
1826 { "Front Mic", 0x3 },
1827 { "Line", 0x2 },
1828 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001829 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001830};
1831
1832/* channel source setting (2/6 channel selection for 3-stack) */
1833/* 2ch mode */
1834static struct hda_verb alc880_threestack_ch2_init[] = {
1835 /* set line-in to input, mute it */
1836 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1837 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1838 /* set mic-in to input vref 80%, mute it */
1839 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1840 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001841 { } /* end */
1842};
1843
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001844/* 6ch mode */
1845static struct hda_verb alc880_threestack_ch6_init[] = {
1846 /* set line-in to output, unmute it */
1847 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1848 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1849 /* set mic-in to output, unmute it */
1850 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1851 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1852 { } /* end */
1853};
1854
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001855static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001856 { 2, alc880_threestack_ch2_init },
1857 { 6, alc880_threestack_ch6_init },
1858};
1859
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001860static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001861 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001862 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001863 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001864 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001865 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1866 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001867 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1868 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1870 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1871 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1872 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1873 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1874 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1875 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1876 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001877 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001878 {
1879 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1880 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001881 .info = alc_ch_mode_info,
1882 .get = alc_ch_mode_get,
1883 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001884 },
1885 { } /* end */
1886};
1887
1888/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001889static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1890 struct snd_ctl_elem_info *uinfo)
1891{
1892 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1893 struct alc_spec *spec = codec->spec;
1894 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001895
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001896 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001897 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1898 HDA_INPUT);
1899 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001900 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001901 return err;
1902}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001903
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001904static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1905 unsigned int size, unsigned int __user *tlv)
1906{
1907 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1908 struct alc_spec *spec = codec->spec;
1909 int err;
1910
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001911 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001912 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1913 HDA_INPUT);
1914 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001915 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001916 return err;
1917}
1918
1919typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1920 struct snd_ctl_elem_value *ucontrol);
1921
1922static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1923 struct snd_ctl_elem_value *ucontrol,
1924 getput_call_t func)
1925{
1926 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1927 struct alc_spec *spec = codec->spec;
1928 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1929 int err;
1930
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001931 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001932 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1933 3, 0, HDA_INPUT);
1934 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001935 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001936 return err;
1937}
1938
1939static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1940 struct snd_ctl_elem_value *ucontrol)
1941{
1942 return alc_cap_getput_caller(kcontrol, ucontrol,
1943 snd_hda_mixer_amp_volume_get);
1944}
1945
1946static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1947 struct snd_ctl_elem_value *ucontrol)
1948{
1949 return alc_cap_getput_caller(kcontrol, ucontrol,
1950 snd_hda_mixer_amp_volume_put);
1951}
1952
1953/* capture mixer elements */
1954#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1955
1956static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1957 struct snd_ctl_elem_value *ucontrol)
1958{
1959 return alc_cap_getput_caller(kcontrol, ucontrol,
1960 snd_hda_mixer_amp_switch_get);
1961}
1962
1963static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1964 struct snd_ctl_elem_value *ucontrol)
1965{
1966 return alc_cap_getput_caller(kcontrol, ucontrol,
1967 snd_hda_mixer_amp_switch_put);
1968}
1969
Takashi Iwaia23b6882009-03-23 15:21:36 +01001970#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001971 { \
1972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1973 .name = "Capture Switch", \
1974 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1975 .count = num, \
1976 .info = alc_cap_sw_info, \
1977 .get = alc_cap_sw_get, \
1978 .put = alc_cap_sw_put, \
1979 }, \
1980 { \
1981 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1982 .name = "Capture Volume", \
1983 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1984 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1985 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1986 .count = num, \
1987 .info = alc_cap_vol_info, \
1988 .get = alc_cap_vol_get, \
1989 .put = alc_cap_vol_put, \
1990 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001991 }
1992
1993#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001994 { \
1995 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1996 /* .name = "Capture Source", */ \
1997 .name = "Input Source", \
1998 .count = num, \
1999 .info = alc_mux_enum_info, \
2000 .get = alc_mux_enum_get, \
2001 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002002 }
2003
2004#define DEFINE_CAPMIX(num) \
2005static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2006 _DEFINE_CAPMIX(num), \
2007 _DEFINE_CAPSRC(num), \
2008 { } /* end */ \
2009}
2010
2011#define DEFINE_CAPMIX_NOSRC(num) \
2012static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2013 _DEFINE_CAPMIX(num), \
2014 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002015}
2016
2017/* up to three ADCs */
2018DEFINE_CAPMIX(1);
2019DEFINE_CAPMIX(2);
2020DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002021DEFINE_CAPMIX_NOSRC(1);
2022DEFINE_CAPMIX_NOSRC(2);
2023DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002024
2025/*
2026 * ALC880 5-stack model
2027 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002028 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2029 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002030 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2031 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2032 */
2033
2034/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002035static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002036 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002037 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002038 { } /* end */
2039};
2040
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002041/* channel source setting (6/8 channel selection for 5-stack) */
2042/* 6ch mode */
2043static struct hda_verb alc880_fivestack_ch6_init[] = {
2044 /* set line-in to input, mute it */
2045 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2046 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002047 { } /* end */
2048};
2049
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002050/* 8ch mode */
2051static struct hda_verb alc880_fivestack_ch8_init[] = {
2052 /* set line-in to output, unmute it */
2053 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2054 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2055 { } /* end */
2056};
2057
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002058static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002059 { 6, alc880_fivestack_ch6_init },
2060 { 8, alc880_fivestack_ch8_init },
2061};
2062
2063
2064/*
2065 * ALC880 6-stack model
2066 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002067 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2068 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002069 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2070 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2071 */
2072
2073static hda_nid_t alc880_6st_dac_nids[4] = {
2074 /* front, rear, clfe, rear_surr */
2075 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002076};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002077
2078static struct hda_input_mux alc880_6stack_capture_source = {
2079 .num_items = 4,
2080 .items = {
2081 { "Mic", 0x0 },
2082 { "Front Mic", 0x1 },
2083 { "Line", 0x2 },
2084 { "CD", 0x4 },
2085 },
2086};
2087
2088/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002089static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002090 { 8, NULL },
2091};
2092
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002093static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002094 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002095 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002096 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002097 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002098 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2099 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002100 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2101 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002102 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002103 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002104 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2105 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2106 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2107 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2109 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2110 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2111 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002112 {
2113 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2114 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002115 .info = alc_ch_mode_info,
2116 .get = alc_ch_mode_get,
2117 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002118 },
2119 { } /* end */
2120};
2121
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002122
2123/*
2124 * ALC880 W810 model
2125 *
2126 * W810 has rear IO for:
2127 * Front (DAC 02)
2128 * Surround (DAC 03)
2129 * Center/LFE (DAC 04)
2130 * Digital out (06)
2131 *
2132 * The system also has a pair of internal speakers, and a headphone jack.
2133 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002134 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002135 * There is a variable resistor to control the speaker or headphone
2136 * volume. This is a hardware-only device without a software API.
2137 *
2138 * Plugging headphones in will disable the internal speakers. This is
2139 * implemented in hardware, not via the driver using jack sense. In
2140 * a similar fashion, plugging into the rear socket marked "front" will
2141 * disable both the speakers and headphones.
2142 *
2143 * For input, there's a microphone jack, and an "audio in" jack.
2144 * These may not do anything useful with this driver yet, because I
2145 * haven't setup any initialization verbs for these yet...
2146 */
2147
2148static hda_nid_t alc880_w810_dac_nids[3] = {
2149 /* front, rear/surround, clfe */
2150 0x02, 0x03, 0x04
2151};
2152
2153/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002154static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002155 { 6, NULL }
2156};
2157
2158/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002159static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002160 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002161 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002162 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002163 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002164 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2165 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002166 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2167 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002168 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2169 { } /* end */
2170};
2171
2172
2173/*
2174 * Z710V model
2175 *
2176 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002177 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2178 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002179 */
2180
2181static hda_nid_t alc880_z71v_dac_nids[1] = {
2182 0x02
2183};
2184#define ALC880_Z71V_HP_DAC 0x03
2185
2186/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002187static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002188 { 2, NULL }
2189};
2190
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002191static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002192 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002193 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002194 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002195 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2200 { } /* end */
2201};
2202
2203
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002204/*
2205 * ALC880 F1734 model
2206 *
2207 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2208 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2209 */
2210
2211static hda_nid_t alc880_f1734_dac_nids[1] = {
2212 0x03
2213};
2214#define ALC880_F1734_HP_DAC 0x02
2215
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002216static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002217 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002218 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002219 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2220 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002221 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2222 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002223 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2224 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002225 { } /* end */
2226};
2227
Takashi Iwai937b4162008-02-11 14:52:36 +01002228static struct hda_input_mux alc880_f1734_capture_source = {
2229 .num_items = 2,
2230 .items = {
2231 { "Mic", 0x1 },
2232 { "CD", 0x4 },
2233 },
2234};
2235
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002236
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002237/*
2238 * ALC880 ASUS model
2239 *
2240 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2241 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2242 * Mic = 0x18, Line = 0x1a
2243 */
2244
2245#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2246#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2247
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002248static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002249 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002250 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002251 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002252 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002253 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2254 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002255 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2256 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002257 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2258 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2259 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2260 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2261 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2262 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002263 {
2264 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2265 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002266 .info = alc_ch_mode_info,
2267 .get = alc_ch_mode_get,
2268 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002269 },
2270 { } /* end */
2271};
2272
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002273/*
2274 * ALC880 ASUS W1V model
2275 *
2276 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2277 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2278 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2279 */
2280
2281/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002282static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002283 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2284 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002285 { } /* end */
2286};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002287
Kailang Yangdf694da2005-12-05 19:42:22 +01002288/* TCL S700 */
2289static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2290 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2291 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2292 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2293 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2294 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2296 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2297 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2298 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002299 { } /* end */
2300};
2301
Kailang Yangccc656c2006-10-17 12:32:26 +02002302/* Uniwill */
2303static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002304 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2305 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2306 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2307 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002308 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2309 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2310 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2311 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2312 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2313 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2314 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2315 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2317 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2318 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2319 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002320 {
2321 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2322 .name = "Channel Mode",
2323 .info = alc_ch_mode_info,
2324 .get = alc_ch_mode_get,
2325 .put = alc_ch_mode_put,
2326 },
2327 { } /* end */
2328};
2329
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002330static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2331 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2332 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2333 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2334 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2335 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2336 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2337 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2338 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2339 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2340 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2341 { } /* end */
2342};
2343
Kailang Yangccc656c2006-10-17 12:32:26 +02002344static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002345 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2346 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2347 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2348 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002349 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2350 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2351 { } /* end */
2352};
2353
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002355 * virtual master controls
2356 */
2357
2358/*
2359 * slave controls for virtual master
2360 */
2361static const char *alc_slave_vols[] = {
2362 "Front Playback Volume",
2363 "Surround Playback Volume",
2364 "Center Playback Volume",
2365 "LFE Playback Volume",
2366 "Side Playback Volume",
2367 "Headphone Playback Volume",
2368 "Speaker Playback Volume",
2369 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002370 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002371 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002372 NULL,
2373};
2374
2375static const char *alc_slave_sws[] = {
2376 "Front Playback Switch",
2377 "Surround Playback Switch",
2378 "Center Playback Switch",
2379 "LFE Playback Switch",
2380 "Side Playback Switch",
2381 "Headphone Playback Switch",
2382 "Speaker Playback Switch",
2383 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002384 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002385 NULL,
2386};
2387
2388/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002389 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002391
2392static void alc_free_kctls(struct hda_codec *codec);
2393
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002394/* additional beep mixers; the actual parameters are overwritten at build */
2395static struct snd_kcontrol_new alc_beep_mixer[] = {
2396 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2397 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2398 { } /* end */
2399};
2400
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401static int alc_build_controls(struct hda_codec *codec)
2402{
2403 struct alc_spec *spec = codec->spec;
2404 int err;
2405 int i;
2406
2407 for (i = 0; i < spec->num_mixers; i++) {
2408 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2409 if (err < 0)
2410 return err;
2411 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002412 if (spec->cap_mixer) {
2413 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2414 if (err < 0)
2415 return err;
2416 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002417 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002418 err = snd_hda_create_spdif_out_ctls(codec,
2419 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002420 if (err < 0)
2421 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002422 if (!spec->no_analog) {
2423 err = snd_hda_create_spdif_share_sw(codec,
2424 &spec->multiout);
2425 if (err < 0)
2426 return err;
2427 spec->multiout.share_spdif = 1;
2428 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002429 }
2430 if (spec->dig_in_nid) {
2431 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2432 if (err < 0)
2433 return err;
2434 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002435
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002436 /* create beep controls if needed */
2437 if (spec->beep_amp) {
2438 struct snd_kcontrol_new *knew;
2439 for (knew = alc_beep_mixer; knew->name; knew++) {
2440 struct snd_kcontrol *kctl;
2441 kctl = snd_ctl_new1(knew, codec);
2442 if (!kctl)
2443 return -ENOMEM;
2444 kctl->private_value = spec->beep_amp;
2445 err = snd_hda_ctl_add(codec, kctl);
2446 if (err < 0)
2447 return err;
2448 }
2449 }
2450
Takashi Iwai2134ea42008-01-10 16:53:55 +01002451 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002452 if (!spec->no_analog &&
2453 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002454 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002455 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002456 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002457 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002458 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002459 if (err < 0)
2460 return err;
2461 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002462 if (!spec->no_analog &&
2463 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002464 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2465 NULL, alc_slave_sws);
2466 if (err < 0)
2467 return err;
2468 }
2469
Takashi Iwai603c4012008-07-30 15:01:44 +02002470 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471 return 0;
2472}
2473
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002474
Linus Torvalds1da177e2005-04-16 15:20:36 -07002475/*
2476 * initialize the codec volumes, etc
2477 */
2478
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002479/*
2480 * generic initialization of ADC, input mixers and output mixers
2481 */
2482static struct hda_verb alc880_volume_init_verbs[] = {
2483 /*
2484 * Unmute ADC0-2 and set the default input to mic-in
2485 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002486 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002488 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002489 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002490 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002491 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002493 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2494 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002495 * Note: PASD motherboards uses the Line In 2 as the input for front
2496 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002498 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002499 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2502 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2503 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002506
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002507 /*
2508 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002509 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002510 /* set vol=0 to output mixers */
2511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2512 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2513 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2514 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2515 /* set up input amps for analog loopback */
2516 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2520 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002521 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002523 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2524 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002525
2526 { }
2527};
2528
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002529/*
2530 * 3-stack pin configuration:
2531 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2532 */
2533static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2534 /*
2535 * preset connection lists of input pins
2536 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2537 */
2538 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2539 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2540 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2541
2542 /*
2543 * Set pin mode and muting
2544 */
2545 /* set front pin widgets 0x14 for output */
2546 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2547 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2548 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2549 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2550 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2551 /* Mic2 (as headphone out) for HP output */
2552 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2553 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2554 /* Line In pin widget for input */
2555 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2556 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2557 /* Line2 (as front mic) pin widget for input and vref at 80% */
2558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2559 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2560 /* CD pin widget for input */
2561 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2562
2563 { }
2564};
2565
2566/*
2567 * 5-stack pin configuration:
2568 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2569 * line-in/side = 0x1a, f-mic = 0x1b
2570 */
2571static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2572 /*
2573 * preset connection lists of input pins
2574 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2575 */
2576 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2577 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2578
2579 /*
2580 * Set pin mode and muting
2581 */
2582 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002583 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2585 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2586 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002587 /* unmute pins for output (no gain on this amp) */
2588 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2589 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2590 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2591 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2592
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002594 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002595 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2596 /* Mic2 (as headphone out) for HP output */
2597 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002598 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002599 /* Line In pin widget for input */
2600 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2601 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2602 /* Line2 (as front mic) pin widget for input and vref at 80% */
2603 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2604 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2605 /* CD pin widget for input */
2606 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002607
2608 { }
2609};
2610
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002611/*
2612 * W810 pin configuration:
2613 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2614 */
2615static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002616 /* hphone/speaker input selector: front DAC */
2617 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2618
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002619 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2620 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2621 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2623 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2624 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2625
2626 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002627 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002628
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629 { }
2630};
2631
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002632/*
2633 * Z71V pin configuration:
2634 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2635 */
2636static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002637 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002638 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002639 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002641
Takashi Iwai16ded522005-06-10 19:58:24 +02002642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002643 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002644 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002645 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002646
2647 { }
2648};
2649
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002650/*
2651 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002652 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2653 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002654 */
2655static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2656 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2657
Takashi Iwai16ded522005-06-10 19:58:24 +02002658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002660 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002661 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002664 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002665 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2666
Takashi Iwai16ded522005-06-10 19:58:24 +02002667 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002668 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002669 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002672 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002673 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002674 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002675 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002676
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002677 { }
2678};
Takashi Iwai16ded522005-06-10 19:58:24 +02002679
Kailang Yangccc656c2006-10-17 12:32:26 +02002680/*
2681 * Uniwill pin configuration:
2682 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2683 * line = 0x1a
2684 */
2685static struct hda_verb alc880_uniwill_init_verbs[] = {
2686 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2687
2688 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2690 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2692 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2693 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2694 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2695 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2696 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2698 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2699 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2700 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2701 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2702
2703 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2704 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2705 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2706 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2707 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2708 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2709 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2710 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2711 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2712
2713 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2714 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2715
2716 { }
2717};
2718
2719/*
2720* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002721* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002722 */
2723static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2724 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2725
2726 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2727 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2728 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2729 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2730 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2731 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2732 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2733 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2734 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2735 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2736 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2737 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2738
2739 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2740 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2743 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2744 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2745
2746 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2747 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2748
2749 { }
2750};
2751
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002752static struct hda_verb alc880_beep_init_verbs[] = {
2753 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2754 { }
2755};
2756
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002757/* auto-toggle front mic */
2758static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2759{
2760 unsigned int present;
2761 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002762
2763 present = snd_hda_codec_read(codec, 0x18, 0,
2764 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002765 bits = present ? HDA_AMP_MUTE : 0;
2766 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002767}
2768
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002769static void alc880_uniwill_init_hook(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002770{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002771 struct alc_spec *spec = codec->spec;
2772
2773 spec->autocfg.hp_pins[0] = 0x14;
2774 spec->autocfg.speaker_pins[0] = 0x15;
2775 spec->autocfg.speaker_pins[0] = 0x16;
2776 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002777 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002778}
2779
2780static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2781 unsigned int res)
2782{
2783 /* Looks like the unsol event is incompatible with the standard
2784 * definition. 4bit tag is placed at 28 bit!
2785 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002786 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002787 case ALC880_MIC_EVENT:
2788 alc880_uniwill_mic_automute(codec);
2789 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002790 default:
2791 alc_automute_amp_unsol_event(codec, res);
2792 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002793 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002794}
2795
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002796static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002797{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002798 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002799
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002800 spec->autocfg.hp_pins[0] = 0x14;
2801 spec->autocfg.speaker_pins[0] = 0x15;
2802 alc_automute_amp(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002803}
2804
2805static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2806{
2807 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002808
Kailang Yangccc656c2006-10-17 12:32:26 +02002809 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002810 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2811 present &= HDA_AMP_VOLMASK;
2812 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2813 HDA_AMP_VOLMASK, present);
2814 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2815 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002816}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002817
Kailang Yangccc656c2006-10-17 12:32:26 +02002818static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2819 unsigned int res)
2820{
2821 /* Looks like the unsol event is incompatible with the standard
2822 * definition. 4bit tag is placed at 28 bit!
2823 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002824 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002825 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002826 else
2827 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002828}
2829
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002830/*
2831 * F1734 pin configuration:
2832 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2833 */
2834static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002835 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002836 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2837 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2838 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2839 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2840
2841 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2842 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2843 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2844 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2845
2846 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2847 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002848 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002849 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2850 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2851 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2852 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2853 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2854 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002855
Takashi Iwai937b4162008-02-11 14:52:36 +01002856 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2857 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2858
Takashi Iwai16ded522005-06-10 19:58:24 +02002859 { }
2860};
2861
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002862/*
2863 * ASUS pin configuration:
2864 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2865 */
2866static struct hda_verb alc880_pin_asus_init_verbs[] = {
2867 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2868 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2869 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2870 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2871
2872 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2873 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2874 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2875 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2876 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2877 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2878 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2879 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2880
2881 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2883 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2884 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2885 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2886 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2887 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2888 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2889 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002890
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002891 { }
2892};
2893
2894/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002895#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2896#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002897#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002898
Kailang Yangdf694da2005-12-05 19:42:22 +01002899/* Clevo m520g init */
2900static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2901 /* headphone output */
2902 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2903 /* line-out */
2904 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2905 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2906 /* Line-in */
2907 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2908 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2909 /* CD */
2910 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2911 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2912 /* Mic1 (rear panel) */
2913 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2914 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2915 /* Mic2 (front panel) */
2916 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2917 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2918 /* headphone */
2919 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2920 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2921 /* change to EAPD mode */
2922 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2923 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2924
2925 { }
2926};
2927
2928static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002929 /* change to EAPD mode */
2930 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2931 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2932
Kailang Yangdf694da2005-12-05 19:42:22 +01002933 /* Headphone output */
2934 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2935 /* Front output*/
2936 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2937 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2938
2939 /* Line In pin widget for input */
2940 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2941 /* CD pin widget for input */
2942 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2943 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2944 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2945
2946 /* change to EAPD mode */
2947 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2948 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2949
2950 { }
2951};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002952
2953/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002954 * LG m1 express dual
2955 *
2956 * Pin assignment:
2957 * Rear Line-In/Out (blue): 0x14
2958 * Build-in Mic-In: 0x15
2959 * Speaker-out: 0x17
2960 * HP-Out (green): 0x1b
2961 * Mic-In/Out (red): 0x19
2962 * SPDIF-Out: 0x1e
2963 */
2964
2965/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2966static hda_nid_t alc880_lg_dac_nids[3] = {
2967 0x05, 0x02, 0x03
2968};
2969
2970/* seems analog CD is not working */
2971static struct hda_input_mux alc880_lg_capture_source = {
2972 .num_items = 3,
2973 .items = {
2974 { "Mic", 0x1 },
2975 { "Line", 0x5 },
2976 { "Internal Mic", 0x6 },
2977 },
2978};
2979
2980/* 2,4,6 channel modes */
2981static struct hda_verb alc880_lg_ch2_init[] = {
2982 /* set line-in and mic-in to input */
2983 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2984 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2985 { }
2986};
2987
2988static struct hda_verb alc880_lg_ch4_init[] = {
2989 /* set line-in to out and mic-in to input */
2990 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2991 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2992 { }
2993};
2994
2995static struct hda_verb alc880_lg_ch6_init[] = {
2996 /* set line-in and mic-in to output */
2997 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2998 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2999 { }
3000};
3001
3002static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3003 { 2, alc880_lg_ch2_init },
3004 { 4, alc880_lg_ch4_init },
3005 { 6, alc880_lg_ch6_init },
3006};
3007
3008static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003009 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3010 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003011 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3012 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3013 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3014 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3015 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3016 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3017 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3018 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3019 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3020 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3021 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3022 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3023 {
3024 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3025 .name = "Channel Mode",
3026 .info = alc_ch_mode_info,
3027 .get = alc_ch_mode_get,
3028 .put = alc_ch_mode_put,
3029 },
3030 { } /* end */
3031};
3032
3033static struct hda_verb alc880_lg_init_verbs[] = {
3034 /* set capture source to mic-in */
3035 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3036 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3037 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3038 /* mute all amp mixer inputs */
3039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003042 /* line-in to input */
3043 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3044 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3045 /* built-in mic */
3046 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3047 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3048 /* speaker-out */
3049 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3050 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3051 /* mic-in to input */
3052 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3053 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3054 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3055 /* HP-out */
3056 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3057 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3058 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3059 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003060 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003061 { }
3062};
3063
3064/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003065static void alc880_lg_init_hook(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003066{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003067 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003068
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003069 spec->autocfg.hp_pins[0] = 0x1b;
3070 spec->autocfg.speaker_pins[0] = 0x17;
3071 alc_automute_amp(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003072}
3073
3074/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003075 * LG LW20
3076 *
3077 * Pin assignment:
3078 * Speaker-out: 0x14
3079 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003080 * Built-in Mic-In: 0x19
3081 * Line-In: 0x1b
3082 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003083 * SPDIF-Out: 0x1e
3084 */
3085
Takashi Iwaid6815182006-03-23 16:06:23 +01003086static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003087 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003088 .items = {
3089 { "Mic", 0x0 },
3090 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003091 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003092 },
3093};
3094
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003095#define alc880_lg_lw_modes alc880_threestack_modes
3096
Takashi Iwaid6815182006-03-23 16:06:23 +01003097static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003098 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3099 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3100 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3101 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3102 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3103 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3104 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3105 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3106 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3107 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3109 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3110 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3111 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003112 {
3113 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3114 .name = "Channel Mode",
3115 .info = alc_ch_mode_info,
3116 .get = alc_ch_mode_get,
3117 .put = alc_ch_mode_put,
3118 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003119 { } /* end */
3120};
3121
3122static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003123 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3124 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3125 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3126
Takashi Iwaid6815182006-03-23 16:06:23 +01003127 /* set capture source to mic-in */
3128 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3129 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3130 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003132 /* speaker-out */
3133 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3134 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3135 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003136 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3137 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3138 /* mic-in to input */
3139 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3140 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3141 /* built-in mic */
3142 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3143 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3144 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003145 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003146 { }
3147};
3148
3149/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003150static void alc880_lg_lw_init_hook(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003151{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003152 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003153
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003154 spec->autocfg.hp_pins[0] = 0x1b;
3155 spec->autocfg.speaker_pins[0] = 0x14;
3156 alc_automute_amp(codec);
Takashi Iwaid6815182006-03-23 16:06:23 +01003157}
3158
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003159static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3160 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3161 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3164 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3165 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3166 { } /* end */
3167};
3168
3169static struct hda_input_mux alc880_medion_rim_capture_source = {
3170 .num_items = 2,
3171 .items = {
3172 { "Mic", 0x0 },
3173 { "Internal Mic", 0x1 },
3174 },
3175};
3176
3177static struct hda_verb alc880_medion_rim_init_verbs[] = {
3178 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3179
3180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3181 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3182
3183 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3184 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3185 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3186 /* Mic2 (as headphone out) for HP output */
3187 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3188 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3189 /* Internal Speaker */
3190 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3191 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3192
3193 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3194 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3195
3196 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3197 { }
3198};
3199
3200/* toggle speaker-output according to the hp-jack state */
3201static void alc880_medion_rim_automute(struct hda_codec *codec)
3202{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003203 struct alc_spec *spec = codec->spec;
3204 alc_automute_amp(codec);
3205 /* toggle EAPD */
3206 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003207 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3208 else
3209 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3210}
3211
3212static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3213 unsigned int res)
3214{
3215 /* Looks like the unsol event is incompatible with the standard
3216 * definition. 4bit tag is placed at 28 bit!
3217 */
3218 if ((res >> 28) == ALC880_HP_EVENT)
3219 alc880_medion_rim_automute(codec);
3220}
3221
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003222static void alc880_medion_rim_init_hook(struct hda_codec *codec)
3223{
3224 struct alc_spec *spec = codec->spec;
3225
3226 spec->autocfg.hp_pins[0] = 0x14;
3227 spec->autocfg.speaker_pins[0] = 0x1b;
3228 alc880_medion_rim_automute(codec);
3229}
3230
Takashi Iwaicb53c622007-08-10 17:21:45 +02003231#ifdef CONFIG_SND_HDA_POWER_SAVE
3232static struct hda_amp_list alc880_loopbacks[] = {
3233 { 0x0b, HDA_INPUT, 0 },
3234 { 0x0b, HDA_INPUT, 1 },
3235 { 0x0b, HDA_INPUT, 2 },
3236 { 0x0b, HDA_INPUT, 3 },
3237 { 0x0b, HDA_INPUT, 4 },
3238 { } /* end */
3239};
3240
3241static struct hda_amp_list alc880_lg_loopbacks[] = {
3242 { 0x0b, HDA_INPUT, 1 },
3243 { 0x0b, HDA_INPUT, 6 },
3244 { 0x0b, HDA_INPUT, 7 },
3245 { } /* end */
3246};
3247#endif
3248
Takashi Iwaid6815182006-03-23 16:06:23 +01003249/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003250 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003251 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003252
Linus Torvalds1da177e2005-04-16 15:20:36 -07003253static int alc_init(struct hda_codec *codec)
3254{
3255 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003256 unsigned int i;
3257
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003258 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003259 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003260
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261 for (i = 0; i < spec->num_init_verbs; i++)
3262 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003263
3264 if (spec->init_hook)
3265 spec->init_hook(codec);
3266
Linus Torvalds1da177e2005-04-16 15:20:36 -07003267 return 0;
3268}
3269
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003270static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3271{
3272 struct alc_spec *spec = codec->spec;
3273
3274 if (spec->unsol_event)
3275 spec->unsol_event(codec, res);
3276}
3277
Takashi Iwaicb53c622007-08-10 17:21:45 +02003278#ifdef CONFIG_SND_HDA_POWER_SAVE
3279static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3280{
3281 struct alc_spec *spec = codec->spec;
3282 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3283}
3284#endif
3285
Linus Torvalds1da177e2005-04-16 15:20:36 -07003286/*
3287 * Analog playback callbacks
3288 */
3289static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3290 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003291 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003292{
3293 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003294 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3295 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003296}
3297
3298static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3299 struct hda_codec *codec,
3300 unsigned int stream_tag,
3301 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003302 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003303{
3304 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003305 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3306 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003307}
3308
3309static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3310 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003311 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003312{
3313 struct alc_spec *spec = codec->spec;
3314 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3315}
3316
3317/*
3318 * Digital out
3319 */
3320static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3321 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003322 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003323{
3324 struct alc_spec *spec = codec->spec;
3325 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3326}
3327
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003328static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3329 struct hda_codec *codec,
3330 unsigned int stream_tag,
3331 unsigned int format,
3332 struct snd_pcm_substream *substream)
3333{
3334 struct alc_spec *spec = codec->spec;
3335 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3336 stream_tag, format, substream);
3337}
3338
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003339static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3340 struct hda_codec *codec,
3341 struct snd_pcm_substream *substream)
3342{
3343 struct alc_spec *spec = codec->spec;
3344 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3345}
3346
Linus Torvalds1da177e2005-04-16 15:20:36 -07003347static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3348 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003349 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003350{
3351 struct alc_spec *spec = codec->spec;
3352 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3353}
3354
3355/*
3356 * Analog capture
3357 */
Takashi Iwai63300792008-01-24 15:31:36 +01003358static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003359 struct hda_codec *codec,
3360 unsigned int stream_tag,
3361 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003362 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003363{
3364 struct alc_spec *spec = codec->spec;
3365
Takashi Iwai63300792008-01-24 15:31:36 +01003366 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003367 stream_tag, 0, format);
3368 return 0;
3369}
3370
Takashi Iwai63300792008-01-24 15:31:36 +01003371static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003372 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003373 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003374{
3375 struct alc_spec *spec = codec->spec;
3376
Takashi Iwai888afa12008-03-18 09:57:50 +01003377 snd_hda_codec_cleanup_stream(codec,
3378 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003379 return 0;
3380}
3381
3382
3383/*
3384 */
3385static struct hda_pcm_stream alc880_pcm_analog_playback = {
3386 .substreams = 1,
3387 .channels_min = 2,
3388 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003389 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003390 .ops = {
3391 .open = alc880_playback_pcm_open,
3392 .prepare = alc880_playback_pcm_prepare,
3393 .cleanup = alc880_playback_pcm_cleanup
3394 },
3395};
3396
3397static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003398 .substreams = 1,
3399 .channels_min = 2,
3400 .channels_max = 2,
3401 /* NID is set in alc_build_pcms */
3402};
3403
3404static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3405 .substreams = 1,
3406 .channels_min = 2,
3407 .channels_max = 2,
3408 /* NID is set in alc_build_pcms */
3409};
3410
3411static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3412 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003413 .channels_min = 2,
3414 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003415 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003416 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003417 .prepare = alc880_alt_capture_pcm_prepare,
3418 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003419 },
3420};
3421
3422static struct hda_pcm_stream alc880_pcm_digital_playback = {
3423 .substreams = 1,
3424 .channels_min = 2,
3425 .channels_max = 2,
3426 /* NID is set in alc_build_pcms */
3427 .ops = {
3428 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003429 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003430 .prepare = alc880_dig_playback_pcm_prepare,
3431 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003432 },
3433};
3434
3435static struct hda_pcm_stream alc880_pcm_digital_capture = {
3436 .substreams = 1,
3437 .channels_min = 2,
3438 .channels_max = 2,
3439 /* NID is set in alc_build_pcms */
3440};
3441
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003442/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003443static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003444 .substreams = 0,
3445 .channels_min = 0,
3446 .channels_max = 0,
3447};
3448
Linus Torvalds1da177e2005-04-16 15:20:36 -07003449static int alc_build_pcms(struct hda_codec *codec)
3450{
3451 struct alc_spec *spec = codec->spec;
3452 struct hda_pcm *info = spec->pcm_rec;
3453 int i;
3454
3455 codec->num_pcms = 1;
3456 codec->pcm_info = info;
3457
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003458 if (spec->no_analog)
3459 goto skip_analog;
3460
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003461 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3462 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003463 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003464
Takashi Iwai4a471b72005-12-07 13:56:29 +01003465 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003466 if (snd_BUG_ON(!spec->multiout.dac_nids))
3467 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003468 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3469 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3470 }
3471 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003472 if (snd_BUG_ON(!spec->adc_nids))
3473 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003474 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3475 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3476 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003477
Takashi Iwai4a471b72005-12-07 13:56:29 +01003478 if (spec->channel_mode) {
3479 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3480 for (i = 0; i < spec->num_channel_mode; i++) {
3481 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3482 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3483 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003484 }
3485 }
3486
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003487 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003488 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003489 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003490 snprintf(spec->stream_name_digital,
3491 sizeof(spec->stream_name_digital),
3492 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003493 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003494 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003495 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003496 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003497 if (spec->dig_out_type)
3498 info->pcm_type = spec->dig_out_type;
3499 else
3500 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003501 if (spec->multiout.dig_out_nid &&
3502 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003503 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3504 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3505 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003506 if (spec->dig_in_nid &&
3507 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003508 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3509 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3510 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003511 /* FIXME: do we need this for all Realtek codec models? */
3512 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003513 }
3514
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003515 if (spec->no_analog)
3516 return 0;
3517
Takashi Iwaie08a0072006-09-07 17:52:14 +02003518 /* If the use of more than one ADC is requested for the current
3519 * model, configure a second analog capture-only PCM.
3520 */
3521 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003522 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3523 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003524 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003525 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003526 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003527 if (spec->alt_dac_nid) {
3528 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3529 *spec->stream_analog_alt_playback;
3530 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3531 spec->alt_dac_nid;
3532 } else {
3533 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3534 alc_pcm_null_stream;
3535 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3536 }
3537 if (spec->num_adc_nids > 1) {
3538 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3539 *spec->stream_analog_alt_capture;
3540 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3541 spec->adc_nids[1];
3542 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3543 spec->num_adc_nids - 1;
3544 } else {
3545 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3546 alc_pcm_null_stream;
3547 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003548 }
3549 }
3550
Linus Torvalds1da177e2005-04-16 15:20:36 -07003551 return 0;
3552}
3553
Takashi Iwai603c4012008-07-30 15:01:44 +02003554static void alc_free_kctls(struct hda_codec *codec)
3555{
3556 struct alc_spec *spec = codec->spec;
3557
3558 if (spec->kctls.list) {
3559 struct snd_kcontrol_new *kctl = spec->kctls.list;
3560 int i;
3561 for (i = 0; i < spec->kctls.used; i++)
3562 kfree(kctl[i].name);
3563 }
3564 snd_array_free(&spec->kctls);
3565}
3566
Linus Torvalds1da177e2005-04-16 15:20:36 -07003567static void alc_free(struct hda_codec *codec)
3568{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003569 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003570
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003571 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003572 return;
3573
Takashi Iwai603c4012008-07-30 15:01:44 +02003574 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003575 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003576 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003577}
3578
Takashi Iwaie044c392008-10-27 16:56:24 +01003579#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003580static int alc_resume(struct hda_codec *codec)
3581{
Takashi Iwaie044c392008-10-27 16:56:24 +01003582 codec->patch_ops.init(codec);
3583 snd_hda_codec_resume_amp(codec);
3584 snd_hda_codec_resume_cache(codec);
3585 return 0;
3586}
Takashi Iwaie044c392008-10-27 16:56:24 +01003587#endif
3588
Linus Torvalds1da177e2005-04-16 15:20:36 -07003589/*
3590 */
3591static struct hda_codec_ops alc_patch_ops = {
3592 .build_controls = alc_build_controls,
3593 .build_pcms = alc_build_pcms,
3594 .init = alc_init,
3595 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003596 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003597#ifdef SND_HDA_NEEDS_RESUME
3598 .resume = alc_resume,
3599#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003600#ifdef CONFIG_SND_HDA_POWER_SAVE
3601 .check_power_status = alc_check_power_status,
3602#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003603};
3604
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003605
3606/*
3607 * Test configuration for debugging
3608 *
3609 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3610 * enum controls.
3611 */
3612#ifdef CONFIG_SND_DEBUG
3613static hda_nid_t alc880_test_dac_nids[4] = {
3614 0x02, 0x03, 0x04, 0x05
3615};
3616
3617static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003618 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003619 .items = {
3620 { "In-1", 0x0 },
3621 { "In-2", 0x1 },
3622 { "In-3", 0x2 },
3623 { "In-4", 0x3 },
3624 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003625 { "Front", 0x5 },
3626 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003627 },
3628};
3629
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003630static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003631 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003632 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003633 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003634 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003635};
3636
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003637static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3638 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003639{
3640 static char *texts[] = {
3641 "N/A", "Line Out", "HP Out",
3642 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3643 };
3644 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3645 uinfo->count = 1;
3646 uinfo->value.enumerated.items = 8;
3647 if (uinfo->value.enumerated.item >= 8)
3648 uinfo->value.enumerated.item = 7;
3649 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3650 return 0;
3651}
3652
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003653static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3654 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003655{
3656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3657 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3658 unsigned int pin_ctl, item = 0;
3659
3660 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3661 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3662 if (pin_ctl & AC_PINCTL_OUT_EN) {
3663 if (pin_ctl & AC_PINCTL_HP_EN)
3664 item = 2;
3665 else
3666 item = 1;
3667 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3668 switch (pin_ctl & AC_PINCTL_VREFEN) {
3669 case AC_PINCTL_VREF_HIZ: item = 3; break;
3670 case AC_PINCTL_VREF_50: item = 4; break;
3671 case AC_PINCTL_VREF_GRD: item = 5; break;
3672 case AC_PINCTL_VREF_80: item = 6; break;
3673 case AC_PINCTL_VREF_100: item = 7; break;
3674 }
3675 }
3676 ucontrol->value.enumerated.item[0] = item;
3677 return 0;
3678}
3679
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003680static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3681 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003682{
3683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3684 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3685 static unsigned int ctls[] = {
3686 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3687 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3688 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3689 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3690 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3691 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3692 };
3693 unsigned int old_ctl, new_ctl;
3694
3695 old_ctl = snd_hda_codec_read(codec, nid, 0,
3696 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3697 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3698 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003699 int val;
3700 snd_hda_codec_write_cache(codec, nid, 0,
3701 AC_VERB_SET_PIN_WIDGET_CONTROL,
3702 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003703 val = ucontrol->value.enumerated.item[0] >= 3 ?
3704 HDA_AMP_MUTE : 0;
3705 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3706 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003707 return 1;
3708 }
3709 return 0;
3710}
3711
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003712static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3713 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003714{
3715 static char *texts[] = {
3716 "Front", "Surround", "CLFE", "Side"
3717 };
3718 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3719 uinfo->count = 1;
3720 uinfo->value.enumerated.items = 4;
3721 if (uinfo->value.enumerated.item >= 4)
3722 uinfo->value.enumerated.item = 3;
3723 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3724 return 0;
3725}
3726
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003727static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3728 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003729{
3730 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3731 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3732 unsigned int sel;
3733
3734 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3735 ucontrol->value.enumerated.item[0] = sel & 3;
3736 return 0;
3737}
3738
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003739static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3740 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003741{
3742 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3743 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3744 unsigned int sel;
3745
3746 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3747 if (ucontrol->value.enumerated.item[0] != sel) {
3748 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003749 snd_hda_codec_write_cache(codec, nid, 0,
3750 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003751 return 1;
3752 }
3753 return 0;
3754}
3755
3756#define PIN_CTL_TEST(xname,nid) { \
3757 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3758 .name = xname, \
3759 .info = alc_test_pin_ctl_info, \
3760 .get = alc_test_pin_ctl_get, \
3761 .put = alc_test_pin_ctl_put, \
3762 .private_value = nid \
3763 }
3764
3765#define PIN_SRC_TEST(xname,nid) { \
3766 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3767 .name = xname, \
3768 .info = alc_test_pin_src_info, \
3769 .get = alc_test_pin_src_get, \
3770 .put = alc_test_pin_src_put, \
3771 .private_value = nid \
3772 }
3773
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003774static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003775 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3776 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3777 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3778 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003779 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3780 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3781 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3782 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003783 PIN_CTL_TEST("Front Pin Mode", 0x14),
3784 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3785 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3786 PIN_CTL_TEST("Side Pin Mode", 0x17),
3787 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3788 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3789 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3790 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3791 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3792 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3793 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3794 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3795 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3796 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3797 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3798 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3799 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3800 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3801 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3802 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3803 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3804 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003805 {
3806 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3807 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003808 .info = alc_ch_mode_info,
3809 .get = alc_ch_mode_get,
3810 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003811 },
3812 { } /* end */
3813};
3814
3815static struct hda_verb alc880_test_init_verbs[] = {
3816 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3818 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3819 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3820 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3821 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3822 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3823 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3824 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003825 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003826 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3827 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3828 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3829 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003830 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003831 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3832 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3833 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3834 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003835 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003836 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3837 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3838 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3839 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003840 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003841 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3842 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003843 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3844 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3845 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003846 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003847 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3848 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3849 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3850 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003851 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003853 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003854 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003855 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003856 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003857 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003858 /* Analog input/passthru */
3859 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3860 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3862 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3863 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003864 { }
3865};
3866#endif
3867
Linus Torvalds1da177e2005-04-16 15:20:36 -07003868/*
3869 */
3870
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003871static const char *alc880_models[ALC880_MODEL_LAST] = {
3872 [ALC880_3ST] = "3stack",
3873 [ALC880_TCL_S700] = "tcl",
3874 [ALC880_3ST_DIG] = "3stack-digout",
3875 [ALC880_CLEVO] = "clevo",
3876 [ALC880_5ST] = "5stack",
3877 [ALC880_5ST_DIG] = "5stack-digout",
3878 [ALC880_W810] = "w810",
3879 [ALC880_Z71V] = "z71v",
3880 [ALC880_6ST] = "6stack",
3881 [ALC880_6ST_DIG] = "6stack-digout",
3882 [ALC880_ASUS] = "asus",
3883 [ALC880_ASUS_W1V] = "asus-w1v",
3884 [ALC880_ASUS_DIG] = "asus-dig",
3885 [ALC880_ASUS_DIG2] = "asus-dig2",
3886 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003887 [ALC880_UNIWILL_P53] = "uniwill-p53",
3888 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003889 [ALC880_F1734] = "F1734",
3890 [ALC880_LG] = "lg",
3891 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003892 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003893#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003894 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003895#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003896 [ALC880_AUTO] = "auto",
3897};
3898
3899static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003900 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003901 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3902 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3903 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3904 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3905 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3906 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3907 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3908 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003909 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3910 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003911 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3912 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3913 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3914 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3915 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3916 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3917 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3918 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3919 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3920 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003921 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003922 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3923 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3924 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003925 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003926 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003927 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3928 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003929 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3930 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003931 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3932 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3933 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3934 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003935 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3936 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003937 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003938 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003939 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003940 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003941 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3942 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003943 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003944 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003945 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003946 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003947 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003948 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003949 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003950 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003951 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003952 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3953 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003954 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003955 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3956 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3957 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3958 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003959 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3960 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003961 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003962 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003963 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3964 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003965 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3966 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3967 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003968 /* default Intel */
3969 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003970 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3971 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003972 {}
3973};
3974
Takashi Iwai16ded522005-06-10 19:58:24 +02003975/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003976 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003977 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003978static struct alc_config_preset alc880_presets[] = {
3979 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003980 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003981 .init_verbs = { alc880_volume_init_verbs,
3982 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003983 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003984 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003985 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3986 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003987 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003988 .input_mux = &alc880_capture_source,
3989 },
3990 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003991 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003992 .init_verbs = { alc880_volume_init_verbs,
3993 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003994 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003995 .dac_nids = alc880_dac_nids,
3996 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003997 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3998 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003999 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004000 .input_mux = &alc880_capture_source,
4001 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004002 [ALC880_TCL_S700] = {
4003 .mixers = { alc880_tcl_s700_mixer },
4004 .init_verbs = { alc880_volume_init_verbs,
4005 alc880_pin_tcl_S700_init_verbs,
4006 alc880_gpio2_init_verbs },
4007 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4008 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004009 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4010 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004011 .hp_nid = 0x03,
4012 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4013 .channel_mode = alc880_2_jack_modes,
4014 .input_mux = &alc880_capture_source,
4015 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004016 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004017 .mixers = { alc880_three_stack_mixer,
4018 alc880_five_stack_mixer},
4019 .init_verbs = { alc880_volume_init_verbs,
4020 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004021 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4022 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004023 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4024 .channel_mode = alc880_fivestack_modes,
4025 .input_mux = &alc880_capture_source,
4026 },
4027 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004028 .mixers = { alc880_three_stack_mixer,
4029 alc880_five_stack_mixer },
4030 .init_verbs = { alc880_volume_init_verbs,
4031 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004032 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4033 .dac_nids = alc880_dac_nids,
4034 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004035 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4036 .channel_mode = alc880_fivestack_modes,
4037 .input_mux = &alc880_capture_source,
4038 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004039 [ALC880_6ST] = {
4040 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004041 .init_verbs = { alc880_volume_init_verbs,
4042 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004043 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4044 .dac_nids = alc880_6st_dac_nids,
4045 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4046 .channel_mode = alc880_sixstack_modes,
4047 .input_mux = &alc880_6stack_capture_source,
4048 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004049 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004050 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004051 .init_verbs = { alc880_volume_init_verbs,
4052 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004053 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4054 .dac_nids = alc880_6st_dac_nids,
4055 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004056 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4057 .channel_mode = alc880_sixstack_modes,
4058 .input_mux = &alc880_6stack_capture_source,
4059 },
4060 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004061 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004062 .init_verbs = { alc880_volume_init_verbs,
4063 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004064 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004065 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4066 .dac_nids = alc880_w810_dac_nids,
4067 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004068 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4069 .channel_mode = alc880_w810_modes,
4070 .input_mux = &alc880_capture_source,
4071 },
4072 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004073 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004074 .init_verbs = { alc880_volume_init_verbs,
4075 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004076 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4077 .dac_nids = alc880_z71v_dac_nids,
4078 .dig_out_nid = ALC880_DIGOUT_NID,
4079 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004080 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4081 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004082 .input_mux = &alc880_capture_source,
4083 },
4084 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004085 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004086 .init_verbs = { alc880_volume_init_verbs,
4087 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004088 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4089 .dac_nids = alc880_f1734_dac_nids,
4090 .hp_nid = 0x02,
4091 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4092 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004093 .input_mux = &alc880_f1734_capture_source,
4094 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004095 .init_hook = alc880_uniwill_p53_init_hook,
Takashi Iwai16ded522005-06-10 19:58:24 +02004096 },
4097 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004098 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004099 .init_verbs = { alc880_volume_init_verbs,
4100 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004101 alc880_gpio1_init_verbs },
4102 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4103 .dac_nids = alc880_asus_dac_nids,
4104 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4105 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004106 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004107 .input_mux = &alc880_capture_source,
4108 },
4109 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004110 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004111 .init_verbs = { alc880_volume_init_verbs,
4112 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004113 alc880_gpio1_init_verbs },
4114 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4115 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004116 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004117 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4118 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004119 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004120 .input_mux = &alc880_capture_source,
4121 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004122 [ALC880_ASUS_DIG2] = {
4123 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004124 .init_verbs = { alc880_volume_init_verbs,
4125 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004126 alc880_gpio2_init_verbs }, /* use GPIO2 */
4127 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4128 .dac_nids = alc880_asus_dac_nids,
4129 .dig_out_nid = ALC880_DIGOUT_NID,
4130 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4131 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004132 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004133 .input_mux = &alc880_capture_source,
4134 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004135 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004136 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004137 .init_verbs = { alc880_volume_init_verbs,
4138 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004139 alc880_gpio1_init_verbs },
4140 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4141 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004142 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004143 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4144 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004145 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004146 .input_mux = &alc880_capture_source,
4147 },
4148 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004149 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004150 .init_verbs = { alc880_volume_init_verbs,
4151 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004152 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4153 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004154 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004155 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4156 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004157 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004158 .input_mux = &alc880_capture_source,
4159 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004160 [ALC880_UNIWILL] = {
4161 .mixers = { alc880_uniwill_mixer },
4162 .init_verbs = { alc880_volume_init_verbs,
4163 alc880_uniwill_init_verbs },
4164 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4165 .dac_nids = alc880_asus_dac_nids,
4166 .dig_out_nid = ALC880_DIGOUT_NID,
4167 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4168 .channel_mode = alc880_threestack_modes,
4169 .need_dac_fix = 1,
4170 .input_mux = &alc880_capture_source,
4171 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004172 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004173 },
4174 [ALC880_UNIWILL_P53] = {
4175 .mixers = { alc880_uniwill_p53_mixer },
4176 .init_verbs = { alc880_volume_init_verbs,
4177 alc880_uniwill_p53_init_verbs },
4178 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4179 .dac_nids = alc880_asus_dac_nids,
4180 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004181 .channel_mode = alc880_threestack_modes,
4182 .input_mux = &alc880_capture_source,
4183 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004184 .init_hook = alc880_uniwill_p53_init_hook,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004185 },
4186 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004187 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004188 .init_verbs = { alc880_volume_init_verbs,
4189 alc880_uniwill_p53_init_verbs,
4190 alc880_beep_init_verbs },
4191 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4192 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004193 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004194 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4195 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004196 .input_mux = &alc880_capture_source,
4197 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004198 .init_hook = alc880_uniwill_p53_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004199 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004200 [ALC880_CLEVO] = {
4201 .mixers = { alc880_three_stack_mixer },
4202 .init_verbs = { alc880_volume_init_verbs,
4203 alc880_pin_clevo_init_verbs },
4204 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4205 .dac_nids = alc880_dac_nids,
4206 .hp_nid = 0x03,
4207 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4208 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004209 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004210 .input_mux = &alc880_capture_source,
4211 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004212 [ALC880_LG] = {
4213 .mixers = { alc880_lg_mixer },
4214 .init_verbs = { alc880_volume_init_verbs,
4215 alc880_lg_init_verbs },
4216 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4217 .dac_nids = alc880_lg_dac_nids,
4218 .dig_out_nid = ALC880_DIGOUT_NID,
4219 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4220 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004221 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004222 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004223 .unsol_event = alc_automute_amp_unsol_event,
4224 .init_hook = alc880_lg_init_hook,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004225#ifdef CONFIG_SND_HDA_POWER_SAVE
4226 .loopbacks = alc880_lg_loopbacks,
4227#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004228 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004229 [ALC880_LG_LW] = {
4230 .mixers = { alc880_lg_lw_mixer },
4231 .init_verbs = { alc880_volume_init_verbs,
4232 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004233 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004234 .dac_nids = alc880_dac_nids,
4235 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004236 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4237 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004238 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004239 .unsol_event = alc_automute_amp_unsol_event,
4240 .init_hook = alc880_lg_lw_init_hook,
Takashi Iwaid6815182006-03-23 16:06:23 +01004241 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004242 [ALC880_MEDION_RIM] = {
4243 .mixers = { alc880_medion_rim_mixer },
4244 .init_verbs = { alc880_volume_init_verbs,
4245 alc880_medion_rim_init_verbs,
4246 alc_gpio2_init_verbs },
4247 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4248 .dac_nids = alc880_dac_nids,
4249 .dig_out_nid = ALC880_DIGOUT_NID,
4250 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4251 .channel_mode = alc880_2_jack_modes,
4252 .input_mux = &alc880_medion_rim_capture_source,
4253 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004254 .init_hook = alc880_medion_rim_init_hook,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004255 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004256#ifdef CONFIG_SND_DEBUG
4257 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004258 .mixers = { alc880_test_mixer },
4259 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004260 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4261 .dac_nids = alc880_test_dac_nids,
4262 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004263 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4264 .channel_mode = alc880_test_modes,
4265 .input_mux = &alc880_test_capture_source,
4266 },
4267#endif
4268};
4269
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004270/*
4271 * Automatic parse of I/O pins from the BIOS configuration
4272 */
4273
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004274enum {
4275 ALC_CTL_WIDGET_VOL,
4276 ALC_CTL_WIDGET_MUTE,
4277 ALC_CTL_BIND_MUTE,
4278};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004279static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004280 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4281 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004282 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004283};
4284
4285/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004286static int add_control(struct alc_spec *spec, int type, const char *name,
4287 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004288{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004289 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004290
Takashi Iwai603c4012008-07-30 15:01:44 +02004291 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4292 knew = snd_array_new(&spec->kctls);
4293 if (!knew)
4294 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004295 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004296 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004297 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004298 return -ENOMEM;
4299 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004300 return 0;
4301}
4302
4303#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4304#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4305#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4306#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4307#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4308#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4309#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4310#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4311#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4312#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4313#define ALC880_PIN_CD_NID 0x1c
4314
4315/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004316static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4317 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004318{
4319 hda_nid_t nid;
4320 int assigned[4];
4321 int i, j;
4322
4323 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004324 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004325
4326 /* check the pins hardwired to audio widget */
4327 for (i = 0; i < cfg->line_outs; i++) {
4328 nid = cfg->line_out_pins[i];
4329 if (alc880_is_fixed_pin(nid)) {
4330 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004331 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004332 assigned[idx] = 1;
4333 }
4334 }
4335 /* left pins can be connect to any audio widget */
4336 for (i = 0; i < cfg->line_outs; i++) {
4337 nid = cfg->line_out_pins[i];
4338 if (alc880_is_fixed_pin(nid))
4339 continue;
4340 /* search for an empty channel */
4341 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004342 if (!assigned[j]) {
4343 spec->multiout.dac_nids[i] =
4344 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004345 assigned[j] = 1;
4346 break;
4347 }
4348 }
4349 }
4350 spec->multiout.num_dacs = cfg->line_outs;
4351 return 0;
4352}
4353
4354/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004355static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4356 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004357{
4358 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004359 static const char *chname[4] = {
4360 "Front", "Surround", NULL /*CLFE*/, "Side"
4361 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004362 hda_nid_t nid;
4363 int i, err;
4364
4365 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004366 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004367 continue;
4368 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4369 if (i == 2) {
4370 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004371 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4372 "Center Playback Volume",
4373 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4374 HDA_OUTPUT));
4375 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004376 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004377 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4378 "LFE Playback Volume",
4379 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4380 HDA_OUTPUT));
4381 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004382 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004383 err = add_control(spec, ALC_CTL_BIND_MUTE,
4384 "Center Playback Switch",
4385 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4386 HDA_INPUT));
4387 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004388 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004389 err = add_control(spec, ALC_CTL_BIND_MUTE,
4390 "LFE Playback Switch",
4391 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4392 HDA_INPUT));
4393 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004394 return err;
4395 } else {
4396 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004397 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4398 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4399 HDA_OUTPUT));
4400 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004401 return err;
4402 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004403 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4404 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4405 HDA_INPUT));
4406 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004407 return err;
4408 }
4409 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004410 return 0;
4411}
4412
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004413/* add playback controls for speaker and HP outputs */
4414static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4415 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004416{
4417 hda_nid_t nid;
4418 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004419 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004420
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004421 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004422 return 0;
4423
4424 if (alc880_is_fixed_pin(pin)) {
4425 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004426 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004427 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004428 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004429 else
4430 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004431 /* control HP volume/switch on the output mixer amp */
4432 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004433 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004434 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4435 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4436 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004437 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004438 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004439 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4440 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4441 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004442 return err;
4443 } else if (alc880_is_multi_pin(pin)) {
4444 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004445 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004446 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004447 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4448 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4449 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004450 return err;
4451 }
4452 return 0;
4453}
4454
4455/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004456static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4457 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004458 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004459{
4460 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004461 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004462
4463 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004464 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4465 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4466 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004467 return err;
4468 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004469 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4470 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4471 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004472 return err;
4473 return 0;
4474}
4475
4476/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004477static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4478 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004479{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004480 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004481 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004482
4483 for (i = 0; i < AUTO_PIN_LAST; i++) {
4484 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004485 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004486 err = new_analog_input(spec, cfg->input_pins[i],
4487 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004488 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004489 if (err < 0)
4490 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004491 imux->items[imux->num_items].label =
4492 auto_pin_cfg_labels[i];
4493 imux->items[imux->num_items].index =
4494 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004495 imux->num_items++;
4496 }
4497 }
4498 return 0;
4499}
4500
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004501static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4502 unsigned int pin_type)
4503{
4504 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4505 pin_type);
4506 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004507 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4508 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004509}
4510
Kailang Yangdf694da2005-12-05 19:42:22 +01004511static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4512 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004513 int dac_idx)
4514{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004515 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004516 /* need the manual connection? */
4517 if (alc880_is_multi_pin(nid)) {
4518 struct alc_spec *spec = codec->spec;
4519 int idx = alc880_multi_pin_idx(nid);
4520 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4521 AC_VERB_SET_CONNECT_SEL,
4522 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4523 }
4524}
4525
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004526static int get_pin_type(int line_out_type)
4527{
4528 if (line_out_type == AUTO_PIN_HP_OUT)
4529 return PIN_HP;
4530 else
4531 return PIN_OUT;
4532}
4533
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004534static void alc880_auto_init_multi_out(struct hda_codec *codec)
4535{
4536 struct alc_spec *spec = codec->spec;
4537 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004538
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004539 for (i = 0; i < spec->autocfg.line_outs; i++) {
4540 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004541 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4542 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004543 }
4544}
4545
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004546static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004547{
4548 struct alc_spec *spec = codec->spec;
4549 hda_nid_t pin;
4550
Takashi Iwai82bc9552006-03-21 11:24:42 +01004551 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004552 if (pin) /* connect to front */
4553 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004554 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004555 if (pin) /* connect to front */
4556 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4557}
4558
4559static void alc880_auto_init_analog_input(struct hda_codec *codec)
4560{
4561 struct alc_spec *spec = codec->spec;
4562 int i;
4563
4564 for (i = 0; i < AUTO_PIN_LAST; i++) {
4565 hda_nid_t nid = spec->autocfg.input_pins[i];
4566 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004567 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004568 if (nid != ALC880_PIN_CD_NID &&
4569 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004570 snd_hda_codec_write(codec, nid, 0,
4571 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004572 AMP_OUT_MUTE);
4573 }
4574 }
4575}
4576
4577/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004578/* return 1 if successful, 0 if the proper config is not found,
4579 * or a negative error code
4580 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004581static int alc880_parse_auto_config(struct hda_codec *codec)
4582{
4583 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004584 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004585 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004586
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004587 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4588 alc880_ignore);
4589 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004590 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004591 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004592 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004593
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004594 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4595 if (err < 0)
4596 return err;
4597 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4598 if (err < 0)
4599 return err;
4600 err = alc880_auto_create_extra_out(spec,
4601 spec->autocfg.speaker_pins[0],
4602 "Speaker");
4603 if (err < 0)
4604 return err;
4605 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4606 "Headphone");
4607 if (err < 0)
4608 return err;
4609 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4610 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004611 return err;
4612
4613 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4614
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004615 /* check multiple SPDIF-out (for recent codecs) */
4616 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4617 hda_nid_t dig_nid;
4618 err = snd_hda_get_connections(codec,
4619 spec->autocfg.dig_out_pins[i],
4620 &dig_nid, 1);
4621 if (err < 0)
4622 continue;
4623 if (!i)
4624 spec->multiout.dig_out_nid = dig_nid;
4625 else {
4626 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4627 spec->slave_dig_outs[i - 1] = dig_nid;
4628 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4629 break;
4630 }
4631 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004632 if (spec->autocfg.dig_in_pin)
4633 spec->dig_in_nid = ALC880_DIGIN_NID;
4634
Takashi Iwai603c4012008-07-30 15:01:44 +02004635 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004636 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004637
Takashi Iwaid88897e2008-10-31 15:01:37 +01004638 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004639
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004640 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004641 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004642
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004643 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4644
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004645 return 1;
4646}
4647
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004648/* additional initialization for auto-configuration model */
4649static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004650{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004651 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004652 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004653 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004654 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004655 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004656 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004657}
4658
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004659/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4660 * one of two digital mic pins, e.g. on ALC272
4661 */
4662static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004663{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004664 struct alc_spec *spec = codec->spec;
4665 int i;
4666
4667 for (i = 0; i < spec->num_adc_nids; i++) {
4668 hda_nid_t cap = spec->capsrc_nids ?
4669 spec->capsrc_nids[i] : spec->adc_nids[i];
4670 int iidx, eidx;
4671
4672 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4673 if (iidx < 0)
4674 continue;
4675 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4676 if (eidx < 0)
4677 continue;
4678 spec->int_mic.mux_idx = iidx;
4679 spec->ext_mic.mux_idx = eidx;
4680 if (spec->capsrc_nids)
4681 spec->capsrc_nids += i;
4682 spec->adc_nids += i;
4683 spec->num_adc_nids = 1;
4684 return;
4685 }
4686 snd_printd(KERN_INFO "hda_codec: %s: "
4687 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4688 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4689 spec->auto_mic = 0; /* disable auto-mic to be sure */
4690}
4691
4692static void set_capture_mixer(struct hda_codec *codec)
4693{
4694 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004695 static struct snd_kcontrol_new *caps[2][3] = {
4696 { alc_capture_mixer_nosrc1,
4697 alc_capture_mixer_nosrc2,
4698 alc_capture_mixer_nosrc3 },
4699 { alc_capture_mixer1,
4700 alc_capture_mixer2,
4701 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004702 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004703 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4704 int mux;
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004705 if (spec->auto_mic) {
4706 mux = 0;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004707 fixup_automic_adc(codec);
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004708 } else if (spec->input_mux && spec->input_mux->num_items > 1)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004709 mux = 1;
4710 else
4711 mux = 0;
4712 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4713 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004714}
4715
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004716#define set_beep_amp(spec, nid, idx, dir) \
4717 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4718
4719/*
4720 * OK, here we have finally the patch for ALC880
4721 */
4722
Linus Torvalds1da177e2005-04-16 15:20:36 -07004723static int patch_alc880(struct hda_codec *codec)
4724{
4725 struct alc_spec *spec;
4726 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004727 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004728
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004729 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004730 if (spec == NULL)
4731 return -ENOMEM;
4732
4733 codec->spec = spec;
4734
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004735 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4736 alc880_models,
4737 alc880_cfg_tbl);
4738 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004739 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4740 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004741 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004742 }
4743
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004744 if (board_config == ALC880_AUTO) {
4745 /* automatic parse from the BIOS config */
4746 err = alc880_parse_auto_config(codec);
4747 if (err < 0) {
4748 alc_free(codec);
4749 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004750 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004751 printk(KERN_INFO
4752 "hda_codec: Cannot set up configuration "
4753 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004754 board_config = ALC880_3ST;
4755 }
4756 }
4757
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004758 err = snd_hda_attach_beep_device(codec, 0x1);
4759 if (err < 0) {
4760 alc_free(codec);
4761 return err;
4762 }
4763
Kailang Yangdf694da2005-12-05 19:42:22 +01004764 if (board_config != ALC880_AUTO)
4765 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004766
Linus Torvalds1da177e2005-04-16 15:20:36 -07004767 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4768 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004769 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004770
Linus Torvalds1da177e2005-04-16 15:20:36 -07004771 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4772 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4773
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004774 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004775 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004776 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004777 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004778 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004779 if (wcap != AC_WID_AUD_IN) {
4780 spec->adc_nids = alc880_adc_nids_alt;
4781 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004782 } else {
4783 spec->adc_nids = alc880_adc_nids;
4784 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004785 }
4786 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004787 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004788 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004789
Takashi Iwai2134ea42008-01-10 16:53:55 +01004790 spec->vmaster_nid = 0x0c;
4791
Linus Torvalds1da177e2005-04-16 15:20:36 -07004792 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004793 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004794 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004795#ifdef CONFIG_SND_HDA_POWER_SAVE
4796 if (!spec->loopback.amplist)
4797 spec->loopback.amplist = alc880_loopbacks;
4798#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004799 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004800
4801 return 0;
4802}
4803
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004804
Linus Torvalds1da177e2005-04-16 15:20:36 -07004805/*
4806 * ALC260 support
4807 */
4808
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004809static hda_nid_t alc260_dac_nids[1] = {
4810 /* front */
4811 0x02,
4812};
4813
4814static hda_nid_t alc260_adc_nids[1] = {
4815 /* ADC0 */
4816 0x04,
4817};
4818
Kailang Yangdf694da2005-12-05 19:42:22 +01004819static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004820 /* ADC1 */
4821 0x05,
4822};
4823
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004824/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4825 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4826 */
4827static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004828 /* ADC0, ADC1 */
4829 0x04, 0x05
4830};
4831
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004832#define ALC260_DIGOUT_NID 0x03
4833#define ALC260_DIGIN_NID 0x06
4834
4835static struct hda_input_mux alc260_capture_source = {
4836 .num_items = 4,
4837 .items = {
4838 { "Mic", 0x0 },
4839 { "Front Mic", 0x1 },
4840 { "Line", 0x2 },
4841 { "CD", 0x4 },
4842 },
4843};
4844
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004845/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004846 * headphone jack and the internal CD lines since these are the only pins at
4847 * which audio can appear. For flexibility, also allow the option of
4848 * recording the mixer output on the second ADC (ADC0 doesn't have a
4849 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004850 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004851static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4852 {
4853 .num_items = 3,
4854 .items = {
4855 { "Mic/Line", 0x0 },
4856 { "CD", 0x4 },
4857 { "Headphone", 0x2 },
4858 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004859 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004860 {
4861 .num_items = 4,
4862 .items = {
4863 { "Mic/Line", 0x0 },
4864 { "CD", 0x4 },
4865 { "Headphone", 0x2 },
4866 { "Mixer", 0x5 },
4867 },
4868 },
4869
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004870};
4871
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004872/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4873 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004874 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004875static struct hda_input_mux alc260_acer_capture_sources[2] = {
4876 {
4877 .num_items = 4,
4878 .items = {
4879 { "Mic", 0x0 },
4880 { "Line", 0x2 },
4881 { "CD", 0x4 },
4882 { "Headphone", 0x5 },
4883 },
4884 },
4885 {
4886 .num_items = 5,
4887 .items = {
4888 { "Mic", 0x0 },
4889 { "Line", 0x2 },
4890 { "CD", 0x4 },
4891 { "Headphone", 0x6 },
4892 { "Mixer", 0x5 },
4893 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004894 },
4895};
Michael Schwingencc959482009-02-22 18:58:45 +01004896
4897/* Maxdata Favorit 100XS */
4898static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4899 {
4900 .num_items = 2,
4901 .items = {
4902 { "Line/Mic", 0x0 },
4903 { "CD", 0x4 },
4904 },
4905 },
4906 {
4907 .num_items = 3,
4908 .items = {
4909 { "Line/Mic", 0x0 },
4910 { "CD", 0x4 },
4911 { "Mixer", 0x5 },
4912 },
4913 },
4914};
4915
Linus Torvalds1da177e2005-04-16 15:20:36 -07004916/*
4917 * This is just place-holder, so there's something for alc_build_pcms to look
4918 * at when it calculates the maximum number of channels. ALC260 has no mixer
4919 * element which allows changing the channel mode, so the verb list is
4920 * never used.
4921 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004922static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004923 { 2, NULL },
4924};
4925
Kailang Yangdf694da2005-12-05 19:42:22 +01004926
4927/* Mixer combinations
4928 *
4929 * basic: base_output + input + pc_beep + capture
4930 * HP: base_output + input + capture_alt
4931 * HP_3013: hp_3013 + input + capture
4932 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004933 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004934 */
4935
4936static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004937 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004938 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004939 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4940 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4941 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4942 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4943 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004944};
Kailang Yangdf694da2005-12-05 19:42:22 +01004945
4946static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004947 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4948 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4949 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4950 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4952 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4953 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4954 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004955 { } /* end */
4956};
4957
Takashi Iwaibec15c32008-01-28 18:16:30 +01004958/* update HP, line and mono out pins according to the master switch */
4959static void alc260_hp_master_update(struct hda_codec *codec,
4960 hda_nid_t hp, hda_nid_t line,
4961 hda_nid_t mono)
4962{
4963 struct alc_spec *spec = codec->spec;
4964 unsigned int val = spec->master_sw ? PIN_HP : 0;
4965 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004966 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004967 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004968 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004969 val);
4970 /* mono (speaker) depending on the HP jack sense */
4971 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004972 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004973 val);
4974}
4975
4976static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4977 struct snd_ctl_elem_value *ucontrol)
4978{
4979 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4980 struct alc_spec *spec = codec->spec;
4981 *ucontrol->value.integer.value = spec->master_sw;
4982 return 0;
4983}
4984
4985static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4986 struct snd_ctl_elem_value *ucontrol)
4987{
4988 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4989 struct alc_spec *spec = codec->spec;
4990 int val = !!*ucontrol->value.integer.value;
4991 hda_nid_t hp, line, mono;
4992
4993 if (val == spec->master_sw)
4994 return 0;
4995 spec->master_sw = val;
4996 hp = (kcontrol->private_value >> 16) & 0xff;
4997 line = (kcontrol->private_value >> 8) & 0xff;
4998 mono = kcontrol->private_value & 0xff;
4999 alc260_hp_master_update(codec, hp, line, mono);
5000 return 1;
5001}
5002
5003static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5004 {
5005 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5006 .name = "Master Playback Switch",
5007 .info = snd_ctl_boolean_mono_info,
5008 .get = alc260_hp_master_sw_get,
5009 .put = alc260_hp_master_sw_put,
5010 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5011 },
5012 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5013 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5014 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5015 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5016 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5017 HDA_OUTPUT),
5018 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5019 { } /* end */
5020};
5021
5022static struct hda_verb alc260_hp_unsol_verbs[] = {
5023 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5024 {},
5025};
5026
5027static void alc260_hp_automute(struct hda_codec *codec)
5028{
5029 struct alc_spec *spec = codec->spec;
5030 unsigned int present;
5031
5032 present = snd_hda_codec_read(codec, 0x10, 0,
5033 AC_VERB_GET_PIN_SENSE, 0);
5034 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5035 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5036}
5037
5038static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5039{
5040 if ((res >> 26) == ALC880_HP_EVENT)
5041 alc260_hp_automute(codec);
5042}
5043
Kailang Yangdf694da2005-12-05 19:42:22 +01005044static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005045 {
5046 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5047 .name = "Master Playback Switch",
5048 .info = snd_ctl_boolean_mono_info,
5049 .get = alc260_hp_master_sw_get,
5050 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005051 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005052 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005053 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5054 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5055 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5056 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5057 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5058 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005059 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5060 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005061 { } /* end */
5062};
5063
Kailang Yang3f878302008-08-26 13:02:23 +02005064static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5065 .ops = &snd_hda_bind_vol,
5066 .values = {
5067 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5068 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5069 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5070 0
5071 },
5072};
5073
5074static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5075 .ops = &snd_hda_bind_sw,
5076 .values = {
5077 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5078 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5079 0
5080 },
5081};
5082
5083static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5084 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5085 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5086 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5087 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5088 { } /* end */
5089};
5090
Takashi Iwaibec15c32008-01-28 18:16:30 +01005091static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5092 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5093 {},
5094};
5095
5096static void alc260_hp_3013_automute(struct hda_codec *codec)
5097{
5098 struct alc_spec *spec = codec->spec;
5099 unsigned int present;
5100
5101 present = snd_hda_codec_read(codec, 0x15, 0,
5102 AC_VERB_GET_PIN_SENSE, 0);
5103 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005104 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005105}
5106
5107static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5108 unsigned int res)
5109{
5110 if ((res >> 26) == ALC880_HP_EVENT)
5111 alc260_hp_3013_automute(codec);
5112}
5113
Kailang Yang3f878302008-08-26 13:02:23 +02005114static void alc260_hp_3012_automute(struct hda_codec *codec)
5115{
5116 unsigned int present, bits;
5117
5118 present = snd_hda_codec_read(codec, 0x10, 0,
5119 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
5120
5121 bits = present ? 0 : PIN_OUT;
5122 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5123 bits);
5124 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5125 bits);
5126 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5127 bits);
5128}
5129
5130static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5131 unsigned int res)
5132{
5133 if ((res >> 26) == ALC880_HP_EVENT)
5134 alc260_hp_3012_automute(codec);
5135}
5136
5137/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005138 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5139 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005140static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005141 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005142 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005143 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005144 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5145 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5146 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5147 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005148 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005149 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5150 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005151 { } /* end */
5152};
5153
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005154/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5155 * versions of the ALC260 don't act on requests to enable mic bias from NID
5156 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5157 * datasheet doesn't mention this restriction. At this stage it's not clear
5158 * whether this behaviour is intentional or is a hardware bug in chip
5159 * revisions available in early 2006. Therefore for now allow the
5160 * "Headphone Jack Mode" control to span all choices, but if it turns out
5161 * that the lack of mic bias for this NID is intentional we could change the
5162 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5163 *
5164 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5165 * don't appear to make the mic bias available from the "line" jack, even
5166 * though the NID used for this jack (0x14) can supply it. The theory is
5167 * that perhaps Acer have included blocking capacitors between the ALC260
5168 * and the output jack. If this turns out to be the case for all such
5169 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5170 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005171 *
5172 * The C20x Tablet series have a mono internal speaker which is controlled
5173 * via the chip's Mono sum widget and pin complex, so include the necessary
5174 * controls for such models. On models without a "mono speaker" the control
5175 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005176 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005177static struct snd_kcontrol_new alc260_acer_mixer[] = {
5178 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5179 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005180 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005181 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005182 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005183 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005184 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005185 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5186 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5187 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5188 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5189 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5190 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5191 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5192 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005193 { } /* end */
5194};
5195
Michael Schwingencc959482009-02-22 18:58:45 +01005196/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5197 */
5198static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5199 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5200 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5201 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5202 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5203 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5204 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5205 { } /* end */
5206};
5207
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005208/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5209 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5210 */
5211static struct snd_kcontrol_new alc260_will_mixer[] = {
5212 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5213 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5215 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5216 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5217 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5218 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5219 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5220 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5221 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005222 { } /* end */
5223};
5224
5225/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5226 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5227 */
5228static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5229 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5230 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5231 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5232 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5233 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5234 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5235 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5236 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5237 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5238 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5239 { } /* end */
5240};
5241
Kailang Yangdf694da2005-12-05 19:42:22 +01005242/*
5243 * initialization verbs
5244 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005245static struct hda_verb alc260_init_verbs[] = {
5246 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005247 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005248 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005249 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005250 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005251 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005252 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005253 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005254 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005255 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005256 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005257 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005258 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005259 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005260 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005261 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005262 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005263 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5264 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005265 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005266 /* set connection select to line in (default select for this ADC) */
5267 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005268 /* mute capture amp left and right */
5269 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5270 /* set connection select to line in (default select for this ADC) */
5271 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005272 /* set vol=0 Line-Out mixer amp left and right */
5273 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5274 /* unmute pin widget amp left and right (no gain on this amp) */
5275 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5276 /* set vol=0 HP mixer amp left and right */
5277 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5278 /* unmute pin widget amp left and right (no gain on this amp) */
5279 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5280 /* set vol=0 Mono mixer amp left and right */
5281 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5282 /* unmute pin widget amp left and right (no gain on this amp) */
5283 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5284 /* unmute LINE-2 out pin */
5285 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005286 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5287 * Line In 2 = 0x03
5288 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005289 /* mute analog inputs */
5290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5292 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5293 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5294 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005295 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005296 /* mute Front out path */
5297 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5298 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5299 /* mute Headphone out path */
5300 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5301 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5302 /* mute Mono out path */
5303 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5304 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005305 { }
5306};
5307
Takashi Iwai474167d2006-05-17 17:17:43 +02005308#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005309static struct hda_verb alc260_hp_init_verbs[] = {
5310 /* Headphone and output */
5311 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5312 /* mono output */
5313 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5314 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5315 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5316 /* Mic2 (front panel) pin widget for input and vref at 80% */
5317 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5318 /* Line In pin widget for input */
5319 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5320 /* Line-2 pin widget for output */
5321 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5322 /* CD pin widget for input */
5323 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5324 /* unmute amp left and right */
5325 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5326 /* set connection select to line in (default select for this ADC) */
5327 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5328 /* unmute Line-Out mixer amp left and right (volume = 0) */
5329 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5330 /* mute pin widget amp left and right (no gain on this amp) */
5331 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5332 /* unmute HP mixer amp left and right (volume = 0) */
5333 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5334 /* mute pin widget amp left and right (no gain on this amp) */
5335 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005336 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5337 * Line In 2 = 0x03
5338 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005339 /* mute analog inputs */
5340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5341 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5342 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5343 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5344 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005345 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5346 /* Unmute Front out path */
5347 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5348 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5349 /* Unmute Headphone out path */
5350 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5351 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5352 /* Unmute Mono out path */
5353 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5354 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5355 { }
5356};
Takashi Iwai474167d2006-05-17 17:17:43 +02005357#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005358
5359static struct hda_verb alc260_hp_3013_init_verbs[] = {
5360 /* Line out and output */
5361 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5362 /* mono output */
5363 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5364 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5365 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5366 /* Mic2 (front panel) pin widget for input and vref at 80% */
5367 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5368 /* Line In pin widget for input */
5369 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5370 /* Headphone pin widget for output */
5371 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5372 /* CD pin widget for input */
5373 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5374 /* unmute amp left and right */
5375 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5376 /* set connection select to line in (default select for this ADC) */
5377 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5378 /* unmute Line-Out mixer amp left and right (volume = 0) */
5379 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5380 /* mute pin widget amp left and right (no gain on this amp) */
5381 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5382 /* unmute HP mixer amp left and right (volume = 0) */
5383 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5384 /* mute pin widget amp left and right (no gain on this amp) */
5385 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005386 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5387 * Line In 2 = 0x03
5388 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005389 /* mute analog inputs */
5390 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5391 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5392 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5393 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5394 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005395 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5396 /* Unmute Front out path */
5397 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5398 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5399 /* Unmute Headphone out path */
5400 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5401 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5402 /* Unmute Mono out path */
5403 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5404 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5405 { }
5406};
5407
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005408/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005409 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5410 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005411 */
5412static struct hda_verb alc260_fujitsu_init_verbs[] = {
5413 /* Disable all GPIOs */
5414 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5415 /* Internal speaker is connected to headphone pin */
5416 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5417 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005419 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5420 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5421 /* Ensure all other unused pins are disabled and muted. */
5422 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5423 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005424 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005425 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005426 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005427 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5428 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5429 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005430
Jonathan Woithef7ace402006-02-28 11:46:14 +01005431 /* Disable digital (SPDIF) pins */
5432 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5433 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005434
Kailang Yangea1fb292008-08-26 12:58:38 +02005435 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005436 * when acting as an output.
5437 */
5438 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5439
5440 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005441 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5442 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5443 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5444 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5445 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5446 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5447 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5448 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5449 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005450
Jonathan Woithef7ace402006-02-28 11:46:14 +01005451 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5452 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5453 /* Unmute Line1 pin widget output buffer since it starts as an output.
5454 * If the pin mode is changed by the user the pin mode control will
5455 * take care of enabling the pin's input/output buffers as needed.
5456 * Therefore there's no need to enable the input buffer at this
5457 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005458 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005459 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005460 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005461 * mixer ctrl)
5462 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005463 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005464
Jonathan Woithef7ace402006-02-28 11:46:14 +01005465 /* Mute capture amp left and right */
5466 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005467 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005468 * in (on mic1 pin)
5469 */
5470 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005471
Jonathan Woithef7ace402006-02-28 11:46:14 +01005472 /* Do the same for the second ADC: mute capture input amp and
5473 * set ADC connection to line in (on mic1 pin)
5474 */
5475 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5476 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005477
Jonathan Woithef7ace402006-02-28 11:46:14 +01005478 /* Mute all inputs to mixer widget (even unconnected ones) */
5479 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5480 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5481 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5482 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5483 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5484 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5485 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5486 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005487
5488 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005489};
5490
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005491/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5492 * similar laptops (adapted from Fujitsu init verbs).
5493 */
5494static struct hda_verb alc260_acer_init_verbs[] = {
5495 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5496 * the headphone jack. Turn this on and rely on the standard mute
5497 * methods whenever the user wants to turn these outputs off.
5498 */
5499 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5500 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5501 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5502 /* Internal speaker/Headphone jack is connected to Line-out pin */
5503 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5504 /* Internal microphone/Mic jack is connected to Mic1 pin */
5505 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5506 /* Line In jack is connected to Line1 pin */
5507 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005508 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5509 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005510 /* Ensure all other unused pins are disabled and muted. */
5511 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5512 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005513 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5514 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5515 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5516 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5517 /* Disable digital (SPDIF) pins */
5518 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5519 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5520
Kailang Yangea1fb292008-08-26 12:58:38 +02005521 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005522 * bus when acting as outputs.
5523 */
5524 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5525 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5526
5527 /* Start with output sum widgets muted and their output gains at min */
5528 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5529 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5530 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5531 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5532 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5533 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5534 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5535 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5536 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5537
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005538 /* Unmute Line-out pin widget amp left and right
5539 * (no equiv mixer ctrl)
5540 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005541 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005542 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5543 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005544 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5545 * inputs. If the pin mode is changed by the user the pin mode control
5546 * will take care of enabling the pin's input/output buffers as needed.
5547 * Therefore there's no need to enable the input buffer at this
5548 * stage.
5549 */
5550 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5551 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5552
5553 /* Mute capture amp left and right */
5554 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5555 /* Set ADC connection select to match default mixer setting - mic
5556 * (on mic1 pin)
5557 */
5558 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5559
5560 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005561 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005562 */
5563 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005564 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005565
5566 /* Mute all inputs to mixer widget (even unconnected ones) */
5567 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5568 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5569 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5571 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5572 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5573 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5574 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5575
5576 { }
5577};
5578
Michael Schwingencc959482009-02-22 18:58:45 +01005579/* Initialisation sequence for Maxdata Favorit 100XS
5580 * (adapted from Acer init verbs).
5581 */
5582static struct hda_verb alc260_favorit100_init_verbs[] = {
5583 /* GPIO 0 enables the output jack.
5584 * Turn this on and rely on the standard mute
5585 * methods whenever the user wants to turn these outputs off.
5586 */
5587 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5588 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5589 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5590 /* Line/Mic input jack is connected to Mic1 pin */
5591 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5592 /* Ensure all other unused pins are disabled and muted. */
5593 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5594 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5595 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5596 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5597 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5598 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5600 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5601 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5602 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5603 /* Disable digital (SPDIF) pins */
5604 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5605 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5606
5607 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5608 * bus when acting as outputs.
5609 */
5610 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5611 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5612
5613 /* Start with output sum widgets muted and their output gains at min */
5614 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5615 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5616 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5617 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5618 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5619 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5620 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5621 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5622 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5623
5624 /* Unmute Line-out pin widget amp left and right
5625 * (no equiv mixer ctrl)
5626 */
5627 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5628 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5629 * inputs. If the pin mode is changed by the user the pin mode control
5630 * will take care of enabling the pin's input/output buffers as needed.
5631 * Therefore there's no need to enable the input buffer at this
5632 * stage.
5633 */
5634 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5635
5636 /* Mute capture amp left and right */
5637 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5638 /* Set ADC connection select to match default mixer setting - mic
5639 * (on mic1 pin)
5640 */
5641 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5642
5643 /* Do similar with the second ADC: mute capture input amp and
5644 * set ADC connection to mic to match ALSA's default state.
5645 */
5646 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5647 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5648
5649 /* Mute all inputs to mixer widget (even unconnected ones) */
5650 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5651 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5652 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5653 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5654 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5655 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5656 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5658
5659 { }
5660};
5661
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005662static struct hda_verb alc260_will_verbs[] = {
5663 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5664 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5665 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5666 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5667 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5668 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5669 {}
5670};
5671
5672static struct hda_verb alc260_replacer_672v_verbs[] = {
5673 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5674 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5675 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5676
5677 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5678 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5679 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5680
5681 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5682 {}
5683};
5684
5685/* toggle speaker-output according to the hp-jack state */
5686static void alc260_replacer_672v_automute(struct hda_codec *codec)
5687{
5688 unsigned int present;
5689
5690 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5691 present = snd_hda_codec_read(codec, 0x0f, 0,
5692 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5693 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005694 snd_hda_codec_write_cache(codec, 0x01, 0,
5695 AC_VERB_SET_GPIO_DATA, 1);
5696 snd_hda_codec_write_cache(codec, 0x0f, 0,
5697 AC_VERB_SET_PIN_WIDGET_CONTROL,
5698 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005699 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005700 snd_hda_codec_write_cache(codec, 0x01, 0,
5701 AC_VERB_SET_GPIO_DATA, 0);
5702 snd_hda_codec_write_cache(codec, 0x0f, 0,
5703 AC_VERB_SET_PIN_WIDGET_CONTROL,
5704 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005705 }
5706}
5707
5708static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5709 unsigned int res)
5710{
5711 if ((res >> 26) == ALC880_HP_EVENT)
5712 alc260_replacer_672v_automute(codec);
5713}
5714
Kailang Yang3f878302008-08-26 13:02:23 +02005715static struct hda_verb alc260_hp_dc7600_verbs[] = {
5716 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5717 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5718 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5719 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5720 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5721 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5722 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5723 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5724 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5725 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5726 {}
5727};
5728
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005729/* Test configuration for debugging, modelled after the ALC880 test
5730 * configuration.
5731 */
5732#ifdef CONFIG_SND_DEBUG
5733static hda_nid_t alc260_test_dac_nids[1] = {
5734 0x02,
5735};
5736static hda_nid_t alc260_test_adc_nids[2] = {
5737 0x04, 0x05,
5738};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005739/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005740 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005741 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005742 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005743static struct hda_input_mux alc260_test_capture_sources[2] = {
5744 {
5745 .num_items = 7,
5746 .items = {
5747 { "MIC1 pin", 0x0 },
5748 { "MIC2 pin", 0x1 },
5749 { "LINE1 pin", 0x2 },
5750 { "LINE2 pin", 0x3 },
5751 { "CD pin", 0x4 },
5752 { "LINE-OUT pin", 0x5 },
5753 { "HP-OUT pin", 0x6 },
5754 },
5755 },
5756 {
5757 .num_items = 8,
5758 .items = {
5759 { "MIC1 pin", 0x0 },
5760 { "MIC2 pin", 0x1 },
5761 { "LINE1 pin", 0x2 },
5762 { "LINE2 pin", 0x3 },
5763 { "CD pin", 0x4 },
5764 { "Mixer", 0x5 },
5765 { "LINE-OUT pin", 0x6 },
5766 { "HP-OUT pin", 0x7 },
5767 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005768 },
5769};
5770static struct snd_kcontrol_new alc260_test_mixer[] = {
5771 /* Output driver widgets */
5772 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5773 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5774 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5775 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5776 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5777 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5778
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005779 /* Modes for retasking pin widgets
5780 * Note: the ALC260 doesn't seem to act on requests to enable mic
5781 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5782 * mention this restriction. At this stage it's not clear whether
5783 * this behaviour is intentional or is a hardware bug in chip
5784 * revisions available at least up until early 2006. Therefore for
5785 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5786 * choices, but if it turns out that the lack of mic bias for these
5787 * NIDs is intentional we could change their modes from
5788 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5789 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005790 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5791 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5792 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5793 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5794 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5795 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5796
5797 /* Loopback mixer controls */
5798 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5799 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5800 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5801 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5802 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5803 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5804 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5805 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5806 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5807 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005808 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5809 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5810 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5811 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005812
5813 /* Controls for GPIO pins, assuming they are configured as outputs */
5814 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5815 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5816 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5817 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5818
Jonathan Woithe92621f12006-02-28 11:47:47 +01005819 /* Switches to allow the digital IO pins to be enabled. The datasheet
5820 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005821 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005822 */
5823 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5824 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5825
Jonathan Woithef8225f62008-01-08 12:16:54 +01005826 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5827 * this output to turn on an external amplifier.
5828 */
5829 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5830 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5831
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005832 { } /* end */
5833};
5834static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005835 /* Enable all GPIOs as outputs with an initial value of 0 */
5836 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5837 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5838 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5839
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005840 /* Enable retasking pins as output, initially without power amp */
5841 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5842 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5843 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5844 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5845 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5846 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5847
Jonathan Woithe92621f12006-02-28 11:47:47 +01005848 /* Disable digital (SPDIF) pins initially, but users can enable
5849 * them via a mixer switch. In the case of SPDIF-out, this initverb
5850 * payload also sets the generation to 0, output to be in "consumer"
5851 * PCM format, copyright asserted, no pre-emphasis and no validity
5852 * control.
5853 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005854 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5855 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5856
Kailang Yangea1fb292008-08-26 12:58:38 +02005857 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005858 * OUT1 sum bus when acting as an output.
5859 */
5860 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5861 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5862 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5863 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5864
5865 /* Start with output sum widgets muted and their output gains at min */
5866 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5868 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5869 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5870 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5871 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5872 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5873 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5874 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5875
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005876 /* Unmute retasking pin widget output buffers since the default
5877 * state appears to be output. As the pin mode is changed by the
5878 * user the pin mode control will take care of enabling the pin's
5879 * input/output buffers as needed.
5880 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005881 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5882 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5883 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5884 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5885 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5886 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5887 /* Also unmute the mono-out pin widget */
5888 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5889
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005890 /* Mute capture amp left and right */
5891 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005892 /* Set ADC connection select to match default mixer setting (mic1
5893 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005894 */
5895 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5896
5897 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005898 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005899 */
5900 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5901 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5902
5903 /* Mute all inputs to mixer widget (even unconnected ones) */
5904 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5905 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5906 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5907 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5908 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5909 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5910 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5911 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5912
5913 { }
5914};
5915#endif
5916
Takashi Iwai63300792008-01-24 15:31:36 +01005917#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5918#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005919
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005920#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5921#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5922
Kailang Yangdf694da2005-12-05 19:42:22 +01005923/*
5924 * for BIOS auto-configuration
5925 */
5926
5927static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005928 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005929{
5930 hda_nid_t nid_vol;
5931 unsigned long vol_val, sw_val;
5932 char name[32];
5933 int err;
5934
5935 if (nid >= 0x0f && nid < 0x11) {
5936 nid_vol = nid - 0x7;
5937 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5938 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5939 } else if (nid == 0x11) {
5940 nid_vol = nid - 0x7;
5941 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5942 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5943 } else if (nid >= 0x12 && nid <= 0x15) {
5944 nid_vol = 0x08;
5945 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5946 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5947 } else
5948 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005949
Takashi Iwai863b4512008-10-21 17:01:47 +02005950 if (!(*vol_bits & (1 << nid_vol))) {
5951 /* first control for the volume widget */
5952 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5953 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5954 if (err < 0)
5955 return err;
5956 *vol_bits |= (1 << nid_vol);
5957 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005958 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005959 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5960 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005961 return err;
5962 return 1;
5963}
5964
5965/* add playback controls from the parsed DAC table */
5966static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5967 const struct auto_pin_cfg *cfg)
5968{
5969 hda_nid_t nid;
5970 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005971 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005972
5973 spec->multiout.num_dacs = 1;
5974 spec->multiout.dac_nids = spec->private_dac_nids;
5975 spec->multiout.dac_nids[0] = 0x02;
5976
5977 nid = cfg->line_out_pins[0];
5978 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005979 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005980 if (err < 0)
5981 return err;
5982 }
5983
Takashi Iwai82bc9552006-03-21 11:24:42 +01005984 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005985 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005986 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005987 if (err < 0)
5988 return err;
5989 }
5990
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005991 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005992 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005993 err = alc260_add_playback_controls(spec, nid, "Headphone",
5994 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005995 if (err < 0)
5996 return err;
5997 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005998 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005999}
6000
6001/* create playback/capture controls for input pins */
6002static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
6003 const struct auto_pin_cfg *cfg)
6004{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006005 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006006 int i, err, idx;
6007
6008 for (i = 0; i < AUTO_PIN_LAST; i++) {
6009 if (cfg->input_pins[i] >= 0x12) {
6010 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01006011 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006012 auto_pin_cfg_labels[i], idx,
6013 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01006014 if (err < 0)
6015 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006016 imux->items[imux->num_items].label =
6017 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01006018 imux->items[imux->num_items].index = idx;
6019 imux->num_items++;
6020 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006021 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01006022 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01006023 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006024 auto_pin_cfg_labels[i], idx,
6025 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01006026 if (err < 0)
6027 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006028 imux->items[imux->num_items].label =
6029 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01006030 imux->items[imux->num_items].index = idx;
6031 imux->num_items++;
6032 }
6033 }
6034 return 0;
6035}
6036
6037static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6038 hda_nid_t nid, int pin_type,
6039 int sel_idx)
6040{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006041 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006042 /* need the manual connection? */
6043 if (nid >= 0x12) {
6044 int idx = nid - 0x12;
6045 snd_hda_codec_write(codec, idx + 0x0b, 0,
6046 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006047 }
6048}
6049
6050static void alc260_auto_init_multi_out(struct hda_codec *codec)
6051{
6052 struct alc_spec *spec = codec->spec;
6053 hda_nid_t nid;
6054
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006055 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006056 if (nid) {
6057 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6058 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6059 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006060
Takashi Iwai82bc9552006-03-21 11:24:42 +01006061 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006062 if (nid)
6063 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6064
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006065 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006066 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006067 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006068}
Kailang Yangdf694da2005-12-05 19:42:22 +01006069
6070#define ALC260_PIN_CD_NID 0x16
6071static void alc260_auto_init_analog_input(struct hda_codec *codec)
6072{
6073 struct alc_spec *spec = codec->spec;
6074 int i;
6075
6076 for (i = 0; i < AUTO_PIN_LAST; i++) {
6077 hda_nid_t nid = spec->autocfg.input_pins[i];
6078 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006079 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006080 if (nid != ALC260_PIN_CD_NID &&
6081 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006082 snd_hda_codec_write(codec, nid, 0,
6083 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006084 AMP_OUT_MUTE);
6085 }
6086 }
6087}
6088
6089/*
6090 * generic initialization of ADC, input mixers and output mixers
6091 */
6092static struct hda_verb alc260_volume_init_verbs[] = {
6093 /*
6094 * Unmute ADC0-1 and set the default input to mic-in
6095 */
6096 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6097 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6098 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6099 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006100
Kailang Yangdf694da2005-12-05 19:42:22 +01006101 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6102 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006103 * Note: PASD motherboards uses the Line In 2 as the input for
6104 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006105 */
6106 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006107 /* mute analog inputs */
6108 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6109 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6110 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6111 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6112 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006113
6114 /*
6115 * Set up output mixers (0x08 - 0x0a)
6116 */
6117 /* set vol=0 to output mixers */
6118 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6119 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6120 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6121 /* set up input amps for analog loopback */
6122 /* Amp Indices: DAC = 0, mixer = 1 */
6123 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6124 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6125 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6126 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6127 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6128 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006129
Kailang Yangdf694da2005-12-05 19:42:22 +01006130 { }
6131};
6132
6133static int alc260_parse_auto_config(struct hda_codec *codec)
6134{
6135 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006136 int err;
6137 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6138
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006139 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6140 alc260_ignore);
6141 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006142 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006143 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6144 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006145 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006146 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006147 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006148 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
6149 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006150 return err;
6151
6152 spec->multiout.max_channels = 2;
6153
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006154 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006155 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006156 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006157 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006158
Takashi Iwaid88897e2008-10-31 15:01:37 +01006159 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006160
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006161 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006162 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006163
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006164 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6165
Kailang Yangdf694da2005-12-05 19:42:22 +01006166 return 1;
6167}
6168
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006169/* additional initialization for auto-configuration model */
6170static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006171{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006172 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006173 alc260_auto_init_multi_out(codec);
6174 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006175 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006176 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006177}
6178
Takashi Iwaicb53c622007-08-10 17:21:45 +02006179#ifdef CONFIG_SND_HDA_POWER_SAVE
6180static struct hda_amp_list alc260_loopbacks[] = {
6181 { 0x07, HDA_INPUT, 0 },
6182 { 0x07, HDA_INPUT, 1 },
6183 { 0x07, HDA_INPUT, 2 },
6184 { 0x07, HDA_INPUT, 3 },
6185 { 0x07, HDA_INPUT, 4 },
6186 { } /* end */
6187};
6188#endif
6189
Kailang Yangdf694da2005-12-05 19:42:22 +01006190/*
6191 * ALC260 configurations
6192 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006193static const char *alc260_models[ALC260_MODEL_LAST] = {
6194 [ALC260_BASIC] = "basic",
6195 [ALC260_HP] = "hp",
6196 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006197 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006198 [ALC260_FUJITSU_S702X] = "fujitsu",
6199 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006200 [ALC260_WILL] = "will",
6201 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006202 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006203#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006204 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006205#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006206 [ALC260_AUTO] = "auto",
6207};
6208
6209static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006210 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006211 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006212 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006213 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006214 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006215 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006216 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006217 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006218 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6219 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6220 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6221 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6222 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6223 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6224 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6225 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6226 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006227 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006228 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006229 {}
6230};
6231
Kailang Yangdf694da2005-12-05 19:42:22 +01006232static struct alc_config_preset alc260_presets[] = {
6233 [ALC260_BASIC] = {
6234 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006235 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006236 .init_verbs = { alc260_init_verbs },
6237 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6238 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006239 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006240 .adc_nids = alc260_adc_nids,
6241 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6242 .channel_mode = alc260_modes,
6243 .input_mux = &alc260_capture_source,
6244 },
6245 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006246 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006247 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006248 .init_verbs = { alc260_init_verbs,
6249 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006250 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6251 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006252 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6253 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006254 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6255 .channel_mode = alc260_modes,
6256 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006257 .unsol_event = alc260_hp_unsol_event,
6258 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006259 },
Kailang Yang3f878302008-08-26 13:02:23 +02006260 [ALC260_HP_DC7600] = {
6261 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006262 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006263 .init_verbs = { alc260_init_verbs,
6264 alc260_hp_dc7600_verbs },
6265 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6266 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006267 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6268 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006269 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6270 .channel_mode = alc260_modes,
6271 .input_mux = &alc260_capture_source,
6272 .unsol_event = alc260_hp_3012_unsol_event,
6273 .init_hook = alc260_hp_3012_automute,
6274 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006275 [ALC260_HP_3013] = {
6276 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006277 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006278 .init_verbs = { alc260_hp_3013_init_verbs,
6279 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006280 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6281 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006282 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6283 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006284 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6285 .channel_mode = alc260_modes,
6286 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006287 .unsol_event = alc260_hp_3013_unsol_event,
6288 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006289 },
6290 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006291 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006292 .init_verbs = { alc260_fujitsu_init_verbs },
6293 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6294 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006295 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6296 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006297 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6298 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006299 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6300 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006301 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006302 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006303 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006304 .init_verbs = { alc260_acer_init_verbs },
6305 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6306 .dac_nids = alc260_dac_nids,
6307 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6308 .adc_nids = alc260_dual_adc_nids,
6309 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6310 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006311 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6312 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006313 },
Michael Schwingencc959482009-02-22 18:58:45 +01006314 [ALC260_FAVORIT100] = {
6315 .mixers = { alc260_favorit100_mixer },
6316 .init_verbs = { alc260_favorit100_init_verbs },
6317 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6318 .dac_nids = alc260_dac_nids,
6319 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6320 .adc_nids = alc260_dual_adc_nids,
6321 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6322 .channel_mode = alc260_modes,
6323 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6324 .input_mux = alc260_favorit100_capture_sources,
6325 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006326 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006327 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006328 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6329 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6330 .dac_nids = alc260_dac_nids,
6331 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6332 .adc_nids = alc260_adc_nids,
6333 .dig_out_nid = ALC260_DIGOUT_NID,
6334 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6335 .channel_mode = alc260_modes,
6336 .input_mux = &alc260_capture_source,
6337 },
6338 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006339 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006340 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6341 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6342 .dac_nids = alc260_dac_nids,
6343 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6344 .adc_nids = alc260_adc_nids,
6345 .dig_out_nid = ALC260_DIGOUT_NID,
6346 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6347 .channel_mode = alc260_modes,
6348 .input_mux = &alc260_capture_source,
6349 .unsol_event = alc260_replacer_672v_unsol_event,
6350 .init_hook = alc260_replacer_672v_automute,
6351 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006352#ifdef CONFIG_SND_DEBUG
6353 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006354 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006355 .init_verbs = { alc260_test_init_verbs },
6356 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6357 .dac_nids = alc260_test_dac_nids,
6358 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6359 .adc_nids = alc260_test_adc_nids,
6360 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6361 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006362 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6363 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006364 },
6365#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006366};
6367
Linus Torvalds1da177e2005-04-16 15:20:36 -07006368static int patch_alc260(struct hda_codec *codec)
6369{
6370 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006371 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006372
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006373 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006374 if (spec == NULL)
6375 return -ENOMEM;
6376
6377 codec->spec = spec;
6378
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006379 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6380 alc260_models,
6381 alc260_cfg_tbl);
6382 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006383 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006384 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006385 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006386 }
6387
Kailang Yangdf694da2005-12-05 19:42:22 +01006388 if (board_config == ALC260_AUTO) {
6389 /* automatic parse from the BIOS config */
6390 err = alc260_parse_auto_config(codec);
6391 if (err < 0) {
6392 alc_free(codec);
6393 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006394 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006395 printk(KERN_INFO
6396 "hda_codec: Cannot set up configuration "
6397 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006398 board_config = ALC260_BASIC;
6399 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006400 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006401
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006402 err = snd_hda_attach_beep_device(codec, 0x1);
6403 if (err < 0) {
6404 alc_free(codec);
6405 return err;
6406 }
6407
Kailang Yangdf694da2005-12-05 19:42:22 +01006408 if (board_config != ALC260_AUTO)
6409 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006410
Linus Torvalds1da177e2005-04-16 15:20:36 -07006411 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6412 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6413
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006414 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6415 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6416
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006417 if (!spec->adc_nids && spec->input_mux) {
6418 /* check whether NID 0x04 is valid */
6419 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006420 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006421 /* get type */
6422 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6423 spec->adc_nids = alc260_adc_nids_alt;
6424 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6425 } else {
6426 spec->adc_nids = alc260_adc_nids;
6427 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6428 }
6429 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006430 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006431 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006432
Takashi Iwai2134ea42008-01-10 16:53:55 +01006433 spec->vmaster_nid = 0x08;
6434
Linus Torvalds1da177e2005-04-16 15:20:36 -07006435 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006436 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006437 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006438#ifdef CONFIG_SND_HDA_POWER_SAVE
6439 if (!spec->loopback.amplist)
6440 spec->loopback.amplist = alc260_loopbacks;
6441#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006442 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006443
6444 return 0;
6445}
6446
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006447
Linus Torvalds1da177e2005-04-16 15:20:36 -07006448/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006449 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006450 *
6451 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6452 * configuration. Each pin widget can choose any input DACs and a mixer.
6453 * Each ADC is connected from a mixer of all inputs. This makes possible
6454 * 6-channel independent captures.
6455 *
6456 * In addition, an independent DAC for the multi-playback (not used in this
6457 * driver yet).
6458 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006459#define ALC882_DIGOUT_NID 0x06
6460#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006461#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6462#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6463#define ALC1200_DIGOUT_NID 0x10
6464
Linus Torvalds1da177e2005-04-16 15:20:36 -07006465
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006466static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006467 { 8, NULL }
6468};
6469
Takashi Iwai4953550a2009-06-30 15:28:30 +02006470/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006471static hda_nid_t alc882_dac_nids[4] = {
6472 /* front, rear, clfe, rear_surr */
6473 0x02, 0x03, 0x04, 0x05
6474};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006475#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006476
Takashi Iwai4953550a2009-06-30 15:28:30 +02006477/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006478#define alc882_adc_nids alc880_adc_nids
6479#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006480#define alc883_adc_nids alc882_adc_nids_alt
6481static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6482static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6483#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006484
Takashi Iwaie1406342008-02-11 18:32:32 +01006485static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6486static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006487#define alc883_capsrc_nids alc882_capsrc_nids_alt
6488static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6489#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006490
Linus Torvalds1da177e2005-04-16 15:20:36 -07006491/* input MUX */
6492/* FIXME: should be a matrix-type input source selection */
6493
6494static struct hda_input_mux alc882_capture_source = {
6495 .num_items = 4,
6496 .items = {
6497 { "Mic", 0x0 },
6498 { "Front Mic", 0x1 },
6499 { "Line", 0x2 },
6500 { "CD", 0x4 },
6501 },
6502};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006503
Takashi Iwai4953550a2009-06-30 15:28:30 +02006504#define alc883_capture_source alc882_capture_source
6505
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006506static struct hda_input_mux alc889_capture_source = {
6507 .num_items = 3,
6508 .items = {
6509 { "Front Mic", 0x0 },
6510 { "Mic", 0x3 },
6511 { "Line", 0x2 },
6512 },
6513};
6514
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006515static struct hda_input_mux mb5_capture_source = {
6516 .num_items = 3,
6517 .items = {
6518 { "Mic", 0x1 },
6519 { "Line", 0x2 },
6520 { "CD", 0x4 },
6521 },
6522};
6523
Takashi Iwai4953550a2009-06-30 15:28:30 +02006524static struct hda_input_mux alc883_3stack_6ch_intel = {
6525 .num_items = 4,
6526 .items = {
6527 { "Mic", 0x1 },
6528 { "Front Mic", 0x0 },
6529 { "Line", 0x2 },
6530 { "CD", 0x4 },
6531 },
6532};
6533
6534static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6535 .num_items = 2,
6536 .items = {
6537 { "Mic", 0x1 },
6538 { "Line", 0x2 },
6539 },
6540};
6541
6542static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6543 .num_items = 4,
6544 .items = {
6545 { "Mic", 0x0 },
6546 { "iMic", 0x1 },
6547 { "Line", 0x2 },
6548 { "CD", 0x4 },
6549 },
6550};
6551
6552static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6553 .num_items = 2,
6554 .items = {
6555 { "Mic", 0x0 },
6556 { "Int Mic", 0x1 },
6557 },
6558};
6559
6560static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6561 .num_items = 3,
6562 .items = {
6563 { "Mic", 0x0 },
6564 { "Front Mic", 0x1 },
6565 { "Line", 0x4 },
6566 },
6567};
6568
6569static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6570 .num_items = 2,
6571 .items = {
6572 { "Mic", 0x0 },
6573 { "Line", 0x2 },
6574 },
6575};
6576
6577static struct hda_input_mux alc889A_mb31_capture_source = {
6578 .num_items = 2,
6579 .items = {
6580 { "Mic", 0x0 },
6581 /* Front Mic (0x01) unused */
6582 { "Line", 0x2 },
6583 /* Line 2 (0x03) unused */
6584 /* CD (0x04) unsused? */
6585 },
6586};
6587
6588/*
6589 * 2ch mode
6590 */
6591static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6592 { 2, NULL }
6593};
6594
Kailang Yangdf694da2005-12-05 19:42:22 +01006595/*
Kailang Yang272a5272007-05-14 11:00:38 +02006596 * 2ch mode
6597 */
6598static struct hda_verb alc882_3ST_ch2_init[] = {
6599 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6600 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6601 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6602 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6603 { } /* end */
6604};
6605
6606/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006607 * 4ch mode
6608 */
6609static struct hda_verb alc882_3ST_ch4_init[] = {
6610 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6611 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6612 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6613 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6614 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6615 { } /* end */
6616};
6617
6618/*
Kailang Yang272a5272007-05-14 11:00:38 +02006619 * 6ch mode
6620 */
6621static struct hda_verb alc882_3ST_ch6_init[] = {
6622 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6623 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6624 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6625 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6626 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6627 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6628 { } /* end */
6629};
6630
Takashi Iwai4953550a2009-06-30 15:28:30 +02006631static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006632 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006633 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006634 { 6, alc882_3ST_ch6_init },
6635};
6636
Takashi Iwai4953550a2009-06-30 15:28:30 +02006637#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6638
Kailang Yang272a5272007-05-14 11:00:38 +02006639/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006640 * 6ch mode
6641 */
6642static struct hda_verb alc882_sixstack_ch6_init[] = {
6643 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6644 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6645 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6646 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6647 { } /* end */
6648};
6649
6650/*
6651 * 8ch mode
6652 */
6653static struct hda_verb alc882_sixstack_ch8_init[] = {
6654 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6655 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6656 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6657 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6658 { } /* end */
6659};
6660
6661static struct hda_channel_mode alc882_sixstack_modes[2] = {
6662 { 6, alc882_sixstack_ch6_init },
6663 { 8, alc882_sixstack_ch8_init },
6664};
6665
Takashi Iwai87350ad2007-08-16 18:19:38 +02006666/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006667 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006668 */
6669
6670/*
6671 * 2ch mode
6672 */
6673static struct hda_verb alc885_mbp_ch2_init[] = {
6674 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6675 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6676 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6677 { } /* end */
6678};
6679
6680/*
6681 * 6ch mode
6682 */
6683static struct hda_verb alc885_mbp_ch6_init[] = {
6684 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6685 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6686 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6687 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6688 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6689 { } /* end */
6690};
6691
6692static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6693 { 2, alc885_mbp_ch2_init },
6694 { 6, alc885_mbp_ch6_init },
6695};
6696
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006697/*
6698 * 2ch
6699 * Speakers/Woofer/HP = Front
6700 * LineIn = Input
6701 */
6702static struct hda_verb alc885_mb5_ch2_init[] = {
6703 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6704 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6705 { } /* end */
6706};
6707
6708/*
6709 * 6ch mode
6710 * Speakers/HP = Front
6711 * Woofer = LFE
6712 * LineIn = Surround
6713 */
6714static struct hda_verb alc885_mb5_ch6_init[] = {
6715 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6716 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6717 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6718 { } /* end */
6719};
6720
6721static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6722 { 2, alc885_mb5_ch2_init },
6723 { 6, alc885_mb5_ch6_init },
6724};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006725
Takashi Iwai4953550a2009-06-30 15:28:30 +02006726
6727/*
6728 * 2ch mode
6729 */
6730static struct hda_verb alc883_4ST_ch2_init[] = {
6731 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6732 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6733 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6734 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6735 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6736 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6737 { } /* end */
6738};
6739
6740/*
6741 * 4ch mode
6742 */
6743static struct hda_verb alc883_4ST_ch4_init[] = {
6744 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6745 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6746 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6747 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6748 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6749 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6750 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6751 { } /* end */
6752};
6753
6754/*
6755 * 6ch mode
6756 */
6757static struct hda_verb alc883_4ST_ch6_init[] = {
6758 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6759 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6760 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6761 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6762 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6763 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6764 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6765 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6766 { } /* end */
6767};
6768
6769/*
6770 * 8ch mode
6771 */
6772static struct hda_verb alc883_4ST_ch8_init[] = {
6773 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6774 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6775 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6776 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6777 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6778 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6779 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6780 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6781 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6782 { } /* end */
6783};
6784
6785static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6786 { 2, alc883_4ST_ch2_init },
6787 { 4, alc883_4ST_ch4_init },
6788 { 6, alc883_4ST_ch6_init },
6789 { 8, alc883_4ST_ch8_init },
6790};
6791
6792
6793/*
6794 * 2ch mode
6795 */
6796static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6797 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6798 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6799 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6800 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6801 { } /* end */
6802};
6803
6804/*
6805 * 4ch mode
6806 */
6807static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6808 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6809 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6810 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6811 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6812 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6813 { } /* end */
6814};
6815
6816/*
6817 * 6ch mode
6818 */
6819static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6820 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6821 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6822 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6823 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6824 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6825 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6826 { } /* end */
6827};
6828
6829static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6830 { 2, alc883_3ST_ch2_intel_init },
6831 { 4, alc883_3ST_ch4_intel_init },
6832 { 6, alc883_3ST_ch6_intel_init },
6833};
6834
6835/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006836 * 2ch mode
6837 */
6838static struct hda_verb alc889_ch2_intel_init[] = {
6839 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6840 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6841 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6842 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6843 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6844 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6845 { } /* end */
6846};
6847
6848/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006849 * 6ch mode
6850 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006851static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006852 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6853 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6854 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6855 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6856 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006857 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6858 { } /* end */
6859};
6860
6861/*
6862 * 8ch mode
6863 */
6864static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006865 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6866 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6867 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6868 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6869 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006870 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6871 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006872 { } /* end */
6873};
6874
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006875static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6876 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006877 { 6, alc889_ch6_intel_init },
6878 { 8, alc889_ch8_intel_init },
6879};
6880
6881/*
6882 * 6ch mode
6883 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006884static struct hda_verb alc883_sixstack_ch6_init[] = {
6885 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6886 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6887 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6888 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6889 { } /* end */
6890};
6891
6892/*
6893 * 8ch mode
6894 */
6895static struct hda_verb alc883_sixstack_ch8_init[] = {
6896 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6897 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6898 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6899 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6900 { } /* end */
6901};
6902
6903static struct hda_channel_mode alc883_sixstack_modes[2] = {
6904 { 6, alc883_sixstack_ch6_init },
6905 { 8, alc883_sixstack_ch8_init },
6906};
6907
6908
Linus Torvalds1da177e2005-04-16 15:20:36 -07006909/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6910 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6911 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006912static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006913 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006914 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006915 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006916 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006917 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6918 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006919 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6920 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006921 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006922 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006923 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6924 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6925 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6926 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6927 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6928 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006929 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006930 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6931 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006932 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006933 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006934 { } /* end */
6935};
6936
Takashi Iwai87350ad2007-08-16 18:19:38 +02006937static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006938 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6939 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6940 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6941 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6942 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6943 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006944 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6945 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006946 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006947 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6948 { } /* end */
6949};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006950
6951static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006952 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6953 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6954 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6955 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6956 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6957 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6958 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6959 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006960 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6961 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6962 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6963 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6964 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6965 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6966 { } /* end */
6967};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006968
Kailang Yangbdd148a2007-05-08 15:19:08 +02006969static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6970 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6971 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6972 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6973 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6974 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6975 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6977 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6978 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006979 { } /* end */
6980};
6981
Kailang Yang272a5272007-05-14 11:00:38 +02006982static struct snd_kcontrol_new alc882_targa_mixer[] = {
6983 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6984 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6985 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6986 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6987 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6988 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6989 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6990 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6991 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006992 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006993 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6994 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006995 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006996 { } /* end */
6997};
6998
6999/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7000 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7001 */
7002static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7003 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7004 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7006 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 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("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7012 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7013 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007015 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007016 { } /* end */
7017};
7018
Takashi Iwai914759b2007-09-06 14:52:04 +02007019static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7020 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7021 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7022 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7023 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7024 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7025 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7026 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7027 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7028 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7029 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007030 { } /* end */
7031};
7032
Kailang Yangdf694da2005-12-05 19:42:22 +01007033static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7034 {
7035 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7036 .name = "Channel Mode",
7037 .info = alc_ch_mode_info,
7038 .get = alc_ch_mode_get,
7039 .put = alc_ch_mode_put,
7040 },
7041 { } /* end */
7042};
7043
Takashi Iwai4953550a2009-06-30 15:28:30 +02007044static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007045 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7048 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007049 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007050 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7051 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7052 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007053 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007054 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7055 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7056 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007057 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007058 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7059 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7060 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007061
Takashi Iwaicb638122009-07-03 10:56:10 +02007062 /* mute analog input loopbacks */
7063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7067 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7068
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007069 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007070 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007071 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007072 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007073 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007074 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007075 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007076 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007077 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007078 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007079 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007080 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007081 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007082 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007083 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007084 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007085 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007086 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007087 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7088 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007089 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007090 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7091 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007092 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007093 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7094 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7095 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7096 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7097 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007098 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007099 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007100
7101 /* FIXME: use matrix-type input source selection */
7102 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007103 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7105 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7106 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7107 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007108 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7112 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007113 /* ADC2: mute amp left and right */
7114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007115 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007116 /* ADC3: mute amp left and right */
7117 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007118 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007119
7120 { }
7121};
7122
Takashi Iwai4953550a2009-06-30 15:28:30 +02007123static struct hda_verb alc882_adc1_init_verbs[] = {
7124 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7125 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7126 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7127 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7128 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7129 /* ADC1: mute amp left and right */
7130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7131 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7132 { }
7133};
7134
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007135static struct hda_verb alc882_eapd_verbs[] = {
7136 /* change to EAPD mode */
7137 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007138 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007139 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007140};
7141
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007142static struct hda_verb alc889_eapd_verbs[] = {
7143 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7144 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7145 { }
7146};
7147
Wu Fengguang6732bd02009-07-30 09:19:14 +02007148static struct hda_verb alc_hp15_unsol_verbs[] = {
7149 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7150 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7151 {}
7152};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007153
7154static struct hda_verb alc885_init_verbs[] = {
7155 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7156 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7157 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7158 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7159 /* Rear mixer */
7160 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7161 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7162 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7163 /* CLFE mixer */
7164 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7165 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7166 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7167 /* Side mixer */
7168 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7169 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7170 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7171
7172 /* mute analog input loopbacks */
7173 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7174 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7175 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7176
7177 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007178 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007179 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7180 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7181 /* Front Pin: output 0 (0x0c) */
7182 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7183 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7184 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7185 /* Rear Pin: output 1 (0x0d) */
7186 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7187 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7188 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7189 /* CLFE Pin: output 2 (0x0e) */
7190 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7191 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7192 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7193 /* Side Pin: output 3 (0x0f) */
7194 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7195 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7196 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7197 /* Mic (rear) pin: input vref at 80% */
7198 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7199 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7200 /* Front Mic pin: input vref at 80% */
7201 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7202 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7203 /* Line In pin: input */
7204 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7205 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7206
7207 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7208 /* Input mixer1 */
7209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7212 /* Input mixer2 */
7213 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7214 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7215 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7216 /* Input mixer3 */
7217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7220 /* ADC2: mute amp left and right */
7221 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7222 /* ADC3: mute amp left and right */
7223 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7224
7225 { }
7226};
7227
7228static struct hda_verb alc885_init_input_verbs[] = {
7229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7231 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7232 { }
7233};
7234
7235
7236/* Unmute Selector 24h and set the default input to front mic */
7237static struct hda_verb alc889_init_input_verbs[] = {
7238 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7239 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7240 { }
7241};
7242
7243
Takashi Iwai4953550a2009-06-30 15:28:30 +02007244#define alc883_init_verbs alc882_base_init_verbs
7245
Tobin Davis9102cd12006-12-15 10:02:12 +01007246/* Mac Pro test */
7247static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7248 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7249 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7250 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7251 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7252 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007253 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01007254 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
7255 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007256 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007257 { } /* end */
7258};
7259
7260static struct hda_verb alc882_macpro_init_verbs[] = {
7261 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7262 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7263 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7264 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7265 /* Front Pin: output 0 (0x0c) */
7266 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7267 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7268 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7269 /* Front Mic pin: input vref at 80% */
7270 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7271 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7272 /* Speaker: output */
7273 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7275 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7276 /* Headphone output (output 0 - 0x0c) */
7277 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7278 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7279 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7280
7281 /* FIXME: use matrix-type input source selection */
7282 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7283 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7284 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7285 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7287 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7288 /* Input mixer2 */
7289 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7290 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7291 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7292 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7293 /* Input mixer3 */
7294 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7295 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7296 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7297 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7298 /* ADC1: mute amp left and right */
7299 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7300 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7301 /* ADC2: mute amp left and right */
7302 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7303 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7304 /* ADC3: mute amp left and right */
7305 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7306 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7307
7308 { }
7309};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007310
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007311/* Macbook 5,1 */
7312static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007313 /* DACs */
7314 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7315 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7316 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7317 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007318 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007319 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7320 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7321 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007322 /* Surround mixer */
7323 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7324 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7325 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7326 /* LFE mixer */
7327 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7328 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7329 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7330 /* HP mixer */
7331 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7332 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7333 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7334 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007335 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7336 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007337 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7338 /* LFE Pin (0x0e) */
7339 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7340 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7341 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7342 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007343 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7344 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007345 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007346 /* Front Mic pin: input vref at 80% */
7347 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7348 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7349 /* Line In pin */
7350 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7351 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7352
7353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7354 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7355 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7356 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7357 { }
7358};
7359
Takashi Iwai87350ad2007-08-16 18:19:38 +02007360/* Macbook Pro rev3 */
7361static struct hda_verb alc885_mbp3_init_verbs[] = {
7362 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7364 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7366 /* Rear mixer */
7367 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7368 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7369 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7370 /* Front Pin: output 0 (0x0c) */
7371 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7372 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7373 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7374 /* HP Pin: output 0 (0x0d) */
7375 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7376 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7377 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7378 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7379 /* Mic (rear) pin: input vref at 80% */
7380 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7381 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7382 /* Front Mic pin: input vref at 80% */
7383 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7384 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7385 /* Line In pin: use output 1 when in LineOut mode */
7386 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7387 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7388 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7389
7390 /* FIXME: use matrix-type input source selection */
7391 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7392 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7393 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7394 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7395 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7396 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7397 /* Input mixer2 */
7398 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7399 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7400 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7401 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7402 /* Input mixer3 */
7403 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7404 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7405 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7406 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7407 /* ADC1: mute amp left and right */
7408 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7409 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7410 /* ADC2: mute amp left and right */
7411 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7412 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7413 /* ADC3: mute amp left and right */
7414 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7415 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7416
7417 { }
7418};
7419
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007420/* iMac 24 mixer. */
7421static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7422 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7423 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7424 { } /* end */
7425};
7426
7427/* iMac 24 init verbs. */
7428static struct hda_verb alc885_imac24_init_verbs[] = {
7429 /* Internal speakers: output 0 (0x0c) */
7430 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7431 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7432 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7433 /* Internal speakers: output 0 (0x0c) */
7434 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7435 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7436 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7437 /* Headphone: output 0 (0x0c) */
7438 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7439 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7440 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7441 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7442 /* Front Mic: input vref at 80% */
7443 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7444 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7445 { }
7446};
7447
7448/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007449static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007450{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007451 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007452
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007453 spec->autocfg.hp_pins[0] = 0x14;
7454 spec->autocfg.speaker_pins[0] = 0x18;
7455 spec->autocfg.speaker_pins[1] = 0x1a;
7456 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007457}
7458
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007459static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007460{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007461 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007462
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007463 spec->autocfg.hp_pins[0] = 0x15;
7464 spec->autocfg.speaker_pins[0] = 0x14;
7465 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02007466}
7467
7468
Kailang Yang272a5272007-05-14 11:00:38 +02007469static struct hda_verb alc882_targa_verbs[] = {
7470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7472
7473 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7474 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007475
Kailang Yang272a5272007-05-14 11:00:38 +02007476 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7477 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7478 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7479
7480 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007481 { } /* end */
7482};
7483
7484/* toggle speaker-output according to the hp-jack state */
7485static void alc882_targa_automute(struct hda_codec *codec)
7486{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007487 struct alc_spec *spec = codec->spec;
7488 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007489 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007490 spec->jack_present ? 1 : 3);
7491}
7492
7493static void alc882_targa_init_hook(struct hda_codec *codec)
7494{
7495 struct alc_spec *spec = codec->spec;
7496
7497 spec->autocfg.hp_pins[0] = 0x14;
7498 spec->autocfg.speaker_pins[0] = 0x1b;
7499 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007500}
7501
7502static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7503{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007504 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007505 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007506}
7507
7508static struct hda_verb alc882_asus_a7j_verbs[] = {
7509 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7511
7512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7513 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7514 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007515
Kailang Yang272a5272007-05-14 11:00:38 +02007516 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7517 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7518 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7519
7520 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7521 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7522 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7523 { } /* end */
7524};
7525
Takashi Iwai914759b2007-09-06 14:52:04 +02007526static struct hda_verb alc882_asus_a7m_verbs[] = {
7527 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7529
7530 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7531 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7532 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007533
Takashi Iwai914759b2007-09-06 14:52:04 +02007534 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7535 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7536 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7537
7538 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7539 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7540 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7541 { } /* end */
7542};
7543
Tobin Davis9102cd12006-12-15 10:02:12 +01007544static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7545{
7546 unsigned int gpiostate, gpiomask, gpiodir;
7547
7548 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7549 AC_VERB_GET_GPIO_DATA, 0);
7550
7551 if (!muted)
7552 gpiostate |= (1 << pin);
7553 else
7554 gpiostate &= ~(1 << pin);
7555
7556 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7557 AC_VERB_GET_GPIO_MASK, 0);
7558 gpiomask |= (1 << pin);
7559
7560 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7561 AC_VERB_GET_GPIO_DIRECTION, 0);
7562 gpiodir |= (1 << pin);
7563
7564
7565 snd_hda_codec_write(codec, codec->afg, 0,
7566 AC_VERB_SET_GPIO_MASK, gpiomask);
7567 snd_hda_codec_write(codec, codec->afg, 0,
7568 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7569
7570 msleep(1);
7571
7572 snd_hda_codec_write(codec, codec->afg, 0,
7573 AC_VERB_SET_GPIO_DATA, gpiostate);
7574}
7575
Takashi Iwai7debbe52007-08-16 15:01:03 +02007576/* set up GPIO at initialization */
7577static void alc885_macpro_init_hook(struct hda_codec *codec)
7578{
7579 alc882_gpio_mute(codec, 0, 0);
7580 alc882_gpio_mute(codec, 1, 0);
7581}
7582
7583/* set up GPIO and update auto-muting at initialization */
7584static void alc885_imac24_init_hook(struct hda_codec *codec)
7585{
7586 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007587 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007588}
7589
Kailang Yangdf694da2005-12-05 19:42:22 +01007590/*
7591 * generic initialization of ADC, input mixers and output mixers
7592 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007593static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007594 /*
7595 * Unmute ADC0-2 and set the default input to mic-in
7596 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007597 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7598 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7599 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7600 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7601
Takashi Iwaicb53c622007-08-10 17:21:45 +02007602 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007603 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007604 * Note: PASD motherboards uses the Line In 2 as the input for
7605 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007606 */
7607 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007608 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7609 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7610 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7611 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7612 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007613
7614 /*
7615 * Set up output mixers (0x0c - 0x0f)
7616 */
7617 /* set vol=0 to output mixers */
7618 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7619 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7620 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7621 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7622 /* set up input amps for analog loopback */
7623 /* Amp Indices: DAC = 0, mixer = 1 */
7624 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7625 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7626 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7627 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7628 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7629 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7630 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7631 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7632 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7633 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7634
7635 /* FIXME: use matrix-type input source selection */
7636 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007637 /* Input mixer2 */
7638 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7639 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7640 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7641 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7642 /* Input mixer3 */
7643 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7644 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7645 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7646 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7647
7648 { }
7649};
7650
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007651/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7652static struct hda_verb alc889A_mb31_ch2_init[] = {
7653 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7654 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7655 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7656 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7657 { } /* end */
7658};
7659
7660/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7661static struct hda_verb alc889A_mb31_ch4_init[] = {
7662 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7663 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7664 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7665 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7666 { } /* end */
7667};
7668
7669/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7670static struct hda_verb alc889A_mb31_ch5_init[] = {
7671 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7672 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7673 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7674 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7675 { } /* end */
7676};
7677
7678/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7679static struct hda_verb alc889A_mb31_ch6_init[] = {
7680 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7681 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7682 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7683 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7684 { } /* end */
7685};
7686
7687static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7688 { 2, alc889A_mb31_ch2_init },
7689 { 4, alc889A_mb31_ch4_init },
7690 { 5, alc889A_mb31_ch5_init },
7691 { 6, alc889A_mb31_ch6_init },
7692};
7693
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007694static struct hda_verb alc883_medion_eapd_verbs[] = {
7695 /* eanable EAPD on medion laptop */
7696 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7697 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7698 { }
7699};
7700
Takashi Iwai4953550a2009-06-30 15:28:30 +02007701#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007702
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007703static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7704 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7705 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7706 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7707 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7708 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7709 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7710 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7711 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7712 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7713 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7714 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7715 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7716 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007717 { } /* end */
7718};
7719
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007720static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007721 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7722 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7723 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7724 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7725 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7726 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7727 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7728 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7729 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7730 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007731 { } /* end */
7732};
7733
Jiang zhefb97dc62008-03-06 11:07:11 +01007734static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7735 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7736 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7737 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7738 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7739 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7740 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7741 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7742 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7743 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7744 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007745 { } /* end */
7746};
7747
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007748static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7749 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7750 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7751 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7752 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7753 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7754 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7755 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7756 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007757 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007758 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7759 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007760 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007761 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007762 { } /* end */
7763};
7764
7765static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7766 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7767 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7768 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7769 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7770 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7771 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7772 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7773 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7774 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7775 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7776 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7777 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7778 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7779 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007780 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007781 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7782 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007783 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007784 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007785 { } /* end */
7786};
7787
Jiang zhe17bba1b2008-06-04 12:11:07 +02007788static struct snd_kcontrol_new alc883_3ST_6ch_intel_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("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7792 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7793 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7794 HDA_OUTPUT),
7795 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7796 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7797 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7798 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7799 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7800 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7801 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7802 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7804 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7805 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7806 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7807 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7808 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007809 { } /* end */
7810};
7811
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007812static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7813 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7814 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7815 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7816 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7817 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7818 HDA_OUTPUT),
7819 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7820 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7821 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7822 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7823 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7824 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7825 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7826 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7827 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7828 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7829 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7830 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7831 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7832 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7833 { } /* end */
7834};
7835
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007836static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007837 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007838 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007839 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007840 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007841 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7842 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007843 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7844 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007845 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7846 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7847 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7848 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7849 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7850 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007851 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007852 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7853 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007854 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007855 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007856 { } /* end */
7857};
7858
Sasha Alexandrc2592492009-06-16 14:52:54 -04007859static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007860 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7861 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7862 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7863 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7864 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7865 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7866 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7867 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7868 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7869 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7870 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7871 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7872 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7873 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007874 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007875 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007876 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007877};
Kailang Yangccc656c2006-10-17 12:32:26 +02007878
Sasha Alexandrc2592492009-06-16 14:52:54 -04007879static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007880 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7881 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7882 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7883 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7884 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7885 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007886 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007887 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007888 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7889 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7890 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007891 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007892};
Kailang Yangccc656c2006-10-17 12:32:26 +02007893
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007894static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7895 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7896 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007897 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7898 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007899 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7900 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7901 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7902 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007903 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007904};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007905
Kailang Yang272a5272007-05-14 11:00:38 +02007906static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7907 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7908 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7909 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7910 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7911 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7914 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7915 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007916 { } /* end */
7917};
7918
7919static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7920 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7921 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7922 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7923 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7924 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7925 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7926 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7927 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7928 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007929 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007930};
Kailang Yang272a5272007-05-14 11:00:38 +02007931
Tobin Davis2880a862007-08-07 11:50:26 +02007932static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007933 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7934 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007935 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007936 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7937 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007938 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7939 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7940 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007941 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007942};
Tobin Davis2880a862007-08-07 11:50:26 +02007943
Tony Vroond2fd4b02009-06-21 00:40:10 +01007944static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
7945 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7946 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7947 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7948 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01007949 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7950 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01007951 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7952 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7954 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7956 { } /* end */
7957};
7958
Kailang Yange2757d52008-08-26 13:17:46 +02007959static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7960 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7961 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7962 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7963 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7964 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7965 0x0d, 1, 0x0, HDA_OUTPUT),
7966 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7967 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7968 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7969 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7970 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007971 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7972 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7973 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7974 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7975 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7976 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7977 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7978 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7979 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7980 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007981 { } /* end */
7982};
7983
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007984static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
7985 /* Output mixers */
7986 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7987 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7988 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7989 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7990 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
7991 HDA_OUTPUT),
7992 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
7993 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
7994 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
7995 /* Output switches */
7996 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
7997 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
7998 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
7999 /* Boost mixers */
8000 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8001 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8002 /* Input mixers */
8003 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8004 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8005 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8006 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8007 { } /* end */
8008};
8009
Guido Günther3e1647c2009-06-05 00:47:26 +02008010static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8011 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8012 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8013 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8014 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8015 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8016 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8017 { } /* end */
8018};
8019
Kailang Yange2757d52008-08-26 13:17:46 +02008020static struct hda_bind_ctls alc883_bind_cap_vol = {
8021 .ops = &snd_hda_bind_vol,
8022 .values = {
8023 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8024 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8025 0
8026 },
8027};
8028
8029static struct hda_bind_ctls alc883_bind_cap_switch = {
8030 .ops = &snd_hda_bind_sw,
8031 .values = {
8032 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8033 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8034 0
8035 },
8036};
8037
8038static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8039 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8040 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8041 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8042 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8043 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8045 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8046 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008047 { } /* end */
8048};
8049
8050static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008051 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8052 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8053 {
8054 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8055 /* .name = "Capture Source", */
8056 .name = "Input Source",
8057 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008058 .info = alc_mux_enum_info,
8059 .get = alc_mux_enum_get,
8060 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008061 },
8062 { } /* end */
8063};
8064
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008065static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8066 {
8067 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8068 .name = "Channel Mode",
8069 .info = alc_ch_mode_info,
8070 .get = alc_ch_mode_get,
8071 .put = alc_ch_mode_put,
8072 },
8073 { } /* end */
8074};
8075
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008076/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008077static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008078{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008079 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008080
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008081 spec->autocfg.hp_pins[0] = 0x15;
8082 spec->autocfg.speaker_pins[0] = 0x14;
8083 spec->autocfg.speaker_pins[1] = 0x17;
8084 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008085}
8086
8087/* auto-toggle front mic */
8088/*
8089static void alc883_mitac_mic_automute(struct hda_codec *codec)
8090{
8091 unsigned int present;
8092 unsigned char bits;
8093
8094 present = snd_hda_codec_read(codec, 0x18, 0,
8095 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8096 bits = present ? HDA_AMP_MUTE : 0;
8097 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8098}
8099*/
8100
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008101static struct hda_verb alc883_mitac_verbs[] = {
8102 /* HP */
8103 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8104 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8105 /* Subwoofer */
8106 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8107 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8108
8109 /* enable unsolicited event */
8110 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8111 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8112
8113 { } /* end */
8114};
8115
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008116static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008117 /* HP */
8118 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8119 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8120 /* Int speaker */
8121 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8122 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8123
8124 /* enable unsolicited event */
8125 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008126 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008127
8128 { } /* end */
8129};
8130
Jiang zhefb97dc62008-03-06 11:07:11 +01008131static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8132 /* HP */
8133 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8134 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8135 /* Subwoofer */
8136 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8137 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8138
8139 /* enable unsolicited event */
8140 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8141
8142 { } /* end */
8143};
8144
Sasha Alexandrc2592492009-06-16 14:52:54 -04008145static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008146 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8147 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8148
8149 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8150 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008151
David Heidelberger64a8be72009-06-08 16:15:18 +02008152/* Connect Line-Out side jack (SPDIF) to Side */
8153 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8154 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8155 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8156/* Connect Mic jack to CLFE */
8157 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8158 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8159 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8160/* Connect Line-in jack to Surround */
8161 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8162 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8163 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8164/* Connect HP out jack to Front */
8165 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8166 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8167 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008168
8169 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008170
8171 { } /* end */
8172};
8173
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008174static struct hda_verb alc883_lenovo_101e_verbs[] = {
8175 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8176 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8177 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8178 { } /* end */
8179};
8180
Kailang Yang272a5272007-05-14 11:00:38 +02008181static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8182 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8183 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8184 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8185 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8186 { } /* end */
8187};
8188
8189static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8190 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8191 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8192 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8193 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8194 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8195 { } /* end */
8196};
8197
Kailang Yang189609a2007-08-20 11:31:23 +02008198static struct hda_verb alc883_haier_w66_verbs[] = {
8199 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8200 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8201
8202 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8203
8204 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8205 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8206 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8207 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8208 { } /* end */
8209};
8210
Kailang Yange2757d52008-08-26 13:17:46 +02008211static struct hda_verb alc888_lenovo_sky_verbs[] = {
8212 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8213 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8214 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8215 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8216 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8217 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8218 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8219 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8220 { } /* end */
8221};
8222
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008223static struct hda_verb alc888_6st_dell_verbs[] = {
8224 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8225 { }
8226};
8227
Guido Günther3e1647c2009-06-05 00:47:26 +02008228static struct hda_verb alc883_vaiott_verbs[] = {
8229 /* HP */
8230 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8231 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8232
8233 /* enable unsolicited event */
8234 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8235
8236 { } /* end */
8237};
8238
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008239static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008240{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008241 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008242
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008243 spec->autocfg.hp_pins[0] = 0x1b;
8244 spec->autocfg.speaker_pins[0] = 0x14;
8245 spec->autocfg.speaker_pins[1] = 0x16;
8246 spec->autocfg.speaker_pins[2] = 0x18;
8247 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008248}
8249
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008250static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008251 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008252 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8253 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008254 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008255 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008256};
8257
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008258/*
8259 * 2ch mode
8260 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008261static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008262 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8263 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8264 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8265 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008266 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008267};
8268
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008269/*
8270 * 4ch mode
8271 */
8272static struct hda_verb alc888_3st_hp_4ch_init[] = {
8273 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8274 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8275 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8276 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8277 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8278 { } /* end */
8279};
8280
8281/*
8282 * 6ch mode
8283 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008284static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008285 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8286 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008287 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008288 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8289 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008290 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8291 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008292};
8293
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008294static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008295 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008296 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008297 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008298};
8299
Kailang Yang272a5272007-05-14 11:00:38 +02008300/* toggle front-jack and RCA according to the hp-jack state */
8301static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8302{
8303 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008304
Kailang Yang272a5272007-05-14 11:00:38 +02008305 present = snd_hda_codec_read(codec, 0x1b, 0,
8306 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008307 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8308 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8309 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8310 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008311}
8312
8313/* toggle RCA according to the front-jack state */
8314static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8315{
8316 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008317
Kailang Yang272a5272007-05-14 11:00:38 +02008318 present = snd_hda_codec_read(codec, 0x14, 0,
8319 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008320 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8321 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008322}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008323
Kailang Yang272a5272007-05-14 11:00:38 +02008324static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8325 unsigned int res)
8326{
8327 if ((res >> 26) == ALC880_HP_EVENT)
8328 alc888_lenovo_ms7195_front_automute(codec);
8329 if ((res >> 26) == ALC880_FRONT_EVENT)
8330 alc888_lenovo_ms7195_rca_automute(codec);
8331}
8332
8333static struct hda_verb alc883_medion_md2_verbs[] = {
8334 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8335 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8336
8337 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8338
8339 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8340 { } /* end */
8341};
8342
8343/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008344static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008345{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008346 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008347
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008348 spec->autocfg.hp_pins[0] = 0x14;
8349 spec->autocfg.speaker_pins[0] = 0x15;
8350 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008351}
8352
Kailang Yangccc656c2006-10-17 12:32:26 +02008353/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008354#define alc883_targa_init_hook alc882_targa_init_hook
8355#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008356
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008357static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8358{
8359 unsigned int present;
8360
8361 present = snd_hda_codec_read(codec, 0x18, 0,
8362 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8363 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8364 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8365}
8366
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008367static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008368{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008369 struct alc_spec *spec = codec->spec;
8370
8371 spec->autocfg.hp_pins[0] = 0x15;
8372 spec->autocfg.speaker_pins[0] = 0x14;
8373 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008374 alc883_clevo_m720_mic_automute(codec);
8375}
8376
8377static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008378 unsigned int res)
8379{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008380 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008381 case ALC880_MIC_EVENT:
8382 alc883_clevo_m720_mic_automute(codec);
8383 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008384 default:
8385 alc_automute_amp_unsol_event(codec, res);
8386 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008387 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008388}
8389
Jiang zhefb97dc62008-03-06 11:07:11 +01008390/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008391static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008392{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008393 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008394
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008395 spec->autocfg.hp_pins[0] = 0x14;
8396 spec->autocfg.speaker_pins[0] = 0x15;
8397 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008398}
8399
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008400static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008401{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008402 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008403
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008404 spec->autocfg.hp_pins[0] = 0x1b;
8405 spec->autocfg.speaker_pins[0] = 0x14;
8406 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008407}
8408
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008409static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8410{
8411 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008412 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008413
David Heidelberger64a8be72009-06-08 16:15:18 +02008414 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8415 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008416 bits = present ? HDA_AMP_MUTE : 0;
8417 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8418 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008419}
8420
8421static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8422{
8423 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008424 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008425
8426 present = snd_hda_codec_read(codec, 0x1b, 0,
8427 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008428 bits = present ? HDA_AMP_MUTE : 0;
8429 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8430 HDA_AMP_MUTE, bits);
8431 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8432 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008433}
8434
8435static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8436 unsigned int res)
8437{
8438 if ((res >> 26) == ALC880_HP_EVENT)
8439 alc883_lenovo_101e_all_automute(codec);
8440 if ((res >> 26) == ALC880_FRONT_EVENT)
8441 alc883_lenovo_101e_ispeaker_automute(codec);
8442}
8443
Takashi Iwai676a9b52007-08-16 15:23:35 +02008444/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008445static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008446{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008447 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008448
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008449 spec->autocfg.hp_pins[0] = 0x14;
8450 spec->autocfg.speaker_pins[0] = 0x15;
8451 spec->autocfg.speaker_pins[1] = 0x16;
8452 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008453}
8454
Kailang Yangd1a991a2007-08-15 16:21:59 +02008455static struct hda_verb alc883_acer_eapd_verbs[] = {
8456 /* HP Pin: output 0 (0x0c) */
8457 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8458 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8459 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8460 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8462 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008463 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008464 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8465 /* eanable EAPD on medion laptop */
8466 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8467 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008468 /* enable unsolicited event */
8469 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008470 { }
8471};
8472
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008473static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008474{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008475 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008476
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008477 spec->autocfg.hp_pins[0] = 0x1b;
8478 spec->autocfg.speaker_pins[0] = 0x14;
8479 spec->autocfg.speaker_pins[1] = 0x15;
8480 spec->autocfg.speaker_pins[2] = 0x16;
8481 spec->autocfg.speaker_pins[3] = 0x17;
8482 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008483}
8484
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008485static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008486{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008487 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008488
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008489 spec->autocfg.hp_pins[0] = 0x1b;
8490 spec->autocfg.speaker_pins[0] = 0x14;
8491 spec->autocfg.speaker_pins[1] = 0x15;
8492 spec->autocfg.speaker_pins[2] = 0x16;
8493 spec->autocfg.speaker_pins[3] = 0x17;
8494 spec->autocfg.speaker_pins[4] = 0x1a;
8495 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008496}
8497
Guido Günther3e1647c2009-06-05 00:47:26 +02008498static void alc883_vaiott_init_hook(struct hda_codec *codec)
8499{
8500 struct alc_spec *spec = codec->spec;
8501
8502 spec->autocfg.hp_pins[0] = 0x15;
8503 spec->autocfg.speaker_pins[0] = 0x14;
8504 spec->autocfg.speaker_pins[1] = 0x17;
8505 alc_automute_amp(codec);
8506}
8507
Kailang Yange2757d52008-08-26 13:17:46 +02008508static struct hda_verb alc888_asus_m90v_verbs[] = {
8509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8510 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8511 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8512 /* enable unsolicited event */
8513 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8514 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8515 { } /* end */
8516};
8517
8518static void alc883_nb_mic_automute(struct hda_codec *codec)
8519{
8520 unsigned int present;
8521
8522 present = snd_hda_codec_read(codec, 0x18, 0,
8523 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8524 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8525 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8526 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8527 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8528}
8529
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008530static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008531{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008532 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008533
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008534 spec->autocfg.hp_pins[0] = 0x1b;
8535 spec->autocfg.speaker_pins[0] = 0x14;
8536 spec->autocfg.speaker_pins[1] = 0x15;
8537 spec->autocfg.speaker_pins[2] = 0x16;
8538 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008539}
8540
8541static void alc883_mode2_unsol_event(struct hda_codec *codec,
8542 unsigned int res)
8543{
8544 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008545 case ALC880_MIC_EVENT:
8546 alc883_nb_mic_automute(codec);
8547 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008548 default:
8549 alc_sku_unsol_event(codec, res);
8550 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008551 }
8552}
8553
8554static void alc883_mode2_inithook(struct hda_codec *codec)
8555{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008556 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008557 alc883_nb_mic_automute(codec);
8558}
8559
8560static struct hda_verb alc888_asus_eee1601_verbs[] = {
8561 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8562 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8563 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8564 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8565 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8566 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8567 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8568 /* enable unsolicited event */
8569 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8570 { } /* end */
8571};
8572
Kailang Yange2757d52008-08-26 13:17:46 +02008573static void alc883_eee1601_inithook(struct hda_codec *codec)
8574{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008575 struct alc_spec *spec = codec->spec;
8576
8577 spec->autocfg.hp_pins[0] = 0x14;
8578 spec->autocfg.speaker_pins[0] = 0x1b;
8579 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008580}
8581
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008582static struct hda_verb alc889A_mb31_verbs[] = {
8583 /* Init rear pin (used as headphone output) */
8584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8585 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8586 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8587 /* Init line pin (used as output in 4ch and 6ch mode) */
8588 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8589 /* Init line 2 pin (used as headphone out by default) */
8590 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8591 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8592 { } /* end */
8593};
8594
8595/* Mute speakers according to the headphone jack state */
8596static void alc889A_mb31_automute(struct hda_codec *codec)
8597{
8598 unsigned int present;
8599
8600 /* Mute only in 2ch or 4ch mode */
8601 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8602 == 0x00) {
8603 present = snd_hda_codec_read(codec, 0x15, 0,
8604 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8605 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8606 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8607 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8608 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8609 }
8610}
8611
8612static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8613{
8614 if ((res >> 26) == ALC880_HP_EVENT)
8615 alc889A_mb31_automute(codec);
8616}
8617
Takashi Iwai4953550a2009-06-30 15:28:30 +02008618
Takashi Iwaicb53c622007-08-10 17:21:45 +02008619#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008620#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008621#endif
8622
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008623/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008624#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8625#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8626#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8627#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8628
8629static hda_nid_t alc883_slave_dig_outs[] = {
8630 ALC1200_DIGOUT_NID, 0,
8631};
8632
8633static hda_nid_t alc1200_slave_dig_outs[] = {
8634 ALC883_DIGOUT_NID, 0,
8635};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008636
8637/*
8638 * configuration and preset
8639 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008640static const char *alc882_models[ALC882_MODEL_LAST] = {
8641 [ALC882_3ST_DIG] = "3stack-dig",
8642 [ALC882_6ST_DIG] = "6stack-dig",
8643 [ALC882_ARIMA] = "arima",
8644 [ALC882_W2JC] = "w2jc",
8645 [ALC882_TARGA] = "targa",
8646 [ALC882_ASUS_A7J] = "asus-a7j",
8647 [ALC882_ASUS_A7M] = "asus-a7m",
8648 [ALC885_MACPRO] = "macpro",
8649 [ALC885_MB5] = "mb5",
8650 [ALC885_MBP3] = "mbp3",
8651 [ALC885_IMAC24] = "imac24",
8652 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008653 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8654 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008655 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008656 [ALC883_TARGA_DIG] = "targa-dig",
8657 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008658 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008659 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008660 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008661 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008662 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008663 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008664 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008665 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008666 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008667 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008668 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8669 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008670 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008671 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008672 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008673 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008674 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008675 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008676 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008677 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008678 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008679 [ALC889A_INTEL] = "intel-alc889a",
8680 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008681 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008682 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008683 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008684 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008685};
8686
Takashi Iwai4953550a2009-06-30 15:28:30 +02008687static struct snd_pci_quirk alc882_cfg_tbl[] = {
8688 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8689
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008690 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008691 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008692 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008693 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8694 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008695 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008696 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8697 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008698 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8699 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008700 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8701 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008702 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8703 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008704 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8705 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008706 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008707 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008708 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008709 ALC888_ACER_ASPIRE_6530G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008710 /* default Acer -- disabled as it causes more problems.
8711 * model=auto should work fine now
8712 */
8713 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008714
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008715 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008716
Tobin Davisfebe3372007-06-12 11:27:46 +02008717 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008718 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8719 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008720 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008721 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008722 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008723
8724 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8725 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8726 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008727 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008728 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8729 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8730 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008731 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008732 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008733 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008734 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008735
8736 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008737 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008738 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008739 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008740 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8741 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008742 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008743 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008744 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8745
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008746 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8747 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8748 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008749 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Jiang zhe4383fae2008-04-14 12:58:57 +02008750 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008751 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008752 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008753 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008754 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8755 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8756 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8757 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8758 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8759 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008760 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008761 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8762 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8763 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008764 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008765 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8766 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008767 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008768 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008769 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008770 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008771 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008772 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008773 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008774 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008775
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008776 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008777 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8778 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008779 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008780 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008781 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008782 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008783 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008784 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008785 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008786 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008787 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008788 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008789 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8790 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008791 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008792 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008793 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008794 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008795 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008796
Jiang zhe17bba1b2008-06-04 12:11:07 +02008797 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8798 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008799 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008800 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8801 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8802 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008803 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008804
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008805 {}
8806};
8807
Takashi Iwai4953550a2009-06-30 15:28:30 +02008808/* codec SSID table for Intel Mac */
8809static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8810 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8811 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8812 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8813 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8814 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8815 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8816 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8817 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8818 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8819 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8820 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8821 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8822 * no perfect solution yet
8823 */
8824 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8825 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008826};
8827
Takashi Iwai4953550a2009-06-30 15:28:30 +02008828static struct alc_config_preset alc882_presets[] = {
8829 [ALC882_3ST_DIG] = {
8830 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008831 .init_verbs = { alc882_base_init_verbs,
8832 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008833 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8834 .dac_nids = alc882_dac_nids,
8835 .dig_out_nid = ALC882_DIGOUT_NID,
8836 .dig_in_nid = ALC882_DIGIN_NID,
8837 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8838 .channel_mode = alc882_ch_modes,
8839 .need_dac_fix = 1,
8840 .input_mux = &alc882_capture_source,
8841 },
8842 [ALC882_6ST_DIG] = {
8843 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008844 .init_verbs = { alc882_base_init_verbs,
8845 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008846 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8847 .dac_nids = alc882_dac_nids,
8848 .dig_out_nid = ALC882_DIGOUT_NID,
8849 .dig_in_nid = ALC882_DIGIN_NID,
8850 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8851 .channel_mode = alc882_sixstack_modes,
8852 .input_mux = &alc882_capture_source,
8853 },
8854 [ALC882_ARIMA] = {
8855 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008856 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8857 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008858 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8859 .dac_nids = alc882_dac_nids,
8860 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8861 .channel_mode = alc882_sixstack_modes,
8862 .input_mux = &alc882_capture_source,
8863 },
8864 [ALC882_W2JC] = {
8865 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008866 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8867 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008868 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8869 .dac_nids = alc882_dac_nids,
8870 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8871 .channel_mode = alc880_threestack_modes,
8872 .need_dac_fix = 1,
8873 .input_mux = &alc882_capture_source,
8874 .dig_out_nid = ALC882_DIGOUT_NID,
8875 },
8876 [ALC885_MBP3] = {
8877 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8878 .init_verbs = { alc885_mbp3_init_verbs,
8879 alc880_gpio1_init_verbs },
8880 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8881 .dac_nids = alc882_dac_nids,
8882 .channel_mode = alc885_mbp_6ch_modes,
8883 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
8884 .input_mux = &alc882_capture_source,
8885 .dig_out_nid = ALC882_DIGOUT_NID,
8886 .dig_in_nid = ALC882_DIGIN_NID,
8887 .unsol_event = alc_automute_amp_unsol_event,
8888 .init_hook = alc885_mbp3_init_hook,
8889 },
8890 [ALC885_MB5] = {
8891 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8892 .init_verbs = { alc885_mb5_init_verbs,
8893 alc880_gpio1_init_verbs },
8894 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8895 .dac_nids = alc882_dac_nids,
8896 .channel_mode = alc885_mb5_6ch_modes,
8897 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8898 .input_mux = &mb5_capture_source,
8899 .dig_out_nid = ALC882_DIGOUT_NID,
8900 .dig_in_nid = ALC882_DIGIN_NID,
8901 },
8902 [ALC885_MACPRO] = {
8903 .mixers = { alc882_macpro_mixer },
8904 .init_verbs = { alc882_macpro_init_verbs },
8905 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8906 .dac_nids = alc882_dac_nids,
8907 .dig_out_nid = ALC882_DIGOUT_NID,
8908 .dig_in_nid = ALC882_DIGIN_NID,
8909 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8910 .channel_mode = alc882_ch_modes,
8911 .input_mux = &alc882_capture_source,
8912 .init_hook = alc885_macpro_init_hook,
8913 },
8914 [ALC885_IMAC24] = {
8915 .mixers = { alc885_imac24_mixer },
8916 .init_verbs = { alc885_imac24_init_verbs },
8917 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8918 .dac_nids = alc882_dac_nids,
8919 .dig_out_nid = ALC882_DIGOUT_NID,
8920 .dig_in_nid = ALC882_DIGIN_NID,
8921 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8922 .channel_mode = alc882_ch_modes,
8923 .input_mux = &alc882_capture_source,
8924 .unsol_event = alc_automute_amp_unsol_event,
8925 .init_hook = alc885_imac24_init_hook,
8926 },
8927 [ALC882_TARGA] = {
8928 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008929 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02008930 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008931 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8932 .dac_nids = alc882_dac_nids,
8933 .dig_out_nid = ALC882_DIGOUT_NID,
8934 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8935 .adc_nids = alc882_adc_nids,
8936 .capsrc_nids = alc882_capsrc_nids,
8937 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8938 .channel_mode = alc882_3ST_6ch_modes,
8939 .need_dac_fix = 1,
8940 .input_mux = &alc882_capture_source,
8941 .unsol_event = alc882_targa_unsol_event,
8942 .init_hook = alc882_targa_init_hook,
8943 },
8944 [ALC882_ASUS_A7J] = {
8945 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008946 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8947 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008948 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8949 .dac_nids = alc882_dac_nids,
8950 .dig_out_nid = ALC882_DIGOUT_NID,
8951 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8952 .adc_nids = alc882_adc_nids,
8953 .capsrc_nids = alc882_capsrc_nids,
8954 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8955 .channel_mode = alc882_3ST_6ch_modes,
8956 .need_dac_fix = 1,
8957 .input_mux = &alc882_capture_source,
8958 },
8959 [ALC882_ASUS_A7M] = {
8960 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008961 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8962 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008963 alc882_asus_a7m_verbs },
8964 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8965 .dac_nids = alc882_dac_nids,
8966 .dig_out_nid = ALC882_DIGOUT_NID,
8967 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8968 .channel_mode = alc880_threestack_modes,
8969 .need_dac_fix = 1,
8970 .input_mux = &alc882_capture_source,
8971 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008972 [ALC883_3ST_2ch_DIG] = {
8973 .mixers = { alc883_3ST_2ch_mixer },
8974 .init_verbs = { alc883_init_verbs },
8975 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8976 .dac_nids = alc883_dac_nids,
8977 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008978 .dig_in_nid = ALC883_DIGIN_NID,
8979 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8980 .channel_mode = alc883_3ST_2ch_modes,
8981 .input_mux = &alc883_capture_source,
8982 },
8983 [ALC883_3ST_6ch_DIG] = {
8984 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8985 .init_verbs = { alc883_init_verbs },
8986 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8987 .dac_nids = alc883_dac_nids,
8988 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008989 .dig_in_nid = ALC883_DIGIN_NID,
8990 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8991 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008992 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008993 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008994 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008995 [ALC883_3ST_6ch] = {
8996 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8997 .init_verbs = { alc883_init_verbs },
8998 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8999 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009000 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9001 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009002 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009003 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009004 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009005 [ALC883_3ST_6ch_INTEL] = {
9006 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9007 .init_verbs = { alc883_init_verbs },
9008 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9009 .dac_nids = alc883_dac_nids,
9010 .dig_out_nid = ALC883_DIGOUT_NID,
9011 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009012 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009013 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9014 .channel_mode = alc883_3ST_6ch_intel_modes,
9015 .need_dac_fix = 1,
9016 .input_mux = &alc883_3stack_6ch_intel,
9017 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009018 [ALC889A_INTEL] = {
9019 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009020 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9021 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009022 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9023 .dac_nids = alc883_dac_nids,
9024 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9025 .adc_nids = alc889_adc_nids,
9026 .dig_out_nid = ALC883_DIGOUT_NID,
9027 .dig_in_nid = ALC883_DIGIN_NID,
9028 .slave_dig_outs = alc883_slave_dig_outs,
9029 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9030 .channel_mode = alc889_8ch_intel_modes,
9031 .capsrc_nids = alc889_capsrc_nids,
9032 .input_mux = &alc889_capture_source,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009033 .init_hook = alc889_automute_init,
9034 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009035 .need_dac_fix = 1,
9036 },
9037 [ALC889_INTEL] = {
9038 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9039 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009040 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009041 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9042 .dac_nids = alc883_dac_nids,
9043 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9044 .adc_nids = alc889_adc_nids,
9045 .dig_out_nid = ALC883_DIGOUT_NID,
9046 .dig_in_nid = ALC883_DIGIN_NID,
9047 .slave_dig_outs = alc883_slave_dig_outs,
9048 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9049 .channel_mode = alc889_8ch_intel_modes,
9050 .capsrc_nids = alc889_capsrc_nids,
9051 .input_mux = &alc889_capture_source,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009052 .init_hook = alc889_intel_init_hook,
9053 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009054 .need_dac_fix = 1,
9055 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009056 [ALC883_6ST_DIG] = {
9057 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9058 .init_verbs = { alc883_init_verbs },
9059 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9060 .dac_nids = alc883_dac_nids,
9061 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009062 .dig_in_nid = ALC883_DIGIN_NID,
9063 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9064 .channel_mode = alc883_sixstack_modes,
9065 .input_mux = &alc883_capture_source,
9066 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009067 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009068 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009069 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9070 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009071 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9072 .dac_nids = alc883_dac_nids,
9073 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009074 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9075 .channel_mode = alc883_3ST_6ch_modes,
9076 .need_dac_fix = 1,
9077 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009078 .unsol_event = alc883_targa_unsol_event,
9079 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009080 },
9081 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009082 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009083 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9084 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009085 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9086 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009087 .adc_nids = alc883_adc_nids_alt,
9088 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009089 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009090 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9091 .channel_mode = alc883_3ST_2ch_modes,
9092 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009093 .unsol_event = alc883_targa_unsol_event,
9094 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009095 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009096 [ALC883_TARGA_8ch_DIG] = {
9097 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9098 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009099 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009100 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9101 .dac_nids = alc883_dac_nids,
9102 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9103 .adc_nids = alc883_adc_nids_rev,
9104 .capsrc_nids = alc883_capsrc_nids_rev,
9105 .dig_out_nid = ALC883_DIGOUT_NID,
9106 .dig_in_nid = ALC883_DIGIN_NID,
9107 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9108 .channel_mode = alc883_4ST_8ch_modes,
9109 .need_dac_fix = 1,
9110 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009111 .unsol_event = alc883_targa_unsol_event,
9112 .init_hook = alc883_targa_init_hook,
David Heidelberger64a8be72009-06-08 16:15:18 +02009113 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009114 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009115 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009116 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9117 * and the headphone jack. Turn this on and rely on the
9118 * standard mute methods whenever the user wants to turn
9119 * these outputs off.
9120 */
9121 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9122 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9123 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009124 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9125 .channel_mode = alc883_3ST_2ch_modes,
9126 .input_mux = &alc883_capture_source,
9127 },
Tobin Davis2880a862007-08-07 11:50:26 +02009128 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009129 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009130 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009131 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9132 .dac_nids = alc883_dac_nids,
9133 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009134 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9135 .channel_mode = alc883_3ST_2ch_modes,
9136 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009137 .unsol_event = alc_automute_amp_unsol_event,
9138 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009139 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009140 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009141 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009142 alc883_chmode_mixer },
9143 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9144 alc888_acer_aspire_4930g_verbs },
9145 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9146 .dac_nids = alc883_dac_nids,
9147 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9148 .adc_nids = alc883_adc_nids_rev,
9149 .capsrc_nids = alc883_capsrc_nids_rev,
9150 .dig_out_nid = ALC883_DIGOUT_NID,
9151 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9152 .channel_mode = alc883_3ST_6ch_modes,
9153 .need_dac_fix = 1,
9154 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009155 ARRAY_SIZE(alc888_2_capture_sources),
9156 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009157 .unsol_event = alc_automute_amp_unsol_event,
9158 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009159 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009160 [ALC888_ACER_ASPIRE_6530G] = {
9161 .mixers = { alc888_acer_aspire_6530_mixer },
9162 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9163 alc888_acer_aspire_6530g_verbs },
9164 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9165 .dac_nids = alc883_dac_nids,
9166 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9167 .adc_nids = alc883_adc_nids_rev,
9168 .capsrc_nids = alc883_capsrc_nids_rev,
9169 .dig_out_nid = ALC883_DIGOUT_NID,
9170 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9171 .channel_mode = alc883_3ST_2ch_modes,
9172 .num_mux_defs =
9173 ARRAY_SIZE(alc888_2_capture_sources),
9174 .input_mux = alc888_acer_aspire_6530_sources,
9175 .unsol_event = alc_automute_amp_unsol_event,
Emilio López320d5922009-06-25 08:18:44 +02009176 .init_hook = alc888_acer_aspire_6530g_init_hook,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009177 },
Hector Martin3b315d72009-06-02 10:54:19 +02009178 [ALC888_ACER_ASPIRE_8930G] = {
9179 .mixers = { alc888_base_mixer,
9180 alc883_chmode_mixer },
9181 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009182 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009183 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9184 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009185 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9186 .adc_nids = alc889_adc_nids,
9187 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009188 .dig_out_nid = ALC883_DIGOUT_NID,
9189 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9190 .channel_mode = alc883_3ST_6ch_modes,
9191 .need_dac_fix = 1,
9192 .const_channel_count = 6,
9193 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009194 ARRAY_SIZE(alc889_capture_sources),
9195 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009196 .unsol_event = alc_automute_amp_unsol_event,
Hector Martin018df412009-06-04 00:13:40 +02009197 .init_hook = alc889_acer_aspire_8930g_init_hook,
Hector Martin3b315d72009-06-02 10:54:19 +02009198 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009199 [ALC883_MEDION] = {
9200 .mixers = { alc883_fivestack_mixer,
9201 alc883_chmode_mixer },
9202 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009203 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009204 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9205 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009206 .adc_nids = alc883_adc_nids_alt,
9207 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009208 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9209 .channel_mode = alc883_sixstack_modes,
9210 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009211 },
Kailang Yang272a5272007-05-14 11:00:38 +02009212 [ALC883_MEDION_MD2] = {
9213 .mixers = { alc883_medion_md2_mixer},
9214 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9215 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9216 .dac_nids = alc883_dac_nids,
9217 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009218 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9219 .channel_mode = alc883_3ST_2ch_modes,
9220 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009221 .unsol_event = alc_automute_amp_unsol_event,
9222 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02009223 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009224 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009225 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009226 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9227 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9228 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009229 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9230 .channel_mode = alc883_3ST_2ch_modes,
9231 .input_mux = &alc883_capture_source,
9232 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009233 [ALC883_CLEVO_M720] = {
9234 .mixers = { alc883_clevo_m720_mixer },
9235 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009236 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9237 .dac_nids = alc883_dac_nids,
9238 .dig_out_nid = ALC883_DIGOUT_NID,
9239 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9240 .channel_mode = alc883_3ST_2ch_modes,
9241 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009242 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009243 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009244 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009245 [ALC883_LENOVO_101E_2ch] = {
9246 .mixers = { alc883_lenovo_101e_2ch_mixer},
9247 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9248 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9249 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009250 .adc_nids = alc883_adc_nids_alt,
9251 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009252 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9253 .channel_mode = alc883_3ST_2ch_modes,
9254 .input_mux = &alc883_lenovo_101e_capture_source,
9255 .unsol_event = alc883_lenovo_101e_unsol_event,
9256 .init_hook = alc883_lenovo_101e_all_automute,
9257 },
Kailang Yang272a5272007-05-14 11:00:38 +02009258 [ALC883_LENOVO_NB0763] = {
9259 .mixers = { alc883_lenovo_nb0763_mixer },
9260 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9261 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9262 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009263 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9264 .channel_mode = alc883_3ST_2ch_modes,
9265 .need_dac_fix = 1,
9266 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009267 .unsol_event = alc_automute_amp_unsol_event,
9268 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02009269 },
9270 [ALC888_LENOVO_MS7195_DIG] = {
9271 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9272 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9273 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9274 .dac_nids = alc883_dac_nids,
9275 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009276 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9277 .channel_mode = alc883_3ST_6ch_modes,
9278 .need_dac_fix = 1,
9279 .input_mux = &alc883_capture_source,
9280 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9281 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009282 },
9283 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009284 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009285 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9286 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9287 .dac_nids = alc883_dac_nids,
9288 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009289 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9290 .channel_mode = alc883_3ST_2ch_modes,
9291 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009292 .unsol_event = alc_automute_amp_unsol_event,
9293 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009294 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009295 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009296 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009297 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009298 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9299 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009300 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9301 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009302 .need_dac_fix = 1,
9303 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009304 .unsol_event = alc_automute_amp_unsol_event,
9305 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009306 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009307 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009308 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009309 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9310 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9311 .dac_nids = alc883_dac_nids,
9312 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009313 .dig_in_nid = ALC883_DIGIN_NID,
9314 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9315 .channel_mode = alc883_sixstack_modes,
9316 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009317 .unsol_event = alc_automute_amp_unsol_event,
9318 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009319 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009320 [ALC883_MITAC] = {
9321 .mixers = { alc883_mitac_mixer },
9322 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9323 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9324 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009325 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9326 .channel_mode = alc883_3ST_2ch_modes,
9327 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009328 .unsol_event = alc_automute_amp_unsol_event,
9329 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009330 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009331 [ALC883_FUJITSU_PI2515] = {
9332 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9333 .init_verbs = { alc883_init_verbs,
9334 alc883_2ch_fujitsu_pi2515_verbs},
9335 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9336 .dac_nids = alc883_dac_nids,
9337 .dig_out_nid = ALC883_DIGOUT_NID,
9338 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9339 .channel_mode = alc883_3ST_2ch_modes,
9340 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009341 .unsol_event = alc_automute_amp_unsol_event,
9342 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01009343 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009344 [ALC888_FUJITSU_XA3530] = {
9345 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9346 .init_verbs = { alc883_init_verbs,
9347 alc888_fujitsu_xa3530_verbs },
9348 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9349 .dac_nids = alc883_dac_nids,
9350 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9351 .adc_nids = alc883_adc_nids_rev,
9352 .capsrc_nids = alc883_capsrc_nids_rev,
9353 .dig_out_nid = ALC883_DIGOUT_NID,
9354 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9355 .channel_mode = alc888_4ST_8ch_intel_modes,
9356 .num_mux_defs =
9357 ARRAY_SIZE(alc888_2_capture_sources),
9358 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009359 .unsol_event = alc_automute_amp_unsol_event,
9360 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009361 },
Kailang Yange2757d52008-08-26 13:17:46 +02009362 [ALC888_LENOVO_SKY] = {
9363 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9364 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9365 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9366 .dac_nids = alc883_dac_nids,
9367 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009368 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9369 .channel_mode = alc883_sixstack_modes,
9370 .need_dac_fix = 1,
9371 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009372 .unsol_event = alc_automute_amp_unsol_event,
9373 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009374 },
9375 [ALC888_ASUS_M90V] = {
9376 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9377 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9378 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9379 .dac_nids = alc883_dac_nids,
9380 .dig_out_nid = ALC883_DIGOUT_NID,
9381 .dig_in_nid = ALC883_DIGIN_NID,
9382 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9383 .channel_mode = alc883_3ST_6ch_modes,
9384 .need_dac_fix = 1,
9385 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9386 .unsol_event = alc883_mode2_unsol_event,
9387 .init_hook = alc883_mode2_inithook,
9388 },
9389 [ALC888_ASUS_EEE1601] = {
9390 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009391 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009392 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9393 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9394 .dac_nids = alc883_dac_nids,
9395 .dig_out_nid = ALC883_DIGOUT_NID,
9396 .dig_in_nid = ALC883_DIGIN_NID,
9397 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9398 .channel_mode = alc883_3ST_2ch_modes,
9399 .need_dac_fix = 1,
9400 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009401 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009402 .init_hook = alc883_eee1601_inithook,
9403 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009404 [ALC1200_ASUS_P5Q] = {
9405 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9406 .init_verbs = { alc883_init_verbs },
9407 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9408 .dac_nids = alc883_dac_nids,
9409 .dig_out_nid = ALC1200_DIGOUT_NID,
9410 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009411 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009412 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9413 .channel_mode = alc883_sixstack_modes,
9414 .input_mux = &alc883_capture_source,
9415 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009416 [ALC889A_MB31] = {
9417 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9418 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9419 alc880_gpio1_init_verbs },
9420 .adc_nids = alc883_adc_nids,
9421 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9422 .dac_nids = alc883_dac_nids,
9423 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9424 .channel_mode = alc889A_mb31_6ch_modes,
9425 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9426 .input_mux = &alc889A_mb31_capture_source,
9427 .dig_out_nid = ALC883_DIGOUT_NID,
9428 .unsol_event = alc889A_mb31_unsol_event,
9429 .init_hook = alc889A_mb31_automute,
9430 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009431 [ALC883_SONY_VAIO_TT] = {
9432 .mixers = { alc883_vaiott_mixer },
9433 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9434 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9435 .dac_nids = alc883_dac_nids,
9436 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9437 .channel_mode = alc883_3ST_2ch_modes,
9438 .input_mux = &alc883_capture_source,
9439 .unsol_event = alc_automute_amp_unsol_event,
9440 .init_hook = alc883_vaiott_init_hook,
9441 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009442};
9443
9444
9445/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009446 * Pin config fixes
9447 */
9448enum {
9449 PINFIX_ABIT_AW9D_MAX
9450};
9451
9452static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9453 { 0x15, 0x01080104 }, /* side */
9454 { 0x16, 0x01011012 }, /* rear */
9455 { 0x17, 0x01016011 }, /* clfe */
9456 { }
9457};
9458
9459static const struct alc_pincfg *alc882_pin_fixes[] = {
9460 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
9461};
9462
9463static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9464 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9465 {}
9466};
9467
9468/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009469 * BIOS auto configuration
9470 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009471static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009472 hda_nid_t nid, int pin_type,
9473 int dac_idx)
9474{
9475 /* set as output */
9476 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009477 int idx;
9478
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009479 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009480 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9481 idx = 4;
9482 else
9483 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009484 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9485
9486}
9487
Takashi Iwai4953550a2009-06-30 15:28:30 +02009488static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009489{
9490 struct alc_spec *spec = codec->spec;
9491 int i;
9492
9493 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009494 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009495 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009496 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009497 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009498 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009499 }
9500}
9501
Takashi Iwai4953550a2009-06-30 15:28:30 +02009502static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009503{
9504 struct alc_spec *spec = codec->spec;
9505 hda_nid_t pin;
9506
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009507 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009508 if (pin) /* connect to front */
9509 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009510 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009511 pin = spec->autocfg.speaker_pins[0];
9512 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009513 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009514}
9515
Takashi Iwai4953550a2009-06-30 15:28:30 +02009516static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009517{
9518 struct alc_spec *spec = codec->spec;
9519 int i;
9520
9521 for (i = 0; i < AUTO_PIN_LAST; i++) {
9522 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009523 if (!nid)
9524 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009525 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009526 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9527 snd_hda_codec_write(codec, nid, 0,
9528 AC_VERB_SET_AMP_GAIN_MUTE,
9529 AMP_OUT_MUTE);
9530 }
9531}
9532
9533static void alc882_auto_init_input_src(struct hda_codec *codec)
9534{
9535 struct alc_spec *spec = codec->spec;
9536 int c;
9537
9538 for (c = 0; c < spec->num_adc_nids; c++) {
9539 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9540 hda_nid_t nid = spec->capsrc_nids[c];
9541 unsigned int mux_idx;
9542 const struct hda_input_mux *imux;
9543 int conns, mute, idx, item;
9544
9545 conns = snd_hda_get_connections(codec, nid, conn_list,
9546 ARRAY_SIZE(conn_list));
9547 if (conns < 0)
9548 continue;
9549 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9550 imux = &spec->input_mux[mux_idx];
9551 for (idx = 0; idx < conns; idx++) {
9552 /* if the current connection is the selected one,
9553 * unmute it as default - otherwise mute it
9554 */
9555 mute = AMP_IN_MUTE(idx);
9556 for (item = 0; item < imux->num_items; item++) {
9557 if (imux->items[item].index == idx) {
9558 if (spec->cur_mux[c] == item)
9559 mute = AMP_IN_UNMUTE(idx);
9560 break;
9561 }
9562 }
9563 /* check if we have a selector or mixer
9564 * we could check for the widget type instead, but
9565 * just check for Amp-In presence (in case of mixer
9566 * without amp-in there is something wrong, this
9567 * function shouldn't be used or capsrc nid is wrong)
9568 */
9569 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009570 snd_hda_codec_write(codec, nid, 0,
9571 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009572 mute);
9573 else if (mute != AMP_IN_MUTE(idx))
9574 snd_hda_codec_write(codec, nid, 0,
9575 AC_VERB_SET_CONNECT_SEL,
9576 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009577 }
9578 }
9579}
9580
Takashi Iwai4953550a2009-06-30 15:28:30 +02009581/* add mic boosts if needed */
9582static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009583{
9584 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009585 int err;
9586 hda_nid_t nid;
9587
9588 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9589 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9590 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9591 "Mic Boost",
9592 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9593 if (err < 0)
9594 return err;
9595 }
9596 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9597 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9598 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9599 "Front Mic Boost",
9600 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9601 if (err < 0)
9602 return err;
9603 }
9604 return 0;
9605}
9606
9607/* almost identical with ALC880 parser... */
9608static int alc882_parse_auto_config(struct hda_codec *codec)
9609{
9610 struct alc_spec *spec = codec->spec;
9611 struct auto_pin_cfg *autocfg = &spec->autocfg;
9612 unsigned int wcap;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009613 int i;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009614 int err = alc880_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009615
9616 if (err < 0)
9617 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009618 else if (!err)
9619 return 0; /* no config found */
9620
9621 err = alc_auto_add_mic_boost(codec);
9622 if (err < 0)
9623 return err;
9624
9625 /* hack - override the init verbs */
9626 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009627 /* if ADC 0x07 is available, initialize it, too */
9628 wcap = get_wcaps(codec, 0x07);
Takashi Iwaia22d5432009-07-27 12:54:26 +02009629 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009630 if (wcap == AC_WID_AUD_IN)
9631 add_verb(spec, alc882_adc1_init_verbs);
Takashi Iwai776e1842007-08-29 15:07:11 +02009632
Takashi Iwai4953550a2009-06-30 15:28:30 +02009633 /* digital-mic input pin is excluded in alc880_auto_create..()
9634 * because it's under 0x18
9635 */
9636 if (autocfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9637 autocfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9638 struct hda_input_mux *imux = &spec->private_imux[0];
9639 for (i = 1; i < 3; i++)
9640 memcpy(&spec->private_imux[i],
9641 &spec->private_imux[0],
9642 sizeof(spec->private_imux[0]));
9643 imux->items[imux->num_items].label = "Int DMic";
9644 imux->items[imux->num_items].index = 0x0b;
9645 imux->num_items++;
9646 spec->num_mux_defs = 3;
9647 spec->input_mux = spec->private_imux;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009648 }
9649
Takashi Iwai776e1842007-08-29 15:07:11 +02009650 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009651}
9652
9653/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009654static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009655{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009656 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009657 alc882_auto_init_multi_out(codec);
9658 alc882_auto_init_hp_out(codec);
9659 alc882_auto_init_analog_input(codec);
9660 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009661 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009662 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009663}
9664
Takashi Iwai4953550a2009-06-30 15:28:30 +02009665static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009666{
9667 struct alc_spec *spec;
9668 int err, board_config;
9669
9670 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9671 if (spec == NULL)
9672 return -ENOMEM;
9673
9674 codec->spec = spec;
9675
Takashi Iwai4953550a2009-06-30 15:28:30 +02009676 switch (codec->vendor_id) {
9677 case 0x10ec0882:
9678 case 0x10ec0885:
9679 break;
9680 default:
9681 /* ALC883 and variants */
9682 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9683 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009684 }
9685
Takashi Iwai4953550a2009-06-30 15:28:30 +02009686 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9687 alc882_models,
9688 alc882_cfg_tbl);
9689
9690 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9691 board_config = snd_hda_check_board_codec_sid_config(codec,
9692 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9693
9694 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009695 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009696 codec->chip_name);
9697 board_config = ALC882_AUTO;
9698 }
9699
9700 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
9701
9702 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009703 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009704 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009705 if (err < 0) {
9706 alc_free(codec);
9707 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009708 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009709 printk(KERN_INFO
9710 "hda_codec: Cannot set up configuration "
9711 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +02009712 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009713 }
9714 }
9715
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009716 err = snd_hda_attach_beep_device(codec, 0x1);
9717 if (err < 0) {
9718 alc_free(codec);
9719 return err;
9720 }
9721
Takashi Iwai4953550a2009-06-30 15:28:30 +02009722 if (board_config != ALC882_AUTO)
9723 setup_preset(spec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009724
Takashi Iwai4953550a2009-06-30 15:28:30 +02009725 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9726 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9727 /* FIXME: setup DAC5 */
9728 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9729 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9730
9731 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9732 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9733
9734 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009735 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009736
9737 if (!spec->adc_nids && spec->input_mux) {
9738 int i;
9739 spec->num_adc_nids = 0;
9740 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9741 hda_nid_t cap;
9742 hda_nid_t nid = alc882_adc_nids[i];
9743 unsigned int wcap = get_wcaps(codec, nid);
9744 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02009745 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009746 if (wcap != AC_WID_AUD_IN)
9747 continue;
9748 spec->private_adc_nids[spec->num_adc_nids] = nid;
9749 err = snd_hda_get_connections(codec, nid, &cap, 1);
9750 if (err < 0)
9751 continue;
9752 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9753 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009754 }
Takashi Iwai4953550a2009-06-30 15:28:30 +02009755 spec->adc_nids = spec->private_adc_nids;
9756 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009757 }
9758
Takashi Iwaib59bdf32009-08-11 09:47:30 +02009759 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009760 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009761
Takashi Iwai2134ea42008-01-10 16:53:55 +01009762 spec->vmaster_nid = 0x0c;
9763
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009764 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009765 if (board_config == ALC882_AUTO)
9766 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009767#ifdef CONFIG_SND_HDA_POWER_SAVE
9768 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009769 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009770#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009771 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009772
9773 return 0;
9774}
9775
Takashi Iwai4953550a2009-06-30 15:28:30 +02009776
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009777/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009778 * ALC262 support
9779 */
9780
9781#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9782#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9783
9784#define alc262_dac_nids alc260_dac_nids
9785#define alc262_adc_nids alc882_adc_nids
9786#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009787#define alc262_capsrc_nids alc882_capsrc_nids
9788#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009789
9790#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009791#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009792
Kailang Yang4e555fe2008-08-26 13:05:55 +02009793static hda_nid_t alc262_dmic_adc_nids[1] = {
9794 /* ADC0 */
9795 0x09
9796};
9797
9798static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9799
Kailang Yangdf694da2005-12-05 19:42:22 +01009800static struct snd_kcontrol_new alc262_base_mixer[] = {
9801 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9802 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9803 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9804 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9805 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9806 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9807 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9808 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009809 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009810 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9811 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009812 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009813 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9814 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9815 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9816 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009817 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009818};
9819
Takashi Iwaice875f02008-01-28 18:17:43 +01009820/* update HP, line and mono-out pins according to the master switch */
9821static void alc262_hp_master_update(struct hda_codec *codec)
9822{
9823 struct alc_spec *spec = codec->spec;
9824 int val = spec->master_sw;
9825
9826 /* HP & line-out */
9827 snd_hda_codec_write_cache(codec, 0x1b, 0,
9828 AC_VERB_SET_PIN_WIDGET_CONTROL,
9829 val ? PIN_HP : 0);
9830 snd_hda_codec_write_cache(codec, 0x15, 0,
9831 AC_VERB_SET_PIN_WIDGET_CONTROL,
9832 val ? PIN_HP : 0);
9833 /* mono (speaker) depending on the HP jack sense */
9834 val = val && !spec->jack_present;
9835 snd_hda_codec_write_cache(codec, 0x16, 0,
9836 AC_VERB_SET_PIN_WIDGET_CONTROL,
9837 val ? PIN_OUT : 0);
9838}
9839
9840static void alc262_hp_bpc_automute(struct hda_codec *codec)
9841{
9842 struct alc_spec *spec = codec->spec;
9843 unsigned int presence;
9844 presence = snd_hda_codec_read(codec, 0x1b, 0,
9845 AC_VERB_GET_PIN_SENSE, 0);
9846 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9847 alc262_hp_master_update(codec);
9848}
9849
9850static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9851{
9852 if ((res >> 26) != ALC880_HP_EVENT)
9853 return;
9854 alc262_hp_bpc_automute(codec);
9855}
9856
9857static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9858{
9859 struct alc_spec *spec = codec->spec;
9860 unsigned int presence;
9861 presence = snd_hda_codec_read(codec, 0x15, 0,
9862 AC_VERB_GET_PIN_SENSE, 0);
9863 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9864 alc262_hp_master_update(codec);
9865}
9866
9867static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9868 unsigned int res)
9869{
9870 if ((res >> 26) != ALC880_HP_EVENT)
9871 return;
9872 alc262_hp_wildwest_automute(codec);
9873}
9874
Takashi Iwaib72519b2009-05-08 14:31:55 +02009875#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009876
9877static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9878 struct snd_ctl_elem_value *ucontrol)
9879{
9880 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9881 struct alc_spec *spec = codec->spec;
9882 int val = !!*ucontrol->value.integer.value;
9883
9884 if (val == spec->master_sw)
9885 return 0;
9886 spec->master_sw = val;
9887 alc262_hp_master_update(codec);
9888 return 1;
9889}
9890
Takashi Iwaib72519b2009-05-08 14:31:55 +02009891#define ALC262_HP_MASTER_SWITCH \
9892 { \
9893 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9894 .name = "Master Playback Switch", \
9895 .info = snd_ctl_boolean_mono_info, \
9896 .get = alc262_hp_master_sw_get, \
9897 .put = alc262_hp_master_sw_put, \
9898 }
9899
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009900static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009901 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009902 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9903 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9904 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009905 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9906 HDA_OUTPUT),
9907 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9908 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009909 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9910 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009911 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009912 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9913 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009914 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009915 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9916 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9917 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9918 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009919 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9920 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9921 { } /* end */
9922};
9923
Kailang Yangcd7509a2007-01-26 18:33:17 +01009924static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009925 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009926 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9927 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9928 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9929 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009930 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9931 HDA_OUTPUT),
9932 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9933 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009934 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9935 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009936 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009937 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9938 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9939 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9940 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009941 { } /* end */
9942};
9943
9944static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9945 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9946 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009947 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009948 { } /* end */
9949};
9950
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009951/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009952static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009953{
9954 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009955
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009956 spec->autocfg.hp_pins[0] = 0x15;
9957 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
9958 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009959}
9960
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009961static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009962 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9963 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009964 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9965 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9966 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9967 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9968 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9969 { } /* end */
9970};
9971
9972static struct hda_verb alc262_hp_t5735_verbs[] = {
9973 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9974 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9975
9976 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9977 { }
9978};
9979
Kailang Yang8c427222008-01-10 13:03:59 +01009980static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009981 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9982 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009983 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9984 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009985 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9986 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9987 { } /* end */
9988};
9989
9990static struct hda_verb alc262_hp_rp5700_verbs[] = {
9991 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9992 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9993 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9994 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9995 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9996 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9997 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9998 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9999 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10000 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10001 {}
10002};
10003
10004static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10005 .num_items = 1,
10006 .items = {
10007 { "Line", 0x1 },
10008 },
10009};
10010
Takashi Iwai42171c12009-05-08 14:11:43 +020010011/* bind hp and internal speaker mute (with plug check) as master switch */
10012static void alc262_hippo_master_update(struct hda_codec *codec)
10013{
10014 struct alc_spec *spec = codec->spec;
10015 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10016 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10017 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10018 unsigned int mute;
10019
10020 /* HP */
10021 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10022 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10023 HDA_AMP_MUTE, mute);
10024 /* mute internal speaker per jack sense */
10025 if (spec->jack_present)
10026 mute = HDA_AMP_MUTE;
10027 if (line_nid)
10028 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10029 HDA_AMP_MUTE, mute);
10030 if (speaker_nid && speaker_nid != line_nid)
10031 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10032 HDA_AMP_MUTE, mute);
10033}
10034
10035#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10036
10037static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10038 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010039{
10040 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010041 struct alc_spec *spec = codec->spec;
10042 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010043
Takashi Iwai42171c12009-05-08 14:11:43 +020010044 if (val == spec->master_sw)
10045 return 0;
10046 spec->master_sw = val;
10047 alc262_hippo_master_update(codec);
10048 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010049}
Takashi Iwai5b319542007-07-26 11:49:22 +020010050
Takashi Iwai42171c12009-05-08 14:11:43 +020010051#define ALC262_HIPPO_MASTER_SWITCH \
10052 { \
10053 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10054 .name = "Master Playback Switch", \
10055 .info = snd_ctl_boolean_mono_info, \
10056 .get = alc262_hippo_master_sw_get, \
10057 .put = alc262_hippo_master_sw_put, \
10058 }
10059
10060static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10061 ALC262_HIPPO_MASTER_SWITCH,
10062 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10063 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10064 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10065 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10066 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10067 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10068 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10069 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10070 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10071 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10072 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10073 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10074 { } /* end */
10075};
10076
10077static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10078 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10079 ALC262_HIPPO_MASTER_SWITCH,
10080 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10081 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10082 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10083 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10084 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10086 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10087 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10088 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10089 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10090 { } /* end */
10091};
10092
10093/* mute/unmute internal speaker according to the hp jack and mute state */
10094static void alc262_hippo_automute(struct hda_codec *codec)
10095{
10096 struct alc_spec *spec = codec->spec;
10097 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10098 unsigned int present;
10099
10100 /* need to execute and sync at first */
10101 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10102 present = snd_hda_codec_read(codec, hp_nid, 0,
10103 AC_VERB_GET_PIN_SENSE, 0);
10104 spec->jack_present = (present & 0x80000000) != 0;
10105 alc262_hippo_master_update(codec);
10106}
10107
10108static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10109{
10110 if ((res >> 26) != ALC880_HP_EVENT)
10111 return;
10112 alc262_hippo_automute(codec);
10113}
10114
10115static void alc262_hippo_init_hook(struct hda_codec *codec)
10116{
10117 struct alc_spec *spec = codec->spec;
10118
10119 spec->autocfg.hp_pins[0] = 0x15;
10120 spec->autocfg.speaker_pins[0] = 0x14;
10121 alc262_hippo_automute(codec);
10122}
10123
10124static void alc262_hippo1_init_hook(struct hda_codec *codec)
10125{
10126 struct alc_spec *spec = codec->spec;
10127
10128 spec->autocfg.hp_pins[0] = 0x1b;
10129 spec->autocfg.speaker_pins[0] = 0x14;
10130 alc262_hippo_automute(codec);
10131}
10132
10133
Kailang Yang272a5272007-05-14 11:00:38 +020010134static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010135 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010136 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10139 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10140 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10141 { } /* end */
10142};
10143
Kailang Yang83c34212007-07-05 11:43:05 +020010144static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010145 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10146 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010147 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10148 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10149 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10150 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10151 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10152 { } /* end */
10153};
Kailang Yang272a5272007-05-14 11:00:38 +020010154
Tony Vroonba340e82009-02-02 19:01:30 +000010155static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10156 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10157 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10158 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10159 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10160 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10161 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10164 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10165 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10166 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10167 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10168 { } /* end */
10169};
10170
10171static struct hda_verb alc262_tyan_verbs[] = {
10172 /* Headphone automute */
10173 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10174 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10175 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10176
10177 /* P11 AUX_IN, white 4-pin connector */
10178 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10179 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10180 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10181 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10182
10183 {}
10184};
10185
10186/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010187static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010188{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010189 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010190
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010191 spec->autocfg.hp_pins[0] = 0x1b;
10192 spec->autocfg.speaker_pins[0] = 0x15;
10193 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +000010194}
10195
Tony Vroonba340e82009-02-02 19:01:30 +000010196
Kailang Yangdf694da2005-12-05 19:42:22 +010010197#define alc262_capture_mixer alc882_capture_mixer
10198#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10199
10200/*
10201 * generic initialization of ADC, input mixers and output mixers
10202 */
10203static struct hda_verb alc262_init_verbs[] = {
10204 /*
10205 * Unmute ADC0-2 and set the default input to mic-in
10206 */
10207 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10208 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10209 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10210 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10211 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10212 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10213
Takashi Iwaicb53c622007-08-10 17:21:45 +020010214 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010215 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010216 * Note: PASD motherboards uses the Line In 2 as the input for
10217 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010218 */
10219 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010220 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10222 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10223 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10224 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010225
10226 /*
10227 * Set up output mixers (0x0c - 0x0e)
10228 */
10229 /* set vol=0 to output mixers */
10230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10231 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10232 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10233 /* set up input amps for analog loopback */
10234 /* Amp Indices: DAC = 0, mixer = 1 */
10235 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10236 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10237 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10238 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10239 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10240 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10241
10242 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10243 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10244 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10245 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10246 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10247 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10248
10249 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10250 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10251 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10252 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10253 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010254
Kailang Yangdf694da2005-12-05 19:42:22 +010010255 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10256 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010257
Kailang Yangdf694da2005-12-05 19:42:22 +010010258 /* FIXME: use matrix-type input source selection */
10259 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10260 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10261 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10262 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10263 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10264 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10265 /* Input mixer2 */
10266 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10267 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10268 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10269 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10270 /* Input mixer3 */
10271 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10272 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10273 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010274 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010275
10276 { }
10277};
10278
Kailang Yang4e555fe2008-08-26 13:05:55 +020010279static struct hda_verb alc262_eapd_verbs[] = {
10280 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10281 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10282 { }
10283};
10284
Kailang Yangccc656c2006-10-17 12:32:26 +020010285static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10286 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10287 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10288 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10289
10290 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10291 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10292 {}
10293};
10294
Kailang Yang272a5272007-05-14 11:00:38 +020010295static struct hda_verb alc262_sony_unsol_verbs[] = {
10296 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10297 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10298 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10299
10300 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10301 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010302 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010303};
10304
Kailang Yang4e555fe2008-08-26 13:05:55 +020010305static struct hda_input_mux alc262_dmic_capture_source = {
10306 .num_items = 2,
10307 .items = {
10308 { "Int DMic", 0x9 },
10309 { "Mic", 0x0 },
10310 },
10311};
10312
10313static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10314 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10315 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10316 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10318 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010319 { } /* end */
10320};
10321
10322static struct hda_verb alc262_toshiba_s06_verbs[] = {
10323 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10324 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10325 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10326 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10327 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10328 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10329 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10330 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10331 {}
10332};
10333
10334static void alc262_dmic_automute(struct hda_codec *codec)
10335{
10336 unsigned int present;
10337
10338 present = snd_hda_codec_read(codec, 0x18, 0,
10339 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10340 snd_hda_codec_write(codec, 0x22, 0,
10341 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10342}
10343
Kailang Yang4e555fe2008-08-26 13:05:55 +020010344
10345/* unsolicited event for HP jack sensing */
10346static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10347 unsigned int res)
10348{
Kailang Yang4e555fe2008-08-26 13:05:55 +020010349 if ((res >> 26) == ALC880_MIC_EVENT)
10350 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010351 else
10352 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010353}
10354
10355static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10356{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010357 struct alc_spec *spec = codec->spec;
10358
10359 spec->autocfg.hp_pins[0] = 0x15;
10360 spec->autocfg.speaker_pins[0] = 0x14;
10361 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010362 alc262_dmic_automute(codec);
10363}
10364
Takashi Iwai834be882006-03-01 14:16:17 +010010365/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010366 * nec model
10367 * 0x15 = headphone
10368 * 0x16 = internal speaker
10369 * 0x18 = external mic
10370 */
10371
10372static struct snd_kcontrol_new alc262_nec_mixer[] = {
10373 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10374 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10375
10376 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10377 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10378 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10379
10380 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10381 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10382 { } /* end */
10383};
10384
10385static struct hda_verb alc262_nec_verbs[] = {
10386 /* Unmute Speaker */
10387 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10388
10389 /* Headphone */
10390 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10391 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10392
10393 /* External mic to headphone */
10394 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10395 /* External mic to speaker */
10396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10397 {}
10398};
10399
10400/*
Takashi Iwai834be882006-03-01 14:16:17 +010010401 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010402 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10403 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010404 */
10405
10406#define ALC_HP_EVENT 0x37
10407
10408static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10409 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10410 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010411 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10412 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010413 {}
10414};
10415
Jiang zhe0e31daf2008-03-20 12:12:39 +010010416static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10417 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10418 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10419 {}
10420};
10421
Takashi Iwai834be882006-03-01 14:16:17 +010010422static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010423 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010424 .items = {
10425 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010426 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010427 { "CD", 0x4 },
10428 },
10429};
10430
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010431static struct hda_input_mux alc262_HP_capture_source = {
10432 .num_items = 5,
10433 .items = {
10434 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010435 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010436 { "Line", 0x2 },
10437 { "CD", 0x4 },
10438 { "AUX IN", 0x6 },
10439 },
10440};
10441
zhejiangaccbe492007-08-31 12:36:05 +020010442static struct hda_input_mux alc262_HP_D7000_capture_source = {
10443 .num_items = 4,
10444 .items = {
10445 { "Mic", 0x0 },
10446 { "Front Mic", 0x2 },
10447 { "Line", 0x1 },
10448 { "CD", 0x4 },
10449 },
10450};
10451
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010452/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010453static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10454{
10455 struct alc_spec *spec = codec->spec;
10456 unsigned int mute;
10457
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010458 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010459 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010460 /* need to execute and sync at first */
10461 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010462 /* check laptop HP jack */
10463 present = snd_hda_codec_read(codec, 0x14, 0,
10464 AC_VERB_GET_PIN_SENSE, 0);
10465 /* need to execute and sync at first */
10466 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10467 /* check docking HP jack */
10468 present |= snd_hda_codec_read(codec, 0x1b, 0,
10469 AC_VERB_GET_PIN_SENSE, 0);
10470 if (present & AC_PINSENSE_PRESENCE)
10471 spec->jack_present = 1;
10472 else
10473 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010474 spec->sense_updated = 1;
10475 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010476 /* unmute internal speaker only if both HPs are unplugged and
10477 * master switch is on
10478 */
10479 if (spec->jack_present)
10480 mute = HDA_AMP_MUTE;
10481 else
Takashi Iwai834be882006-03-01 14:16:17 +010010482 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010483 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10484 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010485}
10486
10487/* unsolicited event for HP jack sensing */
10488static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10489 unsigned int res)
10490{
10491 if ((res >> 26) != ALC_HP_EVENT)
10492 return;
10493 alc262_fujitsu_automute(codec, 1);
10494}
10495
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010496static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10497{
10498 alc262_fujitsu_automute(codec, 1);
10499}
10500
Takashi Iwai834be882006-03-01 14:16:17 +010010501/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010502static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10503 .ops = &snd_hda_bind_vol,
10504 .values = {
10505 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10506 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10507 0
10508 },
10509};
Takashi Iwai834be882006-03-01 14:16:17 +010010510
Jiang zhe0e31daf2008-03-20 12:12:39 +010010511/* mute/unmute internal speaker according to the hp jack and mute state */
10512static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10513{
10514 struct alc_spec *spec = codec->spec;
10515 unsigned int mute;
10516
10517 if (force || !spec->sense_updated) {
10518 unsigned int present_int_hp;
10519 /* need to execute and sync at first */
10520 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10521 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10522 AC_VERB_GET_PIN_SENSE, 0);
10523 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10524 spec->sense_updated = 1;
10525 }
10526 if (spec->jack_present) {
10527 /* mute internal speaker */
10528 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10529 HDA_AMP_MUTE, HDA_AMP_MUTE);
10530 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10531 HDA_AMP_MUTE, HDA_AMP_MUTE);
10532 } else {
10533 /* unmute internal speaker if necessary */
10534 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10535 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10536 HDA_AMP_MUTE, mute);
10537 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10538 HDA_AMP_MUTE, mute);
10539 }
10540}
10541
10542/* unsolicited event for HP jack sensing */
10543static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10544 unsigned int res)
10545{
10546 if ((res >> 26) != ALC_HP_EVENT)
10547 return;
10548 alc262_lenovo_3000_automute(codec, 1);
10549}
10550
Takashi Iwai8de56b72009-07-24 16:51:47 +020010551static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10552 int dir, int idx, long *valp)
10553{
10554 int i, change = 0;
10555
10556 for (i = 0; i < 2; i++, valp++)
10557 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10558 HDA_AMP_MUTE,
10559 *valp ? 0 : HDA_AMP_MUTE);
10560 return change;
10561}
10562
Takashi Iwai834be882006-03-01 14:16:17 +010010563/* bind hp and internal speaker mute (with plug check) */
10564static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10565 struct snd_ctl_elem_value *ucontrol)
10566{
10567 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10568 long *valp = ucontrol->value.integer.value;
10569 int change;
10570
Takashi Iwai8de56b72009-07-24 16:51:47 +020010571 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10572 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010573 if (change)
10574 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010575 return change;
10576}
10577
10578static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010579 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010580 {
10581 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10582 .name = "Master Playback Switch",
10583 .info = snd_hda_mixer_amp_switch_info,
10584 .get = snd_hda_mixer_amp_switch_get,
10585 .put = alc262_fujitsu_master_sw_put,
10586 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10587 },
10588 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10589 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10590 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10591 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10592 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010593 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10594 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10595 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010596 { } /* end */
10597};
10598
Jiang zhe0e31daf2008-03-20 12:12:39 +010010599/* bind hp and internal speaker mute (with plug check) */
10600static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10601 struct snd_ctl_elem_value *ucontrol)
10602{
10603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10604 long *valp = ucontrol->value.integer.value;
10605 int change;
10606
Takashi Iwai8de56b72009-07-24 16:51:47 +020010607 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010608 if (change)
10609 alc262_lenovo_3000_automute(codec, 0);
10610 return change;
10611}
10612
10613static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10614 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10615 {
10616 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10617 .name = "Master Playback Switch",
10618 .info = snd_hda_mixer_amp_switch_info,
10619 .get = snd_hda_mixer_amp_switch_get,
10620 .put = alc262_lenovo_3000_master_sw_put,
10621 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10622 },
10623 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10624 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10625 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10626 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10627 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10628 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10629 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10630 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10631 { } /* end */
10632};
10633
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010634static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10635 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010636 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010637 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10638 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10639 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10640 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10641 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10642 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10643 { } /* end */
10644};
10645
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010646/* additional init verbs for Benq laptops */
10647static struct hda_verb alc262_EAPD_verbs[] = {
10648 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10649 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10650 {}
10651};
10652
Kailang Yang83c34212007-07-05 11:43:05 +020010653static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10654 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10655 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10656
10657 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10658 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10659 {}
10660};
10661
Tobin Davisf651b502007-10-26 12:40:47 +020010662/* Samsung Q1 Ultra Vista model setup */
10663static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010664 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10665 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10667 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10668 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010669 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010670 { } /* end */
10671};
10672
10673static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010674 /* output mixer */
10675 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10676 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10678 /* speaker */
10679 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10680 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10681 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10682 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10683 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010684 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010685 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10686 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10687 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10688 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10689 /* internal mic */
10690 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10691 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10692 /* ADC, choose mic */
10693 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10694 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10695 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10696 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10697 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10698 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10699 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10700 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10701 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10702 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010703 {}
10704};
10705
Tobin Davisf651b502007-10-26 12:40:47 +020010706/* mute/unmute internal speaker according to the hp jack and mute state */
10707static void alc262_ultra_automute(struct hda_codec *codec)
10708{
10709 struct alc_spec *spec = codec->spec;
10710 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010711
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010712 mute = 0;
10713 /* auto-mute only when HP is used as HP */
10714 if (!spec->cur_mux[0]) {
10715 unsigned int present;
10716 /* need to execute and sync at first */
10717 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10718 present = snd_hda_codec_read(codec, 0x15, 0,
10719 AC_VERB_GET_PIN_SENSE, 0);
10720 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10721 if (spec->jack_present)
10722 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010723 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010724 /* mute/unmute internal speaker */
10725 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10726 HDA_AMP_MUTE, mute);
10727 /* mute/unmute HP */
10728 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10729 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010730}
10731
10732/* unsolicited event for HP jack sensing */
10733static void alc262_ultra_unsol_event(struct hda_codec *codec,
10734 unsigned int res)
10735{
10736 if ((res >> 26) != ALC880_HP_EVENT)
10737 return;
10738 alc262_ultra_automute(codec);
10739}
10740
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010741static struct hda_input_mux alc262_ultra_capture_source = {
10742 .num_items = 2,
10743 .items = {
10744 { "Mic", 0x1 },
10745 { "Headphone", 0x7 },
10746 },
10747};
10748
10749static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10750 struct snd_ctl_elem_value *ucontrol)
10751{
10752 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10753 struct alc_spec *spec = codec->spec;
10754 int ret;
10755
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010756 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010757 if (!ret)
10758 return 0;
10759 /* reprogram the HP pin as mic or HP according to the input source */
10760 snd_hda_codec_write_cache(codec, 0x15, 0,
10761 AC_VERB_SET_PIN_WIDGET_CONTROL,
10762 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10763 alc262_ultra_automute(codec); /* mute/unmute HP */
10764 return ret;
10765}
10766
10767static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10768 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10769 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10770 {
10771 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10772 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010773 .info = alc_mux_enum_info,
10774 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010775 .put = alc262_ultra_mux_enum_put,
10776 },
10777 { } /* end */
10778};
10779
Kailang Yangdf694da2005-12-05 19:42:22 +010010780/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010781static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10782 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010783{
10784 hda_nid_t nid;
10785 int err;
10786
10787 spec->multiout.num_dacs = 1; /* only use one dac */
10788 spec->multiout.dac_nids = spec->private_dac_nids;
10789 spec->multiout.dac_nids[0] = 2;
10790
10791 nid = cfg->line_out_pins[0];
10792 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010793 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10794 "Front Playback Volume",
10795 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10796 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010797 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010798 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10799 "Front Playback Switch",
10800 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10801 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010802 return err;
10803 }
10804
Takashi Iwai82bc9552006-03-21 11:24:42 +010010805 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010806 if (nid) {
10807 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010808 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10809 "Speaker Playback Volume",
10810 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10811 HDA_OUTPUT));
10812 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010813 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010814 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10815 "Speaker Playback Switch",
10816 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10817 HDA_OUTPUT));
10818 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010819 return err;
10820 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010821 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10822 "Speaker Playback Switch",
10823 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10824 HDA_OUTPUT));
10825 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010826 return err;
10827 }
10828 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010829 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010830 if (nid) {
10831 /* spec->multiout.hp_nid = 2; */
10832 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010833 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10834 "Headphone Playback Volume",
10835 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10836 HDA_OUTPUT));
10837 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010838 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010839 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10840 "Headphone Playback Switch",
10841 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10842 HDA_OUTPUT));
10843 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010844 return err;
10845 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010846 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10847 "Headphone Playback Switch",
10848 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10849 HDA_OUTPUT));
10850 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010851 return err;
10852 }
10853 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010854 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010855}
10856
Takashi Iwai8c927b42009-06-22 10:56:54 +020010857static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec,
10858 const struct auto_pin_cfg *cfg)
10859{
10860 int err;
10861
10862 err = alc880_auto_create_analog_input_ctls(spec, cfg);
10863 if (err < 0)
10864 return err;
10865 /* digital-mic input pin is excluded in alc880_auto_create..()
10866 * because it's under 0x18
10867 */
10868 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
10869 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
10870 struct hda_input_mux *imux = &spec->private_imux[0];
10871 imux->items[imux->num_items].label = "Int Mic";
10872 imux->items[imux->num_items].index = 0x09;
10873 imux->num_items++;
10874 }
10875 return 0;
10876}
10877
Kailang Yangdf694da2005-12-05 19:42:22 +010010878
10879/*
10880 * generic initialization of ADC, input mixers and output mixers
10881 */
10882static struct hda_verb alc262_volume_init_verbs[] = {
10883 /*
10884 * Unmute ADC0-2 and set the default input to mic-in
10885 */
10886 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10887 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10888 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10889 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10890 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10891 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10892
Takashi Iwaicb53c622007-08-10 17:21:45 +020010893 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010894 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010895 * Note: PASD motherboards uses the Line In 2 as the input for
10896 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010897 */
10898 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10902 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10903 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010904
10905 /*
10906 * Set up output mixers (0x0c - 0x0f)
10907 */
10908 /* set vol=0 to output mixers */
10909 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10910 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10911 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010912
Kailang Yangdf694da2005-12-05 19:42:22 +010010913 /* set up input amps for analog loopback */
10914 /* Amp Indices: DAC = 0, mixer = 1 */
10915 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10916 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10917 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10918 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10919 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10920 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10921
10922 /* FIXME: use matrix-type input source selection */
10923 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10924 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10925 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10926 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10927 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10928 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10929 /* Input mixer2 */
10930 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10931 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10932 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10933 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10934 /* Input mixer3 */
10935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10936 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10937 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10939
10940 { }
10941};
10942
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010943static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10944 /*
10945 * Unmute ADC0-2 and set the default input to mic-in
10946 */
10947 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10948 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10949 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10950 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10951 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10952 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10953
Takashi Iwaicb53c622007-08-10 17:21:45 +020010954 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010955 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010956 * Note: PASD motherboards uses the Line In 2 as the input for
10957 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010958 */
10959 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010960 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10961 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10962 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10963 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10964 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10965 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10966 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010967
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010968 /*
10969 * Set up output mixers (0x0c - 0x0e)
10970 */
10971 /* set vol=0 to output mixers */
10972 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10973 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10974 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10975
10976 /* set up input amps for analog loopback */
10977 /* Amp Indices: DAC = 0, mixer = 1 */
10978 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10979 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10980 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10981 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10982 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10983 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10984
Takashi Iwaice875f02008-01-28 18:17:43 +010010985 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010986 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10987 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10988
10989 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10990 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10991
10992 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10993 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10994
10995 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10996 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10997 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10998 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10999 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11000
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011001 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011002 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11003 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011004 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011005 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11006 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11007
11008
11009 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011010 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11011 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011012 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011013 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11014 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11015 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11016 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11017 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11018 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11019 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11020 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011021 /* Input mixer2 */
11022 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011023 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11024 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11025 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11026 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11027 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11028 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11029 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11030 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011031 /* Input mixer3 */
11032 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011033 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11034 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11035 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11036 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11037 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11039 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11040 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011041
Takashi Iwaice875f02008-01-28 18:17:43 +010011042 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11043
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011044 { }
11045};
11046
Kailang Yangcd7509a2007-01-26 18:33:17 +010011047static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11048 /*
11049 * Unmute ADC0-2 and set the default input to mic-in
11050 */
11051 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11052 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11053 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11054 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11055 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11056 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11057
Takashi Iwaicb53c622007-08-10 17:21:45 +020011058 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011059 * mixer widget
11060 * Note: PASD motherboards uses the Line In 2 as the input for front
11061 * panel mic (mic 2)
11062 */
11063 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11067 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011072 /*
11073 * Set up output mixers (0x0c - 0x0e)
11074 */
11075 /* set vol=0 to output mixers */
11076 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11077 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11078 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11079
11080 /* set up input amps for analog loopback */
11081 /* Amp Indices: DAC = 0, mixer = 1 */
11082 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11083 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11084 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11085 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11086 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11087 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11088
11089
11090 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11091 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11092 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11093 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11094 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11095 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11096 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11097
11098 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11099 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11100
11101 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11102 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11103
11104 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11105 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11106 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11107 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11108 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11109 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11110
11111 /* FIXME: use matrix-type input source selection */
11112 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11113 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11114 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11115 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11116 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11117 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11118 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11119 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11120 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11121 /* Input mixer2 */
11122 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11123 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11124 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11125 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11126 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11127 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11128 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11129 /* Input mixer3 */
11130 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11132 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11133 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11134 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11135 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11136 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11137
Takashi Iwaice875f02008-01-28 18:17:43 +010011138 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11139
Kailang Yangcd7509a2007-01-26 18:33:17 +010011140 { }
11141};
11142
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011143static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11144
11145 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11146 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11147 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11148
11149 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11150 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11151 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11152 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11153
11154 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11155 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11156 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11157 {}
11158};
11159
11160
Takashi Iwaicb53c622007-08-10 17:21:45 +020011161#ifdef CONFIG_SND_HDA_POWER_SAVE
11162#define alc262_loopbacks alc880_loopbacks
11163#endif
11164
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011165/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011166#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11167#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11168#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11169#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11170
11171/*
11172 * BIOS auto configuration
11173 */
11174static int alc262_parse_auto_config(struct hda_codec *codec)
11175{
11176 struct alc_spec *spec = codec->spec;
11177 int err;
11178 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11179
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011180 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11181 alc262_ignore);
11182 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011183 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011184 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011185 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011186 spec->multiout.max_channels = 2;
11187 spec->no_analog = 1;
11188 goto dig_only;
11189 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011190 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011191 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011192 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11193 if (err < 0)
11194 return err;
11195 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
11196 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011197 return err;
11198
11199 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11200
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011201 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011202 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011203 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011204 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011205 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011206 if (spec->autocfg.dig_in_pin)
11207 spec->dig_in_nid = ALC262_DIGIN_NID;
11208
Takashi Iwai603c4012008-07-30 15:01:44 +020011209 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011210 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011211
Takashi Iwaid88897e2008-10-31 15:01:37 +010011212 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011213 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011214 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011215
Takashi Iwai776e1842007-08-29 15:07:11 +020011216 err = alc_auto_add_mic_boost(codec);
11217 if (err < 0)
11218 return err;
11219
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011220 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11221
Kailang Yangdf694da2005-12-05 19:42:22 +010011222 return 1;
11223}
11224
11225#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11226#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11227#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011228#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011229
11230
11231/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011232static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011233{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011234 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011235 alc262_auto_init_multi_out(codec);
11236 alc262_auto_init_hp_out(codec);
11237 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011238 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011239 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011240 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011241}
11242
11243/*
11244 * configuration and preset
11245 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011246static const char *alc262_models[ALC262_MODEL_LAST] = {
11247 [ALC262_BASIC] = "basic",
11248 [ALC262_HIPPO] = "hippo",
11249 [ALC262_HIPPO_1] = "hippo_1",
11250 [ALC262_FUJITSU] = "fujitsu",
11251 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011252 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011253 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011254 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011255 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011256 [ALC262_BENQ_T31] = "benq-t31",
11257 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011258 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011259 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011260 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011261 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011262 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011263 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011264 [ALC262_AUTO] = "auto",
11265};
11266
11267static struct snd_pci_quirk alc262_cfg_tbl[] = {
11268 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011269 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011270 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11271 ALC262_HP_BPC),
11272 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11273 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011274 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11275 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011276 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011277 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011278 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011279 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011280 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011281 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011282 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011283 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011284 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11285 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11286 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011287 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11288 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011289 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011290 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011291 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011292 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011293 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011294 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011295 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11296 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011297 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011298 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011299 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011300 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011301 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011302 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011303 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11304 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011305 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011306 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011307 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011308 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011309 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011310 {}
11311};
11312
11313static struct alc_config_preset alc262_presets[] = {
11314 [ALC262_BASIC] = {
11315 .mixers = { alc262_base_mixer },
11316 .init_verbs = { alc262_init_verbs },
11317 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11318 .dac_nids = alc262_dac_nids,
11319 .hp_nid = 0x03,
11320 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11321 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011322 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011323 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011324 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011325 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011326 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011327 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11328 .dac_nids = alc262_dac_nids,
11329 .hp_nid = 0x03,
11330 .dig_out_nid = ALC262_DIGOUT_NID,
11331 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11332 .channel_mode = alc262_modes,
11333 .input_mux = &alc262_capture_source,
11334 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011335 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011336 },
11337 [ALC262_HIPPO_1] = {
11338 .mixers = { alc262_hippo1_mixer },
11339 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11340 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11341 .dac_nids = alc262_dac_nids,
11342 .hp_nid = 0x02,
11343 .dig_out_nid = ALC262_DIGOUT_NID,
11344 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11345 .channel_mode = alc262_modes,
11346 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011347 .unsol_event = alc262_hippo_unsol_event,
11348 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011349 },
Takashi Iwai834be882006-03-01 14:16:17 +010011350 [ALC262_FUJITSU] = {
11351 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011352 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11353 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011354 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11355 .dac_nids = alc262_dac_nids,
11356 .hp_nid = 0x03,
11357 .dig_out_nid = ALC262_DIGOUT_NID,
11358 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11359 .channel_mode = alc262_modes,
11360 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011361 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011362 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011363 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011364 [ALC262_HP_BPC] = {
11365 .mixers = { alc262_HP_BPC_mixer },
11366 .init_verbs = { alc262_HP_BPC_init_verbs },
11367 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11368 .dac_nids = alc262_dac_nids,
11369 .hp_nid = 0x03,
11370 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11371 .channel_mode = alc262_modes,
11372 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011373 .unsol_event = alc262_hp_bpc_unsol_event,
11374 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011375 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011376 [ALC262_HP_BPC_D7000_WF] = {
11377 .mixers = { alc262_HP_BPC_WildWest_mixer },
11378 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11379 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11380 .dac_nids = alc262_dac_nids,
11381 .hp_nid = 0x03,
11382 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11383 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011384 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011385 .unsol_event = alc262_hp_wildwest_unsol_event,
11386 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011387 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011388 [ALC262_HP_BPC_D7000_WL] = {
11389 .mixers = { alc262_HP_BPC_WildWest_mixer,
11390 alc262_HP_BPC_WildWest_option_mixer },
11391 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11392 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11393 .dac_nids = alc262_dac_nids,
11394 .hp_nid = 0x03,
11395 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11396 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011397 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011398 .unsol_event = alc262_hp_wildwest_unsol_event,
11399 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011400 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011401 [ALC262_HP_TC_T5735] = {
11402 .mixers = { alc262_hp_t5735_mixer },
11403 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11404 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11405 .dac_nids = alc262_dac_nids,
11406 .hp_nid = 0x03,
11407 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11408 .channel_mode = alc262_modes,
11409 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011410 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011411 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011412 },
11413 [ALC262_HP_RP5700] = {
11414 .mixers = { alc262_hp_rp5700_mixer },
11415 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11416 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11417 .dac_nids = alc262_dac_nids,
11418 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11419 .channel_mode = alc262_modes,
11420 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011421 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011422 [ALC262_BENQ_ED8] = {
11423 .mixers = { alc262_base_mixer },
11424 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11425 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11426 .dac_nids = alc262_dac_nids,
11427 .hp_nid = 0x03,
11428 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11429 .channel_mode = alc262_modes,
11430 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011431 },
Kailang Yang272a5272007-05-14 11:00:38 +020011432 [ALC262_SONY_ASSAMD] = {
11433 .mixers = { alc262_sony_mixer },
11434 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11435 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11436 .dac_nids = alc262_dac_nids,
11437 .hp_nid = 0x02,
11438 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11439 .channel_mode = alc262_modes,
11440 .input_mux = &alc262_capture_source,
11441 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011442 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011443 },
11444 [ALC262_BENQ_T31] = {
11445 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011446 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11447 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011448 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11449 .dac_nids = alc262_dac_nids,
11450 .hp_nid = 0x03,
11451 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11452 .channel_mode = alc262_modes,
11453 .input_mux = &alc262_capture_source,
11454 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011455 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011456 },
Tobin Davisf651b502007-10-26 12:40:47 +020011457 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011458 .mixers = { alc262_ultra_mixer },
11459 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011460 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011461 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11462 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011463 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11464 .channel_mode = alc262_modes,
11465 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011466 .adc_nids = alc262_adc_nids, /* ADC0 */
11467 .capsrc_nids = alc262_capsrc_nids,
11468 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011469 .unsol_event = alc262_ultra_unsol_event,
11470 .init_hook = alc262_ultra_automute,
11471 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011472 [ALC262_LENOVO_3000] = {
11473 .mixers = { alc262_lenovo_3000_mixer },
11474 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11475 alc262_lenovo_3000_unsol_verbs },
11476 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11477 .dac_nids = alc262_dac_nids,
11478 .hp_nid = 0x03,
11479 .dig_out_nid = ALC262_DIGOUT_NID,
11480 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11481 .channel_mode = alc262_modes,
11482 .input_mux = &alc262_fujitsu_capture_source,
11483 .unsol_event = alc262_lenovo_3000_unsol_event,
11484 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011485 [ALC262_NEC] = {
11486 .mixers = { alc262_nec_mixer },
11487 .init_verbs = { alc262_nec_verbs },
11488 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11489 .dac_nids = alc262_dac_nids,
11490 .hp_nid = 0x03,
11491 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11492 .channel_mode = alc262_modes,
11493 .input_mux = &alc262_capture_source,
11494 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011495 [ALC262_TOSHIBA_S06] = {
11496 .mixers = { alc262_toshiba_s06_mixer },
11497 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11498 alc262_eapd_verbs },
11499 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11500 .capsrc_nids = alc262_dmic_capsrc_nids,
11501 .dac_nids = alc262_dac_nids,
11502 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011503 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011504 .dig_out_nid = ALC262_DIGOUT_NID,
11505 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11506 .channel_mode = alc262_modes,
11507 .input_mux = &alc262_dmic_capture_source,
11508 .unsol_event = alc262_toshiba_s06_unsol_event,
11509 .init_hook = alc262_toshiba_s06_init_hook,
11510 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011511 [ALC262_TOSHIBA_RX1] = {
11512 .mixers = { alc262_toshiba_rx1_mixer },
11513 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11514 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11515 .dac_nids = alc262_dac_nids,
11516 .hp_nid = 0x03,
11517 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11518 .channel_mode = alc262_modes,
11519 .input_mux = &alc262_capture_source,
11520 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011521 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011522 },
Tony Vroonba340e82009-02-02 19:01:30 +000011523 [ALC262_TYAN] = {
11524 .mixers = { alc262_tyan_mixer },
11525 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11526 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11527 .dac_nids = alc262_dac_nids,
11528 .hp_nid = 0x02,
11529 .dig_out_nid = ALC262_DIGOUT_NID,
11530 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11531 .channel_mode = alc262_modes,
11532 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011533 .unsol_event = alc_automute_amp_unsol_event,
11534 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011535 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011536};
11537
11538static int patch_alc262(struct hda_codec *codec)
11539{
11540 struct alc_spec *spec;
11541 int board_config;
11542 int err;
11543
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011544 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011545 if (spec == NULL)
11546 return -ENOMEM;
11547
11548 codec->spec = spec;
11549#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011550 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11551 * under-run
11552 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011553 {
11554 int tmp;
11555 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11556 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11557 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11558 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11559 }
11560#endif
11561
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011562 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11563
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011564 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11565 alc262_models,
11566 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011567
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011568 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011569 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11570 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011571 board_config = ALC262_AUTO;
11572 }
11573
11574 if (board_config == ALC262_AUTO) {
11575 /* automatic parse from the BIOS config */
11576 err = alc262_parse_auto_config(codec);
11577 if (err < 0) {
11578 alc_free(codec);
11579 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011580 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011581 printk(KERN_INFO
11582 "hda_codec: Cannot set up configuration "
11583 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011584 board_config = ALC262_BASIC;
11585 }
11586 }
11587
Takashi Iwai07eba612009-02-19 08:06:35 +010011588 if (!spec->no_analog) {
11589 err = snd_hda_attach_beep_device(codec, 0x1);
11590 if (err < 0) {
11591 alc_free(codec);
11592 return err;
11593 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011594 }
11595
Kailang Yangdf694da2005-12-05 19:42:22 +010011596 if (board_config != ALC262_AUTO)
11597 setup_preset(spec, &alc262_presets[board_config]);
11598
Kailang Yangdf694da2005-12-05 19:42:22 +010011599 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11600 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011601
Kailang Yangdf694da2005-12-05 19:42:22 +010011602 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11603 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11604
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011605 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011606 int i;
11607 /* check whether the digital-mic has to be supported */
11608 for (i = 0; i < spec->input_mux->num_items; i++) {
11609 if (spec->input_mux->items[i].index >= 9)
11610 break;
11611 }
11612 if (i < spec->input_mux->num_items) {
11613 /* use only ADC0 */
11614 spec->adc_nids = alc262_dmic_adc_nids;
11615 spec->num_adc_nids = 1;
11616 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011617 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011618 /* all analog inputs */
11619 /* check whether NID 0x07 is valid */
11620 unsigned int wcap = get_wcaps(codec, 0x07);
11621
11622 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011623 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011624 if (wcap != AC_WID_AUD_IN) {
11625 spec->adc_nids = alc262_adc_nids_alt;
11626 spec->num_adc_nids =
11627 ARRAY_SIZE(alc262_adc_nids_alt);
11628 spec->capsrc_nids = alc262_capsrc_nids_alt;
11629 } else {
11630 spec->adc_nids = alc262_adc_nids;
11631 spec->num_adc_nids =
11632 ARRAY_SIZE(alc262_adc_nids);
11633 spec->capsrc_nids = alc262_capsrc_nids;
11634 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011635 }
11636 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011637 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011638 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011639 if (!spec->no_analog)
11640 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011641
Takashi Iwai2134ea42008-01-10 16:53:55 +010011642 spec->vmaster_nid = 0x0c;
11643
Kailang Yangdf694da2005-12-05 19:42:22 +010011644 codec->patch_ops = alc_patch_ops;
11645 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011646 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011647#ifdef CONFIG_SND_HDA_POWER_SAVE
11648 if (!spec->loopback.amplist)
11649 spec->loopback.amplist = alc262_loopbacks;
11650#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011651 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011652
Kailang Yangdf694da2005-12-05 19:42:22 +010011653 return 0;
11654}
11655
Kailang Yangdf694da2005-12-05 19:42:22 +010011656/*
Kailang Yanga361d842007-06-05 12:30:55 +020011657 * ALC268 channel source setting (2 channel)
11658 */
11659#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11660#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011661
Kailang Yanga361d842007-06-05 12:30:55 +020011662static hda_nid_t alc268_dac_nids[2] = {
11663 /* front, hp */
11664 0x02, 0x03
11665};
11666
11667static hda_nid_t alc268_adc_nids[2] = {
11668 /* ADC0-1 */
11669 0x08, 0x07
11670};
11671
11672static hda_nid_t alc268_adc_nids_alt[1] = {
11673 /* ADC0 */
11674 0x08
11675};
11676
Takashi Iwaie1406342008-02-11 18:32:32 +010011677static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11678
Kailang Yanga361d842007-06-05 12:30:55 +020011679static struct snd_kcontrol_new alc268_base_mixer[] = {
11680 /* output mixer control */
11681 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11682 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11683 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11684 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011685 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11686 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11687 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011688 { }
11689};
11690
Takashi Iwai42171c12009-05-08 14:11:43 +020011691static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11692 /* output mixer control */
11693 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11694 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11695 ALC262_HIPPO_MASTER_SWITCH,
11696 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11697 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11698 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11699 { }
11700};
11701
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011702/* bind Beep switches of both NID 0x0f and 0x10 */
11703static struct hda_bind_ctls alc268_bind_beep_sw = {
11704 .ops = &snd_hda_bind_sw,
11705 .values = {
11706 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11707 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11708 0
11709 },
11710};
11711
11712static struct snd_kcontrol_new alc268_beep_mixer[] = {
11713 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11714 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11715 { }
11716};
11717
Kailang Yangd1a991a2007-08-15 16:21:59 +020011718static struct hda_verb alc268_eapd_verbs[] = {
11719 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11720 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11721 { }
11722};
11723
Takashi Iwaid2738092007-08-16 14:59:45 +020011724/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011725static struct hda_verb alc268_toshiba_verbs[] = {
11726 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11727 { } /* end */
11728};
11729
Kailang Yang8ef355d2008-08-26 13:10:22 +020011730static struct hda_input_mux alc268_acer_lc_capture_source = {
11731 .num_items = 2,
11732 .items = {
11733 { "i-Mic", 0x6 },
11734 { "E-Mic", 0x0 },
11735 },
11736};
11737
Takashi Iwaid2738092007-08-16 14:59:45 +020011738/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011739/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011740static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11741 .ops = &snd_hda_bind_vol,
11742 .values = {
11743 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11744 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11745 0
11746 },
11747};
11748
Takashi Iwai889c4392007-08-23 18:56:52 +020011749/* mute/unmute internal speaker according to the hp jack and mute state */
11750static void alc268_acer_automute(struct hda_codec *codec, int force)
11751{
11752 struct alc_spec *spec = codec->spec;
11753 unsigned int mute;
11754
11755 if (force || !spec->sense_updated) {
11756 unsigned int present;
11757 present = snd_hda_codec_read(codec, 0x14, 0,
11758 AC_VERB_GET_PIN_SENSE, 0);
11759 spec->jack_present = (present & 0x80000000) != 0;
11760 spec->sense_updated = 1;
11761 }
11762 if (spec->jack_present)
11763 mute = HDA_AMP_MUTE; /* mute internal speaker */
11764 else /* unmute internal speaker if necessary */
11765 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11766 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11767 HDA_AMP_MUTE, mute);
11768}
11769
11770
11771/* bind hp and internal speaker mute (with plug check) */
11772static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11773 struct snd_ctl_elem_value *ucontrol)
11774{
11775 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11776 long *valp = ucontrol->value.integer.value;
11777 int change;
11778
Takashi Iwai8de56b72009-07-24 16:51:47 +020011779 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020011780 if (change)
11781 alc268_acer_automute(codec, 0);
11782 return change;
11783}
Takashi Iwaid2738092007-08-16 14:59:45 +020011784
Kailang Yang8ef355d2008-08-26 13:10:22 +020011785static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11786 /* output mixer control */
11787 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11788 {
11789 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11790 .name = "Master Playback Switch",
11791 .info = snd_hda_mixer_amp_switch_info,
11792 .get = snd_hda_mixer_amp_switch_get,
11793 .put = alc268_acer_master_sw_put,
11794 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11795 },
11796 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11797 { }
11798};
11799
Takashi Iwaid2738092007-08-16 14:59:45 +020011800static struct snd_kcontrol_new alc268_acer_mixer[] = {
11801 /* output mixer control */
11802 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11803 {
11804 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11805 .name = "Master Playback Switch",
11806 .info = snd_hda_mixer_amp_switch_info,
11807 .get = snd_hda_mixer_amp_switch_get,
11808 .put = alc268_acer_master_sw_put,
11809 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11810 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011811 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11812 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11813 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011814 { }
11815};
11816
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011817static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11818 /* output mixer control */
11819 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11820 {
11821 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11822 .name = "Master Playback Switch",
11823 .info = snd_hda_mixer_amp_switch_info,
11824 .get = snd_hda_mixer_amp_switch_get,
11825 .put = alc268_acer_master_sw_put,
11826 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11827 },
11828 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11829 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11830 { }
11831};
11832
Kailang Yang8ef355d2008-08-26 13:10:22 +020011833static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11834 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11835 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11836 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11837 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11838 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11839 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11840 { }
11841};
11842
Takashi Iwaid2738092007-08-16 14:59:45 +020011843static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011844 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11845 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11847 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011848 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11849 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011850 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11851 { }
11852};
11853
11854/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011855#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11856#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011857
11858static void alc268_acer_unsol_event(struct hda_codec *codec,
11859 unsigned int res)
11860{
Takashi Iwai889c4392007-08-23 18:56:52 +020011861 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011862 return;
11863 alc268_acer_automute(codec, 1);
11864}
11865
Takashi Iwai889c4392007-08-23 18:56:52 +020011866static void alc268_acer_init_hook(struct hda_codec *codec)
11867{
11868 alc268_acer_automute(codec, 1);
11869}
11870
Kailang Yang8ef355d2008-08-26 13:10:22 +020011871/* toggle speaker-output according to the hp-jack state */
11872static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11873{
11874 unsigned int present;
11875 unsigned char bits;
11876
11877 present = snd_hda_codec_read(codec, 0x15, 0,
11878 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11879 bits = present ? AMP_IN_MUTE(0) : 0;
11880 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11881 AMP_IN_MUTE(0), bits);
11882 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11883 AMP_IN_MUTE(0), bits);
11884}
11885
11886
11887static void alc268_acer_mic_automute(struct hda_codec *codec)
11888{
11889 unsigned int present;
11890
11891 present = snd_hda_codec_read(codec, 0x18, 0,
11892 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11893 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11894 present ? 0x0 : 0x6);
11895}
11896
11897static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11898 unsigned int res)
11899{
11900 if ((res >> 26) == ALC880_HP_EVENT)
11901 alc268_aspire_one_speaker_automute(codec);
11902 if ((res >> 26) == ALC880_MIC_EVENT)
11903 alc268_acer_mic_automute(codec);
11904}
11905
11906static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11907{
11908 alc268_aspire_one_speaker_automute(codec);
11909 alc268_acer_mic_automute(codec);
11910}
11911
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011912static struct snd_kcontrol_new alc268_dell_mixer[] = {
11913 /* output mixer control */
11914 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11915 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11916 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11917 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11918 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11919 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11920 { }
11921};
11922
11923static struct hda_verb alc268_dell_verbs[] = {
11924 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11925 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11926 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11927 { }
11928};
11929
11930/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011931static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011932{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011933 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011934
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011935 spec->autocfg.hp_pins[0] = 0x15;
11936 spec->autocfg.speaker_pins[0] = 0x14;
11937 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011938}
11939
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011940static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11941 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11942 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11943 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11944 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11945 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11946 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11947 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11948 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11949 { }
11950};
11951
11952static struct hda_verb alc267_quanta_il1_verbs[] = {
11953 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11954 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11955 { }
11956};
11957
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011958static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11959{
11960 unsigned int present;
11961
11962 present = snd_hda_codec_read(codec, 0x18, 0,
11963 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11964 snd_hda_codec_write(codec, 0x23, 0,
11965 AC_VERB_SET_CONNECT_SEL,
11966 present ? 0x00 : 0x01);
11967}
11968
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011969static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011970{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011971 struct alc_spec *spec = codec->spec;
11972
11973 spec->autocfg.hp_pins[0] = 0x15;
11974 spec->autocfg.speaker_pins[0] = 0x14;
11975 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011976 alc267_quanta_il1_mic_automute(codec);
11977}
11978
11979static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11980 unsigned int res)
11981{
11982 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011983 case ALC880_MIC_EVENT:
11984 alc267_quanta_il1_mic_automute(codec);
11985 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011986 default:
11987 alc_sku_unsol_event(codec, res);
11988 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011989 }
11990}
11991
Kailang Yanga361d842007-06-05 12:30:55 +020011992/*
11993 * generic initialization of ADC, input mixers and output mixers
11994 */
11995static struct hda_verb alc268_base_init_verbs[] = {
11996 /* Unmute DAC0-1 and set vol = 0 */
11997 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011998 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011999
12000 /*
12001 * Set up output mixers (0x0c - 0x0e)
12002 */
12003 /* set vol=0 to output mixers */
12004 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012005 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12006
12007 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12008 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12009
12010 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12012 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12013 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12014 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12015 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12016 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12017 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12018
12019 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12020 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12021 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12022 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012023 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012024
12025 /* set PCBEEP vol = 0, mute connections */
12026 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12027 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12028 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012029
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012030 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012031
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012032 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12033 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12034 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12035 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012036
Kailang Yanga361d842007-06-05 12:30:55 +020012037 { }
12038};
12039
12040/*
12041 * generic initialization of ADC, input mixers and output mixers
12042 */
12043static struct hda_verb alc268_volume_init_verbs[] = {
12044 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012045 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12046 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012047
12048 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12049 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12050 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12051 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12052 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12053
Kailang Yanga361d842007-06-05 12:30:55 +020012054 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012055 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12056 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12057
12058 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012059 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012060
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012061 /* set PCBEEP vol = 0, mute connections */
12062 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12063 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12064 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012065
12066 { }
12067};
12068
Kailang Yanga361d842007-06-05 12:30:55 +020012069static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12070 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12071 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12072 {
12073 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12074 /* The multiple "Capture Source" controls confuse alsamixer
12075 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012076 */
12077 /* .name = "Capture Source", */
12078 .name = "Input Source",
12079 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012080 .info = alc_mux_enum_info,
12081 .get = alc_mux_enum_get,
12082 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012083 },
12084 { } /* end */
12085};
12086
12087static struct snd_kcontrol_new alc268_capture_mixer[] = {
12088 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12089 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12090 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12091 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12092 {
12093 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12094 /* The multiple "Capture Source" controls confuse alsamixer
12095 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012096 */
12097 /* .name = "Capture Source", */
12098 .name = "Input Source",
12099 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012100 .info = alc_mux_enum_info,
12101 .get = alc_mux_enum_get,
12102 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012103 },
12104 { } /* end */
12105};
12106
12107static struct hda_input_mux alc268_capture_source = {
12108 .num_items = 4,
12109 .items = {
12110 { "Mic", 0x0 },
12111 { "Front Mic", 0x1 },
12112 { "Line", 0x2 },
12113 { "CD", 0x3 },
12114 },
12115};
12116
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012117static struct hda_input_mux alc268_acer_capture_source = {
12118 .num_items = 3,
12119 .items = {
12120 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012121 { "Internal Mic", 0x1 },
12122 { "Line", 0x2 },
12123 },
12124};
12125
12126static struct hda_input_mux alc268_acer_dmic_capture_source = {
12127 .num_items = 3,
12128 .items = {
12129 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012130 { "Internal Mic", 0x6 },
12131 { "Line", 0x2 },
12132 },
12133};
12134
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012135#ifdef CONFIG_SND_DEBUG
12136static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012137 /* Volume widgets */
12138 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12139 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12140 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12141 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12142 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12143 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12144 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12145 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12146 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12147 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12148 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12149 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12150 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012151 /* The below appears problematic on some hardwares */
12152 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012153 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12154 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12155 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12156 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12157
12158 /* Modes for retasking pin widgets */
12159 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12160 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12161 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12162 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12163
12164 /* Controls for GPIO pins, assuming they are configured as outputs */
12165 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12166 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12167 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12168 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12169
12170 /* Switches to allow the digital SPDIF output pin to be enabled.
12171 * The ALC268 does not have an SPDIF input.
12172 */
12173 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12174
12175 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12176 * this output to turn on an external amplifier.
12177 */
12178 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12179 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12180
12181 { } /* end */
12182};
12183#endif
12184
Kailang Yanga361d842007-06-05 12:30:55 +020012185/* create input playback/capture controls for the given pin */
12186static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12187 const char *ctlname, int idx)
12188{
12189 char name[32];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012190 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012191 int err;
12192
12193 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012194 switch (nid) {
12195 case 0x14:
12196 case 0x16:
12197 dac = 0x02;
12198 break;
12199 case 0x15:
12200 dac = 0x03;
12201 break;
12202 default:
12203 return 0;
12204 }
12205 if (spec->multiout.dac_nids[0] != dac &&
12206 spec->multiout.dac_nids[1] != dac) {
Kailang Yanga361d842007-06-05 12:30:55 +020012207 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012208 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012209 HDA_OUTPUT));
12210 if (err < 0)
12211 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012212 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12213 }
12214
Kailang Yanga361d842007-06-05 12:30:55 +020012215 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012216 if (nid != 0x16)
12217 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yanga361d842007-06-05 12:30:55 +020012218 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012219 else /* mono */
12220 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12221 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012222 if (err < 0)
12223 return err;
12224 return 0;
12225}
12226
12227/* add playback controls from the parsed DAC table */
12228static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12229 const struct auto_pin_cfg *cfg)
12230{
12231 hda_nid_t nid;
12232 int err;
12233
Kailang Yanga361d842007-06-05 12:30:55 +020012234 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012235
12236 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012237 if (nid) {
12238 const char *name;
12239 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12240 name = "Speaker";
12241 else
12242 name = "Front";
12243 err = alc268_new_analog_output(spec, nid, name, 0);
12244 if (err < 0)
12245 return err;
12246 }
Kailang Yanga361d842007-06-05 12:30:55 +020012247
12248 nid = cfg->speaker_pins[0];
12249 if (nid == 0x1d) {
12250 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12251 "Speaker Playback Volume",
12252 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12253 if (err < 0)
12254 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012255 } else {
12256 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12257 if (err < 0)
12258 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012259 }
12260 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012261 if (nid) {
12262 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12263 if (err < 0)
12264 return err;
12265 }
Kailang Yanga361d842007-06-05 12:30:55 +020012266
12267 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12268 if (nid == 0x16) {
12269 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12270 "Mono Playback Switch",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012271 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012272 if (err < 0)
12273 return err;
12274 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012275 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012276}
12277
12278/* create playback/capture controls for input pins */
12279static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12280 const struct auto_pin_cfg *cfg)
12281{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012282 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012283 int i, idx1;
12284
12285 for (i = 0; i < AUTO_PIN_LAST; i++) {
12286 switch(cfg->input_pins[i]) {
12287 case 0x18:
12288 idx1 = 0; /* Mic 1 */
12289 break;
12290 case 0x19:
12291 idx1 = 1; /* Mic 2 */
12292 break;
12293 case 0x1a:
12294 idx1 = 2; /* Line In */
12295 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012296 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012297 idx1 = 3; /* CD */
12298 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012299 case 0x12:
12300 case 0x13:
12301 idx1 = 6; /* digital mics */
12302 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012303 default:
12304 continue;
12305 }
12306 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12307 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012308 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012309 }
12310 return 0;
12311}
12312
12313static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12314{
12315 struct alc_spec *spec = codec->spec;
12316 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12317 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12318 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12319 unsigned int dac_vol1, dac_vol2;
12320
12321 if (speaker_nid) {
12322 snd_hda_codec_write(codec, speaker_nid, 0,
12323 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12324 snd_hda_codec_write(codec, 0x0f, 0,
12325 AC_VERB_SET_AMP_GAIN_MUTE,
12326 AMP_IN_UNMUTE(1));
12327 snd_hda_codec_write(codec, 0x10, 0,
12328 AC_VERB_SET_AMP_GAIN_MUTE,
12329 AMP_IN_UNMUTE(1));
12330 } else {
12331 snd_hda_codec_write(codec, 0x0f, 0,
12332 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12333 snd_hda_codec_write(codec, 0x10, 0,
12334 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12335 }
12336
12337 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012338 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012339 dac_vol2 = AMP_OUT_ZERO;
12340 else if (line_nid == 0x15)
12341 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012342 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012343 dac_vol2 = AMP_OUT_ZERO;
12344 else if (hp_nid == 0x15)
12345 dac_vol1 = AMP_OUT_ZERO;
12346 if (line_nid != 0x16 || hp_nid != 0x16 ||
12347 spec->autocfg.line_out_pins[1] != 0x16 ||
12348 spec->autocfg.line_out_pins[2] != 0x16)
12349 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12350
12351 snd_hda_codec_write(codec, 0x02, 0,
12352 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12353 snd_hda_codec_write(codec, 0x03, 0,
12354 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12355}
12356
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012357/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012358#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12359#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012360#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012361#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12362
12363/*
12364 * BIOS auto configuration
12365 */
12366static int alc268_parse_auto_config(struct hda_codec *codec)
12367{
12368 struct alc_spec *spec = codec->spec;
12369 int err;
12370 static hda_nid_t alc268_ignore[] = { 0 };
12371
12372 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12373 alc268_ignore);
12374 if (err < 0)
12375 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012376 if (!spec->autocfg.line_outs) {
12377 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12378 spec->multiout.max_channels = 2;
12379 spec->no_analog = 1;
12380 goto dig_only;
12381 }
Kailang Yanga361d842007-06-05 12:30:55 +020012382 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012383 }
Kailang Yanga361d842007-06-05 12:30:55 +020012384 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12385 if (err < 0)
12386 return err;
12387 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12388 if (err < 0)
12389 return err;
12390
12391 spec->multiout.max_channels = 2;
12392
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012393 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012394 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012395 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012396 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012397 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12398 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012399 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012400 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012401
Takashi Iwai892981f2009-03-02 08:04:35 +010012402 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012403 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012404
Takashi Iwaid88897e2008-10-31 15:01:37 +010012405 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012406 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012407 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012408
Takashi Iwai776e1842007-08-29 15:07:11 +020012409 err = alc_auto_add_mic_boost(codec);
12410 if (err < 0)
12411 return err;
12412
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012413 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12414
Kailang Yanga361d842007-06-05 12:30:55 +020012415 return 1;
12416}
12417
12418#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12419#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12420#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12421
12422/* init callback for auto-configuration model -- overriding the default init */
12423static void alc268_auto_init(struct hda_codec *codec)
12424{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012425 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012426 alc268_auto_init_multi_out(codec);
12427 alc268_auto_init_hp_out(codec);
12428 alc268_auto_init_mono_speaker_out(codec);
12429 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012430 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012431 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012432}
12433
12434/*
12435 * configuration and preset
12436 */
12437static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012438 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012439 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012440 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012441 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012442 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012443 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012444 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012445 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012446#ifdef CONFIG_SND_DEBUG
12447 [ALC268_TEST] = "test",
12448#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012449 [ALC268_AUTO] = "auto",
12450};
12451
12452static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012453 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012454 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012455 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012456 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012457 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012458 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12459 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012460 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012461 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012462 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12463 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012464 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012465 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12466 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12467 ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012468 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012469 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012470 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012471 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012472 {}
12473};
12474
12475static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012476 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012477 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012478 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12479 alc267_quanta_il1_verbs },
12480 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12481 .dac_nids = alc268_dac_nids,
12482 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12483 .adc_nids = alc268_adc_nids_alt,
12484 .hp_nid = 0x03,
12485 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12486 .channel_mode = alc268_modes,
12487 .input_mux = &alc268_capture_source,
12488 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012489 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012490 },
Kailang Yanga361d842007-06-05 12:30:55 +020012491 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012492 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12493 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012494 .init_verbs = { alc268_base_init_verbs },
12495 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12496 .dac_nids = alc268_dac_nids,
12497 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12498 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012499 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012500 .hp_nid = 0x03,
12501 .dig_out_nid = ALC268_DIGOUT_NID,
12502 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12503 .channel_mode = alc268_modes,
12504 .input_mux = &alc268_capture_source,
12505 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012506 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012507 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012508 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012509 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12510 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012511 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12512 .dac_nids = alc268_dac_nids,
12513 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12514 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012515 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012516 .hp_nid = 0x03,
12517 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12518 .channel_mode = alc268_modes,
12519 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012520 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012521 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012522 },
12523 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012524 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12525 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012526 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12527 alc268_acer_verbs },
12528 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12529 .dac_nids = alc268_dac_nids,
12530 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12531 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012532 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012533 .hp_nid = 0x02,
12534 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12535 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012536 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012537 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012538 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012539 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012540 [ALC268_ACER_DMIC] = {
12541 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12542 alc268_beep_mixer },
12543 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12544 alc268_acer_verbs },
12545 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12546 .dac_nids = alc268_dac_nids,
12547 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12548 .adc_nids = alc268_adc_nids_alt,
12549 .capsrc_nids = alc268_capsrc_nids,
12550 .hp_nid = 0x02,
12551 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12552 .channel_mode = alc268_modes,
12553 .input_mux = &alc268_acer_dmic_capture_source,
12554 .unsol_event = alc268_acer_unsol_event,
12555 .init_hook = alc268_acer_init_hook,
12556 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012557 [ALC268_ACER_ASPIRE_ONE] = {
12558 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012559 alc268_beep_mixer,
12560 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012561 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12562 alc268_acer_aspire_one_verbs },
12563 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12564 .dac_nids = alc268_dac_nids,
12565 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12566 .adc_nids = alc268_adc_nids_alt,
12567 .capsrc_nids = alc268_capsrc_nids,
12568 .hp_nid = 0x03,
12569 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12570 .channel_mode = alc268_modes,
12571 .input_mux = &alc268_acer_lc_capture_source,
12572 .unsol_event = alc268_acer_lc_unsol_event,
12573 .init_hook = alc268_acer_lc_init_hook,
12574 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012575 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012576 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012577 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12578 alc268_dell_verbs },
12579 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12580 .dac_nids = alc268_dac_nids,
12581 .hp_nid = 0x02,
12582 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12583 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012584 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012585 .init_hook = alc268_dell_init_hook,
12586 .input_mux = &alc268_capture_source,
12587 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012588 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012589 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12590 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012591 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12592 alc268_toshiba_verbs },
12593 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12594 .dac_nids = alc268_dac_nids,
12595 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12596 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012597 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012598 .hp_nid = 0x03,
12599 .dig_out_nid = ALC268_DIGOUT_NID,
12600 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12601 .channel_mode = alc268_modes,
12602 .input_mux = &alc268_capture_source,
12603 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012604 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012605 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012606#ifdef CONFIG_SND_DEBUG
12607 [ALC268_TEST] = {
12608 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12609 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12610 alc268_volume_init_verbs },
12611 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12612 .dac_nids = alc268_dac_nids,
12613 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12614 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012615 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012616 .hp_nid = 0x03,
12617 .dig_out_nid = ALC268_DIGOUT_NID,
12618 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12619 .channel_mode = alc268_modes,
12620 .input_mux = &alc268_capture_source,
12621 },
12622#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012623};
12624
12625static int patch_alc268(struct hda_codec *codec)
12626{
12627 struct alc_spec *spec;
12628 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012629 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012630
12631 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12632 if (spec == NULL)
12633 return -ENOMEM;
12634
12635 codec->spec = spec;
12636
12637 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12638 alc268_models,
12639 alc268_cfg_tbl);
12640
12641 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012642 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12643 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012644 board_config = ALC268_AUTO;
12645 }
12646
12647 if (board_config == ALC268_AUTO) {
12648 /* automatic parse from the BIOS config */
12649 err = alc268_parse_auto_config(codec);
12650 if (err < 0) {
12651 alc_free(codec);
12652 return err;
12653 } else if (!err) {
12654 printk(KERN_INFO
12655 "hda_codec: Cannot set up configuration "
12656 "from BIOS. Using base mode...\n");
12657 board_config = ALC268_3ST;
12658 }
12659 }
12660
12661 if (board_config != ALC268_AUTO)
12662 setup_preset(spec, &alc268_presets[board_config]);
12663
Kailang Yanga361d842007-06-05 12:30:55 +020012664 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12665 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012666 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012667
Kailang Yanga361d842007-06-05 12:30:55 +020012668 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12669
Takashi Iwai22971e32009-02-10 11:56:44 +010012670 has_beep = 0;
12671 for (i = 0; i < spec->num_mixers; i++) {
12672 if (spec->mixers[i] == alc268_beep_mixer) {
12673 has_beep = 1;
12674 break;
12675 }
12676 }
12677
12678 if (has_beep) {
12679 err = snd_hda_attach_beep_device(codec, 0x1);
12680 if (err < 0) {
12681 alc_free(codec);
12682 return err;
12683 }
12684 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12685 /* override the amp caps for beep generator */
12686 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012687 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12688 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12689 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12690 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012691 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012692
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012693 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012694 /* check whether NID 0x07 is valid */
12695 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012696 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012697
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012698 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012699 wcap = get_wcaps_type(wcap);
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012700 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012701 spec->adc_nids = alc268_adc_nids_alt;
12702 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012703 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012704 } else {
12705 spec->adc_nids = alc268_adc_nids;
12706 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012707 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012708 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012709 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012710 /* set default input source */
12711 for (i = 0; i < spec->num_adc_nids; i++)
12712 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12713 0, AC_VERB_SET_CONNECT_SEL,
12714 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012715 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012716
12717 spec->vmaster_nid = 0x02;
12718
Kailang Yanga361d842007-06-05 12:30:55 +020012719 codec->patch_ops = alc_patch_ops;
12720 if (board_config == ALC268_AUTO)
12721 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012722
Takashi Iwaidaead532008-11-28 12:55:36 +010012723 codec->proc_widget_hook = print_realtek_coef;
12724
Kailang Yanga361d842007-06-05 12:30:55 +020012725 return 0;
12726}
12727
12728/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012729 * ALC269 channel source setting (2 channel)
12730 */
12731#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12732
12733#define alc269_dac_nids alc260_dac_nids
12734
12735static hda_nid_t alc269_adc_nids[1] = {
12736 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012737 0x08,
12738};
12739
Takashi Iwaie01bf502008-08-21 16:25:07 +020012740static hda_nid_t alc269_capsrc_nids[1] = {
12741 0x23,
12742};
12743
12744/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12745 * not a mux!
12746 */
12747
Kailang Yangf53281e2008-07-18 12:36:43 +020012748static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12749 .num_items = 2,
12750 .items = {
12751 { "i-Mic", 0x5 },
12752 { "e-Mic", 0x0 },
12753 },
12754};
12755
12756static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12757 .num_items = 2,
12758 .items = {
12759 { "i-Mic", 0x1 },
12760 { "e-Mic", 0x0 },
12761 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012762};
12763
12764#define alc269_modes alc260_modes
12765#define alc269_capture_source alc880_lg_lw_capture_source
12766
12767static struct snd_kcontrol_new alc269_base_mixer[] = {
12768 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12769 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12770 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12771 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12772 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12773 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12774 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12775 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12776 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12777 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12778 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12779 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12780 { } /* end */
12781};
12782
Kailang Yang60db6b52008-08-26 13:13:00 +020012783static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12784 /* output mixer control */
12785 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12786 {
12787 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12788 .name = "Master Playback Switch",
12789 .info = snd_hda_mixer_amp_switch_info,
12790 .get = snd_hda_mixer_amp_switch_get,
12791 .put = alc268_acer_master_sw_put,
12792 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12793 },
12794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12795 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12796 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12797 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12798 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12799 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012800 { }
12801};
12802
Tony Vroon64154832008-11-06 15:08:49 +000012803static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12804 /* output mixer control */
12805 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12806 {
12807 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12808 .name = "Master Playback Switch",
12809 .info = snd_hda_mixer_amp_switch_info,
12810 .get = snd_hda_mixer_amp_switch_get,
12811 .put = alc268_acer_master_sw_put,
12812 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12813 },
12814 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12815 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12816 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12817 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12818 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12819 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12820 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12821 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12822 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012823 { }
12824};
12825
Kailang Yangf53281e2008-07-18 12:36:43 +020012826static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012827 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012828 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012829 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012830 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012831 { } /* end */
12832};
12833
Kailang Yangf6a92242007-12-13 16:52:54 +010012834/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012835static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12836 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12837 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012838 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12839 { } /* end */
12840};
12841
12842/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012843#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012844
Kailang Yang60db6b52008-08-26 13:13:00 +020012845static struct hda_verb alc269_quanta_fl1_verbs[] = {
12846 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12847 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12848 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12849 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12850 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12851 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12852 { }
12853};
12854
Tony Vroon64154832008-11-06 15:08:49 +000012855static struct hda_verb alc269_lifebook_verbs[] = {
12856 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12857 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12858 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12859 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12860 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12861 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12862 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12863 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12864 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12865 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12866 { }
12867};
12868
Kailang Yang60db6b52008-08-26 13:13:00 +020012869/* toggle speaker-output according to the hp-jack state */
12870static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12871{
12872 unsigned int present;
12873 unsigned char bits;
12874
12875 present = snd_hda_codec_read(codec, 0x15, 0,
12876 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12877 bits = present ? AMP_IN_MUTE(0) : 0;
12878 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12879 AMP_IN_MUTE(0), bits);
12880 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12881 AMP_IN_MUTE(0), bits);
12882
12883 snd_hda_codec_write(codec, 0x20, 0,
12884 AC_VERB_SET_COEF_INDEX, 0x0c);
12885 snd_hda_codec_write(codec, 0x20, 0,
12886 AC_VERB_SET_PROC_COEF, 0x680);
12887
12888 snd_hda_codec_write(codec, 0x20, 0,
12889 AC_VERB_SET_COEF_INDEX, 0x0c);
12890 snd_hda_codec_write(codec, 0x20, 0,
12891 AC_VERB_SET_PROC_COEF, 0x480);
12892}
12893
Tony Vroon64154832008-11-06 15:08:49 +000012894/* toggle speaker-output according to the hp-jacks state */
12895static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12896{
12897 unsigned int present;
12898 unsigned char bits;
12899
12900 /* Check laptop headphone socket */
12901 present = snd_hda_codec_read(codec, 0x15, 0,
12902 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12903
12904 /* Check port replicator headphone socket */
12905 present |= snd_hda_codec_read(codec, 0x1a, 0,
12906 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12907
12908 bits = present ? AMP_IN_MUTE(0) : 0;
12909 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12910 AMP_IN_MUTE(0), bits);
12911 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12912 AMP_IN_MUTE(0), bits);
12913
12914 snd_hda_codec_write(codec, 0x20, 0,
12915 AC_VERB_SET_COEF_INDEX, 0x0c);
12916 snd_hda_codec_write(codec, 0x20, 0,
12917 AC_VERB_SET_PROC_COEF, 0x680);
12918
12919 snd_hda_codec_write(codec, 0x20, 0,
12920 AC_VERB_SET_COEF_INDEX, 0x0c);
12921 snd_hda_codec_write(codec, 0x20, 0,
12922 AC_VERB_SET_PROC_COEF, 0x480);
12923}
12924
Kailang Yang60db6b52008-08-26 13:13:00 +020012925static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12926{
12927 unsigned int present;
12928
12929 present = snd_hda_codec_read(codec, 0x18, 0,
12930 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12931 snd_hda_codec_write(codec, 0x23, 0,
12932 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12933}
12934
Tony Vroon64154832008-11-06 15:08:49 +000012935static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12936{
12937 unsigned int present_laptop;
12938 unsigned int present_dock;
12939
12940 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12941 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12942
12943 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12944 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12945
12946 /* Laptop mic port overrides dock mic port, design decision */
12947 if (present_dock)
12948 snd_hda_codec_write(codec, 0x23, 0,
12949 AC_VERB_SET_CONNECT_SEL, 0x3);
12950 if (present_laptop)
12951 snd_hda_codec_write(codec, 0x23, 0,
12952 AC_VERB_SET_CONNECT_SEL, 0x0);
12953 if (!present_dock && !present_laptop)
12954 snd_hda_codec_write(codec, 0x23, 0,
12955 AC_VERB_SET_CONNECT_SEL, 0x1);
12956}
12957
Kailang Yang60db6b52008-08-26 13:13:00 +020012958static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12959 unsigned int res)
12960{
12961 if ((res >> 26) == ALC880_HP_EVENT)
12962 alc269_quanta_fl1_speaker_automute(codec);
12963 if ((res >> 26) == ALC880_MIC_EVENT)
12964 alc269_quanta_fl1_mic_automute(codec);
12965}
12966
Tony Vroon64154832008-11-06 15:08:49 +000012967static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12968 unsigned int res)
12969{
12970 if ((res >> 26) == ALC880_HP_EVENT)
12971 alc269_lifebook_speaker_automute(codec);
12972 if ((res >> 26) == ALC880_MIC_EVENT)
12973 alc269_lifebook_mic_autoswitch(codec);
12974}
12975
Kailang Yang60db6b52008-08-26 13:13:00 +020012976static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12977{
12978 alc269_quanta_fl1_speaker_automute(codec);
12979 alc269_quanta_fl1_mic_automute(codec);
12980}
12981
Tony Vroon64154832008-11-06 15:08:49 +000012982static void alc269_lifebook_init_hook(struct hda_codec *codec)
12983{
12984 alc269_lifebook_speaker_automute(codec);
12985 alc269_lifebook_mic_autoswitch(codec);
12986}
12987
Kailang Yang60db6b52008-08-26 13:13:00 +020012988static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12989 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12990 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12991 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12992 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12993 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12994 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12995 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12996 {}
12997};
12998
12999static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13000 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13001 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13002 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13003 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13004 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13005 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13006 {}
13007};
13008
13009/* toggle speaker-output according to the hp-jack state */
13010static void alc269_speaker_automute(struct hda_codec *codec)
13011{
13012 unsigned int present;
13013 unsigned char bits;
13014
13015 present = snd_hda_codec_read(codec, 0x15, 0,
13016 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13017 bits = present ? AMP_IN_MUTE(0) : 0;
13018 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13019 AMP_IN_MUTE(0), bits);
13020 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13021 AMP_IN_MUTE(0), bits);
13022}
13023
13024static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
13025{
13026 unsigned int present;
13027
13028 present = snd_hda_codec_read(codec, 0x18, 0,
13029 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13030 snd_hda_codec_write(codec, 0x23, 0,
13031 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
13032}
13033
13034static void alc269_eeepc_amic_automute(struct hda_codec *codec)
13035{
13036 unsigned int present;
13037
13038 present = snd_hda_codec_read(codec, 0x18, 0,
13039 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13040 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13041 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13042 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13043 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13044}
13045
13046/* unsolicited event for HP jack sensing */
13047static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
13048 unsigned int res)
13049{
13050 if ((res >> 26) == ALC880_HP_EVENT)
13051 alc269_speaker_automute(codec);
13052
13053 if ((res >> 26) == ALC880_MIC_EVENT)
13054 alc269_eeepc_dmic_automute(codec);
13055}
13056
13057static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
13058{
13059 alc269_speaker_automute(codec);
13060 alc269_eeepc_dmic_automute(codec);
13061}
13062
13063/* unsolicited event for HP jack sensing */
13064static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
13065 unsigned int res)
13066{
13067 if ((res >> 26) == ALC880_HP_EVENT)
13068 alc269_speaker_automute(codec);
13069
13070 if ((res >> 26) == ALC880_MIC_EVENT)
13071 alc269_eeepc_amic_automute(codec);
13072}
13073
13074static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
13075{
13076 alc269_speaker_automute(codec);
13077 alc269_eeepc_amic_automute(codec);
13078}
13079
Kailang Yangf6a92242007-12-13 16:52:54 +010013080/*
13081 * generic initialization of ADC, input mixers and output mixers
13082 */
13083static struct hda_verb alc269_init_verbs[] = {
13084 /*
13085 * Unmute ADC0 and set the default input to mic-in
13086 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013087 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013088
13089 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13090 * analog-loopback mixer widget
13091 * Note: PASD motherboards uses the Line In 2 as the input for
13092 * front panel mic (mic 2)
13093 */
13094 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13095 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13096 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13100
13101 /*
13102 * Set up output mixers (0x0c - 0x0e)
13103 */
13104 /* set vol=0 to output mixers */
13105 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13106 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13107
13108 /* set up input amps for analog loopback */
13109 /* Amp Indices: DAC = 0, mixer = 1 */
13110 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13111 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13112 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13113 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13114 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13115 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13116
13117 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13118 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13119 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13120 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13121 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13122 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13123 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13124
13125 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13127 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13128 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13129 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13130 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13131 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13132
13133 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13134 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13135
13136 /* FIXME: use matrix-type input source selection */
13137 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13138 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013139 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13140 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013141 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13142 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13143
13144 /* set EAPD */
13145 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13146 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13147 { }
13148};
13149
13150/* add playback controls from the parsed DAC table */
13151static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
13152 const struct auto_pin_cfg *cfg)
13153{
13154 hda_nid_t nid;
13155 int err;
13156
13157 spec->multiout.num_dacs = 1; /* only use one dac */
13158 spec->multiout.dac_nids = spec->private_dac_nids;
13159 spec->multiout.dac_nids[0] = 2;
13160
13161 nid = cfg->line_out_pins[0];
13162 if (nid) {
13163 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13164 "Front Playback Volume",
13165 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
13166 if (err < 0)
13167 return err;
13168 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13169 "Front Playback Switch",
13170 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13171 if (err < 0)
13172 return err;
13173 }
13174
13175 nid = cfg->speaker_pins[0];
13176 if (nid) {
13177 if (!cfg->line_out_pins[0]) {
13178 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13179 "Speaker Playback Volume",
13180 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13181 HDA_OUTPUT));
13182 if (err < 0)
13183 return err;
13184 }
13185 if (nid == 0x16) {
13186 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13187 "Speaker Playback Switch",
13188 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13189 HDA_OUTPUT));
13190 if (err < 0)
13191 return err;
13192 } else {
13193 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13194 "Speaker Playback Switch",
13195 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13196 HDA_OUTPUT));
13197 if (err < 0)
13198 return err;
13199 }
13200 }
13201 nid = cfg->hp_pins[0];
13202 if (nid) {
13203 /* spec->multiout.hp_nid = 2; */
13204 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
13205 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13206 "Headphone Playback Volume",
13207 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13208 HDA_OUTPUT));
13209 if (err < 0)
13210 return err;
13211 }
13212 if (nid == 0x16) {
13213 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13214 "Headphone Playback Switch",
13215 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13216 HDA_OUTPUT));
13217 if (err < 0)
13218 return err;
13219 } else {
13220 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13221 "Headphone Playback Switch",
13222 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13223 HDA_OUTPUT));
13224 if (err < 0)
13225 return err;
13226 }
13227 }
13228 return 0;
13229}
13230
Takashi Iwai8c927b42009-06-22 10:56:54 +020013231#define alc269_auto_create_analog_input_ctls \
13232 alc262_auto_create_analog_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013233
13234#ifdef CONFIG_SND_HDA_POWER_SAVE
13235#define alc269_loopbacks alc880_loopbacks
13236#endif
13237
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013238/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013239#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13240#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13241#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13242#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13243
Takashi Iwaif03d3112009-03-05 14:18:16 +010013244static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13245 .substreams = 1,
13246 .channels_min = 2,
13247 .channels_max = 8,
13248 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13249 /* NID is set in alc_build_pcms */
13250 .ops = {
13251 .open = alc880_playback_pcm_open,
13252 .prepare = alc880_playback_pcm_prepare,
13253 .cleanup = alc880_playback_pcm_cleanup
13254 },
13255};
13256
13257static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13258 .substreams = 1,
13259 .channels_min = 2,
13260 .channels_max = 2,
13261 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13262 /* NID is set in alc_build_pcms */
13263};
13264
Kailang Yangf6a92242007-12-13 16:52:54 +010013265/*
13266 * BIOS auto configuration
13267 */
13268static int alc269_parse_auto_config(struct hda_codec *codec)
13269{
13270 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013271 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013272 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13273
13274 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13275 alc269_ignore);
13276 if (err < 0)
13277 return err;
13278
13279 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13280 if (err < 0)
13281 return err;
13282 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13283 if (err < 0)
13284 return err;
13285
13286 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13287
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013288 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013289 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13290
Takashi Iwai603c4012008-07-30 15:01:44 +020013291 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013292 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013293
Takashi Iwaid88897e2008-10-31 15:01:37 +010013294 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013295 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013296 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013297 /* set default input source */
13298 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13299 0, AC_VERB_SET_CONNECT_SEL,
13300 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013301
13302 err = alc_auto_add_mic_boost(codec);
13303 if (err < 0)
13304 return err;
13305
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013306 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013307 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013308
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013309 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13310
Kailang Yangf6a92242007-12-13 16:52:54 +010013311 return 1;
13312}
13313
13314#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13315#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13316#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13317
13318
13319/* init callback for auto-configuration model -- overriding the default init */
13320static void alc269_auto_init(struct hda_codec *codec)
13321{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013322 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013323 alc269_auto_init_multi_out(codec);
13324 alc269_auto_init_hp_out(codec);
13325 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013326 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013327 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013328}
13329
13330/*
13331 * configuration and preset
13332 */
13333static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013334 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013335 [ALC269_QUANTA_FL1] = "quanta",
13336 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013337 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013338 [ALC269_FUJITSU] = "fujitsu",
13339 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013340};
13341
13342static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013343 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013344 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13345 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013346 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13347 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13348 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13349 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13350 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13351 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013352 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13353 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013354 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13355 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013356 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013357 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013358 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013359 {}
13360};
13361
13362static struct alc_config_preset alc269_presets[] = {
13363 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013364 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013365 .init_verbs = { alc269_init_verbs },
13366 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13367 .dac_nids = alc269_dac_nids,
13368 .hp_nid = 0x03,
13369 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13370 .channel_mode = alc269_modes,
13371 .input_mux = &alc269_capture_source,
13372 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013373 [ALC269_QUANTA_FL1] = {
13374 .mixers = { alc269_quanta_fl1_mixer },
13375 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13376 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13377 .dac_nids = alc269_dac_nids,
13378 .hp_nid = 0x03,
13379 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13380 .channel_mode = alc269_modes,
13381 .input_mux = &alc269_capture_source,
13382 .unsol_event = alc269_quanta_fl1_unsol_event,
13383 .init_hook = alc269_quanta_fl1_init_hook,
13384 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013385 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013386 .mixers = { alc269_eeepc_mixer },
13387 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013388 .init_verbs = { alc269_init_verbs,
13389 alc269_eeepc_amic_init_verbs },
13390 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13391 .dac_nids = alc269_dac_nids,
13392 .hp_nid = 0x03,
13393 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13394 .channel_mode = alc269_modes,
13395 .input_mux = &alc269_eeepc_amic_capture_source,
13396 .unsol_event = alc269_eeepc_amic_unsol_event,
13397 .init_hook = alc269_eeepc_amic_inithook,
13398 },
13399 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013400 .mixers = { alc269_eeepc_mixer },
13401 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013402 .init_verbs = { alc269_init_verbs,
13403 alc269_eeepc_dmic_init_verbs },
13404 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13405 .dac_nids = alc269_dac_nids,
13406 .hp_nid = 0x03,
13407 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13408 .channel_mode = alc269_modes,
13409 .input_mux = &alc269_eeepc_dmic_capture_source,
13410 .unsol_event = alc269_eeepc_dmic_unsol_event,
13411 .init_hook = alc269_eeepc_dmic_inithook,
13412 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013413 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013414 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013415 .cap_mixer = alc269_epc_capture_mixer,
13416 .init_verbs = { alc269_init_verbs,
13417 alc269_eeepc_dmic_init_verbs },
13418 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13419 .dac_nids = alc269_dac_nids,
13420 .hp_nid = 0x03,
13421 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13422 .channel_mode = alc269_modes,
13423 .input_mux = &alc269_eeepc_dmic_capture_source,
13424 .unsol_event = alc269_eeepc_dmic_unsol_event,
13425 .init_hook = alc269_eeepc_dmic_inithook,
13426 },
Tony Vroon64154832008-11-06 15:08:49 +000013427 [ALC269_LIFEBOOK] = {
13428 .mixers = { alc269_lifebook_mixer },
13429 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13430 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13431 .dac_nids = alc269_dac_nids,
13432 .hp_nid = 0x03,
13433 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13434 .channel_mode = alc269_modes,
13435 .input_mux = &alc269_capture_source,
13436 .unsol_event = alc269_lifebook_unsol_event,
13437 .init_hook = alc269_lifebook_init_hook,
13438 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013439};
13440
13441static int patch_alc269(struct hda_codec *codec)
13442{
13443 struct alc_spec *spec;
13444 int board_config;
13445 int err;
13446
13447 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13448 if (spec == NULL)
13449 return -ENOMEM;
13450
13451 codec->spec = spec;
13452
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013453 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13454
Kailang Yangf6a92242007-12-13 16:52:54 +010013455 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13456 alc269_models,
13457 alc269_cfg_tbl);
13458
13459 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013460 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13461 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013462 board_config = ALC269_AUTO;
13463 }
13464
13465 if (board_config == ALC269_AUTO) {
13466 /* automatic parse from the BIOS config */
13467 err = alc269_parse_auto_config(codec);
13468 if (err < 0) {
13469 alc_free(codec);
13470 return err;
13471 } else if (!err) {
13472 printk(KERN_INFO
13473 "hda_codec: Cannot set up configuration "
13474 "from BIOS. Using base mode...\n");
13475 board_config = ALC269_BASIC;
13476 }
13477 }
13478
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013479 err = snd_hda_attach_beep_device(codec, 0x1);
13480 if (err < 0) {
13481 alc_free(codec);
13482 return err;
13483 }
13484
Kailang Yangf6a92242007-12-13 16:52:54 +010013485 if (board_config != ALC269_AUTO)
13486 setup_preset(spec, &alc269_presets[board_config]);
13487
Takashi Iwaif03d3112009-03-05 14:18:16 +010013488 if (codec->subsystem_id == 0x17aa3bf8) {
13489 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13490 * fix the sample rate of analog I/O to 44.1kHz
13491 */
13492 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13493 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13494 } else {
13495 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13496 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13497 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013498 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13499 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13500
13501 spec->adc_nids = alc269_adc_nids;
13502 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013503 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013504 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013505 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013506 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013507
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013508 spec->vmaster_nid = 0x02;
13509
Kailang Yangf6a92242007-12-13 16:52:54 +010013510 codec->patch_ops = alc_patch_ops;
13511 if (board_config == ALC269_AUTO)
13512 spec->init_hook = alc269_auto_init;
13513#ifdef CONFIG_SND_HDA_POWER_SAVE
13514 if (!spec->loopback.amplist)
13515 spec->loopback.amplist = alc269_loopbacks;
13516#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013517 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013518
13519 return 0;
13520}
13521
13522/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013523 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13524 */
13525
13526/*
13527 * set the path ways for 2 channel output
13528 * need to set the codec line out and mic 1 pin widgets to inputs
13529 */
13530static struct hda_verb alc861_threestack_ch2_init[] = {
13531 /* set pin widget 1Ah (line in) for input */
13532 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013533 /* set pin widget 18h (mic1/2) for input, for mic also enable
13534 * the vref
13535 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013536 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13537
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013538 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13539#if 0
13540 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13541 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13542#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013543 { } /* end */
13544};
13545/*
13546 * 6ch mode
13547 * need to set the codec line out and mic 1 pin widgets to outputs
13548 */
13549static struct hda_verb alc861_threestack_ch6_init[] = {
13550 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13551 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13552 /* set pin widget 18h (mic1) for output (CLFE)*/
13553 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13554
13555 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013556 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013557
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013558 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13559#if 0
13560 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13561 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13562#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013563 { } /* end */
13564};
13565
13566static struct hda_channel_mode alc861_threestack_modes[2] = {
13567 { 2, alc861_threestack_ch2_init },
13568 { 6, alc861_threestack_ch6_init },
13569};
Takashi Iwai22309c32006-08-09 16:57:28 +020013570/* Set mic1 as input and unmute the mixer */
13571static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13572 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13573 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13574 { } /* end */
13575};
13576/* Set mic1 as output and mute mixer */
13577static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13578 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13579 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13580 { } /* end */
13581};
13582
13583static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13584 { 2, alc861_uniwill_m31_ch2_init },
13585 { 4, alc861_uniwill_m31_ch4_init },
13586};
Kailang Yangdf694da2005-12-05 19:42:22 +010013587
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013588/* Set mic1 and line-in as input and unmute the mixer */
13589static struct hda_verb alc861_asus_ch2_init[] = {
13590 /* set pin widget 1Ah (line in) for input */
13591 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013592 /* set pin widget 18h (mic1/2) for input, for mic also enable
13593 * the vref
13594 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013595 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13596
13597 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13598#if 0
13599 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13600 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13601#endif
13602 { } /* end */
13603};
13604/* Set mic1 nad line-in as output and mute mixer */
13605static struct hda_verb alc861_asus_ch6_init[] = {
13606 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13607 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13608 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13609 /* set pin widget 18h (mic1) for output (CLFE)*/
13610 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13611 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13612 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13613 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13614
13615 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13616#if 0
13617 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13618 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13619#endif
13620 { } /* end */
13621};
13622
13623static struct hda_channel_mode alc861_asus_modes[2] = {
13624 { 2, alc861_asus_ch2_init },
13625 { 6, alc861_asus_ch6_init },
13626};
13627
Kailang Yangdf694da2005-12-05 19:42:22 +010013628/* patch-ALC861 */
13629
13630static struct snd_kcontrol_new alc861_base_mixer[] = {
13631 /* output mixer control */
13632 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13633 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13634 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13635 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13636 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13637
13638 /*Input mixer control */
13639 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13640 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13641 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13642 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13643 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13644 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13646 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13647 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13648 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013649
Kailang Yangdf694da2005-12-05 19:42:22 +010013650 { } /* end */
13651};
13652
13653static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13654 /* output mixer control */
13655 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13656 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13657 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13658 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13659 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13660
13661 /* Input mixer control */
13662 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13663 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13664 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13665 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13666 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13667 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13668 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13669 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13670 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13671 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013672
Kailang Yangdf694da2005-12-05 19:42:22 +010013673 {
13674 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13675 .name = "Channel Mode",
13676 .info = alc_ch_mode_info,
13677 .get = alc_ch_mode_get,
13678 .put = alc_ch_mode_put,
13679 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13680 },
13681 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013682};
13683
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013684static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013685 /* output mixer control */
13686 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13687 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13688 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013689
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013690 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013691};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013692
Takashi Iwai22309c32006-08-09 16:57:28 +020013693static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13694 /* output mixer control */
13695 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13696 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13697 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13698 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13699 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13700
13701 /* Input mixer control */
13702 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13703 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13704 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13705 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13706 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13707 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13709 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13710 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13711 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013712
Takashi Iwai22309c32006-08-09 16:57:28 +020013713 {
13714 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13715 .name = "Channel Mode",
13716 .info = alc_ch_mode_info,
13717 .get = alc_ch_mode_get,
13718 .put = alc_ch_mode_put,
13719 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13720 },
13721 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013722};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013723
13724static struct snd_kcontrol_new alc861_asus_mixer[] = {
13725 /* output mixer control */
13726 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13727 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13728 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13729 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13730 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13731
13732 /* Input mixer control */
13733 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13734 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13735 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13736 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13737 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13738 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13739 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13740 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13741 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013742 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13743
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013744 {
13745 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13746 .name = "Channel Mode",
13747 .info = alc_ch_mode_info,
13748 .get = alc_ch_mode_get,
13749 .put = alc_ch_mode_put,
13750 .private_value = ARRAY_SIZE(alc861_asus_modes),
13751 },
13752 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013753};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013754
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013755/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013756static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013757 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13758 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013759 { }
13760};
13761
Kailang Yangdf694da2005-12-05 19:42:22 +010013762/*
13763 * generic initialization of ADC, input mixers and output mixers
13764 */
13765static struct hda_verb alc861_base_init_verbs[] = {
13766 /*
13767 * Unmute ADC0 and set the default input to mic-in
13768 */
13769 /* port-A for surround (rear panel) */
13770 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13771 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13772 /* port-B for mic-in (rear panel) with vref */
13773 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13774 /* port-C for line-in (rear panel) */
13775 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13776 /* port-D for Front */
13777 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13778 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13779 /* port-E for HP out (front panel) */
13780 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13781 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013782 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013783 /* port-F for mic-in (front panel) with vref */
13784 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13785 /* port-G for CLFE (rear panel) */
13786 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13787 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13788 /* port-H for side (rear panel) */
13789 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13790 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13791 /* CD-in */
13792 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13793 /* route front mic to ADC1*/
13794 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13795 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013796
Kailang Yangdf694da2005-12-05 19:42:22 +010013797 /* Unmute DAC0~3 & spdif out*/
13798 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13799 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13800 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13801 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13802 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013803
Kailang Yangdf694da2005-12-05 19:42:22 +010013804 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13805 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13806 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13807 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13808 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013809
Kailang Yangdf694da2005-12-05 19:42:22 +010013810 /* Unmute Stereo Mixer 15 */
13811 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13812 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13813 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013814 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013815
13816 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13817 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13818 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13819 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13820 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13821 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13822 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13823 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013824 /* hp used DAC 3 (Front) */
13825 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013826 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13827
13828 { }
13829};
13830
13831static struct hda_verb alc861_threestack_init_verbs[] = {
13832 /*
13833 * Unmute ADC0 and set the default input to mic-in
13834 */
13835 /* port-A for surround (rear panel) */
13836 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13837 /* port-B for mic-in (rear panel) with vref */
13838 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13839 /* port-C for line-in (rear panel) */
13840 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13841 /* port-D for Front */
13842 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13843 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13844 /* port-E for HP out (front panel) */
13845 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13846 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013847 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013848 /* port-F for mic-in (front panel) with vref */
13849 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13850 /* port-G for CLFE (rear panel) */
13851 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13852 /* port-H for side (rear panel) */
13853 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13854 /* CD-in */
13855 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13856 /* route front mic to ADC1*/
13857 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13858 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13859 /* Unmute DAC0~3 & spdif out*/
13860 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13861 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13862 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13863 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13864 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013865
Kailang Yangdf694da2005-12-05 19:42:22 +010013866 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13867 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13868 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13869 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13870 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013871
Kailang Yangdf694da2005-12-05 19:42:22 +010013872 /* Unmute Stereo Mixer 15 */
13873 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13875 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013876 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013877
13878 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13879 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13880 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13881 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13882 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13883 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13884 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13885 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013886 /* hp used DAC 3 (Front) */
13887 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013888 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13889 { }
13890};
Takashi Iwai22309c32006-08-09 16:57:28 +020013891
13892static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13893 /*
13894 * Unmute ADC0 and set the default input to mic-in
13895 */
13896 /* port-A for surround (rear panel) */
13897 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13898 /* port-B for mic-in (rear panel) with vref */
13899 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13900 /* port-C for line-in (rear panel) */
13901 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13902 /* port-D for Front */
13903 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13904 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13905 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013906 /* this has to be set to VREF80 */
13907 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013908 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013909 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013910 /* port-F for mic-in (front panel) with vref */
13911 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13912 /* port-G for CLFE (rear panel) */
13913 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13914 /* port-H for side (rear panel) */
13915 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13916 /* CD-in */
13917 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13918 /* route front mic to ADC1*/
13919 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13920 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13921 /* Unmute DAC0~3 & spdif out*/
13922 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13923 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13924 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13925 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13926 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013927
Takashi Iwai22309c32006-08-09 16:57:28 +020013928 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13929 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13930 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13931 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13932 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013933
Takashi Iwai22309c32006-08-09 16:57:28 +020013934 /* Unmute Stereo Mixer 15 */
13935 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13936 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13937 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013938 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013939
13940 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13941 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13942 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13943 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13944 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13945 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13946 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13947 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013948 /* hp used DAC 3 (Front) */
13949 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013950 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13951 { }
13952};
13953
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013954static struct hda_verb alc861_asus_init_verbs[] = {
13955 /*
13956 * Unmute ADC0 and set the default input to mic-in
13957 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013958 /* port-A for surround (rear panel)
13959 * according to codec#0 this is the HP jack
13960 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013961 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13962 /* route front PCM to HP */
13963 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13964 /* port-B for mic-in (rear panel) with vref */
13965 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13966 /* port-C for line-in (rear panel) */
13967 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13968 /* port-D for Front */
13969 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13970 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13971 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013972 /* this has to be set to VREF80 */
13973 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013974 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013975 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013976 /* port-F for mic-in (front panel) with vref */
13977 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13978 /* port-G for CLFE (rear panel) */
13979 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13980 /* port-H for side (rear panel) */
13981 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13982 /* CD-in */
13983 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13984 /* route front mic to ADC1*/
13985 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13986 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13987 /* Unmute DAC0~3 & spdif out*/
13988 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13989 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13990 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13991 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13992 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13993 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13994 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13995 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13996 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13997 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013998
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013999 /* Unmute Stereo Mixer 15 */
14000 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14001 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14002 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014003 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014004
14005 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14006 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14007 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14008 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14009 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14010 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14011 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14012 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014013 /* hp used DAC 3 (Front) */
14014 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014015 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14016 { }
14017};
14018
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014019/* additional init verbs for ASUS laptops */
14020static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14021 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14022 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14023 { }
14024};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014025
Kailang Yangdf694da2005-12-05 19:42:22 +010014026/*
14027 * generic initialization of ADC, input mixers and output mixers
14028 */
14029static struct hda_verb alc861_auto_init_verbs[] = {
14030 /*
14031 * Unmute ADC0 and set the default input to mic-in
14032 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014033 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014034 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014035
Kailang Yangdf694da2005-12-05 19:42:22 +010014036 /* Unmute DAC0~3 & spdif out*/
14037 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14038 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14039 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14040 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14041 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014042
Kailang Yangdf694da2005-12-05 19:42:22 +010014043 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14044 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14045 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14046 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14047 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014048
Kailang Yangdf694da2005-12-05 19:42:22 +010014049 /* Unmute Stereo Mixer 15 */
14050 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14052 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14053 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14054
Takashi Iwai1c209302009-07-22 15:17:45 +020014055 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14056 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14057 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14058 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14059 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14060 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14061 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14062 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014063
14064 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14065 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014066 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14067 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014068 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14069 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014070 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14071 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014072
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014073 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014074
14075 { }
14076};
14077
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014078static struct hda_verb alc861_toshiba_init_verbs[] = {
14079 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014080
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014081 { }
14082};
14083
14084/* toggle speaker-output according to the hp-jack state */
14085static void alc861_toshiba_automute(struct hda_codec *codec)
14086{
14087 unsigned int present;
14088
14089 present = snd_hda_codec_read(codec, 0x0f, 0,
14090 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014091 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14092 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14093 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14094 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014095}
14096
14097static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14098 unsigned int res)
14099{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014100 if ((res >> 26) == ALC880_HP_EVENT)
14101 alc861_toshiba_automute(codec);
14102}
14103
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014104/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014105#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14106#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14107#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14108#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14109
14110
14111#define ALC861_DIGOUT_NID 0x07
14112
14113static struct hda_channel_mode alc861_8ch_modes[1] = {
14114 { 8, NULL }
14115};
14116
14117static hda_nid_t alc861_dac_nids[4] = {
14118 /* front, surround, clfe, side */
14119 0x03, 0x06, 0x05, 0x04
14120};
14121
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014122static hda_nid_t alc660_dac_nids[3] = {
14123 /* front, clfe, surround */
14124 0x03, 0x05, 0x06
14125};
14126
Kailang Yangdf694da2005-12-05 19:42:22 +010014127static hda_nid_t alc861_adc_nids[1] = {
14128 /* ADC0-2 */
14129 0x08,
14130};
14131
14132static struct hda_input_mux alc861_capture_source = {
14133 .num_items = 5,
14134 .items = {
14135 { "Mic", 0x0 },
14136 { "Front Mic", 0x3 },
14137 { "Line", 0x1 },
14138 { "CD", 0x4 },
14139 { "Mixer", 0x5 },
14140 },
14141};
14142
Takashi Iwai1c209302009-07-22 15:17:45 +020014143static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14144{
14145 struct alc_spec *spec = codec->spec;
14146 hda_nid_t mix, srcs[5];
14147 int i, j, num;
14148
14149 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14150 return 0;
14151 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14152 if (num < 0)
14153 return 0;
14154 for (i = 0; i < num; i++) {
14155 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014156 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014157 if (type != AC_WID_AUD_OUT)
14158 continue;
14159 for (j = 0; j < spec->multiout.num_dacs; j++)
14160 if (spec->multiout.dac_nids[j] == srcs[i])
14161 break;
14162 if (j >= spec->multiout.num_dacs)
14163 return srcs[i];
14164 }
14165 return 0;
14166}
14167
Kailang Yangdf694da2005-12-05 19:42:22 +010014168/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014169static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014170 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014171{
Takashi Iwai1c209302009-07-22 15:17:45 +020014172 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014173 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014174 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014175
14176 spec->multiout.dac_nids = spec->private_dac_nids;
14177 for (i = 0; i < cfg->line_outs; i++) {
14178 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014179 dac = alc861_look_for_dac(codec, nid);
14180 if (!dac)
14181 continue;
14182 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014183 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014184 return 0;
14185}
14186
Takashi Iwai1c209302009-07-22 15:17:45 +020014187static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14188 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014189{
14190 char name[32];
Takashi Iwai1c209302009-07-22 15:17:45 +020014191 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14192 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14193 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14194}
14195
14196/* add playback controls from the parsed DAC table */
14197static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14198 const struct auto_pin_cfg *cfg)
14199{
14200 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014201 static const char *chname[4] = {
14202 "Front", "Surround", NULL /*CLFE*/, "Side"
14203 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014204 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014205 int i, err;
14206
14207 if (cfg->line_outs == 1) {
14208 const char *pfx = NULL;
14209 if (!cfg->hp_outs)
14210 pfx = "Master";
14211 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14212 pfx = "Speaker";
14213 if (pfx) {
14214 nid = spec->multiout.dac_nids[0];
14215 return alc861_create_out_sw(codec, pfx, nid, 3);
14216 }
14217 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014218
14219 for (i = 0; i < cfg->line_outs; i++) {
14220 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014221 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014222 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014223 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014224 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014225 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014226 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014227 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014228 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014229 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014230 return err;
14231 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014232 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014233 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014234 return err;
14235 }
14236 }
14237 return 0;
14238}
14239
Takashi Iwai1c209302009-07-22 15:17:45 +020014240static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014241{
Takashi Iwai1c209302009-07-22 15:17:45 +020014242 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014243 int err;
14244 hda_nid_t nid;
14245
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014246 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014247 return 0;
14248
14249 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014250 nid = alc861_look_for_dac(codec, pin);
14251 if (nid) {
14252 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14253 if (err < 0)
14254 return err;
14255 spec->multiout.hp_nid = nid;
14256 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014257 }
14258 return 0;
14259}
14260
14261/* create playback/capture controls for input pins */
Takashi Iwai1c209302009-07-22 15:17:45 +020014262static int alc861_auto_create_analog_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014263 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014264{
Takashi Iwai1c209302009-07-22 15:17:45 +020014265 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014266 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014267 int i, err, idx, idx1;
14268
14269 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014270 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014271 case 0x0c:
14272 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014273 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014274 break;
14275 case 0x0f:
14276 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014277 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014278 break;
14279 case 0x0d:
14280 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014281 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014282 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014283 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014284 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014285 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014286 break;
14287 case 0x11:
14288 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014289 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014290 break;
14291 default:
14292 continue;
14293 }
14294
Takashi Iwai4a471b72005-12-07 13:56:29 +010014295 err = new_analog_input(spec, cfg->input_pins[i],
14296 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014297 if (err < 0)
14298 return err;
14299
Takashi Iwai4a471b72005-12-07 13:56:29 +010014300 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014301 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014302 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014303 }
14304 return 0;
14305}
14306
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014307static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14308 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014309 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014310{
Takashi Iwai1c209302009-07-22 15:17:45 +020014311 hda_nid_t mix, srcs[5];
14312 int i, num;
14313
Jacek Luczak564c5be2008-05-03 18:41:23 +020014314 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14315 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014316 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014317 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014318 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14319 return;
14320 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14321 if (num < 0)
14322 return;
14323 for (i = 0; i < num; i++) {
14324 unsigned int mute;
14325 if (srcs[i] == dac || srcs[i] == 0x15)
14326 mute = AMP_IN_UNMUTE(i);
14327 else
14328 mute = AMP_IN_MUTE(i);
14329 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14330 mute);
14331 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014332}
14333
14334static void alc861_auto_init_multi_out(struct hda_codec *codec)
14335{
14336 struct alc_spec *spec = codec->spec;
14337 int i;
14338
14339 for (i = 0; i < spec->autocfg.line_outs; i++) {
14340 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014341 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014342 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014343 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014344 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014345 }
14346}
14347
14348static void alc861_auto_init_hp_out(struct hda_codec *codec)
14349{
14350 struct alc_spec *spec = codec->spec;
14351 hda_nid_t pin;
14352
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014353 pin = spec->autocfg.hp_pins[0];
Takashi Iwai1c209302009-07-22 15:17:45 +020014354 if (pin)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014355 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014356 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014357 pin = spec->autocfg.speaker_pins[0];
14358 if (pin)
Takashi Iwai1c209302009-07-22 15:17:45 +020014359 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT,
14360 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014361}
14362
14363static void alc861_auto_init_analog_input(struct hda_codec *codec)
14364{
14365 struct alc_spec *spec = codec->spec;
14366 int i;
14367
14368 for (i = 0; i < AUTO_PIN_LAST; i++) {
14369 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014370 if (nid >= 0x0c && nid <= 0x11)
14371 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014372 }
14373}
14374
14375/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014376/* return 1 if successful, 0 if the proper config is not found,
14377 * or a negative error code
14378 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014379static int alc861_parse_auto_config(struct hda_codec *codec)
14380{
14381 struct alc_spec *spec = codec->spec;
14382 int err;
14383 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14384
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014385 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14386 alc861_ignore);
14387 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014388 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014389 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014390 return 0; /* can't find valid BIOS pin config */
14391
Takashi Iwai1c209302009-07-22 15:17:45 +020014392 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014393 if (err < 0)
14394 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014395 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014396 if (err < 0)
14397 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014398 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014399 if (err < 0)
14400 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014401 err = alc861_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014402 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014403 return err;
14404
14405 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14406
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014407 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014408 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14409
Takashi Iwai603c4012008-07-30 15:01:44 +020014410 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014411 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014412
Takashi Iwaid88897e2008-10-31 15:01:37 +010014413 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014414
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014415 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014416 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014417
14418 spec->adc_nids = alc861_adc_nids;
14419 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014420 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014421
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014422 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14423
Kailang Yangdf694da2005-12-05 19:42:22 +010014424 return 1;
14425}
14426
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014427/* additional initialization for auto-configuration model */
14428static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014429{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014430 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014431 alc861_auto_init_multi_out(codec);
14432 alc861_auto_init_hp_out(codec);
14433 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014434 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014435 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014436}
14437
Takashi Iwaicb53c622007-08-10 17:21:45 +020014438#ifdef CONFIG_SND_HDA_POWER_SAVE
14439static struct hda_amp_list alc861_loopbacks[] = {
14440 { 0x15, HDA_INPUT, 0 },
14441 { 0x15, HDA_INPUT, 1 },
14442 { 0x15, HDA_INPUT, 2 },
14443 { 0x15, HDA_INPUT, 3 },
14444 { } /* end */
14445};
14446#endif
14447
Kailang Yangdf694da2005-12-05 19:42:22 +010014448
14449/*
14450 * configuration and preset
14451 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014452static const char *alc861_models[ALC861_MODEL_LAST] = {
14453 [ALC861_3ST] = "3stack",
14454 [ALC660_3ST] = "3stack-660",
14455 [ALC861_3ST_DIG] = "3stack-dig",
14456 [ALC861_6ST_DIG] = "6stack-dig",
14457 [ALC861_UNIWILL_M31] = "uniwill-m31",
14458 [ALC861_TOSHIBA] = "toshiba",
14459 [ALC861_ASUS] = "asus",
14460 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14461 [ALC861_AUTO] = "auto",
14462};
14463
14464static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014465 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014466 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14467 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14468 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014469 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014470 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014471 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014472 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14473 * Any other models that need this preset?
14474 */
14475 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014476 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14477 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014478 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14479 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14480 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14481 /* FIXME: the below seems conflict */
14482 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14483 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14484 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014485 {}
14486};
14487
14488static struct alc_config_preset alc861_presets[] = {
14489 [ALC861_3ST] = {
14490 .mixers = { alc861_3ST_mixer },
14491 .init_verbs = { alc861_threestack_init_verbs },
14492 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14493 .dac_nids = alc861_dac_nids,
14494 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14495 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014496 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014497 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14498 .adc_nids = alc861_adc_nids,
14499 .input_mux = &alc861_capture_source,
14500 },
14501 [ALC861_3ST_DIG] = {
14502 .mixers = { alc861_base_mixer },
14503 .init_verbs = { alc861_threestack_init_verbs },
14504 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14505 .dac_nids = alc861_dac_nids,
14506 .dig_out_nid = ALC861_DIGOUT_NID,
14507 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14508 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014509 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014510 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14511 .adc_nids = alc861_adc_nids,
14512 .input_mux = &alc861_capture_source,
14513 },
14514 [ALC861_6ST_DIG] = {
14515 .mixers = { alc861_base_mixer },
14516 .init_verbs = { alc861_base_init_verbs },
14517 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14518 .dac_nids = alc861_dac_nids,
14519 .dig_out_nid = ALC861_DIGOUT_NID,
14520 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14521 .channel_mode = alc861_8ch_modes,
14522 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14523 .adc_nids = alc861_adc_nids,
14524 .input_mux = &alc861_capture_source,
14525 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014526 [ALC660_3ST] = {
14527 .mixers = { alc861_3ST_mixer },
14528 .init_verbs = { alc861_threestack_init_verbs },
14529 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14530 .dac_nids = alc660_dac_nids,
14531 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14532 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014533 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014534 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14535 .adc_nids = alc861_adc_nids,
14536 .input_mux = &alc861_capture_source,
14537 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014538 [ALC861_UNIWILL_M31] = {
14539 .mixers = { alc861_uniwill_m31_mixer },
14540 .init_verbs = { alc861_uniwill_m31_init_verbs },
14541 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14542 .dac_nids = alc861_dac_nids,
14543 .dig_out_nid = ALC861_DIGOUT_NID,
14544 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14545 .channel_mode = alc861_uniwill_m31_modes,
14546 .need_dac_fix = 1,
14547 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14548 .adc_nids = alc861_adc_nids,
14549 .input_mux = &alc861_capture_source,
14550 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014551 [ALC861_TOSHIBA] = {
14552 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014553 .init_verbs = { alc861_base_init_verbs,
14554 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014555 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14556 .dac_nids = alc861_dac_nids,
14557 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14558 .channel_mode = alc883_3ST_2ch_modes,
14559 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14560 .adc_nids = alc861_adc_nids,
14561 .input_mux = &alc861_capture_source,
14562 .unsol_event = alc861_toshiba_unsol_event,
14563 .init_hook = alc861_toshiba_automute,
14564 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014565 [ALC861_ASUS] = {
14566 .mixers = { alc861_asus_mixer },
14567 .init_verbs = { alc861_asus_init_verbs },
14568 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14569 .dac_nids = alc861_dac_nids,
14570 .dig_out_nid = ALC861_DIGOUT_NID,
14571 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14572 .channel_mode = alc861_asus_modes,
14573 .need_dac_fix = 1,
14574 .hp_nid = 0x06,
14575 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14576 .adc_nids = alc861_adc_nids,
14577 .input_mux = &alc861_capture_source,
14578 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014579 [ALC861_ASUS_LAPTOP] = {
14580 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14581 .init_verbs = { alc861_asus_init_verbs,
14582 alc861_asus_laptop_init_verbs },
14583 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14584 .dac_nids = alc861_dac_nids,
14585 .dig_out_nid = ALC861_DIGOUT_NID,
14586 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14587 .channel_mode = alc883_3ST_2ch_modes,
14588 .need_dac_fix = 1,
14589 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14590 .adc_nids = alc861_adc_nids,
14591 .input_mux = &alc861_capture_source,
14592 },
14593};
Kailang Yangdf694da2005-12-05 19:42:22 +010014594
14595
14596static int patch_alc861(struct hda_codec *codec)
14597{
14598 struct alc_spec *spec;
14599 int board_config;
14600 int err;
14601
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014602 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014603 if (spec == NULL)
14604 return -ENOMEM;
14605
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014606 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014607
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014608 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14609 alc861_models,
14610 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014611
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014612 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014613 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14614 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014615 board_config = ALC861_AUTO;
14616 }
14617
14618 if (board_config == ALC861_AUTO) {
14619 /* automatic parse from the BIOS config */
14620 err = alc861_parse_auto_config(codec);
14621 if (err < 0) {
14622 alc_free(codec);
14623 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014624 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014625 printk(KERN_INFO
14626 "hda_codec: Cannot set up configuration "
14627 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014628 board_config = ALC861_3ST_DIG;
14629 }
14630 }
14631
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014632 err = snd_hda_attach_beep_device(codec, 0x23);
14633 if (err < 0) {
14634 alc_free(codec);
14635 return err;
14636 }
14637
Kailang Yangdf694da2005-12-05 19:42:22 +010014638 if (board_config != ALC861_AUTO)
14639 setup_preset(spec, &alc861_presets[board_config]);
14640
Kailang Yangdf694da2005-12-05 19:42:22 +010014641 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14642 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14643
Kailang Yangdf694da2005-12-05 19:42:22 +010014644 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14645 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14646
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014647 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14648
Takashi Iwai2134ea42008-01-10 16:53:55 +010014649 spec->vmaster_nid = 0x03;
14650
Kailang Yangdf694da2005-12-05 19:42:22 +010014651 codec->patch_ops = alc_patch_ops;
14652 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014653 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014654#ifdef CONFIG_SND_HDA_POWER_SAVE
14655 if (!spec->loopback.amplist)
14656 spec->loopback.amplist = alc861_loopbacks;
14657#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014658 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014659
Kailang Yangdf694da2005-12-05 19:42:22 +010014660 return 0;
14661}
14662
14663/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014664 * ALC861-VD support
14665 *
14666 * Based on ALC882
14667 *
14668 * In addition, an independent DAC
14669 */
14670#define ALC861VD_DIGOUT_NID 0x06
14671
14672static hda_nid_t alc861vd_dac_nids[4] = {
14673 /* front, surr, clfe, side surr */
14674 0x02, 0x03, 0x04, 0x05
14675};
14676
14677/* dac_nids for ALC660vd are in a different order - according to
14678 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014679 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014680 * of ALC660vd codecs, but for now there is only 3stack mixer
14681 * - and it is the same as in 861vd.
14682 * adc_nids in ALC660vd are (is) the same as in 861vd
14683 */
14684static hda_nid_t alc660vd_dac_nids[3] = {
14685 /* front, rear, clfe, rear_surr */
14686 0x02, 0x04, 0x03
14687};
14688
14689static hda_nid_t alc861vd_adc_nids[1] = {
14690 /* ADC0 */
14691 0x09,
14692};
14693
Takashi Iwaie1406342008-02-11 18:32:32 +010014694static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14695
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014696/* input MUX */
14697/* FIXME: should be a matrix-type input source selection */
14698static struct hda_input_mux alc861vd_capture_source = {
14699 .num_items = 4,
14700 .items = {
14701 { "Mic", 0x0 },
14702 { "Front Mic", 0x1 },
14703 { "Line", 0x2 },
14704 { "CD", 0x4 },
14705 },
14706};
14707
Kailang Yang272a5272007-05-14 11:00:38 +020014708static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014709 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014710 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014711 { "Ext Mic", 0x0 },
14712 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014713 },
14714};
14715
Kailang Yangd1a991a2007-08-15 16:21:59 +020014716static struct hda_input_mux alc861vd_hp_capture_source = {
14717 .num_items = 2,
14718 .items = {
14719 { "Front Mic", 0x0 },
14720 { "ATAPI Mic", 0x1 },
14721 },
14722};
14723
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014724/*
14725 * 2ch mode
14726 */
14727static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14728 { 2, NULL }
14729};
14730
14731/*
14732 * 6ch mode
14733 */
14734static struct hda_verb alc861vd_6stack_ch6_init[] = {
14735 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14736 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14737 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14738 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14739 { } /* end */
14740};
14741
14742/*
14743 * 8ch mode
14744 */
14745static struct hda_verb alc861vd_6stack_ch8_init[] = {
14746 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14747 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14748 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14749 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14750 { } /* end */
14751};
14752
14753static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14754 { 6, alc861vd_6stack_ch6_init },
14755 { 8, alc861vd_6stack_ch8_init },
14756};
14757
14758static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14759 {
14760 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14761 .name = "Channel Mode",
14762 .info = alc_ch_mode_info,
14763 .get = alc_ch_mode_get,
14764 .put = alc_ch_mode_put,
14765 },
14766 { } /* end */
14767};
14768
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014769/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14770 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14771 */
14772static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14773 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14774 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14775
14776 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14777 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14778
14779 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14780 HDA_OUTPUT),
14781 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14782 HDA_OUTPUT),
14783 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14784 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14785
14786 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14787 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14788
14789 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14790
14791 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14792 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14793 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14794
14795 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14796 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14797 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14798
14799 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14800 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14801
14802 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14803 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14804
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014805 { } /* end */
14806};
14807
14808static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14809 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14810 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14811
14812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14813
14814 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14816 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14817
14818 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14819 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14820 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14821
14822 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14823 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14824
14825 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14826 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14827
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014828 { } /* end */
14829};
14830
Kailang Yangbdd148a2007-05-08 15:19:08 +020014831static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14832 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14833 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14834 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14835
14836 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14837
14838 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14839 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14840 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14841
14842 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14843 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14844 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14845
14846 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14847 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14848
14849 { } /* end */
14850};
14851
Tobin Davisb419f342008-03-07 11:57:51 +010014852/* Pin assignment: Speaker=0x14, HP = 0x15,
14853 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014854 */
14855static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014856 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14857 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014858 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14859 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014860 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14861 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14862 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14863 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14864 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14865 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014866 { } /* end */
14867};
14868
Kailang Yangd1a991a2007-08-15 16:21:59 +020014869/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14870 * Front Mic=0x18, ATAPI Mic = 0x19,
14871 */
14872static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14873 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14874 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14875 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14876 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14877 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14878 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14879 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14880 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014881
Kailang Yangd1a991a2007-08-15 16:21:59 +020014882 { } /* end */
14883};
14884
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014885/*
14886 * generic initialization of ADC, input mixers and output mixers
14887 */
14888static struct hda_verb alc861vd_volume_init_verbs[] = {
14889 /*
14890 * Unmute ADC0 and set the default input to mic-in
14891 */
14892 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14893 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14894
14895 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14896 * the analog-loopback mixer widget
14897 */
14898 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14902 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14903 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014904
14905 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014906 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14908 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014909 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014910
14911 /*
14912 * Set up output mixers (0x02 - 0x05)
14913 */
14914 /* set vol=0 to output mixers */
14915 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14916 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14917 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14918 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14919
14920 /* set up input amps for analog loopback */
14921 /* Amp Indices: DAC = 0, mixer = 1 */
14922 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14923 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14924 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14925 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14926 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14927 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14928 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14929 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14930
14931 { }
14932};
14933
14934/*
14935 * 3-stack pin configuration:
14936 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14937 */
14938static struct hda_verb alc861vd_3stack_init_verbs[] = {
14939 /*
14940 * Set pin mode and muting
14941 */
14942 /* set front pin widgets 0x14 for output */
14943 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14944 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14945 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14946
14947 /* Mic (rear) pin: input vref at 80% */
14948 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14949 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14950 /* Front Mic pin: input vref at 80% */
14951 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14952 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14953 /* Line In pin: input */
14954 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14955 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14956 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14957 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14958 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14959 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14960 /* CD pin widget for input */
14961 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14962
14963 { }
14964};
14965
14966/*
14967 * 6-stack pin configuration:
14968 */
14969static struct hda_verb alc861vd_6stack_init_verbs[] = {
14970 /*
14971 * Set pin mode and muting
14972 */
14973 /* set front pin widgets 0x14 for output */
14974 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14975 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14976 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14977
14978 /* Rear Pin: output 1 (0x0d) */
14979 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14980 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14981 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14982 /* CLFE Pin: output 2 (0x0e) */
14983 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14984 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14985 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14986 /* Side Pin: output 3 (0x0f) */
14987 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14988 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14989 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14990
14991 /* Mic (rear) pin: input vref at 80% */
14992 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14993 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14994 /* Front Mic pin: input vref at 80% */
14995 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14996 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14997 /* Line In pin: input */
14998 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14999 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15000 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15001 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15002 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15003 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15004 /* CD pin widget for input */
15005 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15006
15007 { }
15008};
15009
Kailang Yangbdd148a2007-05-08 15:19:08 +020015010static struct hda_verb alc861vd_eapd_verbs[] = {
15011 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15012 { }
15013};
15014
Kailang Yangf9423e72008-05-27 12:32:25 +020015015static struct hda_verb alc660vd_eapd_verbs[] = {
15016 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15017 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15018 { }
15019};
15020
Kailang Yangbdd148a2007-05-08 15:19:08 +020015021static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15022 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15023 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15024 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15025 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015026 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015027 {}
15028};
15029
Kailang Yangbdd148a2007-05-08 15:19:08 +020015030static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15031{
15032 unsigned int present;
15033 unsigned char bits;
15034
15035 present = snd_hda_codec_read(codec, 0x18, 0,
15036 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015037 bits = present ? HDA_AMP_MUTE : 0;
15038 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15039 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015040}
15041
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015042static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015043{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015044 struct alc_spec *spec = codec->spec;
15045
15046 spec->autocfg.hp_pins[0] = 0x1b;
15047 spec->autocfg.speaker_pins[0] = 0x14;
15048 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015049 alc861vd_lenovo_mic_automute(codec);
15050}
15051
15052static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15053 unsigned int res)
15054{
15055 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015056 case ALC880_MIC_EVENT:
15057 alc861vd_lenovo_mic_automute(codec);
15058 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015059 default:
15060 alc_automute_amp_unsol_event(codec, res);
15061 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015062 }
15063}
15064
Kailang Yang272a5272007-05-14 11:00:38 +020015065static struct hda_verb alc861vd_dallas_verbs[] = {
15066 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15067 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15068 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15069 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15070
15071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15074 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15078 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015079
Kailang Yang272a5272007-05-14 11:00:38 +020015080 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15081 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15082 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15083 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15084 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15085 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15086 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15087 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15088
15089 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15090 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15091 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15092 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15093 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15094 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15095 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15096 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15097
15098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15102
15103 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015104 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015105 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15106
15107 { } /* end */
15108};
15109
15110/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015111static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015112{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015113 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015114
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015115 spec->autocfg.hp_pins[0] = 0x15;
15116 spec->autocfg.speaker_pins[0] = 0x14;
15117 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020015118}
15119
Takashi Iwaicb53c622007-08-10 17:21:45 +020015120#ifdef CONFIG_SND_HDA_POWER_SAVE
15121#define alc861vd_loopbacks alc880_loopbacks
15122#endif
15123
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015124/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015125#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15126#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15127#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15128#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15129
15130/*
15131 * configuration and preset
15132 */
15133static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15134 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015135 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015136 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015137 [ALC861VD_3ST] = "3stack",
15138 [ALC861VD_3ST_DIG] = "3stack-digout",
15139 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015140 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015141 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015142 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015143 [ALC861VD_AUTO] = "auto",
15144};
15145
15146static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015147 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15148 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015149 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015150 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010015151 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015152 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015153 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015154 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015155 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015156 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015157 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015158 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015159 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015160 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015161 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015162 {}
15163};
15164
15165static struct alc_config_preset alc861vd_presets[] = {
15166 [ALC660VD_3ST] = {
15167 .mixers = { alc861vd_3st_mixer },
15168 .init_verbs = { alc861vd_volume_init_verbs,
15169 alc861vd_3stack_init_verbs },
15170 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15171 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015172 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15173 .channel_mode = alc861vd_3stack_2ch_modes,
15174 .input_mux = &alc861vd_capture_source,
15175 },
Mike Crash6963f842007-06-25 12:12:51 +020015176 [ALC660VD_3ST_DIG] = {
15177 .mixers = { alc861vd_3st_mixer },
15178 .init_verbs = { alc861vd_volume_init_verbs,
15179 alc861vd_3stack_init_verbs },
15180 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15181 .dac_nids = alc660vd_dac_nids,
15182 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015183 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15184 .channel_mode = alc861vd_3stack_2ch_modes,
15185 .input_mux = &alc861vd_capture_source,
15186 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015187 [ALC861VD_3ST] = {
15188 .mixers = { alc861vd_3st_mixer },
15189 .init_verbs = { alc861vd_volume_init_verbs,
15190 alc861vd_3stack_init_verbs },
15191 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15192 .dac_nids = alc861vd_dac_nids,
15193 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15194 .channel_mode = alc861vd_3stack_2ch_modes,
15195 .input_mux = &alc861vd_capture_source,
15196 },
15197 [ALC861VD_3ST_DIG] = {
15198 .mixers = { alc861vd_3st_mixer },
15199 .init_verbs = { alc861vd_volume_init_verbs,
15200 alc861vd_3stack_init_verbs },
15201 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15202 .dac_nids = alc861vd_dac_nids,
15203 .dig_out_nid = ALC861VD_DIGOUT_NID,
15204 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15205 .channel_mode = alc861vd_3stack_2ch_modes,
15206 .input_mux = &alc861vd_capture_source,
15207 },
15208 [ALC861VD_6ST_DIG] = {
15209 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15210 .init_verbs = { alc861vd_volume_init_verbs,
15211 alc861vd_6stack_init_verbs },
15212 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15213 .dac_nids = alc861vd_dac_nids,
15214 .dig_out_nid = ALC861VD_DIGOUT_NID,
15215 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15216 .channel_mode = alc861vd_6stack_modes,
15217 .input_mux = &alc861vd_capture_source,
15218 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015219 [ALC861VD_LENOVO] = {
15220 .mixers = { alc861vd_lenovo_mixer },
15221 .init_verbs = { alc861vd_volume_init_verbs,
15222 alc861vd_3stack_init_verbs,
15223 alc861vd_eapd_verbs,
15224 alc861vd_lenovo_unsol_verbs },
15225 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15226 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015227 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15228 .channel_mode = alc861vd_3stack_2ch_modes,
15229 .input_mux = &alc861vd_capture_source,
15230 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015231 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015232 },
Kailang Yang272a5272007-05-14 11:00:38 +020015233 [ALC861VD_DALLAS] = {
15234 .mixers = { alc861vd_dallas_mixer },
15235 .init_verbs = { alc861vd_dallas_verbs },
15236 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15237 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015238 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15239 .channel_mode = alc861vd_3stack_2ch_modes,
15240 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015241 .unsol_event = alc_automute_amp_unsol_event,
15242 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015243 },
15244 [ALC861VD_HP] = {
15245 .mixers = { alc861vd_hp_mixer },
15246 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15247 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15248 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015249 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015250 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15251 .channel_mode = alc861vd_3stack_2ch_modes,
15252 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015253 .unsol_event = alc_automute_amp_unsol_event,
15254 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020015255 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015256 [ALC660VD_ASUS_V1S] = {
15257 .mixers = { alc861vd_lenovo_mixer },
15258 .init_verbs = { alc861vd_volume_init_verbs,
15259 alc861vd_3stack_init_verbs,
15260 alc861vd_eapd_verbs,
15261 alc861vd_lenovo_unsol_verbs },
15262 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15263 .dac_nids = alc660vd_dac_nids,
15264 .dig_out_nid = ALC861VD_DIGOUT_NID,
15265 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15266 .channel_mode = alc861vd_3stack_2ch_modes,
15267 .input_mux = &alc861vd_capture_source,
15268 .unsol_event = alc861vd_lenovo_unsol_event,
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 */
15276static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15277 hda_nid_t nid, int pin_type, int dac_idx)
15278{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015279 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015280}
15281
15282static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15283{
15284 struct alc_spec *spec = codec->spec;
15285 int i;
15286
15287 for (i = 0; i <= HDA_SIDE; i++) {
15288 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015289 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015290 if (nid)
15291 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015292 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015293 }
15294}
15295
15296
15297static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15298{
15299 struct alc_spec *spec = codec->spec;
15300 hda_nid_t pin;
15301
15302 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015303 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015304 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015305 pin = spec->autocfg.speaker_pins[0];
15306 if (pin)
15307 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015308}
15309
15310#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15311#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15312
15313static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15314{
15315 struct alc_spec *spec = codec->spec;
15316 int i;
15317
15318 for (i = 0; i < AUTO_PIN_LAST; i++) {
15319 hda_nid_t nid = spec->autocfg.input_pins[i];
15320 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015321 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015322 if (nid != ALC861VD_PIN_CD_NID &&
15323 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015324 snd_hda_codec_write(codec, nid, 0,
15325 AC_VERB_SET_AMP_GAIN_MUTE,
15326 AMP_OUT_MUTE);
15327 }
15328 }
15329}
15330
Takashi Iwaif511b012008-08-15 16:46:42 +020015331#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15332
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015333#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15334#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15335
15336/* add playback controls from the parsed DAC table */
15337/* Based on ALC880 version. But ALC861VD has separate,
15338 * different NIDs for mute/unmute switch and volume control */
15339static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15340 const struct auto_pin_cfg *cfg)
15341{
15342 char name[32];
15343 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15344 hda_nid_t nid_v, nid_s;
15345 int i, err;
15346
15347 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015348 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015349 continue;
15350 nid_v = alc861vd_idx_to_mixer_vol(
15351 alc880_dac_to_idx(
15352 spec->multiout.dac_nids[i]));
15353 nid_s = alc861vd_idx_to_mixer_switch(
15354 alc880_dac_to_idx(
15355 spec->multiout.dac_nids[i]));
15356
15357 if (i == 2) {
15358 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015359 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15360 "Center Playback Volume",
15361 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15362 HDA_OUTPUT));
15363 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015364 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015365 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15366 "LFE Playback Volume",
15367 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15368 HDA_OUTPUT));
15369 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015370 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015371 err = add_control(spec, ALC_CTL_BIND_MUTE,
15372 "Center Playback Switch",
15373 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15374 HDA_INPUT));
15375 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015376 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015377 err = add_control(spec, ALC_CTL_BIND_MUTE,
15378 "LFE Playback Switch",
15379 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15380 HDA_INPUT));
15381 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015382 return err;
15383 } else {
15384 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015385 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15386 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15387 HDA_OUTPUT));
15388 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015389 return err;
15390 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015391 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015392 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015393 HDA_INPUT));
15394 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015395 return err;
15396 }
15397 }
15398 return 0;
15399}
15400
15401/* add playback controls for speaker and HP outputs */
15402/* Based on ALC880 version. But ALC861VD has separate,
15403 * different NIDs for mute/unmute switch and volume control */
15404static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15405 hda_nid_t pin, const char *pfx)
15406{
15407 hda_nid_t nid_v, nid_s;
15408 int err;
15409 char name[32];
15410
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015411 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015412 return 0;
15413
15414 if (alc880_is_fixed_pin(pin)) {
15415 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15416 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015417 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015418 spec->multiout.hp_nid = nid_v;
15419 else
15420 spec->multiout.extra_out_nid[0] = nid_v;
15421 /* control HP volume/switch on the output mixer amp */
15422 nid_v = alc861vd_idx_to_mixer_vol(
15423 alc880_fixed_pin_idx(pin));
15424 nid_s = alc861vd_idx_to_mixer_switch(
15425 alc880_fixed_pin_idx(pin));
15426
15427 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015428 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15429 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15430 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015431 return err;
15432 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015433 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15434 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15435 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015436 return err;
15437 } else if (alc880_is_multi_pin(pin)) {
15438 /* set manual connection */
15439 /* we have only a switch on HP-out PIN */
15440 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015441 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15442 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15443 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015444 return err;
15445 }
15446 return 0;
15447}
15448
15449/* parse the BIOS configuration and set up the alc_spec
15450 * return 1 if successful, 0 if the proper config is not found,
15451 * or a negative error code
15452 * Based on ALC880 version - had to change it to override
15453 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15454static int alc861vd_parse_auto_config(struct hda_codec *codec)
15455{
15456 struct alc_spec *spec = codec->spec;
15457 int err;
15458 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15459
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015460 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15461 alc861vd_ignore);
15462 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015463 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015464 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015465 return 0; /* can't find valid BIOS pin config */
15466
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015467 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15468 if (err < 0)
15469 return err;
15470 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15471 if (err < 0)
15472 return err;
15473 err = alc861vd_auto_create_extra_out(spec,
15474 spec->autocfg.speaker_pins[0],
15475 "Speaker");
15476 if (err < 0)
15477 return err;
15478 err = alc861vd_auto_create_extra_out(spec,
15479 spec->autocfg.hp_pins[0],
15480 "Headphone");
15481 if (err < 0)
15482 return err;
15483 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15484 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015485 return err;
15486
15487 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15488
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015489 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015490 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15491
Takashi Iwai603c4012008-07-30 15:01:44 +020015492 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015493 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015494
Takashi Iwaid88897e2008-10-31 15:01:37 +010015495 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015496
15497 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015498 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015499
Takashi Iwai776e1842007-08-29 15:07:11 +020015500 err = alc_auto_add_mic_boost(codec);
15501 if (err < 0)
15502 return err;
15503
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015504 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15505
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015506 return 1;
15507}
15508
15509/* additional initialization for auto-configuration model */
15510static void alc861vd_auto_init(struct hda_codec *codec)
15511{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015512 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015513 alc861vd_auto_init_multi_out(codec);
15514 alc861vd_auto_init_hp_out(codec);
15515 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015516 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015517 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015518 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015519}
15520
15521static int patch_alc861vd(struct hda_codec *codec)
15522{
15523 struct alc_spec *spec;
15524 int err, board_config;
15525
15526 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15527 if (spec == NULL)
15528 return -ENOMEM;
15529
15530 codec->spec = spec;
15531
15532 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15533 alc861vd_models,
15534 alc861vd_cfg_tbl);
15535
15536 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015537 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15538 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015539 board_config = ALC861VD_AUTO;
15540 }
15541
15542 if (board_config == ALC861VD_AUTO) {
15543 /* automatic parse from the BIOS config */
15544 err = alc861vd_parse_auto_config(codec);
15545 if (err < 0) {
15546 alc_free(codec);
15547 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015548 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015549 printk(KERN_INFO
15550 "hda_codec: Cannot set up configuration "
15551 "from BIOS. Using base mode...\n");
15552 board_config = ALC861VD_3ST;
15553 }
15554 }
15555
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015556 err = snd_hda_attach_beep_device(codec, 0x23);
15557 if (err < 0) {
15558 alc_free(codec);
15559 return err;
15560 }
15561
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015562 if (board_config != ALC861VD_AUTO)
15563 setup_preset(spec, &alc861vd_presets[board_config]);
15564
Kailang Yang2f893282008-05-27 12:14:47 +020015565 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015566 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015567 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015568 }
15569
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015570 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15571 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15572
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015573 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15574 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15575
Takashi Iwaidd704692009-08-11 08:45:11 +020015576 if (!spec->adc_nids) {
15577 spec->adc_nids = alc861vd_adc_nids;
15578 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15579 }
15580 if (!spec->capsrc_nids)
15581 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015582
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015583 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015584 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015585
Takashi Iwai2134ea42008-01-10 16:53:55 +010015586 spec->vmaster_nid = 0x02;
15587
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015588 codec->patch_ops = alc_patch_ops;
15589
15590 if (board_config == ALC861VD_AUTO)
15591 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015592#ifdef CONFIG_SND_HDA_POWER_SAVE
15593 if (!spec->loopback.amplist)
15594 spec->loopback.amplist = alc861vd_loopbacks;
15595#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015596 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015597
15598 return 0;
15599}
15600
15601/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015602 * ALC662 support
15603 *
15604 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15605 * configuration. Each pin widget can choose any input DACs and a mixer.
15606 * Each ADC is connected from a mixer of all inputs. This makes possible
15607 * 6-channel independent captures.
15608 *
15609 * In addition, an independent DAC for the multi-playback (not used in this
15610 * driver yet).
15611 */
15612#define ALC662_DIGOUT_NID 0x06
15613#define ALC662_DIGIN_NID 0x0a
15614
15615static hda_nid_t alc662_dac_nids[4] = {
15616 /* front, rear, clfe, rear_surr */
15617 0x02, 0x03, 0x04
15618};
15619
Kailang Yang622e84c2009-04-21 07:39:04 +020015620static hda_nid_t alc272_dac_nids[2] = {
15621 0x02, 0x03
15622};
15623
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015624static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015625 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015626 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015627};
Takashi Iwaie1406342008-02-11 18:32:32 +010015628
Kailang Yang622e84c2009-04-21 07:39:04 +020015629static hda_nid_t alc272_adc_nids[1] = {
15630 /* ADC1-2 */
15631 0x08,
15632};
15633
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015634static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015635static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15636
Takashi Iwaie1406342008-02-11 18:32:32 +010015637
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015638/* input MUX */
15639/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015640static struct hda_input_mux alc662_capture_source = {
15641 .num_items = 4,
15642 .items = {
15643 { "Mic", 0x0 },
15644 { "Front Mic", 0x1 },
15645 { "Line", 0x2 },
15646 { "CD", 0x4 },
15647 },
15648};
15649
15650static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15651 .num_items = 2,
15652 .items = {
15653 { "Mic", 0x1 },
15654 { "Line", 0x2 },
15655 },
15656};
Kailang Yang291702f2007-10-16 14:28:03 +020015657
15658static struct hda_input_mux alc662_eeepc_capture_source = {
15659 .num_items = 2,
15660 .items = {
15661 { "i-Mic", 0x1 },
15662 { "e-Mic", 0x0 },
15663 },
15664};
15665
Kailang Yang6dda9f42008-05-27 12:05:31 +020015666static struct hda_input_mux alc663_capture_source = {
15667 .num_items = 3,
15668 .items = {
15669 { "Mic", 0x0 },
15670 { "Front Mic", 0x1 },
15671 { "Line", 0x2 },
15672 },
15673};
15674
15675static struct hda_input_mux alc663_m51va_capture_source = {
15676 .num_items = 2,
15677 .items = {
15678 { "Ext-Mic", 0x0 },
15679 { "D-Mic", 0x9 },
15680 },
15681};
15682
Chris Pockelé9541ba12009-05-12 08:08:53 +020015683#if 1 /* set to 0 for testing other input sources below */
15684static struct hda_input_mux alc272_nc10_capture_source = {
15685 .num_items = 2,
15686 .items = {
15687 { "Autoselect Mic", 0x0 },
15688 { "Internal Mic", 0x1 },
15689 },
15690};
15691#else
15692static struct hda_input_mux alc272_nc10_capture_source = {
15693 .num_items = 16,
15694 .items = {
15695 { "Autoselect Mic", 0x0 },
15696 { "Internal Mic", 0x1 },
15697 { "In-0x02", 0x2 },
15698 { "In-0x03", 0x3 },
15699 { "In-0x04", 0x4 },
15700 { "In-0x05", 0x5 },
15701 { "In-0x06", 0x6 },
15702 { "In-0x07", 0x7 },
15703 { "In-0x08", 0x8 },
15704 { "In-0x09", 0x9 },
15705 { "In-0x0a", 0x0a },
15706 { "In-0x0b", 0x0b },
15707 { "In-0x0c", 0x0c },
15708 { "In-0x0d", 0x0d },
15709 { "In-0x0e", 0x0e },
15710 { "In-0x0f", 0x0f },
15711 },
15712};
15713#endif
15714
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015715/*
15716 * 2ch mode
15717 */
15718static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15719 { 2, NULL }
15720};
15721
15722/*
15723 * 2ch mode
15724 */
15725static struct hda_verb alc662_3ST_ch2_init[] = {
15726 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15727 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15728 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15729 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15730 { } /* end */
15731};
15732
15733/*
15734 * 6ch mode
15735 */
15736static struct hda_verb alc662_3ST_ch6_init[] = {
15737 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15738 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15739 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15740 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15741 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15742 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15743 { } /* end */
15744};
15745
15746static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15747 { 2, alc662_3ST_ch2_init },
15748 { 6, alc662_3ST_ch6_init },
15749};
15750
15751/*
15752 * 2ch mode
15753 */
15754static struct hda_verb alc662_sixstack_ch6_init[] = {
15755 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15756 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15757 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15758 { } /* end */
15759};
15760
15761/*
15762 * 6ch mode
15763 */
15764static struct hda_verb alc662_sixstack_ch8_init[] = {
15765 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15766 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15767 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15768 { } /* end */
15769};
15770
15771static struct hda_channel_mode alc662_5stack_modes[2] = {
15772 { 2, alc662_sixstack_ch6_init },
15773 { 6, alc662_sixstack_ch8_init },
15774};
15775
15776/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15777 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15778 */
15779
15780static struct snd_kcontrol_new alc662_base_mixer[] = {
15781 /* output mixer control */
15782 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015783 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015784 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015785 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015786 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15787 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015788 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15789 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015790 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15791
15792 /*Input mixer control */
15793 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15794 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15795 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15796 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15797 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15798 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15799 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15800 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015801 { } /* end */
15802};
15803
15804static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15805 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015806 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015807 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15808 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15809 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15810 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15811 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15814 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15815 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015816 { } /* end */
15817};
15818
15819static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15820 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015821 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015822 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015823 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015824 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15825 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015826 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15827 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015828 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15829 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15830 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15831 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15832 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15835 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15836 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015837 { } /* end */
15838};
15839
15840static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15841 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15842 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015843 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15844 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015845 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15846 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15847 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15849 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015850 { } /* end */
15851};
15852
Kailang Yang291702f2007-10-16 14:28:03 +020015853static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015854 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15855 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015856
15857 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15858 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15859 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15860
15861 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15862 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15863 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15864 { } /* end */
15865};
15866
Kailang Yang8c427222008-01-10 13:03:59 +010015867static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015868 ALC262_HIPPO_MASTER_SWITCH,
15869 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015870 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015871 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15872 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015873 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15874 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15875 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15876 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15877 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15878 { } /* end */
15879};
15880
Kailang Yangf1d4e282008-08-26 14:03:29 +020015881static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15882 .ops = &snd_hda_bind_vol,
15883 .values = {
15884 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15885 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15886 0
15887 },
15888};
15889
15890static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15891 .ops = &snd_hda_bind_sw,
15892 .values = {
15893 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15894 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15895 0
15896 },
15897};
15898
Kailang Yang6dda9f42008-05-27 12:05:31 +020015899static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015900 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15901 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15902 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15903 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15904 { } /* end */
15905};
15906
15907static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15908 .ops = &snd_hda_bind_sw,
15909 .values = {
15910 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15911 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15912 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15913 0
15914 },
15915};
15916
15917static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15918 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15919 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15920 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15922 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15923 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15924
15925 { } /* end */
15926};
15927
15928static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15929 .ops = &snd_hda_bind_sw,
15930 .values = {
15931 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15932 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15933 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15934 0
15935 },
15936};
15937
15938static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15939 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15940 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15942 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15943 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15944 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15945 { } /* end */
15946};
15947
15948static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015949 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15950 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015951 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15952 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15953 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15954 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15955 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15956 { } /* end */
15957};
15958
15959static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15960 .ops = &snd_hda_bind_vol,
15961 .values = {
15962 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15963 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15964 0
15965 },
15966};
15967
15968static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15969 .ops = &snd_hda_bind_sw,
15970 .values = {
15971 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15972 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15973 0
15974 },
15975};
15976
15977static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15978 HDA_BIND_VOL("Master Playback Volume",
15979 &alc663_asus_two_bind_master_vol),
15980 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15981 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015982 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15983 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15984 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015985 { } /* end */
15986};
15987
15988static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15989 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15990 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15991 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15992 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015995 { } /* end */
15996};
15997
15998static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15999 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16000 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16001 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16002 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16003 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16004
16005 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16006 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16007 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16008 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16009 { } /* end */
16010};
16011
16012static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16013 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16014 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 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 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16022 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16023 { } /* end */
16024};
16025
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016026static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16027 {
16028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16029 .name = "Channel Mode",
16030 .info = alc_ch_mode_info,
16031 .get = alc_ch_mode_get,
16032 .put = alc_ch_mode_put,
16033 },
16034 { } /* end */
16035};
16036
16037static struct hda_verb alc662_init_verbs[] = {
16038 /* ADC: mute amp left and right */
16039 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16040 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16041 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16042
Takashi Iwaicb53c622007-08-10 17:21:45 +020016043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16045 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16046 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16047 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016048
Kailang Yangb60dd392007-09-20 12:50:29 +020016049 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16050 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16051 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16052 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16053 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16054 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016055
16056 /* Front Pin: output 0 (0x0c) */
16057 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16058 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16059
16060 /* Rear Pin: output 1 (0x0d) */
16061 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16062 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16063
16064 /* CLFE Pin: output 2 (0x0e) */
16065 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16066 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16067
16068 /* Mic (rear) pin: input vref at 80% */
16069 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16070 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16071 /* Front Mic pin: input vref at 80% */
16072 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16073 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16074 /* Line In pin: input */
16075 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16076 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16077 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16078 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16079 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16080 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16081 /* CD pin widget for input */
16082 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16083
16084 /* FIXME: use matrix-type input source selection */
16085 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16086 /* Input mixer */
16087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016088 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016089
16090 /* always trun on EAPD */
16091 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16092 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16093
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016094 { }
16095};
16096
16097static struct hda_verb alc662_sue_init_verbs[] = {
16098 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16099 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016100 {}
16101};
16102
16103static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16104 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16105 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16106 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016107};
16108
Kailang Yang8c427222008-01-10 13:03:59 +010016109/* Set Unsolicited Event*/
16110static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16111 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16112 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16113 {}
16114};
16115
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016116/*
16117 * generic initialization of ADC, input mixers and output mixers
16118 */
16119static struct hda_verb alc662_auto_init_verbs[] = {
16120 /*
16121 * Unmute ADC and set the default input to mic-in
16122 */
16123 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16124 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16125
16126 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16127 * mixer widget
16128 * Note: PASD motherboards uses the Line In 2 as the input for front
16129 * panel mic (mic 2)
16130 */
16131 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16136 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016137
16138 /*
16139 * Set up output mixers (0x0c - 0x0f)
16140 */
16141 /* set vol=0 to output mixers */
16142 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16143 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16144 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16145
16146 /* set up input amps for analog loopback */
16147 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016148 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16149 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16150 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16151 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16152 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16153 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016154
16155
16156 /* FIXME: use matrix-type input source selection */
16157 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16158 /* Input mixer */
16159 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016160 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016161 { }
16162};
16163
Takashi Iwai24fb9172008-09-02 14:48:20 +020016164/* additional verbs for ALC663 */
16165static struct hda_verb alc663_auto_init_verbs[] = {
16166 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16167 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16168 { }
16169};
16170
Kailang Yang6dda9f42008-05-27 12:05:31 +020016171static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016172 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16173 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016174 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16175 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016176 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16178 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016179 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16180 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16181 {}
16182};
16183
Kailang Yangf1d4e282008-08-26 14:03:29 +020016184static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16185 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16186 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16187 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16188 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16190 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16191 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16192 {}
16193};
16194
16195static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16196 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16197 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16198 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16199 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* 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 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16204 {}
16205};
16206
16207static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16208 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16209 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16210 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16211 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16212 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16213 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16214 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16215 {}
16216};
16217
16218static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16219 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16220 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16221 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16222 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16223 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16224 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16225 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16226 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16227 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16228 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16229 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16230 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16231 {}
16232};
16233
16234static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16235 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16236 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16237 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16238 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16239 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16241 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16242 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16243 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16244 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16245 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16246 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16247 {}
16248};
16249
Kailang Yang6dda9f42008-05-27 12:05:31 +020016250static struct hda_verb alc663_g71v_init_verbs[] = {
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
16255 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16256 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16257 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16258
16259 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16260 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16261 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16262 {}
16263};
16264
16265static struct hda_verb alc663_g50v_init_verbs[] = {
16266 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16267 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16268 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16269
16270 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16271 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16272 {}
16273};
16274
Kailang Yangf1d4e282008-08-26 14:03:29 +020016275static struct hda_verb alc662_ecs_init_verbs[] = {
16276 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16277 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16278 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16279 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16280 {}
16281};
16282
Kailang Yang622e84c2009-04-21 07:39:04 +020016283static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16284 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16285 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16286 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16287 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16288 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16289 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16290 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16291 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16292 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16293 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16294 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16295 {}
16296};
16297
16298static struct hda_verb alc272_dell_init_verbs[] = {
16299 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16300 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16301 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16302 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16303 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16304 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16305 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16306 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16308 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16309 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16310 {}
16311};
16312
Kailang Yangf1d4e282008-08-26 14:03:29 +020016313static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16314 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16315 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16316 { } /* end */
16317};
16318
Kailang Yang622e84c2009-04-21 07:39:04 +020016319static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16320 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16321 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16322 { } /* end */
16323};
16324
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016325static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16326{
16327 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016328 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016329
16330 present = snd_hda_codec_read(codec, 0x14, 0,
16331 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016332 bits = present ? HDA_AMP_MUTE : 0;
16333 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16334 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016335}
16336
16337static void alc662_lenovo_101e_all_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
16342 present = snd_hda_codec_read(codec, 0x1b, 0,
16343 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016344 bits = present ? HDA_AMP_MUTE : 0;
16345 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16346 HDA_AMP_MUTE, bits);
16347 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16348 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016349}
16350
16351static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16352 unsigned int res)
16353{
16354 if ((res >> 26) == ALC880_HP_EVENT)
16355 alc662_lenovo_101e_all_automute(codec);
16356 if ((res >> 26) == ALC880_FRONT_EVENT)
16357 alc662_lenovo_101e_ispeaker_automute(codec);
16358}
16359
Kailang Yang291702f2007-10-16 14:28:03 +020016360static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16361{
16362 unsigned int present;
16363
16364 present = snd_hda_codec_read(codec, 0x18, 0,
16365 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16366 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16367 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16368 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16369 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16370 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16371 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16372 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16373 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16374}
16375
16376/* unsolicited event for HP jack sensing */
16377static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16378 unsigned int res)
16379{
Kailang Yang291702f2007-10-16 14:28:03 +020016380 if ((res >> 26) == ALC880_MIC_EVENT)
16381 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016382 else
16383 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016384}
16385
16386static void alc662_eeepc_inithook(struct hda_codec *codec)
16387{
Takashi Iwai42171c12009-05-08 14:11:43 +020016388 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020016389 alc662_eeepc_mic_automute(codec);
16390}
16391
Kailang Yang8c427222008-01-10 13:03:59 +010016392static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16393{
Takashi Iwai42171c12009-05-08 14:11:43 +020016394 struct alc_spec *spec = codec->spec;
16395
16396 spec->autocfg.hp_pins[0] = 0x14;
16397 spec->autocfg.speaker_pins[0] = 0x1b;
16398 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010016399}
16400
Kailang Yang6dda9f42008-05-27 12:05:31 +020016401static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16402{
16403 unsigned int present;
16404 unsigned char bits;
16405
16406 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016407 AC_VERB_GET_PIN_SENSE, 0)
16408 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016409 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016410 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16411 AMP_IN_MUTE(0), bits);
16412 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16413 AMP_IN_MUTE(0), bits);
16414}
16415
16416static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16417{
16418 unsigned int present;
16419 unsigned char bits;
16420
16421 present = snd_hda_codec_read(codec, 0x21, 0,
16422 AC_VERB_GET_PIN_SENSE, 0)
16423 & AC_PINSENSE_PRESENCE;
16424 bits = present ? HDA_AMP_MUTE : 0;
16425 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16426 AMP_IN_MUTE(0), bits);
16427 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16428 AMP_IN_MUTE(0), bits);
16429 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16430 AMP_IN_MUTE(0), bits);
16431 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16432 AMP_IN_MUTE(0), bits);
16433}
16434
16435static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16436{
16437 unsigned int present;
16438 unsigned char bits;
16439
16440 present = snd_hda_codec_read(codec, 0x15, 0,
16441 AC_VERB_GET_PIN_SENSE, 0)
16442 & AC_PINSENSE_PRESENCE;
16443 bits = present ? HDA_AMP_MUTE : 0;
16444 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16445 AMP_IN_MUTE(0), bits);
16446 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16447 AMP_IN_MUTE(0), bits);
16448 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16449 AMP_IN_MUTE(0), bits);
16450 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16451 AMP_IN_MUTE(0), bits);
16452}
16453
16454static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16455{
16456 unsigned int present;
16457 unsigned char bits;
16458
16459 present = snd_hda_codec_read(codec, 0x1b, 0,
16460 AC_VERB_GET_PIN_SENSE, 0)
16461 & AC_PINSENSE_PRESENCE;
16462 bits = present ? 0 : PIN_OUT;
16463 snd_hda_codec_write(codec, 0x14, 0,
16464 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16465}
16466
16467static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16468{
16469 unsigned int present1, present2;
16470
16471 present1 = snd_hda_codec_read(codec, 0x21, 0,
16472 AC_VERB_GET_PIN_SENSE, 0)
16473 & AC_PINSENSE_PRESENCE;
16474 present2 = snd_hda_codec_read(codec, 0x15, 0,
16475 AC_VERB_GET_PIN_SENSE, 0)
16476 & AC_PINSENSE_PRESENCE;
16477
16478 if (present1 || present2) {
16479 snd_hda_codec_write_cache(codec, 0x14, 0,
16480 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16481 } else {
16482 snd_hda_codec_write_cache(codec, 0x14, 0,
16483 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16484 }
16485}
16486
16487static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16488{
16489 unsigned int present1, present2;
16490
16491 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16492 AC_VERB_GET_PIN_SENSE, 0)
16493 & AC_PINSENSE_PRESENCE;
16494 present2 = snd_hda_codec_read(codec, 0x15, 0,
16495 AC_VERB_GET_PIN_SENSE, 0)
16496 & AC_PINSENSE_PRESENCE;
16497
16498 if (present1 || present2) {
16499 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16500 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16501 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16502 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16503 } else {
16504 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16505 AMP_IN_MUTE(0), 0);
16506 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16507 AMP_IN_MUTE(0), 0);
16508 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016509}
16510
16511static void alc663_m51va_mic_automute(struct hda_codec *codec)
16512{
16513 unsigned int present;
16514
16515 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016516 AC_VERB_GET_PIN_SENSE, 0)
16517 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016518 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016519 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016520 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016521 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016522 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016523 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016524 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016525 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016526}
16527
16528static void alc663_m51va_unsol_event(struct hda_codec *codec,
16529 unsigned int res)
16530{
16531 switch (res >> 26) {
16532 case ALC880_HP_EVENT:
16533 alc663_m51va_speaker_automute(codec);
16534 break;
16535 case ALC880_MIC_EVENT:
16536 alc663_m51va_mic_automute(codec);
16537 break;
16538 }
16539}
16540
16541static void alc663_m51va_inithook(struct hda_codec *codec)
16542{
16543 alc663_m51va_speaker_automute(codec);
16544 alc663_m51va_mic_automute(codec);
16545}
16546
Kailang Yangf1d4e282008-08-26 14:03:29 +020016547/* ***************** Mode1 ******************************/
16548static void alc663_mode1_unsol_event(struct hda_codec *codec,
16549 unsigned int res)
16550{
16551 switch (res >> 26) {
16552 case ALC880_HP_EVENT:
16553 alc663_m51va_speaker_automute(codec);
16554 break;
16555 case ALC880_MIC_EVENT:
16556 alc662_eeepc_mic_automute(codec);
16557 break;
16558 }
16559}
16560
16561static void alc663_mode1_inithook(struct hda_codec *codec)
16562{
16563 alc663_m51va_speaker_automute(codec);
16564 alc662_eeepc_mic_automute(codec);
16565}
16566/* ***************** Mode2 ******************************/
16567static void alc662_mode2_unsol_event(struct hda_codec *codec,
16568 unsigned int res)
16569{
16570 switch (res >> 26) {
16571 case ALC880_HP_EVENT:
16572 alc662_f5z_speaker_automute(codec);
16573 break;
16574 case ALC880_MIC_EVENT:
16575 alc662_eeepc_mic_automute(codec);
16576 break;
16577 }
16578}
16579
16580static void alc662_mode2_inithook(struct hda_codec *codec)
16581{
16582 alc662_f5z_speaker_automute(codec);
16583 alc662_eeepc_mic_automute(codec);
16584}
16585/* ***************** Mode3 ******************************/
16586static void alc663_mode3_unsol_event(struct hda_codec *codec,
16587 unsigned int res)
16588{
16589 switch (res >> 26) {
16590 case ALC880_HP_EVENT:
16591 alc663_two_hp_m1_speaker_automute(codec);
16592 break;
16593 case ALC880_MIC_EVENT:
16594 alc662_eeepc_mic_automute(codec);
16595 break;
16596 }
16597}
16598
16599static void alc663_mode3_inithook(struct hda_codec *codec)
16600{
16601 alc663_two_hp_m1_speaker_automute(codec);
16602 alc662_eeepc_mic_automute(codec);
16603}
16604/* ***************** Mode4 ******************************/
16605static void alc663_mode4_unsol_event(struct hda_codec *codec,
16606 unsigned int res)
16607{
16608 switch (res >> 26) {
16609 case ALC880_HP_EVENT:
16610 alc663_21jd_two_speaker_automute(codec);
16611 break;
16612 case ALC880_MIC_EVENT:
16613 alc662_eeepc_mic_automute(codec);
16614 break;
16615 }
16616}
16617
16618static void alc663_mode4_inithook(struct hda_codec *codec)
16619{
16620 alc663_21jd_two_speaker_automute(codec);
16621 alc662_eeepc_mic_automute(codec);
16622}
16623/* ***************** Mode5 ******************************/
16624static void alc663_mode5_unsol_event(struct hda_codec *codec,
16625 unsigned int res)
16626{
16627 switch (res >> 26) {
16628 case ALC880_HP_EVENT:
16629 alc663_15jd_two_speaker_automute(codec);
16630 break;
16631 case ALC880_MIC_EVENT:
16632 alc662_eeepc_mic_automute(codec);
16633 break;
16634 }
16635}
16636
16637static void alc663_mode5_inithook(struct hda_codec *codec)
16638{
16639 alc663_15jd_two_speaker_automute(codec);
16640 alc662_eeepc_mic_automute(codec);
16641}
16642/* ***************** Mode6 ******************************/
16643static void alc663_mode6_unsol_event(struct hda_codec *codec,
16644 unsigned int res)
16645{
16646 switch (res >> 26) {
16647 case ALC880_HP_EVENT:
16648 alc663_two_hp_m2_speaker_automute(codec);
16649 break;
16650 case ALC880_MIC_EVENT:
16651 alc662_eeepc_mic_automute(codec);
16652 break;
16653 }
16654}
16655
16656static void alc663_mode6_inithook(struct hda_codec *codec)
16657{
16658 alc663_two_hp_m2_speaker_automute(codec);
16659 alc662_eeepc_mic_automute(codec);
16660}
16661
Kailang Yang6dda9f42008-05-27 12:05:31 +020016662static void alc663_g71v_hp_automute(struct hda_codec *codec)
16663{
16664 unsigned int present;
16665 unsigned char bits;
16666
16667 present = snd_hda_codec_read(codec, 0x21, 0,
16668 AC_VERB_GET_PIN_SENSE, 0)
16669 & AC_PINSENSE_PRESENCE;
16670 bits = present ? HDA_AMP_MUTE : 0;
16671 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16672 HDA_AMP_MUTE, bits);
16673 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16674 HDA_AMP_MUTE, bits);
16675}
16676
16677static void alc663_g71v_front_automute(struct hda_codec *codec)
16678{
16679 unsigned int present;
16680 unsigned char bits;
16681
16682 present = snd_hda_codec_read(codec, 0x15, 0,
16683 AC_VERB_GET_PIN_SENSE, 0)
16684 & AC_PINSENSE_PRESENCE;
16685 bits = present ? HDA_AMP_MUTE : 0;
16686 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16687 HDA_AMP_MUTE, bits);
16688}
16689
16690static void alc663_g71v_unsol_event(struct hda_codec *codec,
16691 unsigned int res)
16692{
16693 switch (res >> 26) {
16694 case ALC880_HP_EVENT:
16695 alc663_g71v_hp_automute(codec);
16696 break;
16697 case ALC880_FRONT_EVENT:
16698 alc663_g71v_front_automute(codec);
16699 break;
16700 case ALC880_MIC_EVENT:
16701 alc662_eeepc_mic_automute(codec);
16702 break;
16703 }
16704}
16705
16706static void alc663_g71v_inithook(struct hda_codec *codec)
16707{
16708 alc663_g71v_front_automute(codec);
16709 alc663_g71v_hp_automute(codec);
16710 alc662_eeepc_mic_automute(codec);
16711}
16712
16713static void alc663_g50v_unsol_event(struct hda_codec *codec,
16714 unsigned int res)
16715{
16716 switch (res >> 26) {
16717 case ALC880_HP_EVENT:
16718 alc663_m51va_speaker_automute(codec);
16719 break;
16720 case ALC880_MIC_EVENT:
16721 alc662_eeepc_mic_automute(codec);
16722 break;
16723 }
16724}
16725
16726static void alc663_g50v_inithook(struct hda_codec *codec)
16727{
16728 alc663_m51va_speaker_automute(codec);
16729 alc662_eeepc_mic_automute(codec);
16730}
16731
Kailang Yangf1d4e282008-08-26 14:03:29 +020016732static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16733 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016734 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016735
16736 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16737 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16738 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16739
16740 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16741 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16742 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16743 { } /* end */
16744};
16745
Chris Pockelé9541ba12009-05-12 08:08:53 +020016746static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16747 /* Master Playback automatically created from Speaker and Headphone */
16748 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16749 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16750 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16751 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16752
16753 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16754 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16755 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16756
16757 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16758 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16759 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16760 { } /* end */
16761};
16762
Takashi Iwaicb53c622007-08-10 17:21:45 +020016763#ifdef CONFIG_SND_HDA_POWER_SAVE
16764#define alc662_loopbacks alc880_loopbacks
16765#endif
16766
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016767
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016768/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016769#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16770#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16771#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16772#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16773
16774/*
16775 * configuration and preset
16776 */
16777static const char *alc662_models[ALC662_MODEL_LAST] = {
16778 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16779 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16780 [ALC662_3ST_6ch] = "3stack-6ch",
16781 [ALC662_5ST_DIG] = "6stack-dig",
16782 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016783 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016784 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016785 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016786 [ALC663_ASUS_M51VA] = "m51va",
16787 [ALC663_ASUS_G71V] = "g71v",
16788 [ALC663_ASUS_H13] = "h13",
16789 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016790 [ALC663_ASUS_MODE1] = "asus-mode1",
16791 [ALC662_ASUS_MODE2] = "asus-mode2",
16792 [ALC663_ASUS_MODE3] = "asus-mode3",
16793 [ALC663_ASUS_MODE4] = "asus-mode4",
16794 [ALC663_ASUS_MODE5] = "asus-mode5",
16795 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016796 [ALC272_DELL] = "dell",
16797 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016798 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016799 [ALC662_AUTO] = "auto",
16800};
16801
16802static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016803 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016804 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16805 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016806 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16807 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16808 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16809 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16810 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16811 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16812 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16813 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16814 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16815 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16816 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16817 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016818 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16819 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16820 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016821 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16822 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16823 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16824 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016825 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016826 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16827 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016828 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016829 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16830 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16831 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016832 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16833 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16834 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016835 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16836 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16837 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016838 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016839 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16840 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016841 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016842 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016843 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016844 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16845 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16846 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016847 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016848 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16849 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016850 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016851 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016852 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016853 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016854 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16855 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016856 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016857 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16858 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016859 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016860 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016861 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016862 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016863 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016864 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16865 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016866 {}
16867};
16868
16869static struct alc_config_preset alc662_presets[] = {
16870 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016871 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016872 .init_verbs = { alc662_init_verbs },
16873 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16874 .dac_nids = alc662_dac_nids,
16875 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016876 .dig_in_nid = ALC662_DIGIN_NID,
16877 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16878 .channel_mode = alc662_3ST_2ch_modes,
16879 .input_mux = &alc662_capture_source,
16880 },
16881 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016882 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016883 .init_verbs = { alc662_init_verbs },
16884 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16885 .dac_nids = alc662_dac_nids,
16886 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016887 .dig_in_nid = ALC662_DIGIN_NID,
16888 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16889 .channel_mode = alc662_3ST_6ch_modes,
16890 .need_dac_fix = 1,
16891 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016892 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016893 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016894 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016895 .init_verbs = { alc662_init_verbs },
16896 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16897 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016898 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16899 .channel_mode = alc662_3ST_6ch_modes,
16900 .need_dac_fix = 1,
16901 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016902 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016903 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016904 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016905 .init_verbs = { alc662_init_verbs },
16906 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16907 .dac_nids = alc662_dac_nids,
16908 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016909 .dig_in_nid = ALC662_DIGIN_NID,
16910 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16911 .channel_mode = alc662_5stack_modes,
16912 .input_mux = &alc662_capture_source,
16913 },
16914 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016915 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016916 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16917 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16918 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016919 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16920 .channel_mode = alc662_3ST_2ch_modes,
16921 .input_mux = &alc662_lenovo_101e_capture_source,
16922 .unsol_event = alc662_lenovo_101e_unsol_event,
16923 .init_hook = alc662_lenovo_101e_all_automute,
16924 },
Kailang Yang291702f2007-10-16 14:28:03 +020016925 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016926 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016927 .init_verbs = { alc662_init_verbs,
16928 alc662_eeepc_sue_init_verbs },
16929 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16930 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016931 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16932 .channel_mode = alc662_3ST_2ch_modes,
16933 .input_mux = &alc662_eeepc_capture_source,
16934 .unsol_event = alc662_eeepc_unsol_event,
16935 .init_hook = alc662_eeepc_inithook,
16936 },
Kailang Yang8c427222008-01-10 13:03:59 +010016937 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016938 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016939 alc662_chmode_mixer },
16940 .init_verbs = { alc662_init_verbs,
16941 alc662_eeepc_ep20_sue_init_verbs },
16942 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16943 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016944 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16945 .channel_mode = alc662_3ST_6ch_modes,
16946 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016947 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016948 .init_hook = alc662_eeepc_ep20_inithook,
16949 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016950 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016951 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016952 .init_verbs = { alc662_init_verbs,
16953 alc662_ecs_init_verbs },
16954 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16955 .dac_nids = alc662_dac_nids,
16956 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16957 .channel_mode = alc662_3ST_2ch_modes,
16958 .input_mux = &alc662_eeepc_capture_source,
16959 .unsol_event = alc662_eeepc_unsol_event,
16960 .init_hook = alc662_eeepc_inithook,
16961 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016962 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016963 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016964 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16965 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16966 .dac_nids = alc662_dac_nids,
16967 .dig_out_nid = ALC662_DIGOUT_NID,
16968 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16969 .channel_mode = alc662_3ST_2ch_modes,
16970 .input_mux = &alc663_m51va_capture_source,
16971 .unsol_event = alc663_m51va_unsol_event,
16972 .init_hook = alc663_m51va_inithook,
16973 },
16974 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016975 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016976 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16977 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16978 .dac_nids = alc662_dac_nids,
16979 .dig_out_nid = ALC662_DIGOUT_NID,
16980 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16981 .channel_mode = alc662_3ST_2ch_modes,
16982 .input_mux = &alc662_eeepc_capture_source,
16983 .unsol_event = alc663_g71v_unsol_event,
16984 .init_hook = alc663_g71v_inithook,
16985 },
16986 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016987 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016988 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16989 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16990 .dac_nids = alc662_dac_nids,
16991 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16992 .channel_mode = alc662_3ST_2ch_modes,
16993 .input_mux = &alc663_m51va_capture_source,
16994 .unsol_event = alc663_m51va_unsol_event,
16995 .init_hook = alc663_m51va_inithook,
16996 },
16997 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016998 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016999 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17000 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17001 .dac_nids = alc662_dac_nids,
17002 .dig_out_nid = ALC662_DIGOUT_NID,
17003 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17004 .channel_mode = alc662_3ST_6ch_modes,
17005 .input_mux = &alc663_capture_source,
17006 .unsol_event = alc663_g50v_unsol_event,
17007 .init_hook = alc663_g50v_inithook,
17008 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017009 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017010 .mixers = { alc663_m51va_mixer },
17011 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017012 .init_verbs = { alc662_init_verbs,
17013 alc663_21jd_amic_init_verbs },
17014 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17015 .hp_nid = 0x03,
17016 .dac_nids = alc662_dac_nids,
17017 .dig_out_nid = ALC662_DIGOUT_NID,
17018 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17019 .channel_mode = alc662_3ST_2ch_modes,
17020 .input_mux = &alc662_eeepc_capture_source,
17021 .unsol_event = alc663_mode1_unsol_event,
17022 .init_hook = alc663_mode1_inithook,
17023 },
17024 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017025 .mixers = { alc662_1bjd_mixer },
17026 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017027 .init_verbs = { alc662_init_verbs,
17028 alc662_1bjd_amic_init_verbs },
17029 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17030 .dac_nids = alc662_dac_nids,
17031 .dig_out_nid = ALC662_DIGOUT_NID,
17032 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17033 .channel_mode = alc662_3ST_2ch_modes,
17034 .input_mux = &alc662_eeepc_capture_source,
17035 .unsol_event = alc662_mode2_unsol_event,
17036 .init_hook = alc662_mode2_inithook,
17037 },
17038 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017039 .mixers = { alc663_two_hp_m1_mixer },
17040 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017041 .init_verbs = { alc662_init_verbs,
17042 alc663_two_hp_amic_m1_init_verbs },
17043 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17044 .hp_nid = 0x03,
17045 .dac_nids = alc662_dac_nids,
17046 .dig_out_nid = ALC662_DIGOUT_NID,
17047 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17048 .channel_mode = alc662_3ST_2ch_modes,
17049 .input_mux = &alc662_eeepc_capture_source,
17050 .unsol_event = alc663_mode3_unsol_event,
17051 .init_hook = alc663_mode3_inithook,
17052 },
17053 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017054 .mixers = { alc663_asus_21jd_clfe_mixer },
17055 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017056 .init_verbs = { alc662_init_verbs,
17057 alc663_21jd_amic_init_verbs},
17058 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17059 .hp_nid = 0x03,
17060 .dac_nids = alc662_dac_nids,
17061 .dig_out_nid = ALC662_DIGOUT_NID,
17062 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17063 .channel_mode = alc662_3ST_2ch_modes,
17064 .input_mux = &alc662_eeepc_capture_source,
17065 .unsol_event = alc663_mode4_unsol_event,
17066 .init_hook = alc663_mode4_inithook,
17067 },
17068 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017069 .mixers = { alc663_asus_15jd_clfe_mixer },
17070 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017071 .init_verbs = { alc662_init_verbs,
17072 alc663_15jd_amic_init_verbs },
17073 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17074 .hp_nid = 0x03,
17075 .dac_nids = alc662_dac_nids,
17076 .dig_out_nid = ALC662_DIGOUT_NID,
17077 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17078 .channel_mode = alc662_3ST_2ch_modes,
17079 .input_mux = &alc662_eeepc_capture_source,
17080 .unsol_event = alc663_mode5_unsol_event,
17081 .init_hook = alc663_mode5_inithook,
17082 },
17083 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017084 .mixers = { alc663_two_hp_m2_mixer },
17085 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017086 .init_verbs = { alc662_init_verbs,
17087 alc663_two_hp_amic_m2_init_verbs },
17088 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17089 .hp_nid = 0x03,
17090 .dac_nids = alc662_dac_nids,
17091 .dig_out_nid = ALC662_DIGOUT_NID,
17092 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17093 .channel_mode = alc662_3ST_2ch_modes,
17094 .input_mux = &alc662_eeepc_capture_source,
17095 .unsol_event = alc663_mode6_unsol_event,
17096 .init_hook = alc663_mode6_inithook,
17097 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017098 [ALC272_DELL] = {
17099 .mixers = { alc663_m51va_mixer },
17100 .cap_mixer = alc272_auto_capture_mixer,
17101 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17102 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17103 .dac_nids = alc662_dac_nids,
17104 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17105 .adc_nids = alc272_adc_nids,
17106 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17107 .capsrc_nids = alc272_capsrc_nids,
17108 .channel_mode = alc662_3ST_2ch_modes,
17109 .input_mux = &alc663_m51va_capture_source,
17110 .unsol_event = alc663_m51va_unsol_event,
17111 .init_hook = alc663_m51va_inithook,
17112 },
17113 [ALC272_DELL_ZM1] = {
17114 .mixers = { alc663_m51va_mixer },
17115 .cap_mixer = alc662_auto_capture_mixer,
17116 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17117 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17118 .dac_nids = alc662_dac_nids,
17119 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17120 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017121 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017122 .capsrc_nids = alc662_capsrc_nids,
17123 .channel_mode = alc662_3ST_2ch_modes,
17124 .input_mux = &alc663_m51va_capture_source,
17125 .unsol_event = alc663_m51va_unsol_event,
17126 .init_hook = alc663_m51va_inithook,
17127 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017128 [ALC272_SAMSUNG_NC10] = {
17129 .mixers = { alc272_nc10_mixer },
17130 .init_verbs = { alc662_init_verbs,
17131 alc663_21jd_amic_init_verbs },
17132 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17133 .dac_nids = alc272_dac_nids,
17134 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17135 .channel_mode = alc662_3ST_2ch_modes,
17136 .input_mux = &alc272_nc10_capture_source,
17137 .unsol_event = alc663_mode4_unsol_event,
17138 .init_hook = alc663_mode4_inithook,
17139 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017140};
17141
17142
17143/*
17144 * BIOS auto configuration
17145 */
17146
17147/* add playback controls from the parsed DAC table */
17148static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17149 const struct auto_pin_cfg *cfg)
17150{
17151 char name[32];
17152 static const char *chname[4] = {
17153 "Front", "Surround", NULL /*CLFE*/, "Side"
17154 };
17155 hda_nid_t nid;
17156 int i, err;
17157
17158 for (i = 0; i < cfg->line_outs; i++) {
17159 if (!spec->multiout.dac_nids[i])
17160 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020017161 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017162 if (i == 2) {
17163 /* Center/LFE */
17164 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17165 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017166 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17167 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017168 if (err < 0)
17169 return err;
17170 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17171 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017172 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17173 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017174 if (err < 0)
17175 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017176 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017177 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017178 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017179 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017180 if (err < 0)
17181 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017182 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017183 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017184 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017185 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017186 if (err < 0)
17187 return err;
17188 } else {
17189 sprintf(name, "%s Playback Volume", chname[i]);
17190 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017191 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17192 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017193 if (err < 0)
17194 return err;
17195 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017196 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17197 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17198 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017199 if (err < 0)
17200 return err;
17201 }
17202 }
17203 return 0;
17204}
17205
17206/* add playback controls for speaker and HP outputs */
17207static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17208 const char *pfx)
17209{
17210 hda_nid_t nid;
17211 int err;
17212 char name[32];
17213
17214 if (!pin)
17215 return 0;
17216
Takashi Iwai24fb9172008-09-02 14:48:20 +020017217 if (pin == 0x17) {
17218 /* ALC663 has a mono output pin on 0x17 */
17219 sprintf(name, "%s Playback Switch", pfx);
17220 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17221 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17222 return err;
17223 }
17224
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017225 if (alc880_is_fixed_pin(pin)) {
17226 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017227 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017228 /* specify the DAC as the extra output */
17229 if (!spec->multiout.hp_nid)
17230 spec->multiout.hp_nid = nid;
17231 else
17232 spec->multiout.extra_out_nid[0] = nid;
17233 /* control HP volume/switch on the output mixer amp */
17234 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17235 sprintf(name, "%s Playback Volume", pfx);
17236 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17237 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17238 if (err < 0)
17239 return err;
17240 sprintf(name, "%s Playback Switch", pfx);
17241 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17242 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17243 if (err < 0)
17244 return err;
17245 } else if (alc880_is_multi_pin(pin)) {
17246 /* set manual connection */
17247 /* we have only a switch on HP-out PIN */
17248 sprintf(name, "%s Playback Switch", pfx);
17249 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17250 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17251 if (err < 0)
17252 return err;
17253 }
17254 return 0;
17255}
17256
Takashi Iwai2d864c42009-03-20 12:52:47 +010017257static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17258{
Takashi Iwai1327a322009-03-23 13:07:47 +010017259 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010017260 return (pincap & AC_PINCAP_IN) != 0;
17261}
17262
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017263/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010017264static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017265 const struct auto_pin_cfg *cfg)
17266{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017267 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017268 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017269 int i, err, idx;
17270
17271 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017272 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
Takashi Iwai6c819492009-08-10 18:47:44 +020017273 idx = get_connection_index(codec, 0x0b,
Takashi Iwai2d864c42009-03-20 12:52:47 +010017274 cfg->input_pins[i]);
17275 if (idx >= 0) {
17276 err = new_analog_input(spec, cfg->input_pins[i],
17277 auto_pin_cfg_labels[i],
17278 idx, 0x0b);
17279 if (err < 0)
17280 return err;
17281 }
Takashi Iwai6c819492009-08-10 18:47:44 +020017282 idx = get_connection_index(codec, 0x22,
Takashi Iwai2d864c42009-03-20 12:52:47 +010017283 cfg->input_pins[i]);
17284 if (idx >= 0) {
17285 imux->items[imux->num_items].label =
17286 auto_pin_cfg_labels[i];
17287 imux->items[imux->num_items].index = idx;
17288 imux->num_items++;
17289 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017290 }
17291 }
17292 return 0;
17293}
17294
17295static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17296 hda_nid_t nid, int pin_type,
17297 int dac_idx)
17298{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017299 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017300 /* need the manual connection? */
17301 if (alc880_is_multi_pin(nid)) {
17302 struct alc_spec *spec = codec->spec;
17303 int idx = alc880_multi_pin_idx(nid);
17304 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17305 AC_VERB_SET_CONNECT_SEL,
17306 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17307 }
17308}
17309
17310static void alc662_auto_init_multi_out(struct hda_codec *codec)
17311{
17312 struct alc_spec *spec = codec->spec;
17313 int i;
17314
17315 for (i = 0; i <= HDA_SIDE; i++) {
17316 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017317 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017318 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017319 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017320 i);
17321 }
17322}
17323
17324static void alc662_auto_init_hp_out(struct hda_codec *codec)
17325{
17326 struct alc_spec *spec = codec->spec;
17327 hda_nid_t pin;
17328
17329 pin = spec->autocfg.hp_pins[0];
17330 if (pin) /* connect to front */
17331 /* use dac 0 */
17332 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017333 pin = spec->autocfg.speaker_pins[0];
17334 if (pin)
17335 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017336}
17337
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017338#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17339
17340static void alc662_auto_init_analog_input(struct hda_codec *codec)
17341{
17342 struct alc_spec *spec = codec->spec;
17343 int i;
17344
17345 for (i = 0; i < AUTO_PIN_LAST; i++) {
17346 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017347 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017348 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017349 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017350 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017351 snd_hda_codec_write(codec, nid, 0,
17352 AC_VERB_SET_AMP_GAIN_MUTE,
17353 AMP_OUT_MUTE);
17354 }
17355 }
17356}
17357
Takashi Iwaif511b012008-08-15 16:46:42 +020017358#define alc662_auto_init_input_src alc882_auto_init_input_src
17359
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017360static int alc662_parse_auto_config(struct hda_codec *codec)
17361{
17362 struct alc_spec *spec = codec->spec;
17363 int err;
17364 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17365
17366 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17367 alc662_ignore);
17368 if (err < 0)
17369 return err;
17370 if (!spec->autocfg.line_outs)
17371 return 0; /* can't find valid BIOS pin config */
17372
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017373 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17374 if (err < 0)
17375 return err;
17376 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17377 if (err < 0)
17378 return err;
17379 err = alc662_auto_create_extra_out(spec,
17380 spec->autocfg.speaker_pins[0],
17381 "Speaker");
17382 if (err < 0)
17383 return err;
17384 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17385 "Headphone");
17386 if (err < 0)
17387 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017388 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017389 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017390 return err;
17391
17392 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17393
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017394 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017395 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17396
Takashi Iwai603c4012008-07-30 15:01:44 +020017397 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017398 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017399
17400 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017401 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017402
Takashi Iwaid88897e2008-10-31 15:01:37 +010017403 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017404 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017405 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017406
17407 err = alc_auto_add_mic_boost(codec);
17408 if (err < 0)
17409 return err;
17410
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017411 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17412
Takashi Iwai8c872862007-06-19 12:11:16 +020017413 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017414}
17415
17416/* additional initialization for auto-configuration model */
17417static void alc662_auto_init(struct hda_codec *codec)
17418{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017419 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017420 alc662_auto_init_multi_out(codec);
17421 alc662_auto_init_hp_out(codec);
17422 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017423 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017424 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017425 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017426}
17427
17428static int patch_alc662(struct hda_codec *codec)
17429{
17430 struct alc_spec *spec;
17431 int err, board_config;
17432
17433 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17434 if (!spec)
17435 return -ENOMEM;
17436
17437 codec->spec = spec;
17438
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017439 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17440
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017441 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17442 alc662_models,
17443 alc662_cfg_tbl);
17444 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017445 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17446 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017447 board_config = ALC662_AUTO;
17448 }
17449
17450 if (board_config == ALC662_AUTO) {
17451 /* automatic parse from the BIOS config */
17452 err = alc662_parse_auto_config(codec);
17453 if (err < 0) {
17454 alc_free(codec);
17455 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020017456 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017457 printk(KERN_INFO
17458 "hda_codec: Cannot set up configuration "
17459 "from BIOS. Using base mode...\n");
17460 board_config = ALC662_3ST_2ch_DIG;
17461 }
17462 }
17463
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017464 err = snd_hda_attach_beep_device(codec, 0x1);
17465 if (err < 0) {
17466 alc_free(codec);
17467 return err;
17468 }
17469
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017470 if (board_config != ALC662_AUTO)
17471 setup_preset(spec, &alc662_presets[board_config]);
17472
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017473 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17474 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17475
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017476 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17477 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17478
Takashi Iwaidd704692009-08-11 08:45:11 +020017479 if (!spec->adc_nids) {
17480 spec->adc_nids = alc662_adc_nids;
17481 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17482 }
17483 if (!spec->capsrc_nids)
17484 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017485
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017486 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017487 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017488 if (codec->vendor_id == 0x10ec0662)
17489 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17490 else
17491 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017492
Takashi Iwai2134ea42008-01-10 16:53:55 +010017493 spec->vmaster_nid = 0x02;
17494
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017495 codec->patch_ops = alc_patch_ops;
17496 if (board_config == ALC662_AUTO)
17497 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017498#ifdef CONFIG_SND_HDA_POWER_SAVE
17499 if (!spec->loopback.amplist)
17500 spec->loopback.amplist = alc662_loopbacks;
17501#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017502 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017503
17504 return 0;
17505}
17506
17507/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017508 * patch entries
17509 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017510static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017511 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017512 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017513 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017514 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017515 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017516 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017517 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017518 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017519 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17520 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17521 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017522 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017523 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017524 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17525 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017526 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017527 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017528 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017529 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017530 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017531 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017532 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017533 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017534 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017535 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017536 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017537 .patch = patch_alc882 },
17538 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17539 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017540 {} /* terminator */
17541};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017542
17543MODULE_ALIAS("snd-hda-codec-id:10ec*");
17544
17545MODULE_LICENSE("GPL");
17546MODULE_DESCRIPTION("Realtek HD-audio codec");
17547
17548static struct hda_codec_preset_list realtek_list = {
17549 .preset = snd_hda_preset_realtek,
17550 .owner = THIS_MODULE,
17551};
17552
17553static int __init patch_realtek_init(void)
17554{
17555 return snd_hda_add_codec_preset(&realtek_list);
17556}
17557
17558static void __exit patch_realtek_exit(void)
17559{
17560 snd_hda_delete_codec_preset(&realtek_list);
17561}
17562
17563module_init(patch_realtek_init)
17564module_exit(patch_realtek_exit)