blob: f594a0960290287263bd792a07403b9e36f4c99f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010081#ifdef CONFIG_SND_DEBUG
82 ALC260_TEST,
83#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010084 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020085 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070086};
87
Kailang Yangdf694da2005-12-05 19:42:22 +010088/* ALC262 models */
89enum {
90 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020091 ALC262_HIPPO,
92 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010093 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020094 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010095 ALC262_HP_BPC_D7000_WL,
96 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010097 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010098 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020099 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200100 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200101 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200102 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100103 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200104 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200105 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200106 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000107 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100108 ALC262_AUTO,
109 ALC262_MODEL_LAST /* last tag */
110};
111
Kailang Yanga361d842007-06-05 12:30:55 +0200112/* ALC268 models */
113enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200114 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200115 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200116 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200117 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100118 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200119 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100120 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100121 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100122#ifdef CONFIG_SND_DEBUG
123 ALC268_TEST,
124#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200125 ALC268_AUTO,
126 ALC268_MODEL_LAST /* last tag */
127};
128
Kailang Yangf6a92242007-12-13 16:52:54 +0100129/* ALC269 models */
130enum {
131 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200132 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200133 ALC269_ASUS_EEEPC_P703,
134 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100135 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000136 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100137 ALC269_AUTO,
138 ALC269_MODEL_LAST /* last tag */
139};
140
Kailang Yangdf694da2005-12-05 19:42:22 +0100141/* ALC861 models */
142enum {
143 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200144 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100145 ALC861_3ST_DIG,
146 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200147 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200148 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200149 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100150 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100151 ALC861_AUTO,
152 ALC861_MODEL_LAST,
153};
154
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100155/* ALC861-VD models */
156enum {
157 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200158 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100159 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100160 ALC861VD_3ST,
161 ALC861VD_3ST_DIG,
162 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200163 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200164 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200165 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100166 ALC861VD_AUTO,
167 ALC861VD_MODEL_LAST,
168};
169
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200170/* ALC662 models */
171enum {
172 ALC662_3ST_2ch_DIG,
173 ALC662_3ST_6ch_DIG,
174 ALC662_3ST_6ch,
175 ALC662_5ST_DIG,
176 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200177 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100178 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200179 ALC663_ASUS_M51VA,
180 ALC663_ASUS_G71V,
181 ALC663_ASUS_H13,
182 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200183 ALC662_ECS,
184 ALC663_ASUS_MODE1,
185 ALC662_ASUS_MODE2,
186 ALC663_ASUS_MODE3,
187 ALC663_ASUS_MODE4,
188 ALC663_ASUS_MODE5,
189 ALC663_ASUS_MODE6,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200190 ALC662_AUTO,
191 ALC662_MODEL_LAST,
192};
193
Kailang Yangdf694da2005-12-05 19:42:22 +0100194/* ALC882 models */
195enum {
196 ALC882_3ST_DIG,
197 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200198 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200199 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200200 ALC882_TARGA,
201 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200202 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100203 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200204 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200205 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200206 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100207 ALC882_MODEL_LAST,
208};
209
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200210/* ALC883 models */
211enum {
212 ALC883_3ST_2ch_DIG,
213 ALC883_3ST_6ch_DIG,
214 ALC883_3ST_6ch,
215 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200216 ALC883_TARGA_DIG,
217 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200218 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200219 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800220 ALC888_ACER_ASPIRE_4930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200221 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200222 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100223 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200224 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200225 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200226 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200227 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200228 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200229 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100230 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100231 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100232 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100233 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800234 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200235 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200236 ALC888_ASUS_M90V,
237 ALC888_ASUS_EEE1601,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100238 ALC1200_ASUS_P5Q,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200239 ALC883_AUTO,
240 ALC883_MODEL_LAST,
241};
242
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200243/* styles of capture selection */
244enum {
245 CAPT_MUX = 0, /* only mux based */
246 CAPT_MIX, /* only mixer based */
247 CAPT_1MUX_MIX, /* first mux and other mixers */
248};
249
Kailang Yangdf694da2005-12-05 19:42:22 +0100250/* for GPIO Poll */
251#define GPIO_MASK 0x03
252
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253struct alc_spec {
254 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100255 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100257 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100258 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
Kailang Yangdf694da2005-12-05 19:42:22 +0100260 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200261 * don't forget NULL
262 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200263 */
264 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265
Takashi Iwai16ded522005-06-10 19:58:24 +0200266 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 struct hda_pcm_stream *stream_analog_playback;
268 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100269 struct hda_pcm_stream *stream_analog_alt_playback;
270 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200272 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 struct hda_pcm_stream *stream_digital_playback;
274 struct hda_pcm_stream *stream_digital_capture;
275
276 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200277 struct hda_multi_out multiout; /* playback set-up
278 * max_channels, dacs must be set
279 * dig_out_nid and hp_nid are optional
280 */
Takashi Iwai63300792008-01-24 15:31:36 +0100281 hda_nid_t alt_dac_nid;
Takashi Iwai8c441982009-01-20 18:30:20 +0100282 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
284 /* capture */
285 unsigned int num_adc_nids;
286 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100287 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200288 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200289 int capture_style; /* capture style (CAPT_*) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290
291 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200292 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 const struct hda_input_mux *input_mux;
294 unsigned int cur_mux[3];
295
296 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100297 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200299 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
301 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100302 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200303
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200304 /* dynamic controls, init_verbs and input_mux */
305 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200306 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200307 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200308 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100309
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100310 /* hooks */
311 void (*init_hook)(struct hda_codec *codec);
312 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
313
Takashi Iwai834be882006-03-01 14:16:17 +0100314 /* for pin sensing */
315 unsigned int sense_updated: 1;
316 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100317 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200318
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100319 /* other flags */
320 unsigned int no_analog :1; /* digital I/O only */
321
Takashi Iwai2134ea42008-01-10 16:53:55 +0100322 /* for virtual master */
323 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200324#ifdef CONFIG_SND_HDA_POWER_SAVE
325 struct hda_loopback_check loopback;
326#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200327
328 /* for PLL fix */
329 hda_nid_t pll_nid;
330 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaie044c392008-10-27 16:56:24 +0100331
332#ifdef SND_HDA_NEEDS_RESUME
333#define ALC_MAX_PINS 16
334 unsigned int num_pins;
335 hda_nid_t pin_nids[ALC_MAX_PINS];
336 unsigned int pin_cfgs[ALC_MAX_PINS];
337#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100338};
339
340/*
341 * configuration template - to be copied to the spec instance
342 */
343struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200344 struct snd_kcontrol_new *mixers[5]; /* should be identical size
345 * with spec
346 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100347 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100348 const struct hda_verb *init_verbs[5];
349 unsigned int num_dacs;
350 hda_nid_t *dac_nids;
351 hda_nid_t dig_out_nid; /* optional */
352 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800353 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100354 unsigned int num_adc_nids;
355 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100356 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100357 hda_nid_t dig_in_nid;
358 unsigned int num_channel_mode;
359 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200360 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200361 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100362 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100363 void (*unsol_event)(struct hda_codec *, unsigned int);
364 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200365#ifdef CONFIG_SND_HDA_POWER_SAVE
366 struct hda_amp_list *loopbacks;
367#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368};
369
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370
371/*
372 * input MUX handling
373 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200374static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
375 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376{
377 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
378 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200379 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
380 if (mux_idx >= spec->num_mux_defs)
381 mux_idx = 0;
382 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383}
384
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200385static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
386 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387{
388 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
389 struct alc_spec *spec = codec->spec;
390 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
391
392 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
393 return 0;
394}
395
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200396static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
397 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398{
399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
400 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100401 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100403 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100404 hda_nid_t nid = spec->capsrc_nids ?
405 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406
Takashi Iwaicd896c32008-11-18 12:36:33 +0100407 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
408 imux = &spec->input_mux[mux_idx];
409
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200410 if (spec->capture_style &&
411 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100412 /* Matrix-mixer style (e.g. ALC882) */
413 unsigned int *cur_val = &spec->cur_mux[adc_idx];
414 unsigned int i, idx;
415
416 idx = ucontrol->value.enumerated.item[0];
417 if (idx >= imux->num_items)
418 idx = imux->num_items - 1;
419 if (*cur_val == idx)
420 return 0;
421 for (i = 0; i < imux->num_items; i++) {
422 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
423 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
424 imux->items[i].index,
425 HDA_AMP_MUTE, v);
426 }
427 *cur_val = idx;
428 return 1;
429 } else {
430 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100431 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100432 &spec->cur_mux[adc_idx]);
433 }
434}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200435
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436/*
437 * channel mode setting
438 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200439static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
440 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441{
442 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
443 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100444 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
445 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446}
447
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200448static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
449 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450{
451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
452 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100453 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200454 spec->num_channel_mode,
455 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456}
457
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200458static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
459 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
462 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200463 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
464 spec->num_channel_mode,
465 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200466 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200467 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
468 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469}
470
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100472 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200473 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100474 * being part of a format specifier. Maximum allowed length of a value is
475 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100476 *
477 * Note: some retasking pin complexes seem to ignore requests for input
478 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
479 * are requested. Therefore order this list so that this behaviour will not
480 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200481 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
482 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200483 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100484static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100485 "Mic 50pc bias", "Mic 80pc bias",
486 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100487};
488static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100489 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100490};
491/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200492 * in the pin being assumed to be exclusively an input or an output pin. In
493 * addition, "input" pins may or may not process the mic bias option
494 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
495 * accept requests for bias as of chip versions up to March 2006) and/or
496 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100497 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200498#define ALC_PIN_DIR_IN 0x00
499#define ALC_PIN_DIR_OUT 0x01
500#define ALC_PIN_DIR_INOUT 0x02
501#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
502#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100503
Kailang Yangea1fb292008-08-26 12:58:38 +0200504/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100505 * For each direction the minimum and maximum values are given.
506 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200507static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100508 { 0, 2 }, /* ALC_PIN_DIR_IN */
509 { 3, 4 }, /* ALC_PIN_DIR_OUT */
510 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200511 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
512 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100513};
514#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
515#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
516#define alc_pin_mode_n_items(_dir) \
517 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
518
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200519static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
520 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200521{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522 unsigned int item_num = uinfo->value.enumerated.item;
523 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
524
525 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200526 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100527 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
528
529 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
530 item_num = alc_pin_mode_min(dir);
531 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200532 return 0;
533}
534
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200535static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
536 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200537{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100538 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200539 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
540 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100541 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200542 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200543 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
544 AC_VERB_GET_PIN_WIDGET_CONTROL,
545 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200546
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100547 /* Find enumerated value for current pinctl setting */
548 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200549 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100550 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200551 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552 return 0;
553}
554
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200555static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
556 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100557{
558 signed int change;
559 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
560 hda_nid_t nid = kcontrol->private_value & 0xffff;
561 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
562 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200563 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
564 AC_VERB_GET_PIN_WIDGET_CONTROL,
565 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100566
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200567 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100568 val = alc_pin_mode_min(dir);
569
570 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100571 if (change) {
572 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200573 snd_hda_codec_write_cache(codec, nid, 0,
574 AC_VERB_SET_PIN_WIDGET_CONTROL,
575 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100576
Kailang Yangea1fb292008-08-26 12:58:38 +0200577 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100578 * for the requested pin mode. Enum values of 2 or less are
579 * input modes.
580 *
581 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200582 * reduces noise slightly (particularly on input) so we'll
583 * do it. However, having both input and output buffers
584 * enabled simultaneously doesn't seem to be problematic if
585 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100586 */
587 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200588 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
589 HDA_AMP_MUTE, HDA_AMP_MUTE);
590 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
591 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100592 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200593 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
594 HDA_AMP_MUTE, HDA_AMP_MUTE);
595 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
596 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100597 }
598 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200599 return change;
600}
601
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100602#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200603 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100604 .info = alc_pin_mode_info, \
605 .get = alc_pin_mode_get, \
606 .put = alc_pin_mode_put, \
607 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100608
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100609/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
610 * together using a mask with more than one bit set. This control is
611 * currently used only by the ALC260 test model. At this stage they are not
612 * needed for any "production" models.
613 */
614#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200615#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200616
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200617static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
618 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100619{
620 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
621 hda_nid_t nid = kcontrol->private_value & 0xffff;
622 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
623 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200624 unsigned int val = snd_hda_codec_read(codec, nid, 0,
625 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100626
627 *valp = (val & mask) != 0;
628 return 0;
629}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200630static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
631 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100632{
633 signed int change;
634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
635 hda_nid_t nid = kcontrol->private_value & 0xffff;
636 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
637 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200638 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
639 AC_VERB_GET_GPIO_DATA,
640 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100641
642 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200643 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
644 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100645 gpio_data &= ~mask;
646 else
647 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200648 snd_hda_codec_write_cache(codec, nid, 0,
649 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100650
651 return change;
652}
653#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
654 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
655 .info = alc_gpio_data_info, \
656 .get = alc_gpio_data_get, \
657 .put = alc_gpio_data_put, \
658 .private_value = nid | (mask<<16) }
659#endif /* CONFIG_SND_DEBUG */
660
Jonathan Woithe92621f12006-02-28 11:47:47 +0100661/* A switch control to allow the enabling of the digital IO pins on the
662 * ALC260. This is incredibly simplistic; the intention of this control is
663 * to provide something in the test model allowing digital outputs to be
664 * identified if present. If models are found which can utilise these
665 * outputs a more complete mixer control can be devised for those models if
666 * necessary.
667 */
668#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200669#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200670
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200671static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
672 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100673{
674 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
675 hda_nid_t nid = kcontrol->private_value & 0xffff;
676 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
677 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200678 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100679 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100680
681 *valp = (val & mask) != 0;
682 return 0;
683}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200684static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
685 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100686{
687 signed int change;
688 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
689 hda_nid_t nid = kcontrol->private_value & 0xffff;
690 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
691 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200692 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100693 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200694 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100695
696 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200697 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100698 if (val==0)
699 ctrl_data &= ~mask;
700 else
701 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200702 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
703 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100704
705 return change;
706}
707#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
708 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
709 .info = alc_spdif_ctrl_info, \
710 .get = alc_spdif_ctrl_get, \
711 .put = alc_spdif_ctrl_put, \
712 .private_value = nid | (mask<<16) }
713#endif /* CONFIG_SND_DEBUG */
714
Jonathan Woithef8225f62008-01-08 12:16:54 +0100715/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
716 * Again, this is only used in the ALC26x test models to help identify when
717 * the EAPD line must be asserted for features to work.
718 */
719#ifdef CONFIG_SND_DEBUG
720#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
721
722static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
723 struct snd_ctl_elem_value *ucontrol)
724{
725 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
726 hda_nid_t nid = kcontrol->private_value & 0xffff;
727 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
728 long *valp = ucontrol->value.integer.value;
729 unsigned int val = snd_hda_codec_read(codec, nid, 0,
730 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
731
732 *valp = (val & mask) != 0;
733 return 0;
734}
735
736static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
737 struct snd_ctl_elem_value *ucontrol)
738{
739 int change;
740 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
741 hda_nid_t nid = kcontrol->private_value & 0xffff;
742 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
743 long val = *ucontrol->value.integer.value;
744 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
745 AC_VERB_GET_EAPD_BTLENABLE,
746 0x00);
747
748 /* Set/unset the masked control bit(s) as needed */
749 change = (!val ? 0 : mask) != (ctrl_data & mask);
750 if (!val)
751 ctrl_data &= ~mask;
752 else
753 ctrl_data |= mask;
754 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
755 ctrl_data);
756
757 return change;
758}
759
760#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
761 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
762 .info = alc_eapd_ctrl_info, \
763 .get = alc_eapd_ctrl_get, \
764 .put = alc_eapd_ctrl_put, \
765 .private_value = nid | (mask<<16) }
766#endif /* CONFIG_SND_DEBUG */
767
Kailang Yangdf694da2005-12-05 19:42:22 +0100768/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100769 */
770static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
771{
772 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
773 return;
774 spec->mixers[spec->num_mixers++] = mix;
775}
776
777static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
778{
779 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
780 return;
781 spec->init_verbs[spec->num_init_verbs++] = verb;
782}
783
Takashi Iwaidaead532008-11-28 12:55:36 +0100784#ifdef CONFIG_PROC_FS
785/*
786 * hook for proc
787 */
788static void print_realtek_coef(struct snd_info_buffer *buffer,
789 struct hda_codec *codec, hda_nid_t nid)
790{
791 int coeff;
792
793 if (nid != 0x20)
794 return;
795 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
796 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
797 coeff = snd_hda_codec_read(codec, nid, 0,
798 AC_VERB_GET_COEF_INDEX, 0);
799 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
800}
801#else
802#define print_realtek_coef NULL
803#endif
804
Takashi Iwaid88897e2008-10-31 15:01:37 +0100805/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100806 * set up from the preset table
807 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200808static void setup_preset(struct alc_spec *spec,
809 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100810{
811 int i;
812
813 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100814 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100815 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200816 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
817 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100818 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200819
Kailang Yangdf694da2005-12-05 19:42:22 +0100820 spec->channel_mode = preset->channel_mode;
821 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200822 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100823
824 spec->multiout.max_channels = spec->channel_mode[0].channels;
825
826 spec->multiout.num_dacs = preset->num_dacs;
827 spec->multiout.dac_nids = preset->dac_nids;
828 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800829 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100830 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200831
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200832 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200833 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200834 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100835 spec->input_mux = preset->input_mux;
836
837 spec->num_adc_nids = preset->num_adc_nids;
838 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100839 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100840 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100841
842 spec->unsol_event = preset->unsol_event;
843 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200844#ifdef CONFIG_SND_HDA_POWER_SAVE
845 spec->loopback.amplist = preset->loopbacks;
846#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100847}
848
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200849/* Enable GPIO mask and set output */
850static struct hda_verb alc_gpio1_init_verbs[] = {
851 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
852 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
853 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
854 { }
855};
856
857static struct hda_verb alc_gpio2_init_verbs[] = {
858 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
859 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
860 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
861 { }
862};
863
Kailang Yangbdd148a2007-05-08 15:19:08 +0200864static struct hda_verb alc_gpio3_init_verbs[] = {
865 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
866 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
867 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
868 { }
869};
870
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200871/*
872 * Fix hardware PLL issue
873 * On some codecs, the analog PLL gating control must be off while
874 * the default value is 1.
875 */
876static void alc_fix_pll(struct hda_codec *codec)
877{
878 struct alc_spec *spec = codec->spec;
879 unsigned int val;
880
881 if (!spec->pll_nid)
882 return;
883 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
884 spec->pll_coef_idx);
885 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
886 AC_VERB_GET_PROC_COEF, 0);
887 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
888 spec->pll_coef_idx);
889 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
890 val & ~(1 << spec->pll_coef_bit));
891}
892
893static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
894 unsigned int coef_idx, unsigned int coef_bit)
895{
896 struct alc_spec *spec = codec->spec;
897 spec->pll_nid = nid;
898 spec->pll_coef_idx = coef_idx;
899 spec->pll_coef_bit = coef_bit;
900 alc_fix_pll(codec);
901}
902
Kailang Yangc9b58002007-10-16 14:30:01 +0200903static void alc_sku_automute(struct hda_codec *codec)
904{
905 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200906 unsigned int present;
907 unsigned int hp_nid = spec->autocfg.hp_pins[0];
908 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
909
910 /* need to execute and sync at first */
911 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
912 present = snd_hda_codec_read(codec, hp_nid, 0,
913 AC_VERB_GET_PIN_SENSE, 0);
914 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100915 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
916 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200917}
918
Takashi Iwai4605b712008-10-31 14:18:24 +0100919#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200920static void alc_mic_automute(struct hda_codec *codec)
921{
922 struct alc_spec *spec = codec->spec;
923 unsigned int present;
924 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
925 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
926 unsigned int mix_nid = spec->capsrc_nids[0];
927 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
928
929 capsrc_idx_mic = mic_nid - 0x18;
930 capsrc_idx_fmic = fmic_nid - 0x18;
931 present = snd_hda_codec_read(codec, mic_nid, 0,
932 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
933 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
934 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
935 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
936 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
937 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
938 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
939}
Takashi Iwai4605b712008-10-31 14:18:24 +0100940#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100941#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100942#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200943
Kailang Yangc9b58002007-10-16 14:30:01 +0200944/* unsolicited event for HP jack sensing */
945static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
946{
947 if (codec->vendor_id == 0x10ec0880)
948 res >>= 28;
949 else
950 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200951 if (res == ALC880_HP_EVENT)
952 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200953
Kailang Yang7fb0d782008-10-15 11:12:35 +0200954 if (res == ALC880_MIC_EVENT)
955 alc_mic_automute(codec);
956}
957
958static void alc_inithook(struct hda_codec *codec)
959{
Kailang Yangc9b58002007-10-16 14:30:01 +0200960 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200961 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200962}
963
Kailang Yangf9423e72008-05-27 12:32:25 +0200964/* additional initialization for ALC888 variants */
965static void alc888_coef_init(struct hda_codec *codec)
966{
967 unsigned int tmp;
968
969 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
970 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
971 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
972 if ((tmp & 0xf0) == 2)
973 /* alc888S-VC */
974 snd_hda_codec_read(codec, 0x20, 0,
975 AC_VERB_SET_PROC_COEF, 0x830);
976 else
977 /* alc888-VB */
978 snd_hda_codec_read(codec, 0x20, 0,
979 AC_VERB_SET_PROC_COEF, 0x3030);
980}
981
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200982/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
983 * 31 ~ 16 : Manufacture ID
984 * 15 ~ 8 : SKU ID
985 * 7 ~ 0 : Assembly ID
986 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
987 */
988static void alc_subsystem_id(struct hda_codec *codec,
989 unsigned int porta, unsigned int porte,
990 unsigned int portd)
991{
Kailang Yangc9b58002007-10-16 14:30:01 +0200992 unsigned int ass, tmp, i;
993 unsigned nid;
994 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200995
Kailang Yangc9b58002007-10-16 14:30:01 +0200996 ass = codec->subsystem_id & 0xffff;
997 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
998 goto do_sku;
999
Kailang Yangea1fb292008-08-26 12:58:38 +02001000 /*
Kailang Yangc9b58002007-10-16 14:30:01 +02001001 * 31~30 : port conetcivity
1002 * 29~21 : reserve
1003 * 20 : PCBEEP input
1004 * 19~16 : Check sum (15:1)
1005 * 15~1 : Custom
1006 * 0 : override
1007 */
1008 nid = 0x1d;
1009 if (codec->vendor_id == 0x10ec0260)
1010 nid = 0x17;
1011 ass = snd_hda_codec_read(codec, nid, 0,
1012 AC_VERB_GET_CONFIG_DEFAULT, 0);
1013 if (!(ass & 1) && !(ass & 0x100000))
1014 return;
1015 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001016 return;
1017
Kailang Yangc9b58002007-10-16 14:30:01 +02001018 /* check sum */
1019 tmp = 0;
1020 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +01001021 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +02001022 tmp++;
1023 }
1024 if (((ass >> 16) & 0xf) != tmp)
1025 return;
1026do_sku:
1027 /*
1028 * 0 : override
1029 * 1 : Swap Jack
1030 * 2 : 0 --> Desktop, 1 --> Laptop
1031 * 3~5 : External Amplifier control
1032 * 7~6 : Reserved
1033 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001034 tmp = (ass & 0x38) >> 3; /* external Amp control */
1035 switch (tmp) {
1036 case 1:
1037 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1038 break;
1039 case 3:
1040 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1041 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001042 case 7:
1043 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1044 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001045 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +02001046 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001047 case 0x10ec0260:
1048 snd_hda_codec_write(codec, 0x0f, 0,
1049 AC_VERB_SET_EAPD_BTLENABLE, 2);
1050 snd_hda_codec_write(codec, 0x10, 0,
1051 AC_VERB_SET_EAPD_BTLENABLE, 2);
1052 break;
1053 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001054 case 0x10ec0267:
1055 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001056 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001057 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001058 case 0x10ec0660:
1059 case 0x10ec0662:
1060 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001061 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001062 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001063 snd_hda_codec_write(codec, 0x14, 0,
1064 AC_VERB_SET_EAPD_BTLENABLE, 2);
1065 snd_hda_codec_write(codec, 0x15, 0,
1066 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001067 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001068 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001069 switch (codec->vendor_id) {
1070 case 0x10ec0260:
1071 snd_hda_codec_write(codec, 0x1a, 0,
1072 AC_VERB_SET_COEF_INDEX, 7);
1073 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1074 AC_VERB_GET_PROC_COEF, 0);
1075 snd_hda_codec_write(codec, 0x1a, 0,
1076 AC_VERB_SET_COEF_INDEX, 7);
1077 snd_hda_codec_write(codec, 0x1a, 0,
1078 AC_VERB_SET_PROC_COEF,
1079 tmp | 0x2010);
1080 break;
1081 case 0x10ec0262:
1082 case 0x10ec0880:
1083 case 0x10ec0882:
1084 case 0x10ec0883:
1085 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001086 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001087 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001088 snd_hda_codec_write(codec, 0x20, 0,
1089 AC_VERB_SET_COEF_INDEX, 7);
1090 tmp = snd_hda_codec_read(codec, 0x20, 0,
1091 AC_VERB_GET_PROC_COEF, 0);
1092 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001093 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001094 snd_hda_codec_write(codec, 0x20, 0,
1095 AC_VERB_SET_PROC_COEF,
1096 tmp | 0x2010);
1097 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001098 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +02001099 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +02001100 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001101 case 0x10ec0267:
1102 case 0x10ec0268:
1103 snd_hda_codec_write(codec, 0x20, 0,
1104 AC_VERB_SET_COEF_INDEX, 7);
1105 tmp = snd_hda_codec_read(codec, 0x20, 0,
1106 AC_VERB_GET_PROC_COEF, 0);
1107 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001108 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001109 snd_hda_codec_write(codec, 0x20, 0,
1110 AC_VERB_SET_PROC_COEF,
1111 tmp | 0x3000);
1112 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001113 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001114 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001115 break;
1116 }
Kailang Yangea1fb292008-08-26 12:58:38 +02001117
Kailang Yang8c427222008-01-10 13:03:59 +01001118 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +02001119 * when the external headphone out jack is plugged"
1120 */
Kailang Yang8c427222008-01-10 13:03:59 +01001121 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +02001122 return;
1123 /*
1124 * 10~8 : Jack location
1125 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1126 * 14~13: Resvered
1127 * 15 : 1 --> enable the function "Mute internal speaker
1128 * when the external headphone out jack is plugged"
1129 */
1130 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001131 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001132 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001133 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001134 else
1135 return;
1136 }
1137
1138 if (!spec->autocfg.hp_pins[0]) {
1139 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1140 if (tmp == 0)
1141 spec->autocfg.hp_pins[0] = porta;
1142 else if (tmp == 1)
1143 spec->autocfg.hp_pins[0] = porte;
1144 else if (tmp == 2)
1145 spec->autocfg.hp_pins[0] = portd;
1146 else
1147 return;
1148 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001149 if (spec->autocfg.hp_pins[0])
1150 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1151 AC_VERB_SET_UNSOLICITED_ENABLE,
1152 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangc9b58002007-10-16 14:30:01 +02001153
Takashi Iwai4605b712008-10-31 14:18:24 +01001154#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001155 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1156 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1157 snd_hda_codec_write(codec,
1158 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1159 AC_VERB_SET_UNSOLICITED_ENABLE,
1160 AC_USRSP_EN | ALC880_MIC_EVENT);
Takashi Iwai4605b712008-10-31 14:18:24 +01001161#endif /* disabled */
Kailang Yangea1fb292008-08-26 12:58:38 +02001162
Kailang Yangc9b58002007-10-16 14:30:01 +02001163 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001164}
1165
Takashi Iwai41e41f12005-06-08 14:48:49 +02001166/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001167 * Fix-up pin default configurations
1168 */
1169
1170struct alc_pincfg {
1171 hda_nid_t nid;
1172 u32 val;
1173};
1174
1175static void alc_fix_pincfg(struct hda_codec *codec,
1176 const struct snd_pci_quirk *quirk,
1177 const struct alc_pincfg **pinfix)
1178{
1179 const struct alc_pincfg *cfg;
1180
1181 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1182 if (!quirk)
1183 return;
1184
1185 cfg = pinfix[quirk->value];
1186 for (; cfg->nid; cfg++) {
1187 int i;
1188 u32 val = cfg->val;
1189 for (i = 0; i < 4; i++) {
1190 snd_hda_codec_write(codec, cfg->nid, 0,
1191 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1192 val & 0xff);
1193 val >>= 8;
1194 }
1195 }
1196}
1197
1198/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001199 * ALC888
1200 */
1201
1202/*
1203 * 2ch mode
1204 */
1205static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1206/* Mic-in jack as mic in */
1207 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1208 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1209/* Line-in jack as Line in */
1210 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1211 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1212/* Line-Out as Front */
1213 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1214 { } /* end */
1215};
1216
1217/*
1218 * 4ch mode
1219 */
1220static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1221/* Mic-in jack as mic in */
1222 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1223 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1224/* Line-in jack as Surround */
1225 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1226 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1227/* Line-Out as Front */
1228 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1229 { } /* end */
1230};
1231
1232/*
1233 * 6ch mode
1234 */
1235static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1236/* Mic-in jack as CLFE */
1237 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1238 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1239/* Line-in jack as Surround */
1240 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1241 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1242/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1243 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1244 { } /* end */
1245};
1246
1247/*
1248 * 8ch mode
1249 */
1250static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1251/* Mic-in jack as CLFE */
1252 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1253 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1254/* Line-in jack as Surround */
1255 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1256 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1257/* Line-Out as Side */
1258 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1259 { } /* end */
1260};
1261
1262static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1263 { 2, alc888_4ST_ch2_intel_init },
1264 { 4, alc888_4ST_ch4_intel_init },
1265 { 6, alc888_4ST_ch6_intel_init },
1266 { 8, alc888_4ST_ch8_intel_init },
1267};
1268
1269/*
1270 * ALC888 Fujitsu Siemens Amillo xa3530
1271 */
1272
1273static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1274/* Front Mic: set to PIN_IN (empty by default) */
1275 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1276/* Connect Internal HP to Front */
1277 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1278 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1279 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1280/* Connect Bass HP to Front */
1281 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1282 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1283 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1284/* Connect Line-Out side jack (SPDIF) to Side */
1285 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1286 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1287 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1288/* Connect Mic jack to CLFE */
1289 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1290 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1291 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1292/* Connect Line-in jack to Surround */
1293 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1294 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1295 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1296/* Connect HP out jack to Front */
1297 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1298 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1299 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1300/* Enable unsolicited event for HP jack and Line-out jack */
1301 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1302 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1303 {}
1304};
1305
1306static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1307{
1308 unsigned int present;
1309 unsigned int bits;
1310 /* Line out presence */
1311 present = snd_hda_codec_read(codec, 0x17, 0,
1312 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1313 /* HP out presence */
1314 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1315 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1316 bits = present ? HDA_AMP_MUTE : 0;
1317 /* Toggle internal speakers muting */
1318 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1319 HDA_AMP_MUTE, bits);
1320 /* Toggle internal bass muting */
1321 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1322 HDA_AMP_MUTE, bits);
1323}
1324
1325static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1326 unsigned int res)
1327{
1328 if (res >> 26 == ALC880_HP_EVENT)
1329 alc888_fujitsu_xa3530_automute(codec);
1330}
1331
1332
1333/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001334 * ALC888 Acer Aspire 4930G model
1335 */
1336
1337static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1338/* Front Mic: set to PIN_IN (empty by default) */
1339 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1340/* Unselect Front Mic by default in input mixer 3 */
1341 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001342/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001343 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1344/* Connect Internal HP to front */
1345 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1346 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1347 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1348/* Connect HP out to front */
1349 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1350 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1351 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1352 { }
1353};
1354
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001355static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001356 /* Front mic only available on one ADC */
1357 {
1358 .num_items = 4,
1359 .items = {
1360 { "Mic", 0x0 },
1361 { "Line", 0x2 },
1362 { "CD", 0x4 },
1363 { "Front Mic", 0xb },
1364 },
1365 },
1366 {
1367 .num_items = 3,
1368 .items = {
1369 { "Mic", 0x0 },
1370 { "Line", 0x2 },
1371 { "CD", 0x4 },
1372 },
1373 }
1374};
1375
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001376static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001377 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1378 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1379 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1380 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1381 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1382 HDA_OUTPUT),
1383 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1384 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1385 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1386 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1387 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1388 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1389 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1390 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1391 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1392 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1393 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001395 { } /* end */
1396};
1397
1398static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1399{
1400 unsigned int present;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001401 unsigned int bits;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001402 present = snd_hda_codec_read(codec, 0x15, 0,
1403 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001404 bits = present ? HDA_AMP_MUTE : 0;
1405 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1406 HDA_AMP_MUTE, bits);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001407}
1408
1409static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1410 unsigned int res)
1411{
1412 if (res >> 26 == ALC880_HP_EVENT)
1413 alc888_acer_aspire_4930g_automute(codec);
1414}
1415
1416/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001417 * ALC880 3-stack model
1418 *
1419 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001420 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1421 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001422 */
1423
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001424static hda_nid_t alc880_dac_nids[4] = {
1425 /* front, rear, clfe, rear_surr */
1426 0x02, 0x05, 0x04, 0x03
1427};
1428
1429static hda_nid_t alc880_adc_nids[3] = {
1430 /* ADC0-2 */
1431 0x07, 0x08, 0x09,
1432};
1433
1434/* The datasheet says the node 0x07 is connected from inputs,
1435 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001436 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001437 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001438static hda_nid_t alc880_adc_nids_alt[2] = {
1439 /* ADC1-2 */
1440 0x08, 0x09,
1441};
1442
1443#define ALC880_DIGOUT_NID 0x06
1444#define ALC880_DIGIN_NID 0x0a
1445
1446static struct hda_input_mux alc880_capture_source = {
1447 .num_items = 4,
1448 .items = {
1449 { "Mic", 0x0 },
1450 { "Front Mic", 0x3 },
1451 { "Line", 0x2 },
1452 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001453 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001454};
1455
1456/* channel source setting (2/6 channel selection for 3-stack) */
1457/* 2ch mode */
1458static struct hda_verb alc880_threestack_ch2_init[] = {
1459 /* set line-in to input, mute it */
1460 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1461 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1462 /* set mic-in to input vref 80%, mute it */
1463 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1464 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465 { } /* end */
1466};
1467
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001468/* 6ch mode */
1469static struct hda_verb alc880_threestack_ch6_init[] = {
1470 /* set line-in to output, unmute it */
1471 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1472 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1473 /* set mic-in to output, unmute it */
1474 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1475 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1476 { } /* end */
1477};
1478
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001479static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001480 { 2, alc880_threestack_ch2_init },
1481 { 6, alc880_threestack_ch6_init },
1482};
1483
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001484static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001485 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001486 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001487 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001488 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001489 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1490 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001491 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1492 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1494 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1495 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1496 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1497 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1498 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1499 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1500 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001502 {
1503 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1504 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001505 .info = alc_ch_mode_info,
1506 .get = alc_ch_mode_get,
1507 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001508 },
1509 { } /* end */
1510};
1511
1512/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001513static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1514 struct snd_ctl_elem_info *uinfo)
1515{
1516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1517 struct alc_spec *spec = codec->spec;
1518 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001519
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001520 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001521 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1522 HDA_INPUT);
1523 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001524 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001525 return err;
1526}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001528static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1529 unsigned int size, unsigned int __user *tlv)
1530{
1531 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1532 struct alc_spec *spec = codec->spec;
1533 int err;
1534
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001535 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001536 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1537 HDA_INPUT);
1538 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001539 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001540 return err;
1541}
1542
1543typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1544 struct snd_ctl_elem_value *ucontrol);
1545
1546static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1547 struct snd_ctl_elem_value *ucontrol,
1548 getput_call_t func)
1549{
1550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1551 struct alc_spec *spec = codec->spec;
1552 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1553 int err;
1554
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001555 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001556 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1557 3, 0, HDA_INPUT);
1558 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001559 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001560 return err;
1561}
1562
1563static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1564 struct snd_ctl_elem_value *ucontrol)
1565{
1566 return alc_cap_getput_caller(kcontrol, ucontrol,
1567 snd_hda_mixer_amp_volume_get);
1568}
1569
1570static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1571 struct snd_ctl_elem_value *ucontrol)
1572{
1573 return alc_cap_getput_caller(kcontrol, ucontrol,
1574 snd_hda_mixer_amp_volume_put);
1575}
1576
1577/* capture mixer elements */
1578#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1579
1580static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1581 struct snd_ctl_elem_value *ucontrol)
1582{
1583 return alc_cap_getput_caller(kcontrol, ucontrol,
1584 snd_hda_mixer_amp_switch_get);
1585}
1586
1587static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1588 struct snd_ctl_elem_value *ucontrol)
1589{
1590 return alc_cap_getput_caller(kcontrol, ucontrol,
1591 snd_hda_mixer_amp_switch_put);
1592}
1593
1594#define DEFINE_CAPMIX(num) \
1595static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1596 { \
1597 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1598 .name = "Capture Switch", \
1599 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1600 .count = num, \
1601 .info = alc_cap_sw_info, \
1602 .get = alc_cap_sw_get, \
1603 .put = alc_cap_sw_put, \
1604 }, \
1605 { \
1606 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1607 .name = "Capture Volume", \
1608 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1609 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1610 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1611 .count = num, \
1612 .info = alc_cap_vol_info, \
1613 .get = alc_cap_vol_get, \
1614 .put = alc_cap_vol_put, \
1615 .tlv = { .c = alc_cap_vol_tlv }, \
1616 }, \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001617 { \
1618 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1619 /* .name = "Capture Source", */ \
1620 .name = "Input Source", \
1621 .count = num, \
1622 .info = alc_mux_enum_info, \
1623 .get = alc_mux_enum_get, \
1624 .put = alc_mux_enum_put, \
1625 }, \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001626 { } /* end */ \
1627}
1628
1629/* up to three ADCs */
1630DEFINE_CAPMIX(1);
1631DEFINE_CAPMIX(2);
1632DEFINE_CAPMIX(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001633
1634
1635/*
1636 * ALC880 5-stack model
1637 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001638 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1639 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001640 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1641 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1642 */
1643
1644/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001645static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001646 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001647 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001648 { } /* end */
1649};
1650
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001651/* channel source setting (6/8 channel selection for 5-stack) */
1652/* 6ch mode */
1653static struct hda_verb alc880_fivestack_ch6_init[] = {
1654 /* set line-in to input, mute it */
1655 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1656 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001657 { } /* end */
1658};
1659
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001660/* 8ch mode */
1661static struct hda_verb alc880_fivestack_ch8_init[] = {
1662 /* set line-in to output, unmute it */
1663 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1664 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1665 { } /* end */
1666};
1667
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001668static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001669 { 6, alc880_fivestack_ch6_init },
1670 { 8, alc880_fivestack_ch8_init },
1671};
1672
1673
1674/*
1675 * ALC880 6-stack model
1676 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001677 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1678 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001679 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1680 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1681 */
1682
1683static hda_nid_t alc880_6st_dac_nids[4] = {
1684 /* front, rear, clfe, rear_surr */
1685 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001686};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001687
1688static struct hda_input_mux alc880_6stack_capture_source = {
1689 .num_items = 4,
1690 .items = {
1691 { "Mic", 0x0 },
1692 { "Front Mic", 0x1 },
1693 { "Line", 0x2 },
1694 { "CD", 0x4 },
1695 },
1696};
1697
1698/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001699static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001700 { 8, NULL },
1701};
1702
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001703static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001704 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001705 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001706 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001707 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001708 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1709 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001710 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1711 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001712 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001713 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001714 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1715 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1716 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1717 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1719 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1720 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1721 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001722 {
1723 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1724 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001725 .info = alc_ch_mode_info,
1726 .get = alc_ch_mode_get,
1727 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001728 },
1729 { } /* end */
1730};
1731
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001732
1733/*
1734 * ALC880 W810 model
1735 *
1736 * W810 has rear IO for:
1737 * Front (DAC 02)
1738 * Surround (DAC 03)
1739 * Center/LFE (DAC 04)
1740 * Digital out (06)
1741 *
1742 * The system also has a pair of internal speakers, and a headphone jack.
1743 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001744 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001745 * There is a variable resistor to control the speaker or headphone
1746 * volume. This is a hardware-only device without a software API.
1747 *
1748 * Plugging headphones in will disable the internal speakers. This is
1749 * implemented in hardware, not via the driver using jack sense. In
1750 * a similar fashion, plugging into the rear socket marked "front" will
1751 * disable both the speakers and headphones.
1752 *
1753 * For input, there's a microphone jack, and an "audio in" jack.
1754 * These may not do anything useful with this driver yet, because I
1755 * haven't setup any initialization verbs for these yet...
1756 */
1757
1758static hda_nid_t alc880_w810_dac_nids[3] = {
1759 /* front, rear/surround, clfe */
1760 0x02, 0x03, 0x04
1761};
1762
1763/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001764static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001765 { 6, NULL }
1766};
1767
1768/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001769static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001770 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001771 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001772 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001773 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001774 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1775 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001776 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1777 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001778 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1779 { } /* end */
1780};
1781
1782
1783/*
1784 * Z710V model
1785 *
1786 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001787 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1788 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001789 */
1790
1791static hda_nid_t alc880_z71v_dac_nids[1] = {
1792 0x02
1793};
1794#define ALC880_Z71V_HP_DAC 0x03
1795
1796/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001797static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001798 { 2, NULL }
1799};
1800
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001801static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001802 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001803 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001804 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001805 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001806 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1807 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1810 { } /* end */
1811};
1812
1813
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001814/*
1815 * ALC880 F1734 model
1816 *
1817 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1818 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1819 */
1820
1821static hda_nid_t alc880_f1734_dac_nids[1] = {
1822 0x03
1823};
1824#define ALC880_F1734_HP_DAC 0x02
1825
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001826static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001827 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001828 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001829 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1830 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001831 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1832 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001835 { } /* end */
1836};
1837
Takashi Iwai937b4162008-02-11 14:52:36 +01001838static struct hda_input_mux alc880_f1734_capture_source = {
1839 .num_items = 2,
1840 .items = {
1841 { "Mic", 0x1 },
1842 { "CD", 0x4 },
1843 },
1844};
1845
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001846
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001847/*
1848 * ALC880 ASUS model
1849 *
1850 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1851 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1852 * Mic = 0x18, Line = 0x1a
1853 */
1854
1855#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1856#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1857
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001858static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001859 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001860 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001861 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001862 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001863 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1864 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001865 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1866 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001867 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1868 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1869 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1870 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1871 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1872 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001873 {
1874 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1875 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001876 .info = alc_ch_mode_info,
1877 .get = alc_ch_mode_get,
1878 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001879 },
1880 { } /* end */
1881};
1882
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001883/*
1884 * ALC880 ASUS W1V model
1885 *
1886 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1887 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1888 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1889 */
1890
1891/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001892static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001893 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1894 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001895 { } /* end */
1896};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001897
Kailang Yangdf694da2005-12-05 19:42:22 +01001898/* TCL S700 */
1899static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1900 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1901 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1902 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1903 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1904 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1905 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1907 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1908 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001909 { } /* end */
1910};
1911
Kailang Yangccc656c2006-10-17 12:32:26 +02001912/* Uniwill */
1913static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001914 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1915 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1916 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1917 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001918 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1919 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1920 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1921 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1922 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1923 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1924 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1925 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1926 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1927 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1928 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1929 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001930 {
1931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1932 .name = "Channel Mode",
1933 .info = alc_ch_mode_info,
1934 .get = alc_ch_mode_get,
1935 .put = alc_ch_mode_put,
1936 },
1937 { } /* end */
1938};
1939
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001940static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1941 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1942 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1943 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1944 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1945 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1946 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1947 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1948 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1949 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1950 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1951 { } /* end */
1952};
1953
Kailang Yangccc656c2006-10-17 12:32:26 +02001954static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001955 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1956 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1957 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1958 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1961 { } /* end */
1962};
1963
Linus Torvalds1da177e2005-04-16 15:20:36 -07001964/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001965 * virtual master controls
1966 */
1967
1968/*
1969 * slave controls for virtual master
1970 */
1971static const char *alc_slave_vols[] = {
1972 "Front Playback Volume",
1973 "Surround Playback Volume",
1974 "Center Playback Volume",
1975 "LFE Playback Volume",
1976 "Side Playback Volume",
1977 "Headphone Playback Volume",
1978 "Speaker Playback Volume",
1979 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001980 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01001981 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001982 NULL,
1983};
1984
1985static const char *alc_slave_sws[] = {
1986 "Front Playback Switch",
1987 "Surround Playback Switch",
1988 "Center Playback Switch",
1989 "LFE Playback Switch",
1990 "Side Playback Switch",
1991 "Headphone Playback Switch",
1992 "Speaker Playback Switch",
1993 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001994 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001995 NULL,
1996};
1997
1998/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001999 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002000 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002001
2002static void alc_free_kctls(struct hda_codec *codec);
2003
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002004/* additional beep mixers; the actual parameters are overwritten at build */
2005static struct snd_kcontrol_new alc_beep_mixer[] = {
2006 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2007 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2008 { } /* end */
2009};
2010
Linus Torvalds1da177e2005-04-16 15:20:36 -07002011static int alc_build_controls(struct hda_codec *codec)
2012{
2013 struct alc_spec *spec = codec->spec;
2014 int err;
2015 int i;
2016
2017 for (i = 0; i < spec->num_mixers; i++) {
2018 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2019 if (err < 0)
2020 return err;
2021 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002022 if (spec->cap_mixer) {
2023 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2024 if (err < 0)
2025 return err;
2026 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002027 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002028 err = snd_hda_create_spdif_out_ctls(codec,
2029 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002030 if (err < 0)
2031 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002032 if (!spec->no_analog) {
2033 err = snd_hda_create_spdif_share_sw(codec,
2034 &spec->multiout);
2035 if (err < 0)
2036 return err;
2037 spec->multiout.share_spdif = 1;
2038 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002039 }
2040 if (spec->dig_in_nid) {
2041 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2042 if (err < 0)
2043 return err;
2044 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002045
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002046 /* create beep controls if needed */
2047 if (spec->beep_amp) {
2048 struct snd_kcontrol_new *knew;
2049 for (knew = alc_beep_mixer; knew->name; knew++) {
2050 struct snd_kcontrol *kctl;
2051 kctl = snd_ctl_new1(knew, codec);
2052 if (!kctl)
2053 return -ENOMEM;
2054 kctl->private_value = spec->beep_amp;
2055 err = snd_hda_ctl_add(codec, kctl);
2056 if (err < 0)
2057 return err;
2058 }
2059 }
2060
Takashi Iwai2134ea42008-01-10 16:53:55 +01002061 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002062 if (!spec->no_analog &&
2063 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002064 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002065 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002066 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002067 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002068 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002069 if (err < 0)
2070 return err;
2071 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002072 if (!spec->no_analog &&
2073 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002074 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2075 NULL, alc_slave_sws);
2076 if (err < 0)
2077 return err;
2078 }
2079
Takashi Iwai603c4012008-07-30 15:01:44 +02002080 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002081 return 0;
2082}
2083
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002084
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085/*
2086 * initialize the codec volumes, etc
2087 */
2088
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002089/*
2090 * generic initialization of ADC, input mixers and output mixers
2091 */
2092static struct hda_verb alc880_volume_init_verbs[] = {
2093 /*
2094 * Unmute ADC0-2 and set the default input to mic-in
2095 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002096 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002097 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002098 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002099 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002100 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002101 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002102
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002103 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2104 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002105 * Note: PASD motherboards uses the Line In 2 as the input for front
2106 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002107 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002108 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002109 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2110 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2111 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002116
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002117 /*
2118 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002119 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002120 /* set vol=0 to output mixers */
2121 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2122 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2123 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2124 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2125 /* set up input amps for analog loopback */
2126 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002127 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2128 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002129 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2130 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002131 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2132 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002133 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2134 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002135
2136 { }
2137};
2138
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002139/*
2140 * 3-stack pin configuration:
2141 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2142 */
2143static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2144 /*
2145 * preset connection lists of input pins
2146 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2147 */
2148 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2149 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2150 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2151
2152 /*
2153 * Set pin mode and muting
2154 */
2155 /* set front pin widgets 0x14 for output */
2156 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2157 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2158 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2159 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2160 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2161 /* Mic2 (as headphone out) for HP output */
2162 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2163 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2164 /* Line In pin widget for input */
2165 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2166 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2167 /* Line2 (as front mic) pin widget for input and vref at 80% */
2168 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2169 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2170 /* CD pin widget for input */
2171 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2172
2173 { }
2174};
2175
2176/*
2177 * 5-stack pin configuration:
2178 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2179 * line-in/side = 0x1a, f-mic = 0x1b
2180 */
2181static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2182 /*
2183 * preset connection lists of input pins
2184 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2185 */
2186 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2187 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2188
2189 /*
2190 * Set pin mode and muting
2191 */
2192 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002193 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2194 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2195 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2196 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002197 /* unmute pins for output (no gain on this amp) */
2198 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2199 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2200 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2201 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2202
Linus Torvalds1da177e2005-04-16 15:20:36 -07002203 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002204 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002205 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2206 /* Mic2 (as headphone out) for HP output */
2207 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002208 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002209 /* Line In pin widget for input */
2210 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2211 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2212 /* Line2 (as front mic) pin widget for input and vref at 80% */
2213 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2214 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2215 /* CD pin widget for input */
2216 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002217
2218 { }
2219};
2220
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002221/*
2222 * W810 pin configuration:
2223 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2224 */
2225static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002226 /* hphone/speaker input selector: front DAC */
2227 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2228
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002229 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2230 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2231 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2232 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2233 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2234 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2235
2236 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002237 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002238
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239 { }
2240};
2241
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002242/*
2243 * Z71V pin configuration:
2244 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2245 */
2246static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002247 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002248 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002249 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002250 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002251
Takashi Iwai16ded522005-06-10 19:58:24 +02002252 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002253 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002254 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002255 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002256
2257 { }
2258};
2259
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002260/*
2261 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002262 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2263 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002264 */
2265static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2266 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2267
Takashi Iwai16ded522005-06-10 19:58:24 +02002268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002269 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002270 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002271 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002273 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002274 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002275 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2276
Takashi Iwai16ded522005-06-10 19:58:24 +02002277 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002278 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002279 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002280 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002281 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002282 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002283 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002284 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002285 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002286
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002287 { }
2288};
Takashi Iwai16ded522005-06-10 19:58:24 +02002289
Kailang Yangccc656c2006-10-17 12:32:26 +02002290/*
2291 * Uniwill pin configuration:
2292 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2293 * line = 0x1a
2294 */
2295static struct hda_verb alc880_uniwill_init_verbs[] = {
2296 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2297
2298 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2299 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2300 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2301 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2302 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2303 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2304 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2305 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2306 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2308 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2309 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2310 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2311 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2312
2313 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2314 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2315 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2316 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2317 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2318 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2319 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2320 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2321 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2322
2323 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2324 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2325
2326 { }
2327};
2328
2329/*
2330* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002331* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002332 */
2333static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2334 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2335
2336 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2337 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2338 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2339 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2340 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2341 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2342 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2343 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2344 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2345 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2346 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2348
2349 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2350 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2351 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2352 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2353 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2354 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2355
2356 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2357 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2358
2359 { }
2360};
2361
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002362static struct hda_verb alc880_beep_init_verbs[] = {
2363 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2364 { }
2365};
2366
Kailang Yangccc656c2006-10-17 12:32:26 +02002367/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002368static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002369{
2370 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002371 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002372
2373 present = snd_hda_codec_read(codec, 0x14, 0,
2374 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002375 bits = present ? HDA_AMP_MUTE : 0;
2376 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2377 HDA_AMP_MUTE, bits);
2378 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2379 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002380}
2381
2382/* auto-toggle front mic */
2383static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2384{
2385 unsigned int present;
2386 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002387
2388 present = snd_hda_codec_read(codec, 0x18, 0,
2389 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002390 bits = present ? HDA_AMP_MUTE : 0;
2391 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002392}
2393
2394static void alc880_uniwill_automute(struct hda_codec *codec)
2395{
2396 alc880_uniwill_hp_automute(codec);
2397 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002398}
2399
2400static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2401 unsigned int res)
2402{
2403 /* Looks like the unsol event is incompatible with the standard
2404 * definition. 4bit tag is placed at 28 bit!
2405 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002406 switch (res >> 28) {
2407 case ALC880_HP_EVENT:
2408 alc880_uniwill_hp_automute(codec);
2409 break;
2410 case ALC880_MIC_EVENT:
2411 alc880_uniwill_mic_automute(codec);
2412 break;
2413 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002414}
2415
2416static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2417{
2418 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002419 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002420
2421 present = snd_hda_codec_read(codec, 0x14, 0,
2422 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002423 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002424 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002425}
2426
2427static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2428{
2429 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002430
Kailang Yangccc656c2006-10-17 12:32:26 +02002431 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002432 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2433 present &= HDA_AMP_VOLMASK;
2434 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2435 HDA_AMP_VOLMASK, present);
2436 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2437 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002438}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002439
Kailang Yangccc656c2006-10-17 12:32:26 +02002440static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2441 unsigned int res)
2442{
2443 /* Looks like the unsol event is incompatible with the standard
2444 * definition. 4bit tag is placed at 28 bit!
2445 */
2446 if ((res >> 28) == ALC880_HP_EVENT)
2447 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002448 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002449 alc880_uniwill_p53_dcvol_automute(codec);
2450}
2451
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002452/*
2453 * F1734 pin configuration:
2454 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2455 */
2456static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002457 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002458 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2459 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2460 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2461 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2462
2463 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2464 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2467
2468 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2469 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002470 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002471 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2472 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2473 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2474 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2475 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2476 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002477
Takashi Iwai937b4162008-02-11 14:52:36 +01002478 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2479 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2480
Takashi Iwai16ded522005-06-10 19:58:24 +02002481 { }
2482};
2483
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002484/*
2485 * ASUS pin configuration:
2486 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2487 */
2488static struct hda_verb alc880_pin_asus_init_verbs[] = {
2489 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2490 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2491 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2492 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2493
2494 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2495 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2497 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2498 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2499 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2500 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2502
2503 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2504 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2505 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2506 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2507 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2508 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2509 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2510 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2511 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002512
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002513 { }
2514};
2515
2516/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002517#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2518#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002519
Kailang Yangdf694da2005-12-05 19:42:22 +01002520/* Clevo m520g init */
2521static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2522 /* headphone output */
2523 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2524 /* line-out */
2525 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2526 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2527 /* Line-in */
2528 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2529 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2530 /* CD */
2531 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2532 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2533 /* Mic1 (rear panel) */
2534 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2535 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2536 /* Mic2 (front panel) */
2537 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2538 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2539 /* headphone */
2540 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2541 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2542 /* change to EAPD mode */
2543 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2544 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2545
2546 { }
2547};
2548
2549static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002550 /* change to EAPD mode */
2551 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2552 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2553
Kailang Yangdf694da2005-12-05 19:42:22 +01002554 /* Headphone output */
2555 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2556 /* Front output*/
2557 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2558 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2559
2560 /* Line In pin widget for input */
2561 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2562 /* CD pin widget for input */
2563 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2564 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2565 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2566
2567 /* change to EAPD mode */
2568 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2569 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2570
2571 { }
2572};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002573
2574/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002575 * LG m1 express dual
2576 *
2577 * Pin assignment:
2578 * Rear Line-In/Out (blue): 0x14
2579 * Build-in Mic-In: 0x15
2580 * Speaker-out: 0x17
2581 * HP-Out (green): 0x1b
2582 * Mic-In/Out (red): 0x19
2583 * SPDIF-Out: 0x1e
2584 */
2585
2586/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2587static hda_nid_t alc880_lg_dac_nids[3] = {
2588 0x05, 0x02, 0x03
2589};
2590
2591/* seems analog CD is not working */
2592static struct hda_input_mux alc880_lg_capture_source = {
2593 .num_items = 3,
2594 .items = {
2595 { "Mic", 0x1 },
2596 { "Line", 0x5 },
2597 { "Internal Mic", 0x6 },
2598 },
2599};
2600
2601/* 2,4,6 channel modes */
2602static struct hda_verb alc880_lg_ch2_init[] = {
2603 /* set line-in and mic-in to input */
2604 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2605 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2606 { }
2607};
2608
2609static struct hda_verb alc880_lg_ch4_init[] = {
2610 /* set line-in to out and mic-in to input */
2611 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2612 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2613 { }
2614};
2615
2616static struct hda_verb alc880_lg_ch6_init[] = {
2617 /* set line-in and mic-in to output */
2618 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2619 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2620 { }
2621};
2622
2623static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2624 { 2, alc880_lg_ch2_init },
2625 { 4, alc880_lg_ch4_init },
2626 { 6, alc880_lg_ch6_init },
2627};
2628
2629static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002630 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2631 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002632 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2633 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2634 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2635 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2636 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2637 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2638 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2639 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2640 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2641 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2642 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2643 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2644 {
2645 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2646 .name = "Channel Mode",
2647 .info = alc_ch_mode_info,
2648 .get = alc_ch_mode_get,
2649 .put = alc_ch_mode_put,
2650 },
2651 { } /* end */
2652};
2653
2654static struct hda_verb alc880_lg_init_verbs[] = {
2655 /* set capture source to mic-in */
2656 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2657 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2658 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2659 /* mute all amp mixer inputs */
2660 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002661 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002663 /* line-in to input */
2664 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2665 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2666 /* built-in mic */
2667 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2668 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2669 /* speaker-out */
2670 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2671 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2672 /* mic-in to input */
2673 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2674 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2675 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2676 /* HP-out */
2677 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2678 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2679 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2680 /* jack sense */
2681 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2682 { }
2683};
2684
2685/* toggle speaker-output according to the hp-jack state */
2686static void alc880_lg_automute(struct hda_codec *codec)
2687{
2688 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002689 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002690
2691 present = snd_hda_codec_read(codec, 0x1b, 0,
2692 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002693 bits = present ? HDA_AMP_MUTE : 0;
2694 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2695 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002696}
2697
2698static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2699{
2700 /* Looks like the unsol event is incompatible with the standard
2701 * definition. 4bit tag is placed at 28 bit!
2702 */
2703 if ((res >> 28) == 0x01)
2704 alc880_lg_automute(codec);
2705}
2706
2707/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002708 * LG LW20
2709 *
2710 * Pin assignment:
2711 * Speaker-out: 0x14
2712 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002713 * Built-in Mic-In: 0x19
2714 * Line-In: 0x1b
2715 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002716 * SPDIF-Out: 0x1e
2717 */
2718
Takashi Iwaid6815182006-03-23 16:06:23 +01002719static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002720 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002721 .items = {
2722 { "Mic", 0x0 },
2723 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002724 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002725 },
2726};
2727
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002728#define alc880_lg_lw_modes alc880_threestack_modes
2729
Takashi Iwaid6815182006-03-23 16:06:23 +01002730static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002731 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2732 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2733 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2734 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2735 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2736 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2737 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2738 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2739 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2740 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2742 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2743 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2744 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002745 {
2746 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2747 .name = "Channel Mode",
2748 .info = alc_ch_mode_info,
2749 .get = alc_ch_mode_get,
2750 .put = alc_ch_mode_put,
2751 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002752 { } /* end */
2753};
2754
2755static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002756 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2757 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2758 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2759
Takashi Iwaid6815182006-03-23 16:06:23 +01002760 /* set capture source to mic-in */
2761 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2762 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2763 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002765 /* speaker-out */
2766 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2767 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2768 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002769 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2770 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2771 /* mic-in to input */
2772 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2773 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2774 /* built-in mic */
2775 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2776 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2777 /* jack sense */
2778 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2779 { }
2780};
2781
2782/* toggle speaker-output according to the hp-jack state */
2783static void alc880_lg_lw_automute(struct hda_codec *codec)
2784{
2785 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002786 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002787
2788 present = snd_hda_codec_read(codec, 0x1b, 0,
2789 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002790 bits = present ? HDA_AMP_MUTE : 0;
2791 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2792 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002793}
2794
2795static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2796{
2797 /* Looks like the unsol event is incompatible with the standard
2798 * definition. 4bit tag is placed at 28 bit!
2799 */
2800 if ((res >> 28) == 0x01)
2801 alc880_lg_lw_automute(codec);
2802}
2803
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002804static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2805 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2806 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2807 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2808 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2809 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2810 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2811 { } /* end */
2812};
2813
2814static struct hda_input_mux alc880_medion_rim_capture_source = {
2815 .num_items = 2,
2816 .items = {
2817 { "Mic", 0x0 },
2818 { "Internal Mic", 0x1 },
2819 },
2820};
2821
2822static struct hda_verb alc880_medion_rim_init_verbs[] = {
2823 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2824
2825 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2826 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2827
2828 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2829 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2830 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2831 /* Mic2 (as headphone out) for HP output */
2832 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2833 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2834 /* Internal Speaker */
2835 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2836 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2837
2838 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2839 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2840
2841 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2842 { }
2843};
2844
2845/* toggle speaker-output according to the hp-jack state */
2846static void alc880_medion_rim_automute(struct hda_codec *codec)
2847{
2848 unsigned int present;
2849 unsigned char bits;
2850
2851 present = snd_hda_codec_read(codec, 0x14, 0,
2852 AC_VERB_GET_PIN_SENSE, 0)
2853 & AC_PINSENSE_PRESENCE;
2854 bits = present ? HDA_AMP_MUTE : 0;
2855 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2856 HDA_AMP_MUTE, bits);
2857 if (present)
2858 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2859 else
2860 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2861}
2862
2863static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2864 unsigned int res)
2865{
2866 /* Looks like the unsol event is incompatible with the standard
2867 * definition. 4bit tag is placed at 28 bit!
2868 */
2869 if ((res >> 28) == ALC880_HP_EVENT)
2870 alc880_medion_rim_automute(codec);
2871}
2872
Takashi Iwaicb53c622007-08-10 17:21:45 +02002873#ifdef CONFIG_SND_HDA_POWER_SAVE
2874static struct hda_amp_list alc880_loopbacks[] = {
2875 { 0x0b, HDA_INPUT, 0 },
2876 { 0x0b, HDA_INPUT, 1 },
2877 { 0x0b, HDA_INPUT, 2 },
2878 { 0x0b, HDA_INPUT, 3 },
2879 { 0x0b, HDA_INPUT, 4 },
2880 { } /* end */
2881};
2882
2883static struct hda_amp_list alc880_lg_loopbacks[] = {
2884 { 0x0b, HDA_INPUT, 1 },
2885 { 0x0b, HDA_INPUT, 6 },
2886 { 0x0b, HDA_INPUT, 7 },
2887 { } /* end */
2888};
2889#endif
2890
Takashi Iwaid6815182006-03-23 16:06:23 +01002891/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002892 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002893 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002894
Linus Torvalds1da177e2005-04-16 15:20:36 -07002895static int alc_init(struct hda_codec *codec)
2896{
2897 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002898 unsigned int i;
2899
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002900 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002901 if (codec->vendor_id == 0x10ec0888)
2902 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002903
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002904 for (i = 0; i < spec->num_init_verbs; i++)
2905 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002906
2907 if (spec->init_hook)
2908 spec->init_hook(codec);
2909
Linus Torvalds1da177e2005-04-16 15:20:36 -07002910 return 0;
2911}
2912
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002913static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2914{
2915 struct alc_spec *spec = codec->spec;
2916
2917 if (spec->unsol_event)
2918 spec->unsol_event(codec, res);
2919}
2920
Takashi Iwaicb53c622007-08-10 17:21:45 +02002921#ifdef CONFIG_SND_HDA_POWER_SAVE
2922static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2923{
2924 struct alc_spec *spec = codec->spec;
2925 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2926}
2927#endif
2928
Linus Torvalds1da177e2005-04-16 15:20:36 -07002929/*
2930 * Analog playback callbacks
2931 */
2932static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2933 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002934 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002935{
2936 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002937 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2938 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002939}
2940
2941static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2942 struct hda_codec *codec,
2943 unsigned int stream_tag,
2944 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002945 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002946{
2947 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002948 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2949 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002950}
2951
2952static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2953 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002954 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002955{
2956 struct alc_spec *spec = codec->spec;
2957 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2958}
2959
2960/*
2961 * Digital out
2962 */
2963static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2964 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002965 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002966{
2967 struct alc_spec *spec = codec->spec;
2968 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2969}
2970
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002971static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2972 struct hda_codec *codec,
2973 unsigned int stream_tag,
2974 unsigned int format,
2975 struct snd_pcm_substream *substream)
2976{
2977 struct alc_spec *spec = codec->spec;
2978 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2979 stream_tag, format, substream);
2980}
2981
Linus Torvalds1da177e2005-04-16 15:20:36 -07002982static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2983 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002984 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002985{
2986 struct alc_spec *spec = codec->spec;
2987 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2988}
2989
2990/*
2991 * Analog capture
2992 */
Takashi Iwai63300792008-01-24 15:31:36 +01002993static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002994 struct hda_codec *codec,
2995 unsigned int stream_tag,
2996 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002997 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002998{
2999 struct alc_spec *spec = codec->spec;
3000
Takashi Iwai63300792008-01-24 15:31:36 +01003001 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003002 stream_tag, 0, format);
3003 return 0;
3004}
3005
Takashi Iwai63300792008-01-24 15:31:36 +01003006static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003007 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003008 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003009{
3010 struct alc_spec *spec = codec->spec;
3011
Takashi Iwai888afa12008-03-18 09:57:50 +01003012 snd_hda_codec_cleanup_stream(codec,
3013 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003014 return 0;
3015}
3016
3017
3018/*
3019 */
3020static struct hda_pcm_stream alc880_pcm_analog_playback = {
3021 .substreams = 1,
3022 .channels_min = 2,
3023 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003024 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003025 .ops = {
3026 .open = alc880_playback_pcm_open,
3027 .prepare = alc880_playback_pcm_prepare,
3028 .cleanup = alc880_playback_pcm_cleanup
3029 },
3030};
3031
3032static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003033 .substreams = 1,
3034 .channels_min = 2,
3035 .channels_max = 2,
3036 /* NID is set in alc_build_pcms */
3037};
3038
3039static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3040 .substreams = 1,
3041 .channels_min = 2,
3042 .channels_max = 2,
3043 /* NID is set in alc_build_pcms */
3044};
3045
3046static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3047 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003048 .channels_min = 2,
3049 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003050 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003051 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003052 .prepare = alc880_alt_capture_pcm_prepare,
3053 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003054 },
3055};
3056
3057static struct hda_pcm_stream alc880_pcm_digital_playback = {
3058 .substreams = 1,
3059 .channels_min = 2,
3060 .channels_max = 2,
3061 /* NID is set in alc_build_pcms */
3062 .ops = {
3063 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003064 .close = alc880_dig_playback_pcm_close,
3065 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07003066 },
3067};
3068
3069static struct hda_pcm_stream alc880_pcm_digital_capture = {
3070 .substreams = 1,
3071 .channels_min = 2,
3072 .channels_max = 2,
3073 /* NID is set in alc_build_pcms */
3074};
3075
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003076/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003077static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003078 .substreams = 0,
3079 .channels_min = 0,
3080 .channels_max = 0,
3081};
3082
Linus Torvalds1da177e2005-04-16 15:20:36 -07003083static int alc_build_pcms(struct hda_codec *codec)
3084{
3085 struct alc_spec *spec = codec->spec;
3086 struct hda_pcm *info = spec->pcm_rec;
3087 int i;
3088
3089 codec->num_pcms = 1;
3090 codec->pcm_info = info;
3091
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003092 if (spec->no_analog)
3093 goto skip_analog;
3094
Linus Torvalds1da177e2005-04-16 15:20:36 -07003095 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003096 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003097 if (snd_BUG_ON(!spec->multiout.dac_nids))
3098 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003099 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3100 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3101 }
3102 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003103 if (snd_BUG_ON(!spec->adc_nids))
3104 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003105 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3106 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3107 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003108
Takashi Iwai4a471b72005-12-07 13:56:29 +01003109 if (spec->channel_mode) {
3110 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3111 for (i = 0; i < spec->num_channel_mode; i++) {
3112 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3113 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3114 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003115 }
3116 }
3117
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003118 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003119 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003120 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003121 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003122 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003123 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003124 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003125 if (spec->dig_out_type)
3126 info->pcm_type = spec->dig_out_type;
3127 else
3128 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003129 if (spec->multiout.dig_out_nid &&
3130 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003131 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3132 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3133 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003134 if (spec->dig_in_nid &&
3135 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003136 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3137 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3138 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003139 /* FIXME: do we need this for all Realtek codec models? */
3140 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003141 }
3142
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003143 if (spec->no_analog)
3144 return 0;
3145
Takashi Iwaie08a0072006-09-07 17:52:14 +02003146 /* If the use of more than one ADC is requested for the current
3147 * model, configure a second analog capture-only PCM.
3148 */
3149 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003150 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3151 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003152 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003153 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003154 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003155 if (spec->alt_dac_nid) {
3156 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3157 *spec->stream_analog_alt_playback;
3158 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3159 spec->alt_dac_nid;
3160 } else {
3161 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3162 alc_pcm_null_stream;
3163 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3164 }
3165 if (spec->num_adc_nids > 1) {
3166 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3167 *spec->stream_analog_alt_capture;
3168 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3169 spec->adc_nids[1];
3170 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3171 spec->num_adc_nids - 1;
3172 } else {
3173 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3174 alc_pcm_null_stream;
3175 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003176 }
3177 }
3178
Linus Torvalds1da177e2005-04-16 15:20:36 -07003179 return 0;
3180}
3181
Takashi Iwai603c4012008-07-30 15:01:44 +02003182static void alc_free_kctls(struct hda_codec *codec)
3183{
3184 struct alc_spec *spec = codec->spec;
3185
3186 if (spec->kctls.list) {
3187 struct snd_kcontrol_new *kctl = spec->kctls.list;
3188 int i;
3189 for (i = 0; i < spec->kctls.used; i++)
3190 kfree(kctl[i].name);
3191 }
3192 snd_array_free(&spec->kctls);
3193}
3194
Linus Torvalds1da177e2005-04-16 15:20:36 -07003195static void alc_free(struct hda_codec *codec)
3196{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003197 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003198
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003199 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003200 return;
3201
Takashi Iwai603c4012008-07-30 15:01:44 +02003202 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003203 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003204 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003205}
3206
Takashi Iwaie044c392008-10-27 16:56:24 +01003207#ifdef SND_HDA_NEEDS_RESUME
3208static void store_pin_configs(struct hda_codec *codec)
3209{
3210 struct alc_spec *spec = codec->spec;
3211 hda_nid_t nid, end_nid;
3212
3213 end_nid = codec->start_nid + codec->num_nodes;
3214 for (nid = codec->start_nid; nid < end_nid; nid++) {
3215 unsigned int wid_caps = get_wcaps(codec, nid);
3216 unsigned int wid_type =
3217 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3218 if (wid_type != AC_WID_PIN)
3219 continue;
3220 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
3221 break;
3222 spec->pin_nids[spec->num_pins] = nid;
3223 spec->pin_cfgs[spec->num_pins] =
3224 snd_hda_codec_read(codec, nid, 0,
3225 AC_VERB_GET_CONFIG_DEFAULT, 0);
3226 spec->num_pins++;
3227 }
3228}
3229
3230static void resume_pin_configs(struct hda_codec *codec)
3231{
3232 struct alc_spec *spec = codec->spec;
3233 int i;
3234
3235 for (i = 0; i < spec->num_pins; i++) {
3236 hda_nid_t pin_nid = spec->pin_nids[i];
3237 unsigned int pin_config = spec->pin_cfgs[i];
3238 snd_hda_codec_write(codec, pin_nid, 0,
3239 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
3240 pin_config & 0x000000ff);
3241 snd_hda_codec_write(codec, pin_nid, 0,
3242 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
3243 (pin_config & 0x0000ff00) >> 8);
3244 snd_hda_codec_write(codec, pin_nid, 0,
3245 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
3246 (pin_config & 0x00ff0000) >> 16);
3247 snd_hda_codec_write(codec, pin_nid, 0,
3248 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
3249 pin_config >> 24);
3250 }
3251}
3252
3253static int alc_resume(struct hda_codec *codec)
3254{
3255 resume_pin_configs(codec);
3256 codec->patch_ops.init(codec);
3257 snd_hda_codec_resume_amp(codec);
3258 snd_hda_codec_resume_cache(codec);
3259 return 0;
3260}
3261#else
3262#define store_pin_configs(codec)
3263#endif
3264
Linus Torvalds1da177e2005-04-16 15:20:36 -07003265/*
3266 */
3267static struct hda_codec_ops alc_patch_ops = {
3268 .build_controls = alc_build_controls,
3269 .build_pcms = alc_build_pcms,
3270 .init = alc_init,
3271 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003272 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003273#ifdef SND_HDA_NEEDS_RESUME
3274 .resume = alc_resume,
3275#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003276#ifdef CONFIG_SND_HDA_POWER_SAVE
3277 .check_power_status = alc_check_power_status,
3278#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003279};
3280
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003281
3282/*
3283 * Test configuration for debugging
3284 *
3285 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3286 * enum controls.
3287 */
3288#ifdef CONFIG_SND_DEBUG
3289static hda_nid_t alc880_test_dac_nids[4] = {
3290 0x02, 0x03, 0x04, 0x05
3291};
3292
3293static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003294 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003295 .items = {
3296 { "In-1", 0x0 },
3297 { "In-2", 0x1 },
3298 { "In-3", 0x2 },
3299 { "In-4", 0x3 },
3300 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003301 { "Front", 0x5 },
3302 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003303 },
3304};
3305
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003306static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003307 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003308 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003309 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003310 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003311};
3312
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003313static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3314 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003315{
3316 static char *texts[] = {
3317 "N/A", "Line Out", "HP Out",
3318 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3319 };
3320 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3321 uinfo->count = 1;
3322 uinfo->value.enumerated.items = 8;
3323 if (uinfo->value.enumerated.item >= 8)
3324 uinfo->value.enumerated.item = 7;
3325 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3326 return 0;
3327}
3328
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003329static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3330 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003331{
3332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3333 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3334 unsigned int pin_ctl, item = 0;
3335
3336 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3337 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3338 if (pin_ctl & AC_PINCTL_OUT_EN) {
3339 if (pin_ctl & AC_PINCTL_HP_EN)
3340 item = 2;
3341 else
3342 item = 1;
3343 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3344 switch (pin_ctl & AC_PINCTL_VREFEN) {
3345 case AC_PINCTL_VREF_HIZ: item = 3; break;
3346 case AC_PINCTL_VREF_50: item = 4; break;
3347 case AC_PINCTL_VREF_GRD: item = 5; break;
3348 case AC_PINCTL_VREF_80: item = 6; break;
3349 case AC_PINCTL_VREF_100: item = 7; break;
3350 }
3351 }
3352 ucontrol->value.enumerated.item[0] = item;
3353 return 0;
3354}
3355
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003356static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3357 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003358{
3359 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3360 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3361 static unsigned int ctls[] = {
3362 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3363 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3364 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3365 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3366 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3367 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3368 };
3369 unsigned int old_ctl, new_ctl;
3370
3371 old_ctl = snd_hda_codec_read(codec, nid, 0,
3372 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3373 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3374 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003375 int val;
3376 snd_hda_codec_write_cache(codec, nid, 0,
3377 AC_VERB_SET_PIN_WIDGET_CONTROL,
3378 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003379 val = ucontrol->value.enumerated.item[0] >= 3 ?
3380 HDA_AMP_MUTE : 0;
3381 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3382 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003383 return 1;
3384 }
3385 return 0;
3386}
3387
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003388static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3389 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003390{
3391 static char *texts[] = {
3392 "Front", "Surround", "CLFE", "Side"
3393 };
3394 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3395 uinfo->count = 1;
3396 uinfo->value.enumerated.items = 4;
3397 if (uinfo->value.enumerated.item >= 4)
3398 uinfo->value.enumerated.item = 3;
3399 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3400 return 0;
3401}
3402
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003403static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3404 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003405{
3406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3407 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3408 unsigned int sel;
3409
3410 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3411 ucontrol->value.enumerated.item[0] = sel & 3;
3412 return 0;
3413}
3414
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003415static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3416 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003417{
3418 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3419 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3420 unsigned int sel;
3421
3422 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3423 if (ucontrol->value.enumerated.item[0] != sel) {
3424 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003425 snd_hda_codec_write_cache(codec, nid, 0,
3426 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003427 return 1;
3428 }
3429 return 0;
3430}
3431
3432#define PIN_CTL_TEST(xname,nid) { \
3433 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3434 .name = xname, \
3435 .info = alc_test_pin_ctl_info, \
3436 .get = alc_test_pin_ctl_get, \
3437 .put = alc_test_pin_ctl_put, \
3438 .private_value = nid \
3439 }
3440
3441#define PIN_SRC_TEST(xname,nid) { \
3442 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3443 .name = xname, \
3444 .info = alc_test_pin_src_info, \
3445 .get = alc_test_pin_src_get, \
3446 .put = alc_test_pin_src_put, \
3447 .private_value = nid \
3448 }
3449
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003450static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003451 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3452 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3453 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3454 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003455 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3456 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3457 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3458 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003459 PIN_CTL_TEST("Front Pin Mode", 0x14),
3460 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3461 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3462 PIN_CTL_TEST("Side Pin Mode", 0x17),
3463 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3464 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3465 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3466 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3467 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3468 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3469 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3470 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3471 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3472 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3473 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3474 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3475 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3476 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3477 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3478 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3479 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3480 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003481 {
3482 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3483 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003484 .info = alc_ch_mode_info,
3485 .get = alc_ch_mode_get,
3486 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003487 },
3488 { } /* end */
3489};
3490
3491static struct hda_verb alc880_test_init_verbs[] = {
3492 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003493 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3494 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3495 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3496 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3497 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3498 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3499 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3500 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003501 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3504 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3505 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003506 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003507 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3508 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3509 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3510 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003511 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003512 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3513 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3514 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3515 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003516 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003517 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3518 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003519 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3520 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3521 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003522 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003523 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3524 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3525 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3526 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003527 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003529 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003530 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003531 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003532 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003533 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003534 /* Analog input/passthru */
3535 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3536 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003540 { }
3541};
3542#endif
3543
Linus Torvalds1da177e2005-04-16 15:20:36 -07003544/*
3545 */
3546
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003547static const char *alc880_models[ALC880_MODEL_LAST] = {
3548 [ALC880_3ST] = "3stack",
3549 [ALC880_TCL_S700] = "tcl",
3550 [ALC880_3ST_DIG] = "3stack-digout",
3551 [ALC880_CLEVO] = "clevo",
3552 [ALC880_5ST] = "5stack",
3553 [ALC880_5ST_DIG] = "5stack-digout",
3554 [ALC880_W810] = "w810",
3555 [ALC880_Z71V] = "z71v",
3556 [ALC880_6ST] = "6stack",
3557 [ALC880_6ST_DIG] = "6stack-digout",
3558 [ALC880_ASUS] = "asus",
3559 [ALC880_ASUS_W1V] = "asus-w1v",
3560 [ALC880_ASUS_DIG] = "asus-dig",
3561 [ALC880_ASUS_DIG2] = "asus-dig2",
3562 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003563 [ALC880_UNIWILL_P53] = "uniwill-p53",
3564 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003565 [ALC880_F1734] = "F1734",
3566 [ALC880_LG] = "lg",
3567 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003568 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003569#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003570 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003571#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003572 [ALC880_AUTO] = "auto",
3573};
3574
3575static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003576 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003577 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3578 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3579 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3580 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3581 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3582 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3583 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3584 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003585 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3586 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003587 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3588 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3589 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3590 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3591 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3592 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3593 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3594 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3595 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3596 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003597 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003598 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3599 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3600 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003601 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003602 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003603 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3604 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003605 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3606 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003607 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3608 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3609 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3610 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003611 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3612 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003613 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003614 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003615 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003616 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003617 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3618 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003619 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003620 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003621 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003622 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003623 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003624 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003625 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003626 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003627 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003628 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3629 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003630 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003631 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3632 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3633 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3634 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003635 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3636 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003637 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003638 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003639 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3640 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003641 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3642 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3643 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003644 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3645 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3646 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003647 {}
3648};
3649
Takashi Iwai16ded522005-06-10 19:58:24 +02003650/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003651 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003652 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003653static struct alc_config_preset alc880_presets[] = {
3654 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003655 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003656 .init_verbs = { alc880_volume_init_verbs,
3657 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003658 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003659 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003660 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3661 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003662 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003663 .input_mux = &alc880_capture_source,
3664 },
3665 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003666 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003667 .init_verbs = { alc880_volume_init_verbs,
3668 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003669 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003670 .dac_nids = alc880_dac_nids,
3671 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003672 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3673 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003674 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003675 .input_mux = &alc880_capture_source,
3676 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003677 [ALC880_TCL_S700] = {
3678 .mixers = { alc880_tcl_s700_mixer },
3679 .init_verbs = { alc880_volume_init_verbs,
3680 alc880_pin_tcl_S700_init_verbs,
3681 alc880_gpio2_init_verbs },
3682 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3683 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003684 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3685 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003686 .hp_nid = 0x03,
3687 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3688 .channel_mode = alc880_2_jack_modes,
3689 .input_mux = &alc880_capture_source,
3690 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003691 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003692 .mixers = { alc880_three_stack_mixer,
3693 alc880_five_stack_mixer},
3694 .init_verbs = { alc880_volume_init_verbs,
3695 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003696 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3697 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003698 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3699 .channel_mode = alc880_fivestack_modes,
3700 .input_mux = &alc880_capture_source,
3701 },
3702 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003703 .mixers = { alc880_three_stack_mixer,
3704 alc880_five_stack_mixer },
3705 .init_verbs = { alc880_volume_init_verbs,
3706 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003707 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3708 .dac_nids = alc880_dac_nids,
3709 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003710 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3711 .channel_mode = alc880_fivestack_modes,
3712 .input_mux = &alc880_capture_source,
3713 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003714 [ALC880_6ST] = {
3715 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003716 .init_verbs = { alc880_volume_init_verbs,
3717 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003718 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3719 .dac_nids = alc880_6st_dac_nids,
3720 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3721 .channel_mode = alc880_sixstack_modes,
3722 .input_mux = &alc880_6stack_capture_source,
3723 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003724 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003725 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003726 .init_verbs = { alc880_volume_init_verbs,
3727 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003728 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3729 .dac_nids = alc880_6st_dac_nids,
3730 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003731 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3732 .channel_mode = alc880_sixstack_modes,
3733 .input_mux = &alc880_6stack_capture_source,
3734 },
3735 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003736 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003737 .init_verbs = { alc880_volume_init_verbs,
3738 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003739 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003740 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3741 .dac_nids = alc880_w810_dac_nids,
3742 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003743 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3744 .channel_mode = alc880_w810_modes,
3745 .input_mux = &alc880_capture_source,
3746 },
3747 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003748 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003749 .init_verbs = { alc880_volume_init_verbs,
3750 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003751 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3752 .dac_nids = alc880_z71v_dac_nids,
3753 .dig_out_nid = ALC880_DIGOUT_NID,
3754 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003755 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3756 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003757 .input_mux = &alc880_capture_source,
3758 },
3759 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003760 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003761 .init_verbs = { alc880_volume_init_verbs,
3762 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003763 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3764 .dac_nids = alc880_f1734_dac_nids,
3765 .hp_nid = 0x02,
3766 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3767 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003768 .input_mux = &alc880_f1734_capture_source,
3769 .unsol_event = alc880_uniwill_p53_unsol_event,
3770 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003771 },
3772 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003773 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003774 .init_verbs = { alc880_volume_init_verbs,
3775 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003776 alc880_gpio1_init_verbs },
3777 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3778 .dac_nids = alc880_asus_dac_nids,
3779 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3780 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003781 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003782 .input_mux = &alc880_capture_source,
3783 },
3784 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003785 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003786 .init_verbs = { alc880_volume_init_verbs,
3787 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003788 alc880_gpio1_init_verbs },
3789 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3790 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003791 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003792 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3793 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003794 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003795 .input_mux = &alc880_capture_source,
3796 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003797 [ALC880_ASUS_DIG2] = {
3798 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003799 .init_verbs = { alc880_volume_init_verbs,
3800 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003801 alc880_gpio2_init_verbs }, /* use GPIO2 */
3802 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3803 .dac_nids = alc880_asus_dac_nids,
3804 .dig_out_nid = ALC880_DIGOUT_NID,
3805 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3806 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003807 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003808 .input_mux = &alc880_capture_source,
3809 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003810 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003811 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003812 .init_verbs = { alc880_volume_init_verbs,
3813 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003814 alc880_gpio1_init_verbs },
3815 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3816 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003817 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003818 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3819 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003820 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003821 .input_mux = &alc880_capture_source,
3822 },
3823 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003824 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003825 .init_verbs = { alc880_volume_init_verbs,
3826 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003827 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3828 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003829 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003830 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3831 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003832 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003833 .input_mux = &alc880_capture_source,
3834 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003835 [ALC880_UNIWILL] = {
3836 .mixers = { alc880_uniwill_mixer },
3837 .init_verbs = { alc880_volume_init_verbs,
3838 alc880_uniwill_init_verbs },
3839 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3840 .dac_nids = alc880_asus_dac_nids,
3841 .dig_out_nid = ALC880_DIGOUT_NID,
3842 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3843 .channel_mode = alc880_threestack_modes,
3844 .need_dac_fix = 1,
3845 .input_mux = &alc880_capture_source,
3846 .unsol_event = alc880_uniwill_unsol_event,
3847 .init_hook = alc880_uniwill_automute,
3848 },
3849 [ALC880_UNIWILL_P53] = {
3850 .mixers = { alc880_uniwill_p53_mixer },
3851 .init_verbs = { alc880_volume_init_verbs,
3852 alc880_uniwill_p53_init_verbs },
3853 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3854 .dac_nids = alc880_asus_dac_nids,
3855 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003856 .channel_mode = alc880_threestack_modes,
3857 .input_mux = &alc880_capture_source,
3858 .unsol_event = alc880_uniwill_p53_unsol_event,
3859 .init_hook = alc880_uniwill_p53_hp_automute,
3860 },
3861 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003862 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003863 .init_verbs = { alc880_volume_init_verbs,
3864 alc880_uniwill_p53_init_verbs,
3865 alc880_beep_init_verbs },
3866 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3867 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003868 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003869 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3870 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003871 .input_mux = &alc880_capture_source,
3872 .unsol_event = alc880_uniwill_p53_unsol_event,
3873 .init_hook = alc880_uniwill_p53_hp_automute,
3874 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003875 [ALC880_CLEVO] = {
3876 .mixers = { alc880_three_stack_mixer },
3877 .init_verbs = { alc880_volume_init_verbs,
3878 alc880_pin_clevo_init_verbs },
3879 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3880 .dac_nids = alc880_dac_nids,
3881 .hp_nid = 0x03,
3882 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3883 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003884 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003885 .input_mux = &alc880_capture_source,
3886 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003887 [ALC880_LG] = {
3888 .mixers = { alc880_lg_mixer },
3889 .init_verbs = { alc880_volume_init_verbs,
3890 alc880_lg_init_verbs },
3891 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3892 .dac_nids = alc880_lg_dac_nids,
3893 .dig_out_nid = ALC880_DIGOUT_NID,
3894 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3895 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003896 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003897 .input_mux = &alc880_lg_capture_source,
3898 .unsol_event = alc880_lg_unsol_event,
3899 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003900#ifdef CONFIG_SND_HDA_POWER_SAVE
3901 .loopbacks = alc880_lg_loopbacks,
3902#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003903 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003904 [ALC880_LG_LW] = {
3905 .mixers = { alc880_lg_lw_mixer },
3906 .init_verbs = { alc880_volume_init_verbs,
3907 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003908 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003909 .dac_nids = alc880_dac_nids,
3910 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003911 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3912 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003913 .input_mux = &alc880_lg_lw_capture_source,
3914 .unsol_event = alc880_lg_lw_unsol_event,
3915 .init_hook = alc880_lg_lw_automute,
3916 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003917 [ALC880_MEDION_RIM] = {
3918 .mixers = { alc880_medion_rim_mixer },
3919 .init_verbs = { alc880_volume_init_verbs,
3920 alc880_medion_rim_init_verbs,
3921 alc_gpio2_init_verbs },
3922 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3923 .dac_nids = alc880_dac_nids,
3924 .dig_out_nid = ALC880_DIGOUT_NID,
3925 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3926 .channel_mode = alc880_2_jack_modes,
3927 .input_mux = &alc880_medion_rim_capture_source,
3928 .unsol_event = alc880_medion_rim_unsol_event,
3929 .init_hook = alc880_medion_rim_automute,
3930 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003931#ifdef CONFIG_SND_DEBUG
3932 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003933 .mixers = { alc880_test_mixer },
3934 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003935 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3936 .dac_nids = alc880_test_dac_nids,
3937 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003938 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3939 .channel_mode = alc880_test_modes,
3940 .input_mux = &alc880_test_capture_source,
3941 },
3942#endif
3943};
3944
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003945/*
3946 * Automatic parse of I/O pins from the BIOS configuration
3947 */
3948
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003949enum {
3950 ALC_CTL_WIDGET_VOL,
3951 ALC_CTL_WIDGET_MUTE,
3952 ALC_CTL_BIND_MUTE,
3953};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003954static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003955 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3956 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003957 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003958};
3959
3960/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003961static int add_control(struct alc_spec *spec, int type, const char *name,
3962 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003963{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003964 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003965
Takashi Iwai603c4012008-07-30 15:01:44 +02003966 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3967 knew = snd_array_new(&spec->kctls);
3968 if (!knew)
3969 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003970 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003971 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003972 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003973 return -ENOMEM;
3974 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003975 return 0;
3976}
3977
3978#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3979#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3980#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3981#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3982#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3983#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3984#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3985#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3986#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3987#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3988#define ALC880_PIN_CD_NID 0x1c
3989
3990/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003991static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3992 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003993{
3994 hda_nid_t nid;
3995 int assigned[4];
3996 int i, j;
3997
3998 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003999 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004000
4001 /* check the pins hardwired to audio widget */
4002 for (i = 0; i < cfg->line_outs; i++) {
4003 nid = cfg->line_out_pins[i];
4004 if (alc880_is_fixed_pin(nid)) {
4005 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004006 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004007 assigned[idx] = 1;
4008 }
4009 }
4010 /* left pins can be connect to any audio widget */
4011 for (i = 0; i < cfg->line_outs; i++) {
4012 nid = cfg->line_out_pins[i];
4013 if (alc880_is_fixed_pin(nid))
4014 continue;
4015 /* search for an empty channel */
4016 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004017 if (!assigned[j]) {
4018 spec->multiout.dac_nids[i] =
4019 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004020 assigned[j] = 1;
4021 break;
4022 }
4023 }
4024 }
4025 spec->multiout.num_dacs = cfg->line_outs;
4026 return 0;
4027}
4028
4029/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004030static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4031 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004032{
4033 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004034 static const char *chname[4] = {
4035 "Front", "Surround", NULL /*CLFE*/, "Side"
4036 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004037 hda_nid_t nid;
4038 int i, err;
4039
4040 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004041 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004042 continue;
4043 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4044 if (i == 2) {
4045 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004046 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4047 "Center Playback Volume",
4048 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4049 HDA_OUTPUT));
4050 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004051 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004052 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4053 "LFE Playback Volume",
4054 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4055 HDA_OUTPUT));
4056 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004057 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004058 err = add_control(spec, ALC_CTL_BIND_MUTE,
4059 "Center Playback Switch",
4060 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4061 HDA_INPUT));
4062 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004063 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004064 err = add_control(spec, ALC_CTL_BIND_MUTE,
4065 "LFE Playback Switch",
4066 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4067 HDA_INPUT));
4068 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004069 return err;
4070 } else {
4071 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004072 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4073 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4074 HDA_OUTPUT));
4075 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004076 return err;
4077 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004078 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4079 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4080 HDA_INPUT));
4081 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004082 return err;
4083 }
4084 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004085 return 0;
4086}
4087
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004088/* add playback controls for speaker and HP outputs */
4089static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4090 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004091{
4092 hda_nid_t nid;
4093 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004094 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004095
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004096 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004097 return 0;
4098
4099 if (alc880_is_fixed_pin(pin)) {
4100 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004101 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004102 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004103 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004104 else
4105 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004106 /* control HP volume/switch on the output mixer amp */
4107 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004108 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004109 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4110 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4111 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004112 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004113 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004114 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4115 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4116 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004117 return err;
4118 } else if (alc880_is_multi_pin(pin)) {
4119 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004120 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004121 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004122 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4123 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4124 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004125 return err;
4126 }
4127 return 0;
4128}
4129
4130/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004131static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4132 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004133 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004134{
4135 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004136 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004137
4138 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004139 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4140 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4141 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004142 return err;
4143 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004144 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4145 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4146 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004147 return err;
4148 return 0;
4149}
4150
4151/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004152static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4153 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004154{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004155 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004156 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004157
4158 for (i = 0; i < AUTO_PIN_LAST; i++) {
4159 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004160 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004161 err = new_analog_input(spec, cfg->input_pins[i],
4162 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004163 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004164 if (err < 0)
4165 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004166 imux->items[imux->num_items].label =
4167 auto_pin_cfg_labels[i];
4168 imux->items[imux->num_items].index =
4169 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004170 imux->num_items++;
4171 }
4172 }
4173 return 0;
4174}
4175
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004176static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4177 unsigned int pin_type)
4178{
4179 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4180 pin_type);
4181 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004182 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4183 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004184}
4185
Kailang Yangdf694da2005-12-05 19:42:22 +01004186static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4187 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004188 int dac_idx)
4189{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004190 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004191 /* need the manual connection? */
4192 if (alc880_is_multi_pin(nid)) {
4193 struct alc_spec *spec = codec->spec;
4194 int idx = alc880_multi_pin_idx(nid);
4195 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4196 AC_VERB_SET_CONNECT_SEL,
4197 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4198 }
4199}
4200
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004201static int get_pin_type(int line_out_type)
4202{
4203 if (line_out_type == AUTO_PIN_HP_OUT)
4204 return PIN_HP;
4205 else
4206 return PIN_OUT;
4207}
4208
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004209static void alc880_auto_init_multi_out(struct hda_codec *codec)
4210{
4211 struct alc_spec *spec = codec->spec;
4212 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004213
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004214 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004215 for (i = 0; i < spec->autocfg.line_outs; i++) {
4216 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004217 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4218 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004219 }
4220}
4221
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004222static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004223{
4224 struct alc_spec *spec = codec->spec;
4225 hda_nid_t pin;
4226
Takashi Iwai82bc9552006-03-21 11:24:42 +01004227 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004228 if (pin) /* connect to front */
4229 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004230 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004231 if (pin) /* connect to front */
4232 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4233}
4234
4235static void alc880_auto_init_analog_input(struct hda_codec *codec)
4236{
4237 struct alc_spec *spec = codec->spec;
4238 int i;
4239
4240 for (i = 0; i < AUTO_PIN_LAST; i++) {
4241 hda_nid_t nid = spec->autocfg.input_pins[i];
4242 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004243 snd_hda_codec_write(codec, nid, 0,
4244 AC_VERB_SET_PIN_WIDGET_CONTROL,
4245 i <= AUTO_PIN_FRONT_MIC ?
4246 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004247 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004248 snd_hda_codec_write(codec, nid, 0,
4249 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004250 AMP_OUT_MUTE);
4251 }
4252 }
4253}
4254
4255/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004256/* return 1 if successful, 0 if the proper config is not found,
4257 * or a negative error code
4258 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004259static int alc880_parse_auto_config(struct hda_codec *codec)
4260{
4261 struct alc_spec *spec = codec->spec;
4262 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004263 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004264
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004265 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4266 alc880_ignore);
4267 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004268 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004269 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004270 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004271
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004272 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4273 if (err < 0)
4274 return err;
4275 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4276 if (err < 0)
4277 return err;
4278 err = alc880_auto_create_extra_out(spec,
4279 spec->autocfg.speaker_pins[0],
4280 "Speaker");
4281 if (err < 0)
4282 return err;
4283 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4284 "Headphone");
4285 if (err < 0)
4286 return err;
4287 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4288 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004289 return err;
4290
4291 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4292
4293 if (spec->autocfg.dig_out_pin)
4294 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
4295 if (spec->autocfg.dig_in_pin)
4296 spec->dig_in_nid = ALC880_DIGIN_NID;
4297
Takashi Iwai603c4012008-07-30 15:01:44 +02004298 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004299 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004300
Takashi Iwaid88897e2008-10-31 15:01:37 +01004301 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004302
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004303 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004304 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004305
Takashi Iwaie044c392008-10-27 16:56:24 +01004306 store_pin_configs(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004307 return 1;
4308}
4309
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004310/* additional initialization for auto-configuration model */
4311static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004312{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004313 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004314 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004315 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004316 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004317 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004318 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004319}
4320
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004321static void set_capture_mixer(struct alc_spec *spec)
4322{
4323 static struct snd_kcontrol_new *caps[3] = {
4324 alc_capture_mixer1,
4325 alc_capture_mixer2,
4326 alc_capture_mixer3,
4327 };
Takashi Iwai30d72e92008-11-27 15:25:34 +01004328 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004329 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4330}
4331
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004332#define set_beep_amp(spec, nid, idx, dir) \
4333 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4334
4335/*
4336 * OK, here we have finally the patch for ALC880
4337 */
4338
Linus Torvalds1da177e2005-04-16 15:20:36 -07004339static int patch_alc880(struct hda_codec *codec)
4340{
4341 struct alc_spec *spec;
4342 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004343 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004344
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004345 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004346 if (spec == NULL)
4347 return -ENOMEM;
4348
4349 codec->spec = spec;
4350
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004351 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4352 alc880_models,
4353 alc880_cfg_tbl);
4354 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004355 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4356 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004357 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004358 }
4359
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004360 if (board_config == ALC880_AUTO) {
4361 /* automatic parse from the BIOS config */
4362 err = alc880_parse_auto_config(codec);
4363 if (err < 0) {
4364 alc_free(codec);
4365 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004366 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004367 printk(KERN_INFO
4368 "hda_codec: Cannot set up configuration "
4369 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004370 board_config = ALC880_3ST;
4371 }
4372 }
4373
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004374 err = snd_hda_attach_beep_device(codec, 0x1);
4375 if (err < 0) {
4376 alc_free(codec);
4377 return err;
4378 }
4379
Kailang Yangdf694da2005-12-05 19:42:22 +01004380 if (board_config != ALC880_AUTO)
4381 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004382
4383 spec->stream_name_analog = "ALC880 Analog";
4384 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4385 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004386 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004387
4388 spec->stream_name_digital = "ALC880 Digital";
4389 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4390 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4391
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004392 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004393 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004394 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004395 /* get type */
4396 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004397 if (wcap != AC_WID_AUD_IN) {
4398 spec->adc_nids = alc880_adc_nids_alt;
4399 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004400 } else {
4401 spec->adc_nids = alc880_adc_nids;
4402 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004403 }
4404 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004405 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004406 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004407
Takashi Iwai2134ea42008-01-10 16:53:55 +01004408 spec->vmaster_nid = 0x0c;
4409
Linus Torvalds1da177e2005-04-16 15:20:36 -07004410 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004411 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004412 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004413#ifdef CONFIG_SND_HDA_POWER_SAVE
4414 if (!spec->loopback.amplist)
4415 spec->loopback.amplist = alc880_loopbacks;
4416#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004417 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004418
4419 return 0;
4420}
4421
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004422
Linus Torvalds1da177e2005-04-16 15:20:36 -07004423/*
4424 * ALC260 support
4425 */
4426
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004427static hda_nid_t alc260_dac_nids[1] = {
4428 /* front */
4429 0x02,
4430};
4431
4432static hda_nid_t alc260_adc_nids[1] = {
4433 /* ADC0 */
4434 0x04,
4435};
4436
Kailang Yangdf694da2005-12-05 19:42:22 +01004437static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004438 /* ADC1 */
4439 0x05,
4440};
4441
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004442/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4443 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4444 */
4445static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004446 /* ADC0, ADC1 */
4447 0x04, 0x05
4448};
4449
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004450#define ALC260_DIGOUT_NID 0x03
4451#define ALC260_DIGIN_NID 0x06
4452
4453static struct hda_input_mux alc260_capture_source = {
4454 .num_items = 4,
4455 .items = {
4456 { "Mic", 0x0 },
4457 { "Front Mic", 0x1 },
4458 { "Line", 0x2 },
4459 { "CD", 0x4 },
4460 },
4461};
4462
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004463/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004464 * headphone jack and the internal CD lines since these are the only pins at
4465 * which audio can appear. For flexibility, also allow the option of
4466 * recording the mixer output on the second ADC (ADC0 doesn't have a
4467 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004468 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004469static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4470 {
4471 .num_items = 3,
4472 .items = {
4473 { "Mic/Line", 0x0 },
4474 { "CD", 0x4 },
4475 { "Headphone", 0x2 },
4476 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004477 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004478 {
4479 .num_items = 4,
4480 .items = {
4481 { "Mic/Line", 0x0 },
4482 { "CD", 0x4 },
4483 { "Headphone", 0x2 },
4484 { "Mixer", 0x5 },
4485 },
4486 },
4487
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004488};
4489
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004490/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4491 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004492 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004493static struct hda_input_mux alc260_acer_capture_sources[2] = {
4494 {
4495 .num_items = 4,
4496 .items = {
4497 { "Mic", 0x0 },
4498 { "Line", 0x2 },
4499 { "CD", 0x4 },
4500 { "Headphone", 0x5 },
4501 },
4502 },
4503 {
4504 .num_items = 5,
4505 .items = {
4506 { "Mic", 0x0 },
4507 { "Line", 0x2 },
4508 { "CD", 0x4 },
4509 { "Headphone", 0x6 },
4510 { "Mixer", 0x5 },
4511 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004512 },
4513};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004514/*
4515 * This is just place-holder, so there's something for alc_build_pcms to look
4516 * at when it calculates the maximum number of channels. ALC260 has no mixer
4517 * element which allows changing the channel mode, so the verb list is
4518 * never used.
4519 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004520static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004521 { 2, NULL },
4522};
4523
Kailang Yangdf694da2005-12-05 19:42:22 +01004524
4525/* Mixer combinations
4526 *
4527 * basic: base_output + input + pc_beep + capture
4528 * HP: base_output + input + capture_alt
4529 * HP_3013: hp_3013 + input + capture
4530 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004531 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004532 */
4533
4534static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004535 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004536 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004537 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4538 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4539 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4540 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4541 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004542};
Kailang Yangdf694da2005-12-05 19:42:22 +01004543
4544static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004545 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4546 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4547 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4548 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4550 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4551 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4552 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004553 { } /* end */
4554};
4555
Takashi Iwaibec15c32008-01-28 18:16:30 +01004556/* update HP, line and mono out pins according to the master switch */
4557static void alc260_hp_master_update(struct hda_codec *codec,
4558 hda_nid_t hp, hda_nid_t line,
4559 hda_nid_t mono)
4560{
4561 struct alc_spec *spec = codec->spec;
4562 unsigned int val = spec->master_sw ? PIN_HP : 0;
4563 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004564 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004565 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004566 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004567 val);
4568 /* mono (speaker) depending on the HP jack sense */
4569 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004570 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004571 val);
4572}
4573
4574static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4575 struct snd_ctl_elem_value *ucontrol)
4576{
4577 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4578 struct alc_spec *spec = codec->spec;
4579 *ucontrol->value.integer.value = spec->master_sw;
4580 return 0;
4581}
4582
4583static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4584 struct snd_ctl_elem_value *ucontrol)
4585{
4586 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4587 struct alc_spec *spec = codec->spec;
4588 int val = !!*ucontrol->value.integer.value;
4589 hda_nid_t hp, line, mono;
4590
4591 if (val == spec->master_sw)
4592 return 0;
4593 spec->master_sw = val;
4594 hp = (kcontrol->private_value >> 16) & 0xff;
4595 line = (kcontrol->private_value >> 8) & 0xff;
4596 mono = kcontrol->private_value & 0xff;
4597 alc260_hp_master_update(codec, hp, line, mono);
4598 return 1;
4599}
4600
4601static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4602 {
4603 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4604 .name = "Master Playback Switch",
4605 .info = snd_ctl_boolean_mono_info,
4606 .get = alc260_hp_master_sw_get,
4607 .put = alc260_hp_master_sw_put,
4608 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4609 },
4610 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4611 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4612 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4613 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4614 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4615 HDA_OUTPUT),
4616 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4617 { } /* end */
4618};
4619
4620static struct hda_verb alc260_hp_unsol_verbs[] = {
4621 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4622 {},
4623};
4624
4625static void alc260_hp_automute(struct hda_codec *codec)
4626{
4627 struct alc_spec *spec = codec->spec;
4628 unsigned int present;
4629
4630 present = snd_hda_codec_read(codec, 0x10, 0,
4631 AC_VERB_GET_PIN_SENSE, 0);
4632 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4633 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4634}
4635
4636static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4637{
4638 if ((res >> 26) == ALC880_HP_EVENT)
4639 alc260_hp_automute(codec);
4640}
4641
Kailang Yangdf694da2005-12-05 19:42:22 +01004642static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004643 {
4644 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4645 .name = "Master Playback Switch",
4646 .info = snd_ctl_boolean_mono_info,
4647 .get = alc260_hp_master_sw_get,
4648 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004649 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004650 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004651 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4652 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4653 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4654 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4655 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4656 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004657 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4658 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004659 { } /* end */
4660};
4661
Kailang Yang3f878302008-08-26 13:02:23 +02004662static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4663 .ops = &snd_hda_bind_vol,
4664 .values = {
4665 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4666 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4667 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4668 0
4669 },
4670};
4671
4672static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4673 .ops = &snd_hda_bind_sw,
4674 .values = {
4675 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4676 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4677 0
4678 },
4679};
4680
4681static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4682 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4683 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4684 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4685 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4686 { } /* end */
4687};
4688
Takashi Iwaibec15c32008-01-28 18:16:30 +01004689static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4690 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4691 {},
4692};
4693
4694static void alc260_hp_3013_automute(struct hda_codec *codec)
4695{
4696 struct alc_spec *spec = codec->spec;
4697 unsigned int present;
4698
4699 present = snd_hda_codec_read(codec, 0x15, 0,
4700 AC_VERB_GET_PIN_SENSE, 0);
4701 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004702 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004703}
4704
4705static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4706 unsigned int res)
4707{
4708 if ((res >> 26) == ALC880_HP_EVENT)
4709 alc260_hp_3013_automute(codec);
4710}
4711
Kailang Yang3f878302008-08-26 13:02:23 +02004712static void alc260_hp_3012_automute(struct hda_codec *codec)
4713{
4714 unsigned int present, bits;
4715
4716 present = snd_hda_codec_read(codec, 0x10, 0,
4717 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4718
4719 bits = present ? 0 : PIN_OUT;
4720 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4721 bits);
4722 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4723 bits);
4724 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4725 bits);
4726}
4727
4728static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4729 unsigned int res)
4730{
4731 if ((res >> 26) == ALC880_HP_EVENT)
4732 alc260_hp_3012_automute(codec);
4733}
4734
4735/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004736 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4737 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004738static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004739 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004740 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004741 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004742 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4743 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4744 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4745 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004746 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004747 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4748 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004749 { } /* end */
4750};
4751
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004752/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4753 * versions of the ALC260 don't act on requests to enable mic bias from NID
4754 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4755 * datasheet doesn't mention this restriction. At this stage it's not clear
4756 * whether this behaviour is intentional or is a hardware bug in chip
4757 * revisions available in early 2006. Therefore for now allow the
4758 * "Headphone Jack Mode" control to span all choices, but if it turns out
4759 * that the lack of mic bias for this NID is intentional we could change the
4760 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4761 *
4762 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4763 * don't appear to make the mic bias available from the "line" jack, even
4764 * though the NID used for this jack (0x14) can supply it. The theory is
4765 * that perhaps Acer have included blocking capacitors between the ALC260
4766 * and the output jack. If this turns out to be the case for all such
4767 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4768 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004769 *
4770 * The C20x Tablet series have a mono internal speaker which is controlled
4771 * via the chip's Mono sum widget and pin complex, so include the necessary
4772 * controls for such models. On models without a "mono speaker" the control
4773 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004774 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004775static struct snd_kcontrol_new alc260_acer_mixer[] = {
4776 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4777 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004778 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004779 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004780 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004781 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004782 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004783 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4784 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4785 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4786 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4787 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4788 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4789 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4790 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004791 { } /* end */
4792};
4793
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004794/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4795 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4796 */
4797static struct snd_kcontrol_new alc260_will_mixer[] = {
4798 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4799 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4800 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4801 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4802 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4803 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4804 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4805 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4806 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4807 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004808 { } /* end */
4809};
4810
4811/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4812 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4813 */
4814static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4815 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4816 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4817 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4818 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4819 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4820 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4821 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4822 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4823 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4824 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4825 { } /* end */
4826};
4827
Kailang Yangdf694da2005-12-05 19:42:22 +01004828/*
4829 * initialization verbs
4830 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004831static struct hda_verb alc260_init_verbs[] = {
4832 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004833 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004834 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004835 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004836 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004837 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004838 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004839 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004840 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004841 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004842 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004843 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004844 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004845 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004846 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004847 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004848 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004849 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4850 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004851 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004852 /* set connection select to line in (default select for this ADC) */
4853 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004854 /* mute capture amp left and right */
4855 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4856 /* set connection select to line in (default select for this ADC) */
4857 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004858 /* set vol=0 Line-Out mixer amp left and right */
4859 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4860 /* unmute pin widget amp left and right (no gain on this amp) */
4861 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4862 /* set vol=0 HP mixer amp left and right */
4863 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4864 /* unmute pin widget amp left and right (no gain on this amp) */
4865 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4866 /* set vol=0 Mono mixer amp left and right */
4867 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4868 /* unmute pin widget amp left and right (no gain on this amp) */
4869 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4870 /* unmute LINE-2 out pin */
4871 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004872 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4873 * Line In 2 = 0x03
4874 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004875 /* mute analog inputs */
4876 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4877 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4878 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4879 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4880 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004881 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004882 /* mute Front out path */
4883 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4884 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4885 /* mute Headphone out path */
4886 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4887 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4888 /* mute Mono out path */
4889 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4890 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004891 { }
4892};
4893
Takashi Iwai474167d2006-05-17 17:17:43 +02004894#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004895static struct hda_verb alc260_hp_init_verbs[] = {
4896 /* Headphone and output */
4897 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4898 /* mono output */
4899 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4900 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4901 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4902 /* Mic2 (front panel) pin widget for input and vref at 80% */
4903 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4904 /* Line In pin widget for input */
4905 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4906 /* Line-2 pin widget for output */
4907 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4908 /* CD pin widget for input */
4909 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4910 /* unmute amp left and right */
4911 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4912 /* set connection select to line in (default select for this ADC) */
4913 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4914 /* unmute Line-Out mixer amp left and right (volume = 0) */
4915 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4916 /* mute pin widget amp left and right (no gain on this amp) */
4917 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4918 /* unmute HP mixer amp left and right (volume = 0) */
4919 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4920 /* mute pin widget amp left and right (no gain on this amp) */
4921 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004922 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4923 * Line In 2 = 0x03
4924 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004925 /* mute analog inputs */
4926 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4927 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4928 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4929 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4930 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004931 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4932 /* Unmute Front out path */
4933 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4934 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4935 /* Unmute Headphone out path */
4936 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4937 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4938 /* Unmute Mono out path */
4939 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4940 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4941 { }
4942};
Takashi Iwai474167d2006-05-17 17:17:43 +02004943#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004944
4945static struct hda_verb alc260_hp_3013_init_verbs[] = {
4946 /* Line out and output */
4947 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4948 /* mono output */
4949 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4950 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4951 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4952 /* Mic2 (front panel) pin widget for input and vref at 80% */
4953 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4954 /* Line In pin widget for input */
4955 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4956 /* Headphone pin widget for output */
4957 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4958 /* CD pin widget for input */
4959 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4960 /* unmute amp left and right */
4961 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4962 /* set connection select to line in (default select for this ADC) */
4963 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4964 /* unmute Line-Out mixer amp left and right (volume = 0) */
4965 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4966 /* mute pin widget amp left and right (no gain on this amp) */
4967 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4968 /* unmute HP mixer amp left and right (volume = 0) */
4969 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4970 /* mute pin widget amp left and right (no gain on this amp) */
4971 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004972 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4973 * Line In 2 = 0x03
4974 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004975 /* mute analog inputs */
4976 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4977 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4978 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4979 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4980 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004981 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4982 /* Unmute Front out path */
4983 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4984 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4985 /* Unmute Headphone out path */
4986 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4987 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4988 /* Unmute Mono out path */
4989 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4990 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4991 { }
4992};
4993
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004994/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004995 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4996 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004997 */
4998static struct hda_verb alc260_fujitsu_init_verbs[] = {
4999 /* Disable all GPIOs */
5000 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5001 /* Internal speaker is connected to headphone pin */
5002 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5003 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5004 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005005 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5006 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5007 /* Ensure all other unused pins are disabled and muted. */
5008 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5009 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005010 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005011 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005012 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005013 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5014 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5015 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005016
Jonathan Woithef7ace402006-02-28 11:46:14 +01005017 /* Disable digital (SPDIF) pins */
5018 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5019 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005020
Kailang Yangea1fb292008-08-26 12:58:38 +02005021 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005022 * when acting as an output.
5023 */
5024 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5025
5026 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005027 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5028 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5029 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5030 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5031 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5032 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5033 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5034 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5035 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005036
Jonathan Woithef7ace402006-02-28 11:46:14 +01005037 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5038 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5039 /* Unmute Line1 pin widget output buffer since it starts as an output.
5040 * If the pin mode is changed by the user the pin mode control will
5041 * take care of enabling the pin's input/output buffers as needed.
5042 * Therefore there's no need to enable the input buffer at this
5043 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005044 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005045 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005046 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005047 * mixer ctrl)
5048 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005049 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005050
Jonathan Woithef7ace402006-02-28 11:46:14 +01005051 /* Mute capture amp left and right */
5052 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005053 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005054 * in (on mic1 pin)
5055 */
5056 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005057
Jonathan Woithef7ace402006-02-28 11:46:14 +01005058 /* Do the same for the second ADC: mute capture input amp and
5059 * set ADC connection to line in (on mic1 pin)
5060 */
5061 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5062 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005063
Jonathan Woithef7ace402006-02-28 11:46:14 +01005064 /* Mute all inputs to mixer widget (even unconnected ones) */
5065 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5066 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5067 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5068 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5069 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5070 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5071 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5072 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005073
5074 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005075};
5076
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005077/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5078 * similar laptops (adapted from Fujitsu init verbs).
5079 */
5080static struct hda_verb alc260_acer_init_verbs[] = {
5081 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5082 * the headphone jack. Turn this on and rely on the standard mute
5083 * methods whenever the user wants to turn these outputs off.
5084 */
5085 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5086 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5087 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5088 /* Internal speaker/Headphone jack is connected to Line-out pin */
5089 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5090 /* Internal microphone/Mic jack is connected to Mic1 pin */
5091 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5092 /* Line In jack is connected to Line1 pin */
5093 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005094 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5095 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005096 /* Ensure all other unused pins are disabled and muted. */
5097 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5098 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005099 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5100 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5101 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5102 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5103 /* Disable digital (SPDIF) pins */
5104 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5105 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5106
Kailang Yangea1fb292008-08-26 12:58:38 +02005107 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005108 * bus when acting as outputs.
5109 */
5110 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5111 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5112
5113 /* Start with output sum widgets muted and their output gains at min */
5114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5115 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5116 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5117 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5118 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5119 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5120 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5121 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5122 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5123
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005124 /* Unmute Line-out pin widget amp left and right
5125 * (no equiv mixer ctrl)
5126 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005127 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005128 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5129 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005130 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5131 * inputs. If the pin mode is changed by the user the pin mode control
5132 * will take care of enabling the pin's input/output buffers as needed.
5133 * Therefore there's no need to enable the input buffer at this
5134 * stage.
5135 */
5136 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5137 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5138
5139 /* Mute capture amp left and right */
5140 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5141 /* Set ADC connection select to match default mixer setting - mic
5142 * (on mic1 pin)
5143 */
5144 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5145
5146 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005147 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005148 */
5149 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005150 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005151
5152 /* Mute all inputs to mixer widget (even unconnected ones) */
5153 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5154 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5155 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5156 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5158 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5159 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5160 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5161
5162 { }
5163};
5164
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005165static struct hda_verb alc260_will_verbs[] = {
5166 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5167 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5168 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5169 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5170 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5171 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5172 {}
5173};
5174
5175static struct hda_verb alc260_replacer_672v_verbs[] = {
5176 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5177 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5178 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5179
5180 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5181 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5182 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5183
5184 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5185 {}
5186};
5187
5188/* toggle speaker-output according to the hp-jack state */
5189static void alc260_replacer_672v_automute(struct hda_codec *codec)
5190{
5191 unsigned int present;
5192
5193 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5194 present = snd_hda_codec_read(codec, 0x0f, 0,
5195 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5196 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005197 snd_hda_codec_write_cache(codec, 0x01, 0,
5198 AC_VERB_SET_GPIO_DATA, 1);
5199 snd_hda_codec_write_cache(codec, 0x0f, 0,
5200 AC_VERB_SET_PIN_WIDGET_CONTROL,
5201 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005202 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005203 snd_hda_codec_write_cache(codec, 0x01, 0,
5204 AC_VERB_SET_GPIO_DATA, 0);
5205 snd_hda_codec_write_cache(codec, 0x0f, 0,
5206 AC_VERB_SET_PIN_WIDGET_CONTROL,
5207 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005208 }
5209}
5210
5211static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5212 unsigned int res)
5213{
5214 if ((res >> 26) == ALC880_HP_EVENT)
5215 alc260_replacer_672v_automute(codec);
5216}
5217
Kailang Yang3f878302008-08-26 13:02:23 +02005218static struct hda_verb alc260_hp_dc7600_verbs[] = {
5219 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5220 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5221 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5222 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5223 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5224 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5225 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5226 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5227 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5228 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5229 {}
5230};
5231
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005232/* Test configuration for debugging, modelled after the ALC880 test
5233 * configuration.
5234 */
5235#ifdef CONFIG_SND_DEBUG
5236static hda_nid_t alc260_test_dac_nids[1] = {
5237 0x02,
5238};
5239static hda_nid_t alc260_test_adc_nids[2] = {
5240 0x04, 0x05,
5241};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005242/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005243 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005244 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005245 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005246static struct hda_input_mux alc260_test_capture_sources[2] = {
5247 {
5248 .num_items = 7,
5249 .items = {
5250 { "MIC1 pin", 0x0 },
5251 { "MIC2 pin", 0x1 },
5252 { "LINE1 pin", 0x2 },
5253 { "LINE2 pin", 0x3 },
5254 { "CD pin", 0x4 },
5255 { "LINE-OUT pin", 0x5 },
5256 { "HP-OUT pin", 0x6 },
5257 },
5258 },
5259 {
5260 .num_items = 8,
5261 .items = {
5262 { "MIC1 pin", 0x0 },
5263 { "MIC2 pin", 0x1 },
5264 { "LINE1 pin", 0x2 },
5265 { "LINE2 pin", 0x3 },
5266 { "CD pin", 0x4 },
5267 { "Mixer", 0x5 },
5268 { "LINE-OUT pin", 0x6 },
5269 { "HP-OUT pin", 0x7 },
5270 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005271 },
5272};
5273static struct snd_kcontrol_new alc260_test_mixer[] = {
5274 /* Output driver widgets */
5275 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5276 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5277 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5278 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5279 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5280 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5281
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005282 /* Modes for retasking pin widgets
5283 * Note: the ALC260 doesn't seem to act on requests to enable mic
5284 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5285 * mention this restriction. At this stage it's not clear whether
5286 * this behaviour is intentional or is a hardware bug in chip
5287 * revisions available at least up until early 2006. Therefore for
5288 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5289 * choices, but if it turns out that the lack of mic bias for these
5290 * NIDs is intentional we could change their modes from
5291 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5292 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005293 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5294 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5295 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5296 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5297 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5298 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5299
5300 /* Loopback mixer controls */
5301 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5302 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5303 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5304 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5305 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5306 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5307 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5308 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5309 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5310 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005311 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5312 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5313 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5314 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005315
5316 /* Controls for GPIO pins, assuming they are configured as outputs */
5317 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5318 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5319 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5320 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5321
Jonathan Woithe92621f12006-02-28 11:47:47 +01005322 /* Switches to allow the digital IO pins to be enabled. The datasheet
5323 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005324 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005325 */
5326 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5327 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5328
Jonathan Woithef8225f62008-01-08 12:16:54 +01005329 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5330 * this output to turn on an external amplifier.
5331 */
5332 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5333 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5334
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005335 { } /* end */
5336};
5337static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005338 /* Enable all GPIOs as outputs with an initial value of 0 */
5339 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5340 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5341 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5342
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005343 /* Enable retasking pins as output, initially without power amp */
5344 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5345 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5346 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5347 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5348 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5349 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5350
Jonathan Woithe92621f12006-02-28 11:47:47 +01005351 /* Disable digital (SPDIF) pins initially, but users can enable
5352 * them via a mixer switch. In the case of SPDIF-out, this initverb
5353 * payload also sets the generation to 0, output to be in "consumer"
5354 * PCM format, copyright asserted, no pre-emphasis and no validity
5355 * control.
5356 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005357 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5358 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5359
Kailang Yangea1fb292008-08-26 12:58:38 +02005360 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005361 * OUT1 sum bus when acting as an output.
5362 */
5363 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5364 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5365 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5366 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5367
5368 /* Start with output sum widgets muted and their output gains at min */
5369 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5370 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5371 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5372 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5373 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5374 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5375 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5376 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5377 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5378
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005379 /* Unmute retasking pin widget output buffers since the default
5380 * state appears to be output. As the pin mode is changed by the
5381 * user the pin mode control will take care of enabling the pin's
5382 * input/output buffers as needed.
5383 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005384 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5385 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5386 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5387 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5388 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5389 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5390 /* Also unmute the mono-out pin widget */
5391 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5392
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005393 /* Mute capture amp left and right */
5394 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005395 /* Set ADC connection select to match default mixer setting (mic1
5396 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005397 */
5398 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5399
5400 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005401 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005402 */
5403 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5404 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5405
5406 /* Mute all inputs to mixer widget (even unconnected ones) */
5407 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5408 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5409 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5410 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5411 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5412 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5413 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5414 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5415
5416 { }
5417};
5418#endif
5419
Takashi Iwai63300792008-01-24 15:31:36 +01005420#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5421#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005422
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005423#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5424#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5425
Kailang Yangdf694da2005-12-05 19:42:22 +01005426/*
5427 * for BIOS auto-configuration
5428 */
5429
5430static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005431 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005432{
5433 hda_nid_t nid_vol;
5434 unsigned long vol_val, sw_val;
5435 char name[32];
5436 int err;
5437
5438 if (nid >= 0x0f && nid < 0x11) {
5439 nid_vol = nid - 0x7;
5440 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5441 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5442 } else if (nid == 0x11) {
5443 nid_vol = nid - 0x7;
5444 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5445 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5446 } else if (nid >= 0x12 && nid <= 0x15) {
5447 nid_vol = 0x08;
5448 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5449 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5450 } else
5451 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005452
Takashi Iwai863b4512008-10-21 17:01:47 +02005453 if (!(*vol_bits & (1 << nid_vol))) {
5454 /* first control for the volume widget */
5455 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5456 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5457 if (err < 0)
5458 return err;
5459 *vol_bits |= (1 << nid_vol);
5460 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005461 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005462 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5463 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005464 return err;
5465 return 1;
5466}
5467
5468/* add playback controls from the parsed DAC table */
5469static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5470 const struct auto_pin_cfg *cfg)
5471{
5472 hda_nid_t nid;
5473 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005474 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005475
5476 spec->multiout.num_dacs = 1;
5477 spec->multiout.dac_nids = spec->private_dac_nids;
5478 spec->multiout.dac_nids[0] = 0x02;
5479
5480 nid = cfg->line_out_pins[0];
5481 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005482 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005483 if (err < 0)
5484 return err;
5485 }
5486
Takashi Iwai82bc9552006-03-21 11:24:42 +01005487 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005488 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005489 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005490 if (err < 0)
5491 return err;
5492 }
5493
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005494 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005495 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005496 err = alc260_add_playback_controls(spec, nid, "Headphone",
5497 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005498 if (err < 0)
5499 return err;
5500 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005501 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005502}
5503
5504/* create playback/capture controls for input pins */
5505static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5506 const struct auto_pin_cfg *cfg)
5507{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005508 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005509 int i, err, idx;
5510
5511 for (i = 0; i < AUTO_PIN_LAST; i++) {
5512 if (cfg->input_pins[i] >= 0x12) {
5513 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005514 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005515 auto_pin_cfg_labels[i], idx,
5516 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005517 if (err < 0)
5518 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005519 imux->items[imux->num_items].label =
5520 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005521 imux->items[imux->num_items].index = idx;
5522 imux->num_items++;
5523 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005524 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005525 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005526 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005527 auto_pin_cfg_labels[i], idx,
5528 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005529 if (err < 0)
5530 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005531 imux->items[imux->num_items].label =
5532 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005533 imux->items[imux->num_items].index = idx;
5534 imux->num_items++;
5535 }
5536 }
5537 return 0;
5538}
5539
5540static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5541 hda_nid_t nid, int pin_type,
5542 int sel_idx)
5543{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005544 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005545 /* need the manual connection? */
5546 if (nid >= 0x12) {
5547 int idx = nid - 0x12;
5548 snd_hda_codec_write(codec, idx + 0x0b, 0,
5549 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005550 }
5551}
5552
5553static void alc260_auto_init_multi_out(struct hda_codec *codec)
5554{
5555 struct alc_spec *spec = codec->spec;
5556 hda_nid_t nid;
5557
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005558 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005559 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005560 if (nid) {
5561 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5562 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5563 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005564
Takashi Iwai82bc9552006-03-21 11:24:42 +01005565 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005566 if (nid)
5567 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5568
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005569 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005570 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005571 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005572}
Kailang Yangdf694da2005-12-05 19:42:22 +01005573
5574#define ALC260_PIN_CD_NID 0x16
5575static void alc260_auto_init_analog_input(struct hda_codec *codec)
5576{
5577 struct alc_spec *spec = codec->spec;
5578 int i;
5579
5580 for (i = 0; i < AUTO_PIN_LAST; i++) {
5581 hda_nid_t nid = spec->autocfg.input_pins[i];
5582 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005583 snd_hda_codec_write(codec, nid, 0,
5584 AC_VERB_SET_PIN_WIDGET_CONTROL,
5585 i <= AUTO_PIN_FRONT_MIC ?
5586 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005587 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005588 snd_hda_codec_write(codec, nid, 0,
5589 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005590 AMP_OUT_MUTE);
5591 }
5592 }
5593}
5594
5595/*
5596 * generic initialization of ADC, input mixers and output mixers
5597 */
5598static struct hda_verb alc260_volume_init_verbs[] = {
5599 /*
5600 * Unmute ADC0-1 and set the default input to mic-in
5601 */
5602 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5603 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5604 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5605 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005606
Kailang Yangdf694da2005-12-05 19:42:22 +01005607 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5608 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005609 * Note: PASD motherboards uses the Line In 2 as the input for
5610 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005611 */
5612 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005613 /* mute analog inputs */
5614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5618 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005619
5620 /*
5621 * Set up output mixers (0x08 - 0x0a)
5622 */
5623 /* set vol=0 to output mixers */
5624 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5625 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5626 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5627 /* set up input amps for analog loopback */
5628 /* Amp Indices: DAC = 0, mixer = 1 */
5629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5631 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5632 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5633 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5634 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005635
Kailang Yangdf694da2005-12-05 19:42:22 +01005636 { }
5637};
5638
5639static int alc260_parse_auto_config(struct hda_codec *codec)
5640{
5641 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005642 int err;
5643 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5644
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005645 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5646 alc260_ignore);
5647 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005648 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005649 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5650 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005651 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005652 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005653 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005654 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5655 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005656 return err;
5657
5658 spec->multiout.max_channels = 2;
5659
5660 if (spec->autocfg.dig_out_pin)
5661 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005662 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005663 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005664
Takashi Iwaid88897e2008-10-31 15:01:37 +01005665 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005666
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005667 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005668 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005669
Takashi Iwaie044c392008-10-27 16:56:24 +01005670 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005671 return 1;
5672}
5673
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005674/* additional initialization for auto-configuration model */
5675static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005676{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005677 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005678 alc260_auto_init_multi_out(codec);
5679 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005680 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005681 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005682}
5683
Takashi Iwaicb53c622007-08-10 17:21:45 +02005684#ifdef CONFIG_SND_HDA_POWER_SAVE
5685static struct hda_amp_list alc260_loopbacks[] = {
5686 { 0x07, HDA_INPUT, 0 },
5687 { 0x07, HDA_INPUT, 1 },
5688 { 0x07, HDA_INPUT, 2 },
5689 { 0x07, HDA_INPUT, 3 },
5690 { 0x07, HDA_INPUT, 4 },
5691 { } /* end */
5692};
5693#endif
5694
Kailang Yangdf694da2005-12-05 19:42:22 +01005695/*
5696 * ALC260 configurations
5697 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005698static const char *alc260_models[ALC260_MODEL_LAST] = {
5699 [ALC260_BASIC] = "basic",
5700 [ALC260_HP] = "hp",
5701 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005702 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005703 [ALC260_FUJITSU_S702X] = "fujitsu",
5704 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005705 [ALC260_WILL] = "will",
5706 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005707#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005708 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005709#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005710 [ALC260_AUTO] = "auto",
5711};
5712
5713static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005714 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005715 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005716 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005717 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005718 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005719 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005720 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005721 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5722 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5723 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5724 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5725 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5726 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5727 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5728 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5729 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005730 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005731 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005732 {}
5733};
5734
Kailang Yangdf694da2005-12-05 19:42:22 +01005735static struct alc_config_preset alc260_presets[] = {
5736 [ALC260_BASIC] = {
5737 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005738 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005739 .init_verbs = { alc260_init_verbs },
5740 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5741 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005742 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005743 .adc_nids = alc260_adc_nids,
5744 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5745 .channel_mode = alc260_modes,
5746 .input_mux = &alc260_capture_source,
5747 },
5748 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005749 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005750 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005751 .init_verbs = { alc260_init_verbs,
5752 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005753 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5754 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005755 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5756 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005757 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5758 .channel_mode = alc260_modes,
5759 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005760 .unsol_event = alc260_hp_unsol_event,
5761 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005762 },
Kailang Yang3f878302008-08-26 13:02:23 +02005763 [ALC260_HP_DC7600] = {
5764 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005765 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005766 .init_verbs = { alc260_init_verbs,
5767 alc260_hp_dc7600_verbs },
5768 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5769 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005770 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5771 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005772 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5773 .channel_mode = alc260_modes,
5774 .input_mux = &alc260_capture_source,
5775 .unsol_event = alc260_hp_3012_unsol_event,
5776 .init_hook = alc260_hp_3012_automute,
5777 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005778 [ALC260_HP_3013] = {
5779 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005780 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005781 .init_verbs = { alc260_hp_3013_init_verbs,
5782 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005783 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5784 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005785 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5786 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005787 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5788 .channel_mode = alc260_modes,
5789 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005790 .unsol_event = alc260_hp_3013_unsol_event,
5791 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005792 },
5793 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005794 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005795 .init_verbs = { alc260_fujitsu_init_verbs },
5796 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5797 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005798 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5799 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005800 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5801 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005802 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5803 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005804 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005805 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005806 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005807 .init_verbs = { alc260_acer_init_verbs },
5808 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5809 .dac_nids = alc260_dac_nids,
5810 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5811 .adc_nids = alc260_dual_adc_nids,
5812 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5813 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005814 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5815 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005816 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005817 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005818 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005819 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5820 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5821 .dac_nids = alc260_dac_nids,
5822 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5823 .adc_nids = alc260_adc_nids,
5824 .dig_out_nid = ALC260_DIGOUT_NID,
5825 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5826 .channel_mode = alc260_modes,
5827 .input_mux = &alc260_capture_source,
5828 },
5829 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005830 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005831 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5832 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5833 .dac_nids = alc260_dac_nids,
5834 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5835 .adc_nids = alc260_adc_nids,
5836 .dig_out_nid = ALC260_DIGOUT_NID,
5837 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5838 .channel_mode = alc260_modes,
5839 .input_mux = &alc260_capture_source,
5840 .unsol_event = alc260_replacer_672v_unsol_event,
5841 .init_hook = alc260_replacer_672v_automute,
5842 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005843#ifdef CONFIG_SND_DEBUG
5844 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005845 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005846 .init_verbs = { alc260_test_init_verbs },
5847 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5848 .dac_nids = alc260_test_dac_nids,
5849 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5850 .adc_nids = alc260_test_adc_nids,
5851 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5852 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005853 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5854 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005855 },
5856#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005857};
5858
Linus Torvalds1da177e2005-04-16 15:20:36 -07005859static int patch_alc260(struct hda_codec *codec)
5860{
5861 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005862 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005863
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005864 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005865 if (spec == NULL)
5866 return -ENOMEM;
5867
5868 codec->spec = spec;
5869
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005870 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5871 alc260_models,
5872 alc260_cfg_tbl);
5873 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005874 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5875 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005876 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005877 }
5878
Kailang Yangdf694da2005-12-05 19:42:22 +01005879 if (board_config == ALC260_AUTO) {
5880 /* automatic parse from the BIOS config */
5881 err = alc260_parse_auto_config(codec);
5882 if (err < 0) {
5883 alc_free(codec);
5884 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005885 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005886 printk(KERN_INFO
5887 "hda_codec: Cannot set up configuration "
5888 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005889 board_config = ALC260_BASIC;
5890 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005891 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005892
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005893 err = snd_hda_attach_beep_device(codec, 0x1);
5894 if (err < 0) {
5895 alc_free(codec);
5896 return err;
5897 }
5898
Kailang Yangdf694da2005-12-05 19:42:22 +01005899 if (board_config != ALC260_AUTO)
5900 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005901
5902 spec->stream_name_analog = "ALC260 Analog";
5903 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5904 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5905
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005906 spec->stream_name_digital = "ALC260 Digital";
5907 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5908 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5909
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01005910 if (!spec->adc_nids && spec->input_mux) {
5911 /* check whether NID 0x04 is valid */
5912 unsigned int wcap = get_wcaps(codec, 0x04);
5913 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5914 /* get type */
5915 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5916 spec->adc_nids = alc260_adc_nids_alt;
5917 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5918 } else {
5919 spec->adc_nids = alc260_adc_nids;
5920 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5921 }
5922 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005923 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005924 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005925
Takashi Iwai2134ea42008-01-10 16:53:55 +01005926 spec->vmaster_nid = 0x08;
5927
Linus Torvalds1da177e2005-04-16 15:20:36 -07005928 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005929 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005930 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005931#ifdef CONFIG_SND_HDA_POWER_SAVE
5932 if (!spec->loopback.amplist)
5933 spec->loopback.amplist = alc260_loopbacks;
5934#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01005935 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005936
5937 return 0;
5938}
5939
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005940
Linus Torvalds1da177e2005-04-16 15:20:36 -07005941/*
5942 * ALC882 support
5943 *
5944 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5945 * configuration. Each pin widget can choose any input DACs and a mixer.
5946 * Each ADC is connected from a mixer of all inputs. This makes possible
5947 * 6-channel independent captures.
5948 *
5949 * In addition, an independent DAC for the multi-playback (not used in this
5950 * driver yet).
5951 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005952#define ALC882_DIGOUT_NID 0x06
5953#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005954
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005955static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005956 { 8, NULL }
5957};
5958
5959static hda_nid_t alc882_dac_nids[4] = {
5960 /* front, rear, clfe, rear_surr */
5961 0x02, 0x03, 0x04, 0x05
5962};
5963
Kailang Yangdf694da2005-12-05 19:42:22 +01005964/* identical with ALC880 */
5965#define alc882_adc_nids alc880_adc_nids
5966#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005967
Takashi Iwaie1406342008-02-11 18:32:32 +01005968static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5969static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5970
Linus Torvalds1da177e2005-04-16 15:20:36 -07005971/* input MUX */
5972/* FIXME: should be a matrix-type input source selection */
5973
5974static struct hda_input_mux alc882_capture_source = {
5975 .num_items = 4,
5976 .items = {
5977 { "Mic", 0x0 },
5978 { "Front Mic", 0x1 },
5979 { "Line", 0x2 },
5980 { "CD", 0x4 },
5981 },
5982};
Kailang Yangdf694da2005-12-05 19:42:22 +01005983/*
Kailang Yang272a5272007-05-14 11:00:38 +02005984 * 2ch mode
5985 */
5986static struct hda_verb alc882_3ST_ch2_init[] = {
5987 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5988 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5989 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5990 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5991 { } /* end */
5992};
5993
5994/*
5995 * 6ch mode
5996 */
5997static struct hda_verb alc882_3ST_ch6_init[] = {
5998 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5999 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6000 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6001 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6002 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6003 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6004 { } /* end */
6005};
6006
6007static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6008 { 2, alc882_3ST_ch2_init },
6009 { 6, alc882_3ST_ch6_init },
6010};
6011
6012/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006013 * 6ch mode
6014 */
6015static struct hda_verb alc882_sixstack_ch6_init[] = {
6016 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6017 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6018 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6019 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6020 { } /* end */
6021};
6022
6023/*
6024 * 8ch mode
6025 */
6026static struct hda_verb alc882_sixstack_ch8_init[] = {
6027 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6028 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6029 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6030 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6031 { } /* end */
6032};
6033
6034static struct hda_channel_mode alc882_sixstack_modes[2] = {
6035 { 6, alc882_sixstack_ch6_init },
6036 { 8, alc882_sixstack_ch8_init },
6037};
6038
Takashi Iwai87350ad2007-08-16 18:19:38 +02006039/*
6040 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6041 */
6042
6043/*
6044 * 2ch mode
6045 */
6046static struct hda_verb alc885_mbp_ch2_init[] = {
6047 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6048 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6049 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6050 { } /* end */
6051};
6052
6053/*
6054 * 6ch mode
6055 */
6056static struct hda_verb alc885_mbp_ch6_init[] = {
6057 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6058 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6059 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6060 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6061 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6062 { } /* end */
6063};
6064
6065static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6066 { 2, alc885_mbp_ch2_init },
6067 { 6, alc885_mbp_ch6_init },
6068};
6069
6070
Linus Torvalds1da177e2005-04-16 15:20:36 -07006071/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6072 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6073 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006074static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006075 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006076 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006077 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006078 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006079 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6080 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006081 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6082 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006083 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006084 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006085 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6086 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6087 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6088 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6089 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6090 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006091 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006092 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6093 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006094 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006095 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006096 { } /* end */
6097};
6098
Takashi Iwai87350ad2007-08-16 18:19:38 +02006099static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006100 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6101 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6102 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6103 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6104 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6105 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006106 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6107 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006108 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006109 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6110 { } /* end */
6111};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006112static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6113 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6114 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6115 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6116 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6117 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6118 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6119 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6120 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6121 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006122 { } /* end */
6123};
6124
Kailang Yang272a5272007-05-14 11:00:38 +02006125static struct snd_kcontrol_new alc882_targa_mixer[] = {
6126 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6127 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6128 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6129 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6130 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6131 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6132 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6133 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6134 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006135 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006136 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6137 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006138 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006139 { } /* end */
6140};
6141
6142/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6143 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6144 */
6145static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6146 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6147 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6148 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6149 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6150 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6151 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6152 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6153 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6154 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6155 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006158 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006159 { } /* end */
6160};
6161
Takashi Iwai914759b2007-09-06 14:52:04 +02006162static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6163 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6164 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6165 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6166 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6167 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6168 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6169 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6170 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6171 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6172 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006173 { } /* end */
6174};
6175
Kailang Yangdf694da2005-12-05 19:42:22 +01006176static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6177 {
6178 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6179 .name = "Channel Mode",
6180 .info = alc_ch_mode_info,
6181 .get = alc_ch_mode_get,
6182 .put = alc_ch_mode_put,
6183 },
6184 { } /* end */
6185};
6186
Linus Torvalds1da177e2005-04-16 15:20:36 -07006187static struct hda_verb alc882_init_verbs[] = {
6188 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006189 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6190 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6191 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006192 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006193 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6194 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6195 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006196 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006197 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6198 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6199 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006200 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006201 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6202 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6203 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006204
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006205 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006207 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006208 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006209 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006210 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006211 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006212 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006213 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006214 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006215 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006216 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006217 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006218 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006219 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006220 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006221 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006222 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006223 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6224 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006225 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006226 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6227 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006228 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006229 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6230 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6231 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6232 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6233 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006234 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006235 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006236
6237 /* FIXME: use matrix-type input source selection */
6238 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6239 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006240 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6241 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6242 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6243 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006244 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006245 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6246 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6247 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6248 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006249 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006250 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6251 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6252 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6253 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6254 /* ADC1: mute amp left and right */
6255 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006256 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006257 /* ADC2: mute amp left and right */
6258 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006259 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006260 /* ADC3: mute amp left and right */
6261 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006262 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006263
6264 { }
6265};
6266
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006267static struct hda_verb alc882_eapd_verbs[] = {
6268 /* change to EAPD mode */
6269 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006270 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006271 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006272};
6273
Tobin Davis9102cd12006-12-15 10:02:12 +01006274/* Mac Pro test */
6275static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6276 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6277 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6278 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6279 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6280 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006281 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006282 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6283 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006284 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006285 { } /* end */
6286};
6287
6288static struct hda_verb alc882_macpro_init_verbs[] = {
6289 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6290 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6291 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6292 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6293 /* Front Pin: output 0 (0x0c) */
6294 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6295 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6296 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6297 /* Front Mic pin: input vref at 80% */
6298 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6299 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6300 /* Speaker: output */
6301 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6302 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6303 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6304 /* Headphone output (output 0 - 0x0c) */
6305 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6307 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6308
6309 /* FIXME: use matrix-type input source selection */
6310 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6311 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6312 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6313 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6314 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6315 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6316 /* Input mixer2 */
6317 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6318 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6319 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6320 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6321 /* Input mixer3 */
6322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6323 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6324 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6325 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6326 /* ADC1: mute amp left and right */
6327 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6328 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6329 /* ADC2: mute amp left and right */
6330 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6331 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6332 /* ADC3: mute amp left and right */
6333 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6334 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6335
6336 { }
6337};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006338
Takashi Iwai87350ad2007-08-16 18:19:38 +02006339/* Macbook Pro rev3 */
6340static struct hda_verb alc885_mbp3_init_verbs[] = {
6341 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6342 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6343 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6345 /* Rear mixer */
6346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6348 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6349 /* Front Pin: output 0 (0x0c) */
6350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6352 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6353 /* HP Pin: output 0 (0x0d) */
6354 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6355 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6356 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6357 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6358 /* Mic (rear) pin: input vref at 80% */
6359 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6360 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6361 /* Front Mic pin: input vref at 80% */
6362 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6363 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6364 /* Line In pin: use output 1 when in LineOut mode */
6365 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6366 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6367 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6368
6369 /* FIXME: use matrix-type input source selection */
6370 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6371 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6372 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6373 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6374 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6375 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6376 /* Input mixer2 */
6377 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6378 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6379 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6380 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6381 /* Input mixer3 */
6382 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6383 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6384 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6385 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6386 /* ADC1: mute amp left and right */
6387 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6388 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6389 /* ADC2: mute amp left and right */
6390 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6391 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6392 /* ADC3: mute amp left and right */
6393 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6394 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6395
6396 { }
6397};
6398
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006399/* iMac 24 mixer. */
6400static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6401 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6402 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6403 { } /* end */
6404};
6405
6406/* iMac 24 init verbs. */
6407static struct hda_verb alc885_imac24_init_verbs[] = {
6408 /* Internal speakers: output 0 (0x0c) */
6409 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6410 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6411 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6412 /* Internal speakers: output 0 (0x0c) */
6413 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6414 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6415 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6416 /* Headphone: output 0 (0x0c) */
6417 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6418 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6419 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6420 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6421 /* Front Mic: input vref at 80% */
6422 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6423 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6424 { }
6425};
6426
6427/* Toggle speaker-output according to the hp-jack state */
6428static void alc885_imac24_automute(struct hda_codec *codec)
6429{
6430 unsigned int present;
6431
6432 present = snd_hda_codec_read(codec, 0x14, 0,
6433 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006434 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6435 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6436 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6437 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006438}
6439
6440/* Processes unsolicited events. */
6441static void alc885_imac24_unsol_event(struct hda_codec *codec,
6442 unsigned int res)
6443{
6444 /* Headphone insertion or removal. */
6445 if ((res >> 26) == ALC880_HP_EVENT)
6446 alc885_imac24_automute(codec);
6447}
6448
Takashi Iwai87350ad2007-08-16 18:19:38 +02006449static void alc885_mbp3_automute(struct hda_codec *codec)
6450{
6451 unsigned int present;
6452
6453 present = snd_hda_codec_read(codec, 0x15, 0,
6454 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6455 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6456 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6457 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6458 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6459
6460}
6461static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6462 unsigned int res)
6463{
6464 /* Headphone insertion or removal. */
6465 if ((res >> 26) == ALC880_HP_EVENT)
6466 alc885_mbp3_automute(codec);
6467}
6468
6469
Kailang Yang272a5272007-05-14 11:00:38 +02006470static struct hda_verb alc882_targa_verbs[] = {
6471 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6473
6474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6475 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006476
Kailang Yang272a5272007-05-14 11:00:38 +02006477 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6478 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6479 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6480
6481 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6482 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6483 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6484 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6485 { } /* end */
6486};
6487
6488/* toggle speaker-output according to the hp-jack state */
6489static void alc882_targa_automute(struct hda_codec *codec)
6490{
6491 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006492
Kailang Yang272a5272007-05-14 11:00:38 +02006493 present = snd_hda_codec_read(codec, 0x14, 0,
6494 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006495 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6496 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006497 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6498 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006499}
6500
6501static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6502{
6503 /* Looks like the unsol event is incompatible with the standard
6504 * definition. 4bit tag is placed at 26 bit!
6505 */
6506 if (((res >> 26) == ALC880_HP_EVENT)) {
6507 alc882_targa_automute(codec);
6508 }
6509}
6510
6511static struct hda_verb alc882_asus_a7j_verbs[] = {
6512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6513 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6514
6515 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6516 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6517 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006518
Kailang Yang272a5272007-05-14 11:00:38 +02006519 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6520 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6521 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6522
6523 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6524 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6525 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6526 { } /* end */
6527};
6528
Takashi Iwai914759b2007-09-06 14:52:04 +02006529static struct hda_verb alc882_asus_a7m_verbs[] = {
6530 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6531 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6532
6533 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6534 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6535 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006536
Takashi Iwai914759b2007-09-06 14:52:04 +02006537 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6538 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6539 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6540
6541 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6542 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6543 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6544 { } /* end */
6545};
6546
Tobin Davis9102cd12006-12-15 10:02:12 +01006547static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6548{
6549 unsigned int gpiostate, gpiomask, gpiodir;
6550
6551 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6552 AC_VERB_GET_GPIO_DATA, 0);
6553
6554 if (!muted)
6555 gpiostate |= (1 << pin);
6556 else
6557 gpiostate &= ~(1 << pin);
6558
6559 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6560 AC_VERB_GET_GPIO_MASK, 0);
6561 gpiomask |= (1 << pin);
6562
6563 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6564 AC_VERB_GET_GPIO_DIRECTION, 0);
6565 gpiodir |= (1 << pin);
6566
6567
6568 snd_hda_codec_write(codec, codec->afg, 0,
6569 AC_VERB_SET_GPIO_MASK, gpiomask);
6570 snd_hda_codec_write(codec, codec->afg, 0,
6571 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6572
6573 msleep(1);
6574
6575 snd_hda_codec_write(codec, codec->afg, 0,
6576 AC_VERB_SET_GPIO_DATA, gpiostate);
6577}
6578
Takashi Iwai7debbe52007-08-16 15:01:03 +02006579/* set up GPIO at initialization */
6580static void alc885_macpro_init_hook(struct hda_codec *codec)
6581{
6582 alc882_gpio_mute(codec, 0, 0);
6583 alc882_gpio_mute(codec, 1, 0);
6584}
6585
6586/* set up GPIO and update auto-muting at initialization */
6587static void alc885_imac24_init_hook(struct hda_codec *codec)
6588{
6589 alc885_macpro_init_hook(codec);
6590 alc885_imac24_automute(codec);
6591}
6592
Kailang Yangdf694da2005-12-05 19:42:22 +01006593/*
6594 * generic initialization of ADC, input mixers and output mixers
6595 */
6596static struct hda_verb alc882_auto_init_verbs[] = {
6597 /*
6598 * Unmute ADC0-2 and set the default input to mic-in
6599 */
6600 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6601 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6602 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6603 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6604 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6605 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6606
Takashi Iwaicb53c622007-08-10 17:21:45 +02006607 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006608 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006609 * Note: PASD motherboards uses the Line In 2 as the input for
6610 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006611 */
6612 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006613 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6614 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6615 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6616 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6617 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006618
6619 /*
6620 * Set up output mixers (0x0c - 0x0f)
6621 */
6622 /* set vol=0 to output mixers */
6623 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6624 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6625 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6626 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6627 /* set up input amps for analog loopback */
6628 /* Amp Indices: DAC = 0, mixer = 1 */
6629 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6630 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6631 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6632 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6633 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6634 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6635 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6636 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6637 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6638 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6639
6640 /* FIXME: use matrix-type input source selection */
6641 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6642 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6643 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6644 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6645 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6646 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6647 /* Input mixer2 */
6648 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6649 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6650 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6651 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6652 /* Input mixer3 */
6653 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6654 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6655 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6656 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6657
6658 { }
6659};
6660
Takashi Iwaicb53c622007-08-10 17:21:45 +02006661#ifdef CONFIG_SND_HDA_POWER_SAVE
6662#define alc882_loopbacks alc880_loopbacks
6663#endif
6664
Kailang Yangdf694da2005-12-05 19:42:22 +01006665/* pcm configuration: identiacal with ALC880 */
6666#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6667#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6668#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6669#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6670
6671/*
6672 * configuration and preset
6673 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006674static const char *alc882_models[ALC882_MODEL_LAST] = {
6675 [ALC882_3ST_DIG] = "3stack-dig",
6676 [ALC882_6ST_DIG] = "6stack-dig",
6677 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006678 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006679 [ALC882_TARGA] = "targa",
6680 [ALC882_ASUS_A7J] = "asus-a7j",
6681 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006682 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006683 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006684 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006685 [ALC882_AUTO] = "auto",
6686};
6687
6688static struct snd_pci_quirk alc882_cfg_tbl[] = {
6689 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006690 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006691 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006692 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006693 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006694 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006695 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006696 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006697 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006698 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6699 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6700 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006701 {}
6702};
6703
6704static struct alc_config_preset alc882_presets[] = {
6705 [ALC882_3ST_DIG] = {
6706 .mixers = { alc882_base_mixer },
6707 .init_verbs = { alc882_init_verbs },
6708 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6709 .dac_nids = alc882_dac_nids,
6710 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006711 .dig_in_nid = ALC882_DIGIN_NID,
6712 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6713 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006714 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006715 .input_mux = &alc882_capture_source,
6716 },
6717 [ALC882_6ST_DIG] = {
6718 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6719 .init_verbs = { alc882_init_verbs },
6720 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6721 .dac_nids = alc882_dac_nids,
6722 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006723 .dig_in_nid = ALC882_DIGIN_NID,
6724 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6725 .channel_mode = alc882_sixstack_modes,
6726 .input_mux = &alc882_capture_source,
6727 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006728 [ALC882_ARIMA] = {
6729 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6730 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6731 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6732 .dac_nids = alc882_dac_nids,
6733 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6734 .channel_mode = alc882_sixstack_modes,
6735 .input_mux = &alc882_capture_source,
6736 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006737 [ALC882_W2JC] = {
6738 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6739 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6740 alc880_gpio1_init_verbs },
6741 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6742 .dac_nids = alc882_dac_nids,
6743 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6744 .channel_mode = alc880_threestack_modes,
6745 .need_dac_fix = 1,
6746 .input_mux = &alc882_capture_source,
6747 .dig_out_nid = ALC882_DIGOUT_NID,
6748 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006749 [ALC885_MBP3] = {
6750 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6751 .init_verbs = { alc885_mbp3_init_verbs,
6752 alc880_gpio1_init_verbs },
6753 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6754 .dac_nids = alc882_dac_nids,
6755 .channel_mode = alc885_mbp_6ch_modes,
6756 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6757 .input_mux = &alc882_capture_source,
6758 .dig_out_nid = ALC882_DIGOUT_NID,
6759 .dig_in_nid = ALC882_DIGIN_NID,
6760 .unsol_event = alc885_mbp3_unsol_event,
6761 .init_hook = alc885_mbp3_automute,
6762 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006763 [ALC885_MACPRO] = {
6764 .mixers = { alc882_macpro_mixer },
6765 .init_verbs = { alc882_macpro_init_verbs },
6766 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6767 .dac_nids = alc882_dac_nids,
6768 .dig_out_nid = ALC882_DIGOUT_NID,
6769 .dig_in_nid = ALC882_DIGIN_NID,
6770 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6771 .channel_mode = alc882_ch_modes,
6772 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006773 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006774 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006775 [ALC885_IMAC24] = {
6776 .mixers = { alc885_imac24_mixer },
6777 .init_verbs = { alc885_imac24_init_verbs },
6778 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6779 .dac_nids = alc882_dac_nids,
6780 .dig_out_nid = ALC882_DIGOUT_NID,
6781 .dig_in_nid = ALC882_DIGIN_NID,
6782 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6783 .channel_mode = alc882_ch_modes,
6784 .input_mux = &alc882_capture_source,
6785 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006786 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006787 },
Kailang Yang272a5272007-05-14 11:00:38 +02006788 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006789 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006790 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6791 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6792 .dac_nids = alc882_dac_nids,
6793 .dig_out_nid = ALC882_DIGOUT_NID,
6794 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6795 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006796 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006797 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6798 .channel_mode = alc882_3ST_6ch_modes,
6799 .need_dac_fix = 1,
6800 .input_mux = &alc882_capture_source,
6801 .unsol_event = alc882_targa_unsol_event,
6802 .init_hook = alc882_targa_automute,
6803 },
6804 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006805 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006806 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6807 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6808 .dac_nids = alc882_dac_nids,
6809 .dig_out_nid = ALC882_DIGOUT_NID,
6810 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6811 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006812 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006813 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6814 .channel_mode = alc882_3ST_6ch_modes,
6815 .need_dac_fix = 1,
6816 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006817 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006818 [ALC882_ASUS_A7M] = {
6819 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6820 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6821 alc880_gpio1_init_verbs,
6822 alc882_asus_a7m_verbs },
6823 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6824 .dac_nids = alc882_dac_nids,
6825 .dig_out_nid = ALC882_DIGOUT_NID,
6826 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6827 .channel_mode = alc880_threestack_modes,
6828 .need_dac_fix = 1,
6829 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006830 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006831};
6832
6833
6834/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006835 * Pin config fixes
6836 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006837enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006838 PINFIX_ABIT_AW9D_MAX
6839};
6840
6841static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6842 { 0x15, 0x01080104 }, /* side */
6843 { 0x16, 0x01011012 }, /* rear */
6844 { 0x17, 0x01016011 }, /* clfe */
6845 { }
6846};
6847
6848static const struct alc_pincfg *alc882_pin_fixes[] = {
6849 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6850};
6851
6852static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6853 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6854 {}
6855};
6856
6857/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006858 * BIOS auto configuration
6859 */
6860static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6861 hda_nid_t nid, int pin_type,
6862 int dac_idx)
6863{
6864 /* set as output */
6865 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006866 int idx;
6867
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006868 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006869 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6870 idx = 4;
6871 else
6872 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006873 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6874
6875}
6876
6877static void alc882_auto_init_multi_out(struct hda_codec *codec)
6878{
6879 struct alc_spec *spec = codec->spec;
6880 int i;
6881
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006882 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006883 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006884 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006885 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006886 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006887 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006888 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006889 }
6890}
6891
6892static void alc882_auto_init_hp_out(struct hda_codec *codec)
6893{
6894 struct alc_spec *spec = codec->spec;
6895 hda_nid_t pin;
6896
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006897 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006898 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006899 /* use dac 0 */
6900 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006901 pin = spec->autocfg.speaker_pins[0];
6902 if (pin)
6903 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006904}
6905
6906#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6907#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6908
6909static void alc882_auto_init_analog_input(struct hda_codec *codec)
6910{
6911 struct alc_spec *spec = codec->spec;
6912 int i;
6913
6914 for (i = 0; i < AUTO_PIN_LAST; i++) {
6915 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006916 unsigned int vref;
6917 if (!nid)
6918 continue;
6919 vref = PIN_IN;
6920 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006921 unsigned int pincap;
6922 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6923 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006924 AC_PINCAP_VREF_80)
6925 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006926 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006927 snd_hda_codec_write(codec, nid, 0,
6928 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6929 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6930 snd_hda_codec_write(codec, nid, 0,
6931 AC_VERB_SET_AMP_GAIN_MUTE,
6932 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006933 }
6934}
6935
Takashi Iwaif511b012008-08-15 16:46:42 +02006936static void alc882_auto_init_input_src(struct hda_codec *codec)
6937{
6938 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02006939 int c;
6940
6941 for (c = 0; c < spec->num_adc_nids; c++) {
6942 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6943 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02006944 unsigned int mux_idx;
6945 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02006946 int conns, mute, idx, item;
6947
6948 conns = snd_hda_get_connections(codec, nid, conn_list,
6949 ARRAY_SIZE(conn_list));
6950 if (conns < 0)
6951 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02006952 mux_idx = c >= spec->num_mux_defs ? 0 : c;
6953 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02006954 for (idx = 0; idx < conns; idx++) {
6955 /* if the current connection is the selected one,
6956 * unmute it as default - otherwise mute it
6957 */
6958 mute = AMP_IN_MUTE(idx);
6959 for (item = 0; item < imux->num_items; item++) {
6960 if (imux->items[item].index == idx) {
6961 if (spec->cur_mux[c] == item)
6962 mute = AMP_IN_UNMUTE(idx);
6963 break;
6964 }
6965 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02006966 /* check if we have a selector or mixer
6967 * we could check for the widget type instead, but
6968 * just check for Amp-In presence (in case of mixer
6969 * without amp-in there is something wrong, this
6970 * function shouldn't be used or capsrc nid is wrong)
6971 */
6972 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
6973 snd_hda_codec_write(codec, nid, 0,
6974 AC_VERB_SET_AMP_GAIN_MUTE,
6975 mute);
6976 else if (mute != AMP_IN_MUTE(idx))
6977 snd_hda_codec_write(codec, nid, 0,
6978 AC_VERB_SET_CONNECT_SEL,
6979 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02006980 }
6981 }
6982}
6983
Takashi Iwai776e1842007-08-29 15:07:11 +02006984/* add mic boosts if needed */
6985static int alc_auto_add_mic_boost(struct hda_codec *codec)
6986{
6987 struct alc_spec *spec = codec->spec;
6988 int err;
6989 hda_nid_t nid;
6990
6991 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006992 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006993 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6994 "Mic Boost",
6995 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6996 if (err < 0)
6997 return err;
6998 }
6999 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007000 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007001 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7002 "Front Mic Boost",
7003 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7004 if (err < 0)
7005 return err;
7006 }
7007 return 0;
7008}
7009
Kailang Yangdf694da2005-12-05 19:42:22 +01007010/* almost identical with ALC880 parser... */
7011static int alc882_parse_auto_config(struct hda_codec *codec)
7012{
7013 struct alc_spec *spec = codec->spec;
7014 int err = alc880_parse_auto_config(codec);
7015
7016 if (err < 0)
7017 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007018 else if (!err)
7019 return 0; /* no config found */
7020
7021 err = alc_auto_add_mic_boost(codec);
7022 if (err < 0)
7023 return err;
7024
7025 /* hack - override the init verbs */
7026 spec->init_verbs[0] = alc882_auto_init_verbs;
7027
7028 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007029}
7030
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007031/* additional initialization for auto-configuration model */
7032static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007033{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007034 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007035 alc882_auto_init_multi_out(codec);
7036 alc882_auto_init_hp_out(codec);
7037 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007038 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007039 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007040 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007041}
7042
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007043static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7044
Linus Torvalds1da177e2005-04-16 15:20:36 -07007045static int patch_alc882(struct hda_codec *codec)
7046{
7047 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007048 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007049
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007050 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007051 if (spec == NULL)
7052 return -ENOMEM;
7053
Linus Torvalds1da177e2005-04-16 15:20:36 -07007054 codec->spec = spec;
7055
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007056 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7057 alc882_models,
7058 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007059
Kailang Yangdf694da2005-12-05 19:42:22 +01007060 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007061 /* Pick up systems that don't supply PCI SSID */
7062 switch (codec->subsystem_id) {
7063 case 0x106b0c00: /* Mac Pro */
7064 board_config = ALC885_MACPRO;
7065 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007066 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007067 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007068 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007069 board_config = ALC885_IMAC24;
7070 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02007071 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007072 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007073 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007074 case 0x106b3600: /* Macbook 3.1 */
Luke Yelavich2a884642009-01-28 15:58:38 +11007075 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007076 board_config = ALC885_MBP3;
7077 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007078 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007079 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007080 if (codec->revision_id == 0x100101 ||
7081 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007082 alc_free(codec);
7083 return patch_alc883(codec);
7084 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007085 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7086 "trying auto-probe from BIOS...\n");
7087 board_config = ALC882_AUTO;
7088 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007089 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007090
Takashi Iwaif95474e2007-07-10 00:47:43 +02007091 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7092
Kailang Yangdf694da2005-12-05 19:42:22 +01007093 if (board_config == ALC882_AUTO) {
7094 /* automatic parse from the BIOS config */
7095 err = alc882_parse_auto_config(codec);
7096 if (err < 0) {
7097 alc_free(codec);
7098 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007099 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007100 printk(KERN_INFO
7101 "hda_codec: Cannot set up configuration "
7102 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007103 board_config = ALC882_3ST_DIG;
7104 }
7105 }
7106
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007107 err = snd_hda_attach_beep_device(codec, 0x1);
7108 if (err < 0) {
7109 alc_free(codec);
7110 return err;
7111 }
7112
Kailang Yangdf694da2005-12-05 19:42:22 +01007113 if (board_config != ALC882_AUTO)
7114 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007115
Kailang Yang2f893282008-05-27 12:14:47 +02007116 if (codec->vendor_id == 0x10ec0885) {
7117 spec->stream_name_analog = "ALC885 Analog";
7118 spec->stream_name_digital = "ALC885 Digital";
7119 } else {
7120 spec->stream_name_analog = "ALC882 Analog";
7121 spec->stream_name_digital = "ALC882 Digital";
7122 }
7123
Kailang Yangdf694da2005-12-05 19:42:22 +01007124 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7125 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007126 /* FIXME: setup DAC5 */
7127 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7128 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007129
Kailang Yangdf694da2005-12-05 19:42:22 +01007130 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7131 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007132
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007133 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007134 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007135 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007136 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007137 /* get type */
7138 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007139 if (wcap != AC_WID_AUD_IN) {
7140 spec->adc_nids = alc882_adc_nids_alt;
7141 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007142 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007143 } else {
7144 spec->adc_nids = alc882_adc_nids;
7145 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007146 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007147 }
7148 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007149 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007150 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007151
Takashi Iwai2134ea42008-01-10 16:53:55 +01007152 spec->vmaster_nid = 0x0c;
7153
Linus Torvalds1da177e2005-04-16 15:20:36 -07007154 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007155 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007156 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007157#ifdef CONFIG_SND_HDA_POWER_SAVE
7158 if (!spec->loopback.amplist)
7159 spec->loopback.amplist = alc882_loopbacks;
7160#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007161 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007162
7163 return 0;
7164}
7165
7166/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007167 * ALC883 support
7168 *
7169 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7170 * configuration. Each pin widget can choose any input DACs and a mixer.
7171 * Each ADC is connected from a mixer of all inputs. This makes possible
7172 * 6-channel independent captures.
7173 *
7174 * In addition, an independent DAC for the multi-playback (not used in this
7175 * driver yet).
7176 */
7177#define ALC883_DIGOUT_NID 0x06
7178#define ALC883_DIGIN_NID 0x0a
7179
Wu Fengguang3ab90932008-11-17 09:51:09 +01007180#define ALC1200_DIGOUT_NID 0x10
7181
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007182static hda_nid_t alc883_dac_nids[4] = {
7183 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007184 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007185};
7186
7187static hda_nid_t alc883_adc_nids[2] = {
7188 /* ADC1-2 */
7189 0x08, 0x09,
7190};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007191
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007192static hda_nid_t alc883_adc_nids_alt[1] = {
7193 /* ADC1 */
7194 0x08,
7195};
7196
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007197static hda_nid_t alc883_adc_nids_rev[2] = {
7198 /* ADC2-1 */
7199 0x09, 0x08
7200};
7201
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007202#define alc889_adc_nids alc880_adc_nids
7203
Takashi Iwaie1406342008-02-11 18:32:32 +01007204static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7205
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007206static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7207
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007208#define alc889_capsrc_nids alc882_capsrc_nids
7209
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007210/* input MUX */
7211/* FIXME: should be a matrix-type input source selection */
7212
7213static struct hda_input_mux alc883_capture_source = {
7214 .num_items = 4,
7215 .items = {
7216 { "Mic", 0x0 },
7217 { "Front Mic", 0x1 },
7218 { "Line", 0x2 },
7219 { "CD", 0x4 },
7220 },
7221};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007222
Jiang zhe17bba1b2008-06-04 12:11:07 +02007223static struct hda_input_mux alc883_3stack_6ch_intel = {
7224 .num_items = 4,
7225 .items = {
7226 { "Mic", 0x1 },
7227 { "Front Mic", 0x0 },
7228 { "Line", 0x2 },
7229 { "CD", 0x4 },
7230 },
7231};
7232
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007233static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7234 .num_items = 2,
7235 .items = {
7236 { "Mic", 0x1 },
7237 { "Line", 0x2 },
7238 },
7239};
7240
Kailang Yang272a5272007-05-14 11:00:38 +02007241static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7242 .num_items = 4,
7243 .items = {
7244 { "Mic", 0x0 },
7245 { "iMic", 0x1 },
7246 { "Line", 0x2 },
7247 { "CD", 0x4 },
7248 },
7249};
7250
Jiang zhefb97dc62008-03-06 11:07:11 +01007251static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7252 .num_items = 2,
7253 .items = {
7254 { "Mic", 0x0 },
7255 { "Int Mic", 0x1 },
7256 },
7257};
7258
Kailang Yange2757d52008-08-26 13:17:46 +02007259static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7260 .num_items = 3,
7261 .items = {
7262 { "Mic", 0x0 },
7263 { "Front Mic", 0x1 },
7264 { "Line", 0x4 },
7265 },
7266};
7267
7268static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7269 .num_items = 2,
7270 .items = {
7271 { "Mic", 0x0 },
7272 { "Line", 0x2 },
7273 },
7274};
7275
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007276/*
7277 * 2ch mode
7278 */
7279static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7280 { 2, NULL }
7281};
7282
7283/*
7284 * 2ch mode
7285 */
7286static struct hda_verb alc883_3ST_ch2_init[] = {
7287 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7288 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7289 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7290 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7291 { } /* end */
7292};
7293
7294/*
Tobin Davisb2011312007-09-17 12:45:11 +02007295 * 4ch mode
7296 */
7297static struct hda_verb alc883_3ST_ch4_init[] = {
7298 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7299 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7300 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7301 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7302 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7303 { } /* end */
7304};
7305
7306/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007307 * 6ch mode
7308 */
7309static struct hda_verb alc883_3ST_ch6_init[] = {
7310 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7311 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7312 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7313 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7314 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7315 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7316 { } /* end */
7317};
7318
Tobin Davisb2011312007-09-17 12:45:11 +02007319static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007320 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007321 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007322 { 6, alc883_3ST_ch6_init },
7323};
7324
7325/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007326 * 2ch mode
7327 */
7328static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7329 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7330 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7331 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7332 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7333 { } /* end */
7334};
7335
7336/*
7337 * 4ch mode
7338 */
7339static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7340 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7341 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7342 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7343 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7344 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7345 { } /* end */
7346};
7347
7348/*
7349 * 6ch mode
7350 */
7351static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7352 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7353 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7354 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7355 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7356 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7357 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7358 { } /* end */
7359};
7360
7361static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7362 { 2, alc883_3ST_ch2_intel_init },
7363 { 4, alc883_3ST_ch4_intel_init },
7364 { 6, alc883_3ST_ch6_intel_init },
7365};
7366
7367/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007368 * 6ch mode
7369 */
7370static struct hda_verb alc883_sixstack_ch6_init[] = {
7371 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7372 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7373 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7374 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7375 { } /* end */
7376};
7377
7378/*
7379 * 8ch mode
7380 */
7381static struct hda_verb alc883_sixstack_ch8_init[] = {
7382 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7383 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7384 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7385 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7386 { } /* end */
7387};
7388
7389static struct hda_channel_mode alc883_sixstack_modes[2] = {
7390 { 6, alc883_sixstack_ch6_init },
7391 { 8, alc883_sixstack_ch8_init },
7392};
7393
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007394static struct hda_verb alc883_medion_eapd_verbs[] = {
7395 /* eanable EAPD on medion laptop */
7396 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7397 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7398 { }
7399};
7400
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007401/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7402 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7403 */
7404
7405static struct snd_kcontrol_new alc883_base_mixer[] = {
7406 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7407 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7408 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7409 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7410 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7411 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7412 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7413 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7414 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7415 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7416 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7417 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7418 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7419 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7420 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7421 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007422 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007423 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7424 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007425 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007426 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007427 { } /* end */
7428};
7429
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007430static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7431 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7432 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7433 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7434 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7435 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7436 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7437 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7438 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7439 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7440 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7441 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7442 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7443 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007444 { } /* end */
7445};
7446
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007447static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007448 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7449 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7450 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7451 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7452 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7453 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7454 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7455 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7456 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7457 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007458 { } /* end */
7459};
7460
Jiang zhefb97dc62008-03-06 11:07:11 +01007461static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7462 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7463 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7464 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7465 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7466 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7467 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7468 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7469 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7470 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7471 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007472 { } /* end */
7473};
7474
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007475static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7476 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7477 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7478 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7479 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7480 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7481 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7482 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7483 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007484 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007485 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7486 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007487 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007488 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007489 { } /* end */
7490};
7491
7492static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7493 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7494 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7495 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7496 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7497 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7498 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7499 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7500 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7501 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7502 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7503 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7504 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7505 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007507 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007508 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7509 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007510 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007511 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007512 { } /* end */
7513};
7514
Jiang zhe17bba1b2008-06-04 12:11:07 +02007515static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7516 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7517 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7518 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7519 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7520 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7521 HDA_OUTPUT),
7522 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7523 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7524 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7525 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7526 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7527 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7528 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7529 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7530 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7531 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7532 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7533 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7534 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7535 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007536 { } /* end */
7537};
7538
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007539static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007540 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007541 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007542 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007543 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007544 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7545 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007546 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7547 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007548 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7549 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7550 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7551 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7552 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7553 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007554 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007555 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7556 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007557 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007558 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007559 { } /* end */
7560};
7561
Kailang Yangccc656c2006-10-17 12:32:26 +02007562static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7563 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7564 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7565 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7566 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7567 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7568 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7569 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7570 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7571 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7572 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7573 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7574 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7575 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7576 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007577 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007578 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007579 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007580};
Kailang Yangccc656c2006-10-17 12:32:26 +02007581
7582static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7583 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7584 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7585 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7586 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7587 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7588 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007589 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007591 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7592 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7593 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007594 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007595};
Kailang Yangccc656c2006-10-17 12:32:26 +02007596
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007597static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7598 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7599 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007600 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7601 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007602 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7604 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7605 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007606 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007607};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007608
Kailang Yang272a5272007-05-14 11:00:38 +02007609static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7610 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7611 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7612 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7613 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7614 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7615 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7616 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7617 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7618 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007619 { } /* end */
7620};
7621
7622static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7623 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7624 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7625 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7626 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7627 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7628 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7629 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7630 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7631 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007632 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007633};
Kailang Yang272a5272007-05-14 11:00:38 +02007634
Tobin Davis2880a862007-08-07 11:50:26 +02007635static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007636 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7637 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007638 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007639 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7640 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007641 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7642 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7643 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007644 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007645};
Tobin Davis2880a862007-08-07 11:50:26 +02007646
Kailang Yange2757d52008-08-26 13:17:46 +02007647static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7648 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7649 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7650 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7651 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7652 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7653 0x0d, 1, 0x0, HDA_OUTPUT),
7654 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7655 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7656 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7657 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7658 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7659 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7660 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7661 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7662 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7663 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7664 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7665 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7666 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7667 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7668 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7669 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7670 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007671 { } /* end */
7672};
7673
7674static struct hda_bind_ctls alc883_bind_cap_vol = {
7675 .ops = &snd_hda_bind_vol,
7676 .values = {
7677 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7678 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7679 0
7680 },
7681};
7682
7683static struct hda_bind_ctls alc883_bind_cap_switch = {
7684 .ops = &snd_hda_bind_sw,
7685 .values = {
7686 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7687 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7688 0
7689 },
7690};
7691
7692static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7693 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7694 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7695 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7696 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7697 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7698 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7699 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7700 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007701 { } /* end */
7702};
7703
7704static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007705 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7706 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7707 {
7708 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7709 /* .name = "Capture Source", */
7710 .name = "Input Source",
7711 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007712 .info = alc_mux_enum_info,
7713 .get = alc_mux_enum_get,
7714 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007715 },
7716 { } /* end */
7717};
7718
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007719static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7720 {
7721 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7722 .name = "Channel Mode",
7723 .info = alc_ch_mode_info,
7724 .get = alc_ch_mode_get,
7725 .put = alc_ch_mode_put,
7726 },
7727 { } /* end */
7728};
7729
7730static struct hda_verb alc883_init_verbs[] = {
7731 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007732 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007733 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7734 /* ADC2: mute amp left and right */
7735 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7736 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7737 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7739 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7741 /* Rear mixer */
7742 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7743 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7744 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7745 /* CLFE mixer */
7746 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7747 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7748 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7749 /* Side mixer */
7750 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7751 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7752 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7753
Takashi Iwaicb53c622007-08-10 17:21:45 +02007754 /* mute analog input loopbacks */
7755 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7756 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7757 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7758 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7759 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007760
7761 /* Front Pin: output 0 (0x0c) */
7762 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7763 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7764 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7765 /* Rear Pin: output 1 (0x0d) */
7766 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7767 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7768 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7769 /* CLFE Pin: output 2 (0x0e) */
7770 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7771 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7772 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7773 /* Side Pin: output 3 (0x0f) */
7774 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7775 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7776 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7777 /* Mic (rear) pin: input vref at 80% */
7778 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7779 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7780 /* Front Mic pin: input vref at 80% */
7781 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7782 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7783 /* Line In pin: input */
7784 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7785 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7786 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7787 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7788 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7789 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7790 /* CD pin widget for input */
7791 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7792
7793 /* FIXME: use matrix-type input source selection */
7794 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7795 /* Input mixer2 */
7796 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007797 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7798 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7799 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007800 /* Input mixer3 */
7801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7804 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007805 { }
7806};
7807
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007808/* toggle speaker-output according to the hp-jack state */
7809static void alc883_mitac_hp_automute(struct hda_codec *codec)
7810{
7811 unsigned int present;
7812
7813 present = snd_hda_codec_read(codec, 0x15, 0,
7814 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7815 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7816 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7817 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7818 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7819}
7820
7821/* auto-toggle front mic */
7822/*
7823static void alc883_mitac_mic_automute(struct hda_codec *codec)
7824{
7825 unsigned int present;
7826 unsigned char bits;
7827
7828 present = snd_hda_codec_read(codec, 0x18, 0,
7829 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7830 bits = present ? HDA_AMP_MUTE : 0;
7831 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7832}
7833*/
7834
7835static void alc883_mitac_automute(struct hda_codec *codec)
7836{
7837 alc883_mitac_hp_automute(codec);
7838 /* alc883_mitac_mic_automute(codec); */
7839}
7840
7841static void alc883_mitac_unsol_event(struct hda_codec *codec,
7842 unsigned int res)
7843{
7844 switch (res >> 26) {
7845 case ALC880_HP_EVENT:
7846 alc883_mitac_hp_automute(codec);
7847 break;
7848 case ALC880_MIC_EVENT:
7849 /* alc883_mitac_mic_automute(codec); */
7850 break;
7851 }
7852}
7853
7854static struct hda_verb alc883_mitac_verbs[] = {
7855 /* HP */
7856 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7857 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7858 /* Subwoofer */
7859 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7860 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7861
7862 /* enable unsolicited event */
7863 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7864 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7865
7866 { } /* end */
7867};
7868
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007869static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007870 /* HP */
7871 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7872 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7873 /* Int speaker */
7874 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7875 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7876
7877 /* enable unsolicited event */
7878 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007879 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007880
7881 { } /* end */
7882};
7883
Jiang zhefb97dc62008-03-06 11:07:11 +01007884static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7885 /* HP */
7886 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7887 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7888 /* Subwoofer */
7889 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7890 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7891
7892 /* enable unsolicited event */
7893 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7894
7895 { } /* end */
7896};
7897
Kailang Yangccc656c2006-10-17 12:32:26 +02007898static struct hda_verb alc883_tagra_verbs[] = {
7899 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7900 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7901
7902 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7903 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007904
Kailang Yangccc656c2006-10-17 12:32:26 +02007905 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7906 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7907 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7908
7909 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007910 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7911 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7912 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007913
7914 { } /* end */
7915};
7916
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007917static struct hda_verb alc883_lenovo_101e_verbs[] = {
7918 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7919 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7920 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7921 { } /* end */
7922};
7923
Kailang Yang272a5272007-05-14 11:00:38 +02007924static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7925 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7926 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7927 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7928 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7929 { } /* end */
7930};
7931
7932static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7933 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7934 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7935 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7936 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7937 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7938 { } /* end */
7939};
7940
Kailang Yang189609a2007-08-20 11:31:23 +02007941static struct hda_verb alc883_haier_w66_verbs[] = {
7942 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7943 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7944
7945 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7946
7947 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7948 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7949 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7950 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7951 { } /* end */
7952};
7953
Kailang Yange2757d52008-08-26 13:17:46 +02007954static struct hda_verb alc888_lenovo_sky_verbs[] = {
7955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7956 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7957 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7958 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7959 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7960 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7961 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7962 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7963 { } /* end */
7964};
7965
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007966static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007967 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007968 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7969 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007970 { }
7971};
7972
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007973static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007974 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7975 { }
7976};
7977
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007978static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007979 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7980 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7981 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7982 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7983 { }
7984};
7985
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007986static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007987 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7988 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7989 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7990 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7991 { }
7992};
7993
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007994static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7995 { 2, alc888_3st_hp_2ch_init },
7996 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007997};
7998
Kailang Yang272a5272007-05-14 11:00:38 +02007999/* toggle front-jack and RCA according to the hp-jack state */
8000static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8001{
8002 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008003
Kailang Yang272a5272007-05-14 11:00:38 +02008004 present = snd_hda_codec_read(codec, 0x1b, 0,
8005 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008006 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8007 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8008 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8009 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008010}
8011
8012/* toggle RCA according to the front-jack state */
8013static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8014{
8015 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008016
Kailang Yang272a5272007-05-14 11:00:38 +02008017 present = snd_hda_codec_read(codec, 0x14, 0,
8018 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008019 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8020 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008021}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008022
Kailang Yang272a5272007-05-14 11:00:38 +02008023static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8024 unsigned int res)
8025{
8026 if ((res >> 26) == ALC880_HP_EVENT)
8027 alc888_lenovo_ms7195_front_automute(codec);
8028 if ((res >> 26) == ALC880_FRONT_EVENT)
8029 alc888_lenovo_ms7195_rca_automute(codec);
8030}
8031
8032static struct hda_verb alc883_medion_md2_verbs[] = {
8033 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8034 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8035
8036 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8037
8038 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8039 { } /* end */
8040};
8041
8042/* toggle speaker-output according to the hp-jack state */
8043static void alc883_medion_md2_automute(struct hda_codec *codec)
8044{
8045 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008046
Kailang Yang272a5272007-05-14 11:00:38 +02008047 present = snd_hda_codec_read(codec, 0x14, 0,
8048 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008049 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8050 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008051}
8052
8053static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8054 unsigned int res)
8055{
8056 if ((res >> 26) == ALC880_HP_EVENT)
8057 alc883_medion_md2_automute(codec);
8058}
8059
Kailang Yangccc656c2006-10-17 12:32:26 +02008060/* toggle speaker-output according to the hp-jack state */
8061static void alc883_tagra_automute(struct hda_codec *codec)
8062{
8063 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008064 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02008065
8066 present = snd_hda_codec_read(codec, 0x14, 0,
8067 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008068 bits = present ? HDA_AMP_MUTE : 0;
8069 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8070 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008071 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8072 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02008073}
8074
8075static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8076{
8077 if ((res >> 26) == ALC880_HP_EVENT)
8078 alc883_tagra_automute(codec);
8079}
8080
Jiang zhe368c7a92008-03-04 11:20:33 +01008081/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008082static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01008083{
8084 unsigned int present;
8085 unsigned char bits;
8086
8087 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8088 & AC_PINSENSE_PRESENCE;
8089 bits = present ? HDA_AMP_MUTE : 0;
8090 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8091 HDA_AMP_MUTE, bits);
8092}
8093
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008094static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8095{
8096 unsigned int present;
8097
8098 present = snd_hda_codec_read(codec, 0x18, 0,
8099 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8100 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8101 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8102}
8103
8104static void alc883_clevo_m720_automute(struct hda_codec *codec)
8105{
8106 alc883_clevo_m720_hp_automute(codec);
8107 alc883_clevo_m720_mic_automute(codec);
8108}
8109
8110static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008111 unsigned int res)
8112{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008113 switch (res >> 26) {
8114 case ALC880_HP_EVENT:
8115 alc883_clevo_m720_hp_automute(codec);
8116 break;
8117 case ALC880_MIC_EVENT:
8118 alc883_clevo_m720_mic_automute(codec);
8119 break;
8120 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008121}
8122
Jiang zhefb97dc62008-03-06 11:07:11 +01008123/* toggle speaker-output according to the hp-jack state */
8124static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8125{
8126 unsigned int present;
8127 unsigned char bits;
8128
8129 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8130 & AC_PINSENSE_PRESENCE;
8131 bits = present ? HDA_AMP_MUTE : 0;
8132 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8133 HDA_AMP_MUTE, bits);
8134}
8135
8136static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8137 unsigned int res)
8138{
8139 if ((res >> 26) == ALC880_HP_EVENT)
8140 alc883_2ch_fujitsu_pi2515_automute(codec);
8141}
8142
Kailang Yang189609a2007-08-20 11:31:23 +02008143static void alc883_haier_w66_automute(struct hda_codec *codec)
8144{
8145 unsigned int present;
8146 unsigned char bits;
8147
8148 present = snd_hda_codec_read(codec, 0x1b, 0,
8149 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8150 bits = present ? 0x80 : 0;
8151 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8152 0x80, bits);
8153}
8154
8155static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8156 unsigned int res)
8157{
8158 if ((res >> 26) == ALC880_HP_EVENT)
8159 alc883_haier_w66_automute(codec);
8160}
8161
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008162static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8163{
8164 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008165 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008166
8167 present = snd_hda_codec_read(codec, 0x14, 0,
8168 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008169 bits = present ? HDA_AMP_MUTE : 0;
8170 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8171 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008172}
8173
8174static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8175{
8176 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008177 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008178
8179 present = snd_hda_codec_read(codec, 0x1b, 0,
8180 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008181 bits = present ? HDA_AMP_MUTE : 0;
8182 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8183 HDA_AMP_MUTE, bits);
8184 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8185 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008186}
8187
8188static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8189 unsigned int res)
8190{
8191 if ((res >> 26) == ALC880_HP_EVENT)
8192 alc883_lenovo_101e_all_automute(codec);
8193 if ((res >> 26) == ALC880_FRONT_EVENT)
8194 alc883_lenovo_101e_ispeaker_automute(codec);
8195}
8196
Takashi Iwai676a9b52007-08-16 15:23:35 +02008197/* toggle speaker-output according to the hp-jack state */
8198static void alc883_acer_aspire_automute(struct hda_codec *codec)
8199{
8200 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008201
Takashi Iwai676a9b52007-08-16 15:23:35 +02008202 present = snd_hda_codec_read(codec, 0x14, 0,
8203 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8204 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8205 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8206 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8207 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8208}
8209
8210static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8211 unsigned int res)
8212{
8213 if ((res >> 26) == ALC880_HP_EVENT)
8214 alc883_acer_aspire_automute(codec);
8215}
8216
Kailang Yangd1a991a2007-08-15 16:21:59 +02008217static struct hda_verb alc883_acer_eapd_verbs[] = {
8218 /* HP Pin: output 0 (0x0c) */
8219 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8220 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8221 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8222 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008223 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8224 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008225 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008226 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8227 /* eanable EAPD on medion laptop */
8228 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8229 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008230 /* enable unsolicited event */
8231 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008232 { }
8233};
8234
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008235static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8236{
8237 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008238
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008239 present = snd_hda_codec_read(codec, 0x1b, 0,
8240 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8241 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8242 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8243 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8244 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8245 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8246 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8247 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8248 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8249}
8250
8251static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8252 unsigned int res)
8253{
8254 switch (res >> 26) {
8255 case ALC880_HP_EVENT:
Takashi Iwai939778a2009-02-05 15:57:55 +01008256 /* printk(KERN_DEBUG "hp_event\n"); */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008257 alc888_6st_dell_front_automute(codec);
8258 break;
8259 }
8260}
8261
Kailang Yange2757d52008-08-26 13:17:46 +02008262static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8263{
8264 unsigned int mute;
8265 unsigned int present;
8266
8267 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8268 present = snd_hda_codec_read(codec, 0x1b, 0,
8269 AC_VERB_GET_PIN_SENSE, 0);
8270 present = (present & 0x80000000) != 0;
8271 if (present) {
8272 /* mute internal speaker */
8273 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8274 HDA_AMP_MUTE, HDA_AMP_MUTE);
8275 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8276 HDA_AMP_MUTE, HDA_AMP_MUTE);
8277 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8278 HDA_AMP_MUTE, HDA_AMP_MUTE);
8279 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8280 HDA_AMP_MUTE, HDA_AMP_MUTE);
8281 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8282 HDA_AMP_MUTE, HDA_AMP_MUTE);
8283 } else {
8284 /* unmute internal speaker if necessary */
8285 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8286 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8287 HDA_AMP_MUTE, mute);
8288 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8289 HDA_AMP_MUTE, mute);
8290 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8291 HDA_AMP_MUTE, mute);
8292 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8293 HDA_AMP_MUTE, mute);
8294 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8295 HDA_AMP_MUTE, mute);
8296 }
8297}
8298
8299static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8300 unsigned int res)
8301{
8302 if ((res >> 26) == ALC880_HP_EVENT)
8303 alc888_lenovo_sky_front_automute(codec);
8304}
8305
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008306/*
8307 * generic initialization of ADC, input mixers and output mixers
8308 */
8309static struct hda_verb alc883_auto_init_verbs[] = {
8310 /*
8311 * Unmute ADC0-2 and set the default input to mic-in
8312 */
8313 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8314 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8315 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8316 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8317
Takashi Iwaicb53c622007-08-10 17:21:45 +02008318 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008319 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008320 * Note: PASD motherboards uses the Line In 2 as the input for
8321 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008322 */
8323 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008324 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8325 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8326 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8327 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8328 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008329
8330 /*
8331 * Set up output mixers (0x0c - 0x0f)
8332 */
8333 /* set vol=0 to output mixers */
8334 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8335 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8336 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8337 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8338 /* set up input amps for analog loopback */
8339 /* Amp Indices: DAC = 0, mixer = 1 */
8340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8341 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8342 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8343 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8344 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8345 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8346 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8347 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8348 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8349 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8350
8351 /* FIXME: use matrix-type input source selection */
8352 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8353 /* Input mixer1 */
8354 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8355 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8356 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008357 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8359 /* Input mixer2 */
8360 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8361 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008363 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008364 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008365
8366 { }
8367};
8368
Kailang Yange2757d52008-08-26 13:17:46 +02008369static struct hda_verb alc888_asus_m90v_verbs[] = {
8370 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8371 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8373 /* enable unsolicited event */
8374 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8375 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8376 { } /* end */
8377};
8378
8379static void alc883_nb_mic_automute(struct hda_codec *codec)
8380{
8381 unsigned int present;
8382
8383 present = snd_hda_codec_read(codec, 0x18, 0,
8384 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8385 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8386 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8387 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8388 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8389}
8390
8391static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8392{
8393 unsigned int present;
8394 unsigned char bits;
8395
8396 present = snd_hda_codec_read(codec, 0x1b, 0,
8397 AC_VERB_GET_PIN_SENSE, 0)
8398 & AC_PINSENSE_PRESENCE;
8399 bits = present ? 0 : PIN_OUT;
8400 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8401 bits);
8402 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8403 bits);
8404 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8405 bits);
8406}
8407
8408static void alc883_mode2_unsol_event(struct hda_codec *codec,
8409 unsigned int res)
8410{
8411 switch (res >> 26) {
8412 case ALC880_HP_EVENT:
8413 alc883_M90V_speaker_automute(codec);
8414 break;
8415 case ALC880_MIC_EVENT:
8416 alc883_nb_mic_automute(codec);
8417 break;
8418 }
8419}
8420
8421static void alc883_mode2_inithook(struct hda_codec *codec)
8422{
8423 alc883_M90V_speaker_automute(codec);
8424 alc883_nb_mic_automute(codec);
8425}
8426
8427static struct hda_verb alc888_asus_eee1601_verbs[] = {
8428 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8429 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8430 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8431 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8432 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8433 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8434 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8435 /* enable unsolicited event */
8436 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8437 { } /* end */
8438};
8439
8440static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8441{
8442 unsigned int present;
8443 unsigned char bits;
8444
8445 present = snd_hda_codec_read(codec, 0x14, 0,
8446 AC_VERB_GET_PIN_SENSE, 0)
8447 & AC_PINSENSE_PRESENCE;
8448 bits = present ? 0 : PIN_OUT;
8449 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8450 bits);
8451}
8452
8453static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8454 unsigned int res)
8455{
8456 switch (res >> 26) {
8457 case ALC880_HP_EVENT:
8458 alc883_eee1601_speaker_automute(codec);
8459 break;
8460 }
8461}
8462
8463static void alc883_eee1601_inithook(struct hda_codec *codec)
8464{
8465 alc883_eee1601_speaker_automute(codec);
8466}
8467
Takashi Iwaicb53c622007-08-10 17:21:45 +02008468#ifdef CONFIG_SND_HDA_POWER_SAVE
8469#define alc883_loopbacks alc880_loopbacks
8470#endif
8471
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008472/* pcm configuration: identiacal with ALC880 */
8473#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8474#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008475#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008476#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8477#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8478
8479/*
8480 * configuration and preset
8481 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008482static const char *alc883_models[ALC883_MODEL_LAST] = {
8483 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8484 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8485 [ALC883_3ST_6ch] = "3stack-6ch",
8486 [ALC883_6ST_DIG] = "6stack-dig",
8487 [ALC883_TARGA_DIG] = "targa-dig",
8488 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008489 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008490 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008491 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008492 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008493 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008494 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008495 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008496 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8497 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008498 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008499 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008500 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008501 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008502 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008503 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008504 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008505 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008506 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008507 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008508 [ALC883_AUTO] = "auto",
8509};
8510
8511static struct snd_pci_quirk alc883_cfg_tbl[] = {
8512 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008513 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008514 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008515 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8516 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008517 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008518 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8519 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008520 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8521 ALC888_ACER_ASPIRE_4930G),
8522 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8523 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008524 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008525 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008526 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008527 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8528 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008529 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008530 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008531 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008532 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008533 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008534 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008535 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008536 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008537 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008538 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8539 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008540 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008541 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008542 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008543 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8544 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8545 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008546 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008547 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008548 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008549 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8550 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8551 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8552 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8553 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8554 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8555 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8556 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8557 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008558 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8559 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008560 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008561 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008562 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008563 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008564 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008565 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008566 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008567 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8568 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008569 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008570 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008571 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaif67d8172009-02-04 23:30:19 +01008572 SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550",
8573 ALC883_FUJITSU_PI2515),
Jiang zhefb97dc62008-03-06 11:07:11 +01008574 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008575 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8576 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008577 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008578 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008579 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8580 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008581 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008582 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008583 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008584 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008585 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008586 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8587 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008588 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008589 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008590 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008591 {}
8592};
8593
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008594static hda_nid_t alc1200_slave_dig_outs[] = {
8595 ALC883_DIGOUT_NID, 0,
8596};
8597
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008598static struct alc_config_preset alc883_presets[] = {
8599 [ALC883_3ST_2ch_DIG] = {
8600 .mixers = { alc883_3ST_2ch_mixer },
8601 .init_verbs = { alc883_init_verbs },
8602 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8603 .dac_nids = alc883_dac_nids,
8604 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008605 .dig_in_nid = ALC883_DIGIN_NID,
8606 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8607 .channel_mode = alc883_3ST_2ch_modes,
8608 .input_mux = &alc883_capture_source,
8609 },
8610 [ALC883_3ST_6ch_DIG] = {
8611 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8612 .init_verbs = { alc883_init_verbs },
8613 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8614 .dac_nids = alc883_dac_nids,
8615 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008616 .dig_in_nid = ALC883_DIGIN_NID,
8617 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8618 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008619 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008620 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008621 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008622 [ALC883_3ST_6ch] = {
8623 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8624 .init_verbs = { alc883_init_verbs },
8625 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8626 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008627 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8628 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008629 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008630 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008631 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008632 [ALC883_3ST_6ch_INTEL] = {
8633 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8634 .init_verbs = { alc883_init_verbs },
8635 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8636 .dac_nids = alc883_dac_nids,
8637 .dig_out_nid = ALC883_DIGOUT_NID,
8638 .dig_in_nid = ALC883_DIGIN_NID,
8639 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8640 .channel_mode = alc883_3ST_6ch_intel_modes,
8641 .need_dac_fix = 1,
8642 .input_mux = &alc883_3stack_6ch_intel,
8643 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008644 [ALC883_6ST_DIG] = {
8645 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8646 .init_verbs = { alc883_init_verbs },
8647 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8648 .dac_nids = alc883_dac_nids,
8649 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008650 .dig_in_nid = ALC883_DIGIN_NID,
8651 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8652 .channel_mode = alc883_sixstack_modes,
8653 .input_mux = &alc883_capture_source,
8654 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008655 [ALC883_TARGA_DIG] = {
8656 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8657 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8658 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8659 .dac_nids = alc883_dac_nids,
8660 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008661 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8662 .channel_mode = alc883_3ST_6ch_modes,
8663 .need_dac_fix = 1,
8664 .input_mux = &alc883_capture_source,
8665 .unsol_event = alc883_tagra_unsol_event,
8666 .init_hook = alc883_tagra_automute,
8667 },
8668 [ALC883_TARGA_2ch_DIG] = {
8669 .mixers = { alc883_tagra_2ch_mixer},
8670 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8671 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8672 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008673 .adc_nids = alc883_adc_nids_alt,
8674 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008675 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008676 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8677 .channel_mode = alc883_3ST_2ch_modes,
8678 .input_mux = &alc883_capture_source,
8679 .unsol_event = alc883_tagra_unsol_event,
8680 .init_hook = alc883_tagra_automute,
8681 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008682 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008683 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008684 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8685 * and the headphone jack. Turn this on and rely on the
8686 * standard mute methods whenever the user wants to turn
8687 * these outputs off.
8688 */
8689 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8690 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8691 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008692 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8693 .channel_mode = alc883_3ST_2ch_modes,
8694 .input_mux = &alc883_capture_source,
8695 },
Tobin Davis2880a862007-08-07 11:50:26 +02008696 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008697 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008698 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008699 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8700 .dac_nids = alc883_dac_nids,
8701 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008702 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8703 .channel_mode = alc883_3ST_2ch_modes,
8704 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008705 .unsol_event = alc883_acer_aspire_unsol_event,
8706 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008707 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008708 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008709 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008710 alc883_chmode_mixer },
8711 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8712 alc888_acer_aspire_4930g_verbs },
8713 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8714 .dac_nids = alc883_dac_nids,
8715 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8716 .adc_nids = alc883_adc_nids_rev,
8717 .capsrc_nids = alc883_capsrc_nids_rev,
8718 .dig_out_nid = ALC883_DIGOUT_NID,
8719 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8720 .channel_mode = alc883_3ST_6ch_modes,
8721 .need_dac_fix = 1,
8722 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008723 ARRAY_SIZE(alc888_2_capture_sources),
8724 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008725 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8726 .init_hook = alc888_acer_aspire_4930g_automute,
8727 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008728 [ALC883_MEDION] = {
8729 .mixers = { alc883_fivestack_mixer,
8730 alc883_chmode_mixer },
8731 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008732 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008733 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8734 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008735 .adc_nids = alc883_adc_nids_alt,
8736 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008737 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8738 .channel_mode = alc883_sixstack_modes,
8739 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008740 },
Kailang Yang272a5272007-05-14 11:00:38 +02008741 [ALC883_MEDION_MD2] = {
8742 .mixers = { alc883_medion_md2_mixer},
8743 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8744 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8745 .dac_nids = alc883_dac_nids,
8746 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008747 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8748 .channel_mode = alc883_3ST_2ch_modes,
8749 .input_mux = &alc883_capture_source,
8750 .unsol_event = alc883_medion_md2_unsol_event,
8751 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008752 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008753 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008754 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008755 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8756 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8757 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008758 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8759 .channel_mode = alc883_3ST_2ch_modes,
8760 .input_mux = &alc883_capture_source,
8761 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008762 [ALC883_CLEVO_M720] = {
8763 .mixers = { alc883_clevo_m720_mixer },
8764 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008765 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8766 .dac_nids = alc883_dac_nids,
8767 .dig_out_nid = ALC883_DIGOUT_NID,
8768 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8769 .channel_mode = alc883_3ST_2ch_modes,
8770 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008771 .unsol_event = alc883_clevo_m720_unsol_event,
8772 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008773 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008774 [ALC883_LENOVO_101E_2ch] = {
8775 .mixers = { alc883_lenovo_101e_2ch_mixer},
8776 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8777 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8778 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008779 .adc_nids = alc883_adc_nids_alt,
8780 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008781 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8782 .channel_mode = alc883_3ST_2ch_modes,
8783 .input_mux = &alc883_lenovo_101e_capture_source,
8784 .unsol_event = alc883_lenovo_101e_unsol_event,
8785 .init_hook = alc883_lenovo_101e_all_automute,
8786 },
Kailang Yang272a5272007-05-14 11:00:38 +02008787 [ALC883_LENOVO_NB0763] = {
8788 .mixers = { alc883_lenovo_nb0763_mixer },
8789 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8790 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8791 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008792 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8793 .channel_mode = alc883_3ST_2ch_modes,
8794 .need_dac_fix = 1,
8795 .input_mux = &alc883_lenovo_nb0763_capture_source,
8796 .unsol_event = alc883_medion_md2_unsol_event,
8797 .init_hook = alc883_medion_md2_automute,
8798 },
8799 [ALC888_LENOVO_MS7195_DIG] = {
8800 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8801 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8802 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8803 .dac_nids = alc883_dac_nids,
8804 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008805 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8806 .channel_mode = alc883_3ST_6ch_modes,
8807 .need_dac_fix = 1,
8808 .input_mux = &alc883_capture_source,
8809 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8810 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008811 },
8812 [ALC883_HAIER_W66] = {
8813 .mixers = { alc883_tagra_2ch_mixer},
8814 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8815 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8816 .dac_nids = alc883_dac_nids,
8817 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008818 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8819 .channel_mode = alc883_3ST_2ch_modes,
8820 .input_mux = &alc883_capture_source,
8821 .unsol_event = alc883_haier_w66_unsol_event,
8822 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008823 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008824 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008825 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008826 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008827 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8828 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008829 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8830 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008831 .need_dac_fix = 1,
8832 .input_mux = &alc883_capture_source,
8833 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008834 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008835 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008836 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8837 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8838 .dac_nids = alc883_dac_nids,
8839 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008840 .dig_in_nid = ALC883_DIGIN_NID,
8841 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8842 .channel_mode = alc883_sixstack_modes,
8843 .input_mux = &alc883_capture_source,
8844 .unsol_event = alc888_6st_dell_unsol_event,
8845 .init_hook = alc888_6st_dell_front_automute,
8846 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008847 [ALC883_MITAC] = {
8848 .mixers = { alc883_mitac_mixer },
8849 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8850 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8851 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008852 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8853 .channel_mode = alc883_3ST_2ch_modes,
8854 .input_mux = &alc883_capture_source,
8855 .unsol_event = alc883_mitac_unsol_event,
8856 .init_hook = alc883_mitac_automute,
8857 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008858 [ALC883_FUJITSU_PI2515] = {
8859 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8860 .init_verbs = { alc883_init_verbs,
8861 alc883_2ch_fujitsu_pi2515_verbs},
8862 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8863 .dac_nids = alc883_dac_nids,
8864 .dig_out_nid = ALC883_DIGOUT_NID,
8865 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8866 .channel_mode = alc883_3ST_2ch_modes,
8867 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8868 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8869 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8870 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008871 [ALC888_FUJITSU_XA3530] = {
8872 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8873 .init_verbs = { alc883_init_verbs,
8874 alc888_fujitsu_xa3530_verbs },
8875 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8876 .dac_nids = alc883_dac_nids,
8877 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8878 .adc_nids = alc883_adc_nids_rev,
8879 .capsrc_nids = alc883_capsrc_nids_rev,
8880 .dig_out_nid = ALC883_DIGOUT_NID,
8881 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8882 .channel_mode = alc888_4ST_8ch_intel_modes,
8883 .num_mux_defs =
8884 ARRAY_SIZE(alc888_2_capture_sources),
8885 .input_mux = alc888_2_capture_sources,
8886 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
8887 .init_hook = alc888_fujitsu_xa3530_automute,
8888 },
Kailang Yange2757d52008-08-26 13:17:46 +02008889 [ALC888_LENOVO_SKY] = {
8890 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8891 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8892 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8893 .dac_nids = alc883_dac_nids,
8894 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02008895 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8896 .channel_mode = alc883_sixstack_modes,
8897 .need_dac_fix = 1,
8898 .input_mux = &alc883_lenovo_sky_capture_source,
8899 .unsol_event = alc883_lenovo_sky_unsol_event,
8900 .init_hook = alc888_lenovo_sky_front_automute,
8901 },
8902 [ALC888_ASUS_M90V] = {
8903 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8904 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8905 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8906 .dac_nids = alc883_dac_nids,
8907 .dig_out_nid = ALC883_DIGOUT_NID,
8908 .dig_in_nid = ALC883_DIGIN_NID,
8909 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8910 .channel_mode = alc883_3ST_6ch_modes,
8911 .need_dac_fix = 1,
8912 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8913 .unsol_event = alc883_mode2_unsol_event,
8914 .init_hook = alc883_mode2_inithook,
8915 },
8916 [ALC888_ASUS_EEE1601] = {
8917 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008918 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02008919 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8920 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8921 .dac_nids = alc883_dac_nids,
8922 .dig_out_nid = ALC883_DIGOUT_NID,
8923 .dig_in_nid = ALC883_DIGIN_NID,
8924 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8925 .channel_mode = alc883_3ST_2ch_modes,
8926 .need_dac_fix = 1,
8927 .input_mux = &alc883_asus_eee1601_capture_source,
8928 .unsol_event = alc883_eee1601_unsol_event,
8929 .init_hook = alc883_eee1601_inithook,
8930 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01008931 [ALC1200_ASUS_P5Q] = {
8932 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8933 .init_verbs = { alc883_init_verbs },
8934 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8935 .dac_nids = alc883_dac_nids,
8936 .dig_out_nid = ALC1200_DIGOUT_NID,
8937 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008938 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01008939 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8940 .channel_mode = alc883_sixstack_modes,
8941 .input_mux = &alc883_capture_source,
8942 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008943};
8944
8945
8946/*
8947 * BIOS auto configuration
8948 */
8949static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8950 hda_nid_t nid, int pin_type,
8951 int dac_idx)
8952{
8953 /* set as output */
8954 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008955 int idx;
8956
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008957 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008958 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8959 idx = 4;
8960 else
8961 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008962 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8963
8964}
8965
8966static void alc883_auto_init_multi_out(struct hda_codec *codec)
8967{
8968 struct alc_spec *spec = codec->spec;
8969 int i;
8970
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008971 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008972 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008973 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008974 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008975 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008976 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008977 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008978 }
8979}
8980
8981static void alc883_auto_init_hp_out(struct hda_codec *codec)
8982{
8983 struct alc_spec *spec = codec->spec;
8984 hda_nid_t pin;
8985
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008986 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008987 if (pin) /* connect to front */
8988 /* use dac 0 */
8989 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008990 pin = spec->autocfg.speaker_pins[0];
8991 if (pin)
8992 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008993}
8994
8995#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8996#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8997
8998static void alc883_auto_init_analog_input(struct hda_codec *codec)
8999{
9000 struct alc_spec *spec = codec->spec;
9001 int i;
9002
9003 for (i = 0; i < AUTO_PIN_LAST; i++) {
9004 hda_nid_t nid = spec->autocfg.input_pins[i];
9005 if (alc883_is_input_pin(nid)) {
9006 snd_hda_codec_write(codec, nid, 0,
9007 AC_VERB_SET_PIN_WIDGET_CONTROL,
9008 (i <= AUTO_PIN_FRONT_MIC ?
9009 PIN_VREF80 : PIN_IN));
9010 if (nid != ALC883_PIN_CD_NID)
9011 snd_hda_codec_write(codec, nid, 0,
9012 AC_VERB_SET_AMP_GAIN_MUTE,
9013 AMP_OUT_MUTE);
9014 }
9015 }
9016}
9017
Takashi Iwaif511b012008-08-15 16:46:42 +02009018#define alc883_auto_init_input_src alc882_auto_init_input_src
9019
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009020/* almost identical with ALC880 parser... */
9021static int alc883_parse_auto_config(struct hda_codec *codec)
9022{
9023 struct alc_spec *spec = codec->spec;
9024 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009025 struct auto_pin_cfg *cfg = &spec->autocfg;
9026 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009027
9028 if (err < 0)
9029 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009030 else if (!err)
9031 return 0; /* no config found */
9032
9033 err = alc_auto_add_mic_boost(codec);
9034 if (err < 0)
9035 return err;
9036
9037 /* hack - override the init verbs */
9038 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009039
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009040 /* setup input_mux for ALC889 */
9041 if (codec->vendor_id == 0x10ec0889) {
9042 /* digital-mic input pin is excluded in alc880_auto_create..()
9043 * because it's under 0x18
9044 */
9045 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9046 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9047 struct hda_input_mux *imux = &spec->private_imux[0];
9048 for (i = 1; i < 3; i++)
9049 memcpy(&spec->private_imux[i],
9050 &spec->private_imux[0],
9051 sizeof(spec->private_imux[0]));
9052 imux->items[imux->num_items].label = "Int DMic";
9053 imux->items[imux->num_items].index = 0x0b;
9054 imux->num_items++;
9055 spec->num_mux_defs = 3;
9056 spec->input_mux = spec->private_imux;
9057 }
9058 }
9059
Takashi Iwai776e1842007-08-29 15:07:11 +02009060 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009061}
9062
9063/* additional initialization for auto-configuration model */
9064static void alc883_auto_init(struct hda_codec *codec)
9065{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009066 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009067 alc883_auto_init_multi_out(codec);
9068 alc883_auto_init_hp_out(codec);
9069 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009070 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009071 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009072 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009073}
9074
9075static int patch_alc883(struct hda_codec *codec)
9076{
9077 struct alc_spec *spec;
9078 int err, board_config;
9079
9080 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9081 if (spec == NULL)
9082 return -ENOMEM;
9083
9084 codec->spec = spec;
9085
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009086 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9087
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009088 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9089 alc883_models,
9090 alc883_cfg_tbl);
9091 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009092 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9093 "trying auto-probe from BIOS...\n");
9094 board_config = ALC883_AUTO;
9095 }
9096
9097 if (board_config == ALC883_AUTO) {
9098 /* automatic parse from the BIOS config */
9099 err = alc883_parse_auto_config(codec);
9100 if (err < 0) {
9101 alc_free(codec);
9102 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009103 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009104 printk(KERN_INFO
9105 "hda_codec: Cannot set up configuration "
9106 "from BIOS. Using base mode...\n");
9107 board_config = ALC883_3ST_2ch_DIG;
9108 }
9109 }
9110
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009111 err = snd_hda_attach_beep_device(codec, 0x1);
9112 if (err < 0) {
9113 alc_free(codec);
9114 return err;
9115 }
9116
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009117 if (board_config != ALC883_AUTO)
9118 setup_preset(spec, &alc883_presets[board_config]);
9119
Kailang Yang2f893282008-05-27 12:14:47 +02009120 switch (codec->vendor_id) {
9121 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009122 if (codec->revision_id == 0x100101) {
9123 spec->stream_name_analog = "ALC1200 Analog";
9124 spec->stream_name_digital = "ALC1200 Digital";
9125 } else {
9126 spec->stream_name_analog = "ALC888 Analog";
9127 spec->stream_name_digital = "ALC888 Digital";
9128 }
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009129 if (!spec->num_adc_nids) {
9130 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9131 spec->adc_nids = alc883_adc_nids;
9132 }
9133 if (!spec->capsrc_nids)
9134 spec->capsrc_nids = alc883_capsrc_nids;
9135 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009136 break;
9137 case 0x10ec0889:
9138 spec->stream_name_analog = "ALC889 Analog";
9139 spec->stream_name_digital = "ALC889 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009140 if (!spec->num_adc_nids) {
9141 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9142 spec->adc_nids = alc889_adc_nids;
9143 }
9144 if (!spec->capsrc_nids)
9145 spec->capsrc_nids = alc889_capsrc_nids;
9146 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9147 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009148 break;
9149 default:
9150 spec->stream_name_analog = "ALC883 Analog";
9151 spec->stream_name_digital = "ALC883 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009152 if (!spec->num_adc_nids) {
9153 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9154 spec->adc_nids = alc883_adc_nids;
9155 }
9156 if (!spec->capsrc_nids)
9157 spec->capsrc_nids = alc883_capsrc_nids;
9158 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009159 break;
9160 }
9161
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009162 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9163 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009164 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009165
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009166 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9167 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9168
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009169 if (!spec->cap_mixer)
9170 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009171 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009172
Takashi Iwai2134ea42008-01-10 16:53:55 +01009173 spec->vmaster_nid = 0x0c;
9174
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009175 codec->patch_ops = alc_patch_ops;
9176 if (board_config == ALC883_AUTO)
9177 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009178
Takashi Iwaicb53c622007-08-10 17:21:45 +02009179#ifdef CONFIG_SND_HDA_POWER_SAVE
9180 if (!spec->loopback.amplist)
9181 spec->loopback.amplist = alc883_loopbacks;
9182#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009183 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009184
9185 return 0;
9186}
9187
9188/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009189 * ALC262 support
9190 */
9191
9192#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9193#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9194
9195#define alc262_dac_nids alc260_dac_nids
9196#define alc262_adc_nids alc882_adc_nids
9197#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009198#define alc262_capsrc_nids alc882_capsrc_nids
9199#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009200
9201#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009202#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009203
Kailang Yang4e555fe2008-08-26 13:05:55 +02009204static hda_nid_t alc262_dmic_adc_nids[1] = {
9205 /* ADC0 */
9206 0x09
9207};
9208
9209static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9210
Kailang Yangdf694da2005-12-05 19:42:22 +01009211static struct snd_kcontrol_new alc262_base_mixer[] = {
9212 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9213 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9214 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9215 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9216 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9217 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9218 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9219 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009220 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009221 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9222 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009223 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009224 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9225 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9226 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9227 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009228 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009229};
9230
Kailang Yangccc656c2006-10-17 12:32:26 +02009231static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9232 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9233 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9234 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9235 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9236 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9237 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9238 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9239 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009240 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009241 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9242 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009243 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009244 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9245 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9246 { } /* end */
9247};
9248
Takashi Iwaice875f02008-01-28 18:17:43 +01009249/* update HP, line and mono-out pins according to the master switch */
9250static void alc262_hp_master_update(struct hda_codec *codec)
9251{
9252 struct alc_spec *spec = codec->spec;
9253 int val = spec->master_sw;
9254
9255 /* HP & line-out */
9256 snd_hda_codec_write_cache(codec, 0x1b, 0,
9257 AC_VERB_SET_PIN_WIDGET_CONTROL,
9258 val ? PIN_HP : 0);
9259 snd_hda_codec_write_cache(codec, 0x15, 0,
9260 AC_VERB_SET_PIN_WIDGET_CONTROL,
9261 val ? PIN_HP : 0);
9262 /* mono (speaker) depending on the HP jack sense */
9263 val = val && !spec->jack_present;
9264 snd_hda_codec_write_cache(codec, 0x16, 0,
9265 AC_VERB_SET_PIN_WIDGET_CONTROL,
9266 val ? PIN_OUT : 0);
9267}
9268
9269static void alc262_hp_bpc_automute(struct hda_codec *codec)
9270{
9271 struct alc_spec *spec = codec->spec;
9272 unsigned int presence;
9273 presence = snd_hda_codec_read(codec, 0x1b, 0,
9274 AC_VERB_GET_PIN_SENSE, 0);
9275 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9276 alc262_hp_master_update(codec);
9277}
9278
9279static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9280{
9281 if ((res >> 26) != ALC880_HP_EVENT)
9282 return;
9283 alc262_hp_bpc_automute(codec);
9284}
9285
9286static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9287{
9288 struct alc_spec *spec = codec->spec;
9289 unsigned int presence;
9290 presence = snd_hda_codec_read(codec, 0x15, 0,
9291 AC_VERB_GET_PIN_SENSE, 0);
9292 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9293 alc262_hp_master_update(codec);
9294}
9295
9296static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9297 unsigned int res)
9298{
9299 if ((res >> 26) != ALC880_HP_EVENT)
9300 return;
9301 alc262_hp_wildwest_automute(codec);
9302}
9303
9304static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9305 struct snd_ctl_elem_value *ucontrol)
9306{
9307 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9308 struct alc_spec *spec = codec->spec;
9309 *ucontrol->value.integer.value = spec->master_sw;
9310 return 0;
9311}
9312
9313static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9314 struct snd_ctl_elem_value *ucontrol)
9315{
9316 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9317 struct alc_spec *spec = codec->spec;
9318 int val = !!*ucontrol->value.integer.value;
9319
9320 if (val == spec->master_sw)
9321 return 0;
9322 spec->master_sw = val;
9323 alc262_hp_master_update(codec);
9324 return 1;
9325}
9326
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009327static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009328 {
9329 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9330 .name = "Master Playback Switch",
9331 .info = snd_ctl_boolean_mono_info,
9332 .get = alc262_hp_master_sw_get,
9333 .put = alc262_hp_master_sw_put,
9334 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009335 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9336 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9337 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009338 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9339 HDA_OUTPUT),
9340 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9341 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009342 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9343 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009344 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009345 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9346 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009347 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009348 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9349 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9350 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9351 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009352 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9353 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9354 { } /* end */
9355};
9356
Kailang Yangcd7509a2007-01-26 18:33:17 +01009357static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009358 {
9359 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9360 .name = "Master Playback Switch",
9361 .info = snd_ctl_boolean_mono_info,
9362 .get = alc262_hp_master_sw_get,
9363 .put = alc262_hp_master_sw_put,
9364 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009365 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9366 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9367 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9368 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009369 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9370 HDA_OUTPUT),
9371 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9372 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009373 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9374 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009375 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009376 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9377 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9378 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9379 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009380 { } /* end */
9381};
9382
9383static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9384 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9385 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009386 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009387 { } /* end */
9388};
9389
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009390/* mute/unmute internal speaker according to the hp jack and mute state */
9391static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9392{
9393 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009394
9395 if (force || !spec->sense_updated) {
9396 unsigned int present;
9397 present = snd_hda_codec_read(codec, 0x15, 0,
9398 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009399 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009400 spec->sense_updated = 1;
9401 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009402 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9403 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009404}
9405
9406static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9407 unsigned int res)
9408{
9409 if ((res >> 26) != ALC880_HP_EVENT)
9410 return;
9411 alc262_hp_t5735_automute(codec, 1);
9412}
9413
9414static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9415{
9416 alc262_hp_t5735_automute(codec, 1);
9417}
9418
9419static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009420 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9421 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009422 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9423 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9424 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9425 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9426 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9427 { } /* end */
9428};
9429
9430static struct hda_verb alc262_hp_t5735_verbs[] = {
9431 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9432 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9433
9434 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9435 { }
9436};
9437
Kailang Yang8c427222008-01-10 13:03:59 +01009438static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009439 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9440 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009441 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9442 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009443 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9444 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9445 { } /* end */
9446};
9447
9448static struct hda_verb alc262_hp_rp5700_verbs[] = {
9449 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9450 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9451 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9452 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9453 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9454 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9455 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9456 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9457 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9458 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9459 {}
9460};
9461
9462static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9463 .num_items = 1,
9464 .items = {
9465 { "Line", 0x1 },
9466 },
9467};
9468
Takashi Iwai0724ea22007-08-23 00:31:43 +02009469/* bind hp and internal speaker mute (with plug check) */
9470static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9471 struct snd_ctl_elem_value *ucontrol)
9472{
9473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9474 long *valp = ucontrol->value.integer.value;
9475 int change;
9476
9477 /* change hp mute */
9478 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9479 HDA_AMP_MUTE,
9480 valp[0] ? 0 : HDA_AMP_MUTE);
9481 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9482 HDA_AMP_MUTE,
9483 valp[1] ? 0 : HDA_AMP_MUTE);
9484 if (change) {
9485 /* change speaker according to HP jack state */
9486 struct alc_spec *spec = codec->spec;
9487 unsigned int mute;
9488 if (spec->jack_present)
9489 mute = HDA_AMP_MUTE;
9490 else
9491 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9492 HDA_OUTPUT, 0);
9493 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9494 HDA_AMP_MUTE, mute);
9495 }
9496 return change;
9497}
Takashi Iwai5b319542007-07-26 11:49:22 +02009498
Kailang Yang272a5272007-05-14 11:00:38 +02009499static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009500 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9501 {
9502 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9503 .name = "Master Playback Switch",
9504 .info = snd_hda_mixer_amp_switch_info,
9505 .get = snd_hda_mixer_amp_switch_get,
9506 .put = alc262_sony_master_sw_put,
9507 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9508 },
Kailang Yang272a5272007-05-14 11:00:38 +02009509 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9510 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9511 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9512 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9513 { } /* end */
9514};
9515
Kailang Yang83c34212007-07-05 11:43:05 +02009516static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9517 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9518 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9519 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9520 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9521 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9522 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9523 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9524 { } /* end */
9525};
Kailang Yang272a5272007-05-14 11:00:38 +02009526
Tony Vroonba340e82009-02-02 19:01:30 +00009527static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9528 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9529 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9530 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9531 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9532 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9533 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9534 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9535 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9536 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9537 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9538 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9539 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9540 { } /* end */
9541};
9542
9543static struct hda_verb alc262_tyan_verbs[] = {
9544 /* Headphone automute */
9545 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9546 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9547 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9548
9549 /* P11 AUX_IN, white 4-pin connector */
9550 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9551 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9552 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9553 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9554
9555 {}
9556};
9557
9558/* unsolicited event for HP jack sensing */
9559static void alc262_tyan_automute(struct hda_codec *codec)
9560{
9561 unsigned int mute;
9562 unsigned int present;
9563
9564 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9565 present = snd_hda_codec_read(codec, 0x1b, 0,
9566 AC_VERB_GET_PIN_SENSE, 0);
9567 present = (present & 0x80000000) != 0;
9568 if (present) {
9569 /* mute line output on ATX panel */
9570 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9571 HDA_AMP_MUTE, HDA_AMP_MUTE);
9572 } else {
9573 /* unmute line output if necessary */
9574 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9575 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9576 HDA_AMP_MUTE, mute);
9577 }
9578}
9579
9580static void alc262_tyan_unsol_event(struct hda_codec *codec,
9581 unsigned int res)
9582{
9583 if ((res >> 26) != ALC880_HP_EVENT)
9584 return;
9585 alc262_tyan_automute(codec);
9586}
9587
Kailang Yangdf694da2005-12-05 19:42:22 +01009588#define alc262_capture_mixer alc882_capture_mixer
9589#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9590
9591/*
9592 * generic initialization of ADC, input mixers and output mixers
9593 */
9594static struct hda_verb alc262_init_verbs[] = {
9595 /*
9596 * Unmute ADC0-2 and set the default input to mic-in
9597 */
9598 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9599 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9600 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9601 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9602 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9603 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9604
Takashi Iwaicb53c622007-08-10 17:21:45 +02009605 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009606 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009607 * Note: PASD motherboards uses the Line In 2 as the input for
9608 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009609 */
9610 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009611 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9612 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9613 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9614 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9615 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009616
9617 /*
9618 * Set up output mixers (0x0c - 0x0e)
9619 */
9620 /* set vol=0 to output mixers */
9621 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9622 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9623 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9624 /* set up input amps for analog loopback */
9625 /* Amp Indices: DAC = 0, mixer = 1 */
9626 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9627 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9628 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9629 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9630 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9631 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9632
9633 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9634 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9635 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9636 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9637 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9638 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9639
9640 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9642 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9643 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9644 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009645
Kailang Yangdf694da2005-12-05 19:42:22 +01009646 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9647 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009648
Kailang Yangdf694da2005-12-05 19:42:22 +01009649 /* FIXME: use matrix-type input source selection */
9650 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9651 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9652 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9653 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9654 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9655 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9656 /* Input mixer2 */
9657 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9658 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9659 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9660 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9661 /* Input mixer3 */
9662 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9663 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9664 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009665 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009666
9667 { }
9668};
9669
Kailang Yang4e555fe2008-08-26 13:05:55 +02009670static struct hda_verb alc262_eapd_verbs[] = {
9671 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9672 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9673 { }
9674};
9675
Kailang Yangccc656c2006-10-17 12:32:26 +02009676static struct hda_verb alc262_hippo_unsol_verbs[] = {
9677 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9678 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9679 {}
9680};
9681
9682static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9683 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9684 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9685 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9686
9687 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9688 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9689 {}
9690};
9691
Kailang Yang272a5272007-05-14 11:00:38 +02009692static struct hda_verb alc262_sony_unsol_verbs[] = {
9693 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9694 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9695 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9696
9697 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9698 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009699 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009700};
9701
Kailang Yang4e555fe2008-08-26 13:05:55 +02009702static struct hda_input_mux alc262_dmic_capture_source = {
9703 .num_items = 2,
9704 .items = {
9705 { "Int DMic", 0x9 },
9706 { "Mic", 0x0 },
9707 },
9708};
9709
9710static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9711 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9712 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9713 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9714 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9715 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009716 { } /* end */
9717};
9718
9719static struct hda_verb alc262_toshiba_s06_verbs[] = {
9720 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9721 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9722 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9723 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9724 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9725 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9726 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9727 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9728 {}
9729};
9730
9731static void alc262_dmic_automute(struct hda_codec *codec)
9732{
9733 unsigned int present;
9734
9735 present = snd_hda_codec_read(codec, 0x18, 0,
9736 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9737 snd_hda_codec_write(codec, 0x22, 0,
9738 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9739}
9740
9741/* toggle speaker-output according to the hp-jack state */
9742static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9743{
9744 unsigned int present;
9745 unsigned char bits;
9746
9747 present = snd_hda_codec_read(codec, 0x15, 0,
9748 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9749 bits = present ? 0 : PIN_OUT;
9750 snd_hda_codec_write(codec, 0x14, 0,
9751 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9752}
9753
9754
9755
9756/* unsolicited event for HP jack sensing */
9757static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9758 unsigned int res)
9759{
9760 if ((res >> 26) == ALC880_HP_EVENT)
9761 alc262_toshiba_s06_speaker_automute(codec);
9762 if ((res >> 26) == ALC880_MIC_EVENT)
9763 alc262_dmic_automute(codec);
9764
9765}
9766
9767static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9768{
9769 alc262_toshiba_s06_speaker_automute(codec);
9770 alc262_dmic_automute(codec);
9771}
9772
Kailang Yangccc656c2006-10-17 12:32:26 +02009773/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009774static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009775{
9776 struct alc_spec *spec = codec->spec;
9777 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009778 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009779
Takashi Iwai5b319542007-07-26 11:49:22 +02009780 /* need to execute and sync at first */
9781 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9782 present = snd_hda_codec_read(codec, 0x15, 0,
9783 AC_VERB_GET_PIN_SENSE, 0);
9784 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009785 if (spec->jack_present) {
9786 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009787 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9788 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009789 } else {
9790 /* unmute internal speaker if necessary */
9791 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009792 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9793 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009794 }
9795}
9796
9797/* unsolicited event for HP jack sensing */
9798static void alc262_hippo_unsol_event(struct hda_codec *codec,
9799 unsigned int res)
9800{
9801 if ((res >> 26) != ALC880_HP_EVENT)
9802 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009803 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009804}
9805
Takashi Iwai5b319542007-07-26 11:49:22 +02009806static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009807{
Kailang Yangccc656c2006-10-17 12:32:26 +02009808 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009809 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009810
Takashi Iwai5b319542007-07-26 11:49:22 +02009811 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9812 present = snd_hda_codec_read(codec, 0x1b, 0,
9813 AC_VERB_GET_PIN_SENSE, 0);
9814 present = (present & 0x80000000) != 0;
9815 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009816 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009817 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9818 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009819 } else {
9820 /* unmute internal speaker if necessary */
9821 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009822 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9823 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009824 }
9825}
9826
9827/* unsolicited event for HP jack sensing */
9828static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9829 unsigned int res)
9830{
9831 if ((res >> 26) != ALC880_HP_EVENT)
9832 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009833 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009834}
9835
Takashi Iwai834be882006-03-01 14:16:17 +01009836/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009837 * nec model
9838 * 0x15 = headphone
9839 * 0x16 = internal speaker
9840 * 0x18 = external mic
9841 */
9842
9843static struct snd_kcontrol_new alc262_nec_mixer[] = {
9844 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9845 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9846
9847 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9848 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9849 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9850
9851 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9852 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9853 { } /* end */
9854};
9855
9856static struct hda_verb alc262_nec_verbs[] = {
9857 /* Unmute Speaker */
9858 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9859
9860 /* Headphone */
9861 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9863
9864 /* External mic to headphone */
9865 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9866 /* External mic to speaker */
9867 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9868 {}
9869};
9870
9871/*
Takashi Iwai834be882006-03-01 14:16:17 +01009872 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009873 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9874 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009875 */
9876
9877#define ALC_HP_EVENT 0x37
9878
9879static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9880 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9881 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009882 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9883 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009884 {}
9885};
9886
Jiang zhe0e31daf2008-03-20 12:12:39 +01009887static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9888 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9889 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9890 {}
9891};
9892
Takashi Iwai834be882006-03-01 14:16:17 +01009893static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009894 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009895 .items = {
9896 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009897 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009898 { "CD", 0x4 },
9899 },
9900};
9901
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009902static struct hda_input_mux alc262_HP_capture_source = {
9903 .num_items = 5,
9904 .items = {
9905 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009906 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009907 { "Line", 0x2 },
9908 { "CD", 0x4 },
9909 { "AUX IN", 0x6 },
9910 },
9911};
9912
zhejiangaccbe492007-08-31 12:36:05 +02009913static struct hda_input_mux alc262_HP_D7000_capture_source = {
9914 .num_items = 4,
9915 .items = {
9916 { "Mic", 0x0 },
9917 { "Front Mic", 0x2 },
9918 { "Line", 0x1 },
9919 { "CD", 0x4 },
9920 },
9921};
9922
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009923/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009924static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9925{
9926 struct alc_spec *spec = codec->spec;
9927 unsigned int mute;
9928
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009929 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009930 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009931 /* need to execute and sync at first */
9932 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009933 /* check laptop HP jack */
9934 present = snd_hda_codec_read(codec, 0x14, 0,
9935 AC_VERB_GET_PIN_SENSE, 0);
9936 /* need to execute and sync at first */
9937 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9938 /* check docking HP jack */
9939 present |= snd_hda_codec_read(codec, 0x1b, 0,
9940 AC_VERB_GET_PIN_SENSE, 0);
9941 if (present & AC_PINSENSE_PRESENCE)
9942 spec->jack_present = 1;
9943 else
9944 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009945 spec->sense_updated = 1;
9946 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009947 /* unmute internal speaker only if both HPs are unplugged and
9948 * master switch is on
9949 */
9950 if (spec->jack_present)
9951 mute = HDA_AMP_MUTE;
9952 else
Takashi Iwai834be882006-03-01 14:16:17 +01009953 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009954 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9955 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009956}
9957
9958/* unsolicited event for HP jack sensing */
9959static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9960 unsigned int res)
9961{
9962 if ((res >> 26) != ALC_HP_EVENT)
9963 return;
9964 alc262_fujitsu_automute(codec, 1);
9965}
9966
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009967static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9968{
9969 alc262_fujitsu_automute(codec, 1);
9970}
9971
Takashi Iwai834be882006-03-01 14:16:17 +01009972/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009973static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9974 .ops = &snd_hda_bind_vol,
9975 .values = {
9976 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9977 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9978 0
9979 },
9980};
Takashi Iwai834be882006-03-01 14:16:17 +01009981
Jiang zhe0e31daf2008-03-20 12:12:39 +01009982/* mute/unmute internal speaker according to the hp jack and mute state */
9983static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9984{
9985 struct alc_spec *spec = codec->spec;
9986 unsigned int mute;
9987
9988 if (force || !spec->sense_updated) {
9989 unsigned int present_int_hp;
9990 /* need to execute and sync at first */
9991 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9992 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9993 AC_VERB_GET_PIN_SENSE, 0);
9994 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9995 spec->sense_updated = 1;
9996 }
9997 if (spec->jack_present) {
9998 /* mute internal speaker */
9999 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10000 HDA_AMP_MUTE, HDA_AMP_MUTE);
10001 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10002 HDA_AMP_MUTE, HDA_AMP_MUTE);
10003 } else {
10004 /* unmute internal speaker if necessary */
10005 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10006 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10007 HDA_AMP_MUTE, mute);
10008 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10009 HDA_AMP_MUTE, mute);
10010 }
10011}
10012
10013/* unsolicited event for HP jack sensing */
10014static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10015 unsigned int res)
10016{
10017 if ((res >> 26) != ALC_HP_EVENT)
10018 return;
10019 alc262_lenovo_3000_automute(codec, 1);
10020}
10021
Takashi Iwai834be882006-03-01 14:16:17 +010010022/* bind hp and internal speaker mute (with plug check) */
10023static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10024 struct snd_ctl_elem_value *ucontrol)
10025{
10026 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10027 long *valp = ucontrol->value.integer.value;
10028 int change;
10029
Tony Vroon5d9fab22008-03-14 17:09:18 +010010030 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10031 HDA_AMP_MUTE,
10032 valp ? 0 : HDA_AMP_MUTE);
10033 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10034 HDA_AMP_MUTE,
10035 valp ? 0 : HDA_AMP_MUTE);
10036
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010037 if (change)
10038 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010039 return change;
10040}
10041
10042static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010043 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010044 {
10045 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10046 .name = "Master Playback Switch",
10047 .info = snd_hda_mixer_amp_switch_info,
10048 .get = snd_hda_mixer_amp_switch_get,
10049 .put = alc262_fujitsu_master_sw_put,
10050 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10051 },
10052 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10053 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10054 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10055 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10056 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010057 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10058 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10059 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010060 { } /* end */
10061};
10062
Jiang zhe0e31daf2008-03-20 12:12:39 +010010063/* bind hp and internal speaker mute (with plug check) */
10064static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10065 struct snd_ctl_elem_value *ucontrol)
10066{
10067 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10068 long *valp = ucontrol->value.integer.value;
10069 int change;
10070
10071 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10072 HDA_AMP_MUTE,
10073 valp ? 0 : HDA_AMP_MUTE);
10074
10075 if (change)
10076 alc262_lenovo_3000_automute(codec, 0);
10077 return change;
10078}
10079
10080static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10081 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10082 {
10083 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10084 .name = "Master Playback Switch",
10085 .info = snd_hda_mixer_amp_switch_info,
10086 .get = snd_hda_mixer_amp_switch_get,
10087 .put = alc262_lenovo_3000_master_sw_put,
10088 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10089 },
10090 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10091 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10092 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10093 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10094 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10095 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10096 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10097 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10098 { } /* end */
10099};
10100
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010101static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10102 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10103 {
10104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10105 .name = "Master Playback Switch",
10106 .info = snd_hda_mixer_amp_switch_info,
10107 .get = snd_hda_mixer_amp_switch_get,
10108 .put = alc262_sony_master_sw_put,
10109 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
10110 },
10111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10113 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10114 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10115 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10116 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10117 { } /* end */
10118};
10119
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010120/* additional init verbs for Benq laptops */
10121static struct hda_verb alc262_EAPD_verbs[] = {
10122 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10123 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10124 {}
10125};
10126
Kailang Yang83c34212007-07-05 11:43:05 +020010127static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10128 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10129 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10130
10131 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10132 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10133 {}
10134};
10135
Tobin Davisf651b502007-10-26 12:40:47 +020010136/* Samsung Q1 Ultra Vista model setup */
10137static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010138 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10139 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10141 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10142 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010143 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010144 { } /* end */
10145};
10146
10147static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010148 /* output mixer */
10149 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10150 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10151 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10152 /* speaker */
10153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10154 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10155 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10156 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10157 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010158 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010159 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10160 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10161 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10162 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10163 /* internal mic */
10164 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10165 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10166 /* ADC, choose mic */
10167 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10168 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10169 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10170 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10171 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10172 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10173 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10174 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10175 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10176 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010177 {}
10178};
10179
Tobin Davisf651b502007-10-26 12:40:47 +020010180/* mute/unmute internal speaker according to the hp jack and mute state */
10181static void alc262_ultra_automute(struct hda_codec *codec)
10182{
10183 struct alc_spec *spec = codec->spec;
10184 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010185
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010186 mute = 0;
10187 /* auto-mute only when HP is used as HP */
10188 if (!spec->cur_mux[0]) {
10189 unsigned int present;
10190 /* need to execute and sync at first */
10191 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10192 present = snd_hda_codec_read(codec, 0x15, 0,
10193 AC_VERB_GET_PIN_SENSE, 0);
10194 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10195 if (spec->jack_present)
10196 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010197 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010198 /* mute/unmute internal speaker */
10199 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10200 HDA_AMP_MUTE, mute);
10201 /* mute/unmute HP */
10202 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10203 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010204}
10205
10206/* unsolicited event for HP jack sensing */
10207static void alc262_ultra_unsol_event(struct hda_codec *codec,
10208 unsigned int res)
10209{
10210 if ((res >> 26) != ALC880_HP_EVENT)
10211 return;
10212 alc262_ultra_automute(codec);
10213}
10214
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010215static struct hda_input_mux alc262_ultra_capture_source = {
10216 .num_items = 2,
10217 .items = {
10218 { "Mic", 0x1 },
10219 { "Headphone", 0x7 },
10220 },
10221};
10222
10223static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10224 struct snd_ctl_elem_value *ucontrol)
10225{
10226 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10227 struct alc_spec *spec = codec->spec;
10228 int ret;
10229
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010230 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010231 if (!ret)
10232 return 0;
10233 /* reprogram the HP pin as mic or HP according to the input source */
10234 snd_hda_codec_write_cache(codec, 0x15, 0,
10235 AC_VERB_SET_PIN_WIDGET_CONTROL,
10236 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10237 alc262_ultra_automute(codec); /* mute/unmute HP */
10238 return ret;
10239}
10240
10241static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10242 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10243 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10244 {
10245 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10246 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010247 .info = alc_mux_enum_info,
10248 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010249 .put = alc262_ultra_mux_enum_put,
10250 },
10251 { } /* end */
10252};
10253
Kailang Yangdf694da2005-12-05 19:42:22 +010010254/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010255static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10256 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010257{
10258 hda_nid_t nid;
10259 int err;
10260
10261 spec->multiout.num_dacs = 1; /* only use one dac */
10262 spec->multiout.dac_nids = spec->private_dac_nids;
10263 spec->multiout.dac_nids[0] = 2;
10264
10265 nid = cfg->line_out_pins[0];
10266 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010267 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10268 "Front Playback Volume",
10269 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10270 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010271 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010272 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10273 "Front Playback Switch",
10274 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10275 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010276 return err;
10277 }
10278
Takashi Iwai82bc9552006-03-21 11:24:42 +010010279 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010280 if (nid) {
10281 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010282 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10283 "Speaker Playback Volume",
10284 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10285 HDA_OUTPUT));
10286 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010287 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010288 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10289 "Speaker Playback Switch",
10290 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10291 HDA_OUTPUT));
10292 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010293 return err;
10294 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010295 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10296 "Speaker Playback Switch",
10297 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10298 HDA_OUTPUT));
10299 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010300 return err;
10301 }
10302 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010303 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010304 if (nid) {
10305 /* spec->multiout.hp_nid = 2; */
10306 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010307 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10308 "Headphone Playback Volume",
10309 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10310 HDA_OUTPUT));
10311 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010312 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010313 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10314 "Headphone Playback Switch",
10315 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10316 HDA_OUTPUT));
10317 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010318 return err;
10319 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010320 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10321 "Headphone Playback Switch",
10322 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10323 HDA_OUTPUT));
10324 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010325 return err;
10326 }
10327 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010328 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010329}
10330
10331/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010332#define alc262_auto_create_analog_input_ctls \
10333 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010334
10335/*
10336 * generic initialization of ADC, input mixers and output mixers
10337 */
10338static struct hda_verb alc262_volume_init_verbs[] = {
10339 /*
10340 * Unmute ADC0-2 and set the default input to mic-in
10341 */
10342 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10343 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10344 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10345 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10346 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10347 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10348
Takashi Iwaicb53c622007-08-10 17:21:45 +020010349 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010350 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010351 * Note: PASD motherboards uses the Line In 2 as the input for
10352 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010353 */
10354 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010355 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10356 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10357 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10358 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10359 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010360
10361 /*
10362 * Set up output mixers (0x0c - 0x0f)
10363 */
10364 /* set vol=0 to output mixers */
10365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10366 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10367 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010368
Kailang Yangdf694da2005-12-05 19:42:22 +010010369 /* set up input amps for analog loopback */
10370 /* Amp Indices: DAC = 0, mixer = 1 */
10371 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10374 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10375 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10376 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10377
10378 /* FIXME: use matrix-type input source selection */
10379 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10380 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10381 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10382 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10383 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10384 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10385 /* Input mixer2 */
10386 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10387 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10388 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10389 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10390 /* Input mixer3 */
10391 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10392 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10393 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10394 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10395
10396 { }
10397};
10398
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010399static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10400 /*
10401 * Unmute ADC0-2 and set the default input to mic-in
10402 */
10403 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10405 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10406 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10407 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10408 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10409
Takashi Iwaicb53c622007-08-10 17:21:45 +020010410 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010411 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010412 * Note: PASD motherboards uses the Line In 2 as the input for
10413 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010414 */
10415 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010416 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10417 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10418 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10419 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10420 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10421 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10422 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010423
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010424 /*
10425 * Set up output mixers (0x0c - 0x0e)
10426 */
10427 /* set vol=0 to output mixers */
10428 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10429 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10430 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10431
10432 /* set up input amps for analog loopback */
10433 /* Amp Indices: DAC = 0, mixer = 1 */
10434 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10435 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10436 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10437 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10438 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10440
Takashi Iwaice875f02008-01-28 18:17:43 +010010441 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010442 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10443 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10444
10445 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10446 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10447
10448 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10449 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10450
10451 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10452 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10453 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10454 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10455 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10456
10457 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10458 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10459 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10460 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10461 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10462 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10463
10464
10465 /* FIXME: use matrix-type input source selection */
10466 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10467 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10468 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10469 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10470 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10471 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10472 /* Input mixer2 */
10473 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10474 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10475 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10476 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10477 /* Input mixer3 */
10478 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10479 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10482
Takashi Iwaice875f02008-01-28 18:17:43 +010010483 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10484
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010485 { }
10486};
10487
Kailang Yangcd7509a2007-01-26 18:33:17 +010010488static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10489 /*
10490 * Unmute ADC0-2 and set the default input to mic-in
10491 */
10492 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10493 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10494 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10495 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10496 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10497 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10498
Takashi Iwaicb53c622007-08-10 17:21:45 +020010499 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010500 * mixer widget
10501 * Note: PASD motherboards uses the Line In 2 as the input for front
10502 * panel mic (mic 2)
10503 */
10504 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10508 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10509 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10510 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10511 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10512 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010513 /*
10514 * Set up output mixers (0x0c - 0x0e)
10515 */
10516 /* set vol=0 to output mixers */
10517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10518 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10519 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10520
10521 /* set up input amps for analog loopback */
10522 /* Amp Indices: DAC = 0, mixer = 1 */
10523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10524 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10525 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10526 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10527 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10528 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10529
10530
10531 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10532 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10533 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10534 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10535 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10536 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10537 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10538
10539 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10540 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10541
10542 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10543 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10544
10545 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10546 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10547 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10548 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10549 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10550 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10551
10552 /* FIXME: use matrix-type input source selection */
10553 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10554 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10555 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10556 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10557 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10558 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10559 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10560 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10561 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10562 /* Input mixer2 */
10563 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10564 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10565 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10566 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10567 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10568 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10569 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10570 /* Input mixer3 */
10571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10574 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10575 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10576 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10578
Takashi Iwaice875f02008-01-28 18:17:43 +010010579 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10580
Kailang Yangcd7509a2007-01-26 18:33:17 +010010581 { }
10582};
10583
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010584static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10585
10586 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10587 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10588 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10589
10590 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10591 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10592 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10593 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10594
10595 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10596 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10597 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10598 {}
10599};
10600
10601
Takashi Iwaicb53c622007-08-10 17:21:45 +020010602#ifdef CONFIG_SND_HDA_POWER_SAVE
10603#define alc262_loopbacks alc880_loopbacks
10604#endif
10605
Kailang Yangdf694da2005-12-05 19:42:22 +010010606/* pcm configuration: identiacal with ALC880 */
10607#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10608#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10609#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10610#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10611
10612/*
10613 * BIOS auto configuration
10614 */
10615static int alc262_parse_auto_config(struct hda_codec *codec)
10616{
10617 struct alc_spec *spec = codec->spec;
10618 int err;
10619 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10620
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010621 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10622 alc262_ignore);
10623 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010624 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010625 if (!spec->autocfg.line_outs) {
10626 if (spec->autocfg.dig_out_pin || spec->autocfg.dig_in_pin) {
10627 spec->multiout.max_channels = 2;
10628 spec->no_analog = 1;
10629 goto dig_only;
10630 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010631 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010632 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010633 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10634 if (err < 0)
10635 return err;
10636 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10637 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010638 return err;
10639
10640 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10641
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010642 dig_only:
10643 if (spec->autocfg.dig_out_pin) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010644 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010645 spec->dig_out_type = spec->autocfg.dig_out_type;
10646 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010647 if (spec->autocfg.dig_in_pin)
10648 spec->dig_in_nid = ALC262_DIGIN_NID;
10649
Takashi Iwai603c4012008-07-30 15:01:44 +020010650 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010651 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010652
Takashi Iwaid88897e2008-10-31 15:01:37 +010010653 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010654 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010655 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010656
Takashi Iwai776e1842007-08-29 15:07:11 +020010657 err = alc_auto_add_mic_boost(codec);
10658 if (err < 0)
10659 return err;
10660
Takashi Iwaie044c392008-10-27 16:56:24 +010010661 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010662 return 1;
10663}
10664
10665#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10666#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10667#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010668#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010669
10670
10671/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010672static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010673{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010674 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010675 alc262_auto_init_multi_out(codec);
10676 alc262_auto_init_hp_out(codec);
10677 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010678 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010679 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010680 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010681}
10682
10683/*
10684 * configuration and preset
10685 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010686static const char *alc262_models[ALC262_MODEL_LAST] = {
10687 [ALC262_BASIC] = "basic",
10688 [ALC262_HIPPO] = "hippo",
10689 [ALC262_HIPPO_1] = "hippo_1",
10690 [ALC262_FUJITSU] = "fujitsu",
10691 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010692 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010693 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010694 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010695 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010696 [ALC262_BENQ_T31] = "benq-t31",
10697 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010698 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010699 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010700 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010701 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010702 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010703 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010704 [ALC262_AUTO] = "auto",
10705};
10706
10707static struct snd_pci_quirk alc262_cfg_tbl[] = {
10708 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010709 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010710 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010711 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010712 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
10713 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010714 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010715 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010716 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010717 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010718 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010719 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010720 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010721 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010722 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010723 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010724 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010725 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010726 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10727 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10728 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010729 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10730 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010731 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010732 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010733 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010734 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10735 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10736 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwai57a5ef42008-11-28 14:46:28 +010010737 SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN",
10738 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010739 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010740 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010741 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010742 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010743 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010744 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010745 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010746 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010747 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010748 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010749 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010750 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010751 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010752 {}
10753};
10754
10755static struct alc_config_preset alc262_presets[] = {
10756 [ALC262_BASIC] = {
10757 .mixers = { alc262_base_mixer },
10758 .init_verbs = { alc262_init_verbs },
10759 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10760 .dac_nids = alc262_dac_nids,
10761 .hp_nid = 0x03,
10762 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10763 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010764 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010765 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010766 [ALC262_HIPPO] = {
10767 .mixers = { alc262_base_mixer },
10768 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10769 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10770 .dac_nids = alc262_dac_nids,
10771 .hp_nid = 0x03,
10772 .dig_out_nid = ALC262_DIGOUT_NID,
10773 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10774 .channel_mode = alc262_modes,
10775 .input_mux = &alc262_capture_source,
10776 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010777 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010778 },
10779 [ALC262_HIPPO_1] = {
10780 .mixers = { alc262_hippo1_mixer },
10781 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10782 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10783 .dac_nids = alc262_dac_nids,
10784 .hp_nid = 0x02,
10785 .dig_out_nid = ALC262_DIGOUT_NID,
10786 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10787 .channel_mode = alc262_modes,
10788 .input_mux = &alc262_capture_source,
10789 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010790 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010791 },
Takashi Iwai834be882006-03-01 14:16:17 +010010792 [ALC262_FUJITSU] = {
10793 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010794 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10795 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010796 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10797 .dac_nids = alc262_dac_nids,
10798 .hp_nid = 0x03,
10799 .dig_out_nid = ALC262_DIGOUT_NID,
10800 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10801 .channel_mode = alc262_modes,
10802 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010803 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010804 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010805 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010806 [ALC262_HP_BPC] = {
10807 .mixers = { alc262_HP_BPC_mixer },
10808 .init_verbs = { alc262_HP_BPC_init_verbs },
10809 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10810 .dac_nids = alc262_dac_nids,
10811 .hp_nid = 0x03,
10812 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10813 .channel_mode = alc262_modes,
10814 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010815 .unsol_event = alc262_hp_bpc_unsol_event,
10816 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010817 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010818 [ALC262_HP_BPC_D7000_WF] = {
10819 .mixers = { alc262_HP_BPC_WildWest_mixer },
10820 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10821 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10822 .dac_nids = alc262_dac_nids,
10823 .hp_nid = 0x03,
10824 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10825 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010826 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010827 .unsol_event = alc262_hp_wildwest_unsol_event,
10828 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010829 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010830 [ALC262_HP_BPC_D7000_WL] = {
10831 .mixers = { alc262_HP_BPC_WildWest_mixer,
10832 alc262_HP_BPC_WildWest_option_mixer },
10833 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10834 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10835 .dac_nids = alc262_dac_nids,
10836 .hp_nid = 0x03,
10837 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10838 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010839 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010840 .unsol_event = alc262_hp_wildwest_unsol_event,
10841 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010842 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010843 [ALC262_HP_TC_T5735] = {
10844 .mixers = { alc262_hp_t5735_mixer },
10845 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10846 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10847 .dac_nids = alc262_dac_nids,
10848 .hp_nid = 0x03,
10849 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10850 .channel_mode = alc262_modes,
10851 .input_mux = &alc262_capture_source,
10852 .unsol_event = alc262_hp_t5735_unsol_event,
10853 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010854 },
10855 [ALC262_HP_RP5700] = {
10856 .mixers = { alc262_hp_rp5700_mixer },
10857 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10858 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10859 .dac_nids = alc262_dac_nids,
10860 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10861 .channel_mode = alc262_modes,
10862 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010863 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010864 [ALC262_BENQ_ED8] = {
10865 .mixers = { alc262_base_mixer },
10866 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10867 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10868 .dac_nids = alc262_dac_nids,
10869 .hp_nid = 0x03,
10870 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10871 .channel_mode = alc262_modes,
10872 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010873 },
Kailang Yang272a5272007-05-14 11:00:38 +020010874 [ALC262_SONY_ASSAMD] = {
10875 .mixers = { alc262_sony_mixer },
10876 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10877 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10878 .dac_nids = alc262_dac_nids,
10879 .hp_nid = 0x02,
10880 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10881 .channel_mode = alc262_modes,
10882 .input_mux = &alc262_capture_source,
10883 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010884 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010885 },
10886 [ALC262_BENQ_T31] = {
10887 .mixers = { alc262_benq_t31_mixer },
10888 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10889 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10890 .dac_nids = alc262_dac_nids,
10891 .hp_nid = 0x03,
10892 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10893 .channel_mode = alc262_modes,
10894 .input_mux = &alc262_capture_source,
10895 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010896 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010897 },
Tobin Davisf651b502007-10-26 12:40:47 +020010898 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010899 .mixers = { alc262_ultra_mixer },
10900 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010901 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010902 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10903 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010904 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10905 .channel_mode = alc262_modes,
10906 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010907 .adc_nids = alc262_adc_nids, /* ADC0 */
10908 .capsrc_nids = alc262_capsrc_nids,
10909 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010910 .unsol_event = alc262_ultra_unsol_event,
10911 .init_hook = alc262_ultra_automute,
10912 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010913 [ALC262_LENOVO_3000] = {
10914 .mixers = { alc262_lenovo_3000_mixer },
10915 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10916 alc262_lenovo_3000_unsol_verbs },
10917 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10918 .dac_nids = alc262_dac_nids,
10919 .hp_nid = 0x03,
10920 .dig_out_nid = ALC262_DIGOUT_NID,
10921 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10922 .channel_mode = alc262_modes,
10923 .input_mux = &alc262_fujitsu_capture_source,
10924 .unsol_event = alc262_lenovo_3000_unsol_event,
10925 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010926 [ALC262_NEC] = {
10927 .mixers = { alc262_nec_mixer },
10928 .init_verbs = { alc262_nec_verbs },
10929 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10930 .dac_nids = alc262_dac_nids,
10931 .hp_nid = 0x03,
10932 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10933 .channel_mode = alc262_modes,
10934 .input_mux = &alc262_capture_source,
10935 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010936 [ALC262_TOSHIBA_S06] = {
10937 .mixers = { alc262_toshiba_s06_mixer },
10938 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10939 alc262_eapd_verbs },
10940 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10941 .capsrc_nids = alc262_dmic_capsrc_nids,
10942 .dac_nids = alc262_dac_nids,
10943 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10944 .dig_out_nid = ALC262_DIGOUT_NID,
10945 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10946 .channel_mode = alc262_modes,
10947 .input_mux = &alc262_dmic_capture_source,
10948 .unsol_event = alc262_toshiba_s06_unsol_event,
10949 .init_hook = alc262_toshiba_s06_init_hook,
10950 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010951 [ALC262_TOSHIBA_RX1] = {
10952 .mixers = { alc262_toshiba_rx1_mixer },
10953 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10954 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10955 .dac_nids = alc262_dac_nids,
10956 .hp_nid = 0x03,
10957 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10958 .channel_mode = alc262_modes,
10959 .input_mux = &alc262_capture_source,
10960 .unsol_event = alc262_hippo_unsol_event,
10961 .init_hook = alc262_hippo_automute,
10962 },
Tony Vroonba340e82009-02-02 19:01:30 +000010963 [ALC262_TYAN] = {
10964 .mixers = { alc262_tyan_mixer },
10965 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
10966 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10967 .dac_nids = alc262_dac_nids,
10968 .hp_nid = 0x02,
10969 .dig_out_nid = ALC262_DIGOUT_NID,
10970 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10971 .channel_mode = alc262_modes,
10972 .input_mux = &alc262_capture_source,
10973 .unsol_event = alc262_tyan_unsol_event,
10974 .init_hook = alc262_tyan_automute,
10975 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010976};
10977
10978static int patch_alc262(struct hda_codec *codec)
10979{
10980 struct alc_spec *spec;
10981 int board_config;
10982 int err;
10983
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010984 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010985 if (spec == NULL)
10986 return -ENOMEM;
10987
10988 codec->spec = spec;
10989#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010990 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10991 * under-run
10992 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010993 {
10994 int tmp;
10995 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10996 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10997 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10998 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10999 }
11000#endif
11001
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011002 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11003
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011004 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11005 alc262_models,
11006 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011007
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011008 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011009 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11010 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011011 board_config = ALC262_AUTO;
11012 }
11013
11014 if (board_config == ALC262_AUTO) {
11015 /* automatic parse from the BIOS config */
11016 err = alc262_parse_auto_config(codec);
11017 if (err < 0) {
11018 alc_free(codec);
11019 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011020 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011021 printk(KERN_INFO
11022 "hda_codec: Cannot set up configuration "
11023 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011024 board_config = ALC262_BASIC;
11025 }
11026 }
11027
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011028 err = snd_hda_attach_beep_device(codec, 0x1);
11029 if (err < 0) {
11030 alc_free(codec);
11031 return err;
11032 }
11033
Kailang Yangdf694da2005-12-05 19:42:22 +010011034 if (board_config != ALC262_AUTO)
11035 setup_preset(spec, &alc262_presets[board_config]);
11036
11037 spec->stream_name_analog = "ALC262 Analog";
11038 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11039 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011040
Kailang Yangdf694da2005-12-05 19:42:22 +010011041 spec->stream_name_digital = "ALC262 Digital";
11042 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11043 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11044
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011045 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011046 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011047 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011048 unsigned int wcap = get_wcaps(codec, 0x07);
11049
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011050 /* get type */
11051 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011052 if (wcap != AC_WID_AUD_IN) {
11053 spec->adc_nids = alc262_adc_nids_alt;
11054 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011055 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011056 } else {
11057 spec->adc_nids = alc262_adc_nids;
11058 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011059 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011060 }
11061 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011062 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011063 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010011064 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011065
Takashi Iwai2134ea42008-01-10 16:53:55 +010011066 spec->vmaster_nid = 0x0c;
11067
Kailang Yangdf694da2005-12-05 19:42:22 +010011068 codec->patch_ops = alc_patch_ops;
11069 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011070 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011071#ifdef CONFIG_SND_HDA_POWER_SAVE
11072 if (!spec->loopback.amplist)
11073 spec->loopback.amplist = alc262_loopbacks;
11074#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011075 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011076
Kailang Yangdf694da2005-12-05 19:42:22 +010011077 return 0;
11078}
11079
Kailang Yangdf694da2005-12-05 19:42:22 +010011080/*
Kailang Yanga361d842007-06-05 12:30:55 +020011081 * ALC268 channel source setting (2 channel)
11082 */
11083#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11084#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011085
Kailang Yanga361d842007-06-05 12:30:55 +020011086static hda_nid_t alc268_dac_nids[2] = {
11087 /* front, hp */
11088 0x02, 0x03
11089};
11090
11091static hda_nid_t alc268_adc_nids[2] = {
11092 /* ADC0-1 */
11093 0x08, 0x07
11094};
11095
11096static hda_nid_t alc268_adc_nids_alt[1] = {
11097 /* ADC0 */
11098 0x08
11099};
11100
Takashi Iwaie1406342008-02-11 18:32:32 +010011101static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11102
Kailang Yanga361d842007-06-05 12:30:55 +020011103static struct snd_kcontrol_new alc268_base_mixer[] = {
11104 /* output mixer control */
11105 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11106 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11107 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11108 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011109 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11110 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11111 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011112 { }
11113};
11114
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011115/* bind Beep switches of both NID 0x0f and 0x10 */
11116static struct hda_bind_ctls alc268_bind_beep_sw = {
11117 .ops = &snd_hda_bind_sw,
11118 .values = {
11119 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11120 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11121 0
11122 },
11123};
11124
11125static struct snd_kcontrol_new alc268_beep_mixer[] = {
11126 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11127 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11128 { }
11129};
11130
Kailang Yangd1a991a2007-08-15 16:21:59 +020011131static struct hda_verb alc268_eapd_verbs[] = {
11132 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11133 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11134 { }
11135};
11136
Takashi Iwaid2738092007-08-16 14:59:45 +020011137/* Toshiba specific */
11138#define alc268_toshiba_automute alc262_hippo_automute
11139
11140static struct hda_verb alc268_toshiba_verbs[] = {
11141 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11142 { } /* end */
11143};
11144
Kailang Yang8ef355d2008-08-26 13:10:22 +020011145static struct hda_input_mux alc268_acer_lc_capture_source = {
11146 .num_items = 2,
11147 .items = {
11148 { "i-Mic", 0x6 },
11149 { "E-Mic", 0x0 },
11150 },
11151};
11152
Takashi Iwaid2738092007-08-16 14:59:45 +020011153/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011154/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011155static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11156 .ops = &snd_hda_bind_vol,
11157 .values = {
11158 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11159 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11160 0
11161 },
11162};
11163
Takashi Iwai889c4392007-08-23 18:56:52 +020011164/* mute/unmute internal speaker according to the hp jack and mute state */
11165static void alc268_acer_automute(struct hda_codec *codec, int force)
11166{
11167 struct alc_spec *spec = codec->spec;
11168 unsigned int mute;
11169
11170 if (force || !spec->sense_updated) {
11171 unsigned int present;
11172 present = snd_hda_codec_read(codec, 0x14, 0,
11173 AC_VERB_GET_PIN_SENSE, 0);
11174 spec->jack_present = (present & 0x80000000) != 0;
11175 spec->sense_updated = 1;
11176 }
11177 if (spec->jack_present)
11178 mute = HDA_AMP_MUTE; /* mute internal speaker */
11179 else /* unmute internal speaker if necessary */
11180 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11181 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11182 HDA_AMP_MUTE, mute);
11183}
11184
11185
11186/* bind hp and internal speaker mute (with plug check) */
11187static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11188 struct snd_ctl_elem_value *ucontrol)
11189{
11190 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11191 long *valp = ucontrol->value.integer.value;
11192 int change;
11193
11194 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11195 HDA_AMP_MUTE,
11196 valp[0] ? 0 : HDA_AMP_MUTE);
11197 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11198 HDA_AMP_MUTE,
11199 valp[1] ? 0 : HDA_AMP_MUTE);
11200 if (change)
11201 alc268_acer_automute(codec, 0);
11202 return change;
11203}
Takashi Iwaid2738092007-08-16 14:59:45 +020011204
Kailang Yang8ef355d2008-08-26 13:10:22 +020011205static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11206 /* output mixer control */
11207 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11208 {
11209 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11210 .name = "Master Playback Switch",
11211 .info = snd_hda_mixer_amp_switch_info,
11212 .get = snd_hda_mixer_amp_switch_get,
11213 .put = alc268_acer_master_sw_put,
11214 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11215 },
11216 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11217 { }
11218};
11219
Takashi Iwaid2738092007-08-16 14:59:45 +020011220static struct snd_kcontrol_new alc268_acer_mixer[] = {
11221 /* output mixer control */
11222 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11223 {
11224 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11225 .name = "Master Playback Switch",
11226 .info = snd_hda_mixer_amp_switch_info,
11227 .get = snd_hda_mixer_amp_switch_get,
11228 .put = alc268_acer_master_sw_put,
11229 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11230 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011231 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11232 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11233 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011234 { }
11235};
11236
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011237static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11238 /* output mixer control */
11239 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11240 {
11241 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11242 .name = "Master Playback Switch",
11243 .info = snd_hda_mixer_amp_switch_info,
11244 .get = snd_hda_mixer_amp_switch_get,
11245 .put = alc268_acer_master_sw_put,
11246 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11247 },
11248 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11249 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11250 { }
11251};
11252
Kailang Yang8ef355d2008-08-26 13:10:22 +020011253static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11254 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11255 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11256 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11257 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11258 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11259 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11260 { }
11261};
11262
Takashi Iwaid2738092007-08-16 14:59:45 +020011263static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011264 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11265 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11267 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011268 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011270 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11271 { }
11272};
11273
11274/* unsolicited event for HP jack sensing */
11275static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11276 unsigned int res)
11277{
Takashi Iwai889c4392007-08-23 18:56:52 +020011278 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011279 return;
11280 alc268_toshiba_automute(codec);
11281}
11282
11283static void alc268_acer_unsol_event(struct hda_codec *codec,
11284 unsigned int res)
11285{
Takashi Iwai889c4392007-08-23 18:56:52 +020011286 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011287 return;
11288 alc268_acer_automute(codec, 1);
11289}
11290
Takashi Iwai889c4392007-08-23 18:56:52 +020011291static void alc268_acer_init_hook(struct hda_codec *codec)
11292{
11293 alc268_acer_automute(codec, 1);
11294}
11295
Kailang Yang8ef355d2008-08-26 13:10:22 +020011296/* toggle speaker-output according to the hp-jack state */
11297static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11298{
11299 unsigned int present;
11300 unsigned char bits;
11301
11302 present = snd_hda_codec_read(codec, 0x15, 0,
11303 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11304 bits = present ? AMP_IN_MUTE(0) : 0;
11305 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11306 AMP_IN_MUTE(0), bits);
11307 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11308 AMP_IN_MUTE(0), bits);
11309}
11310
11311
11312static void alc268_acer_mic_automute(struct hda_codec *codec)
11313{
11314 unsigned int present;
11315
11316 present = snd_hda_codec_read(codec, 0x18, 0,
11317 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11318 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11319 present ? 0x0 : 0x6);
11320}
11321
11322static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11323 unsigned int res)
11324{
11325 if ((res >> 26) == ALC880_HP_EVENT)
11326 alc268_aspire_one_speaker_automute(codec);
11327 if ((res >> 26) == ALC880_MIC_EVENT)
11328 alc268_acer_mic_automute(codec);
11329}
11330
11331static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11332{
11333 alc268_aspire_one_speaker_automute(codec);
11334 alc268_acer_mic_automute(codec);
11335}
11336
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011337static struct snd_kcontrol_new alc268_dell_mixer[] = {
11338 /* output mixer control */
11339 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11340 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11341 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11342 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11343 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11344 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11345 { }
11346};
11347
11348static struct hda_verb alc268_dell_verbs[] = {
11349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11350 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11351 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11352 { }
11353};
11354
11355/* mute/unmute internal speaker according to the hp jack and mute state */
11356static void alc268_dell_automute(struct hda_codec *codec)
11357{
11358 unsigned int present;
11359 unsigned int mute;
11360
11361 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11362 if (present & 0x80000000)
11363 mute = HDA_AMP_MUTE;
11364 else
11365 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11366 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11367 HDA_AMP_MUTE, mute);
11368}
11369
11370static void alc268_dell_unsol_event(struct hda_codec *codec,
11371 unsigned int res)
11372{
11373 if ((res >> 26) != ALC880_HP_EVENT)
11374 return;
11375 alc268_dell_automute(codec);
11376}
11377
11378#define alc268_dell_init_hook alc268_dell_automute
11379
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011380static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11381 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11382 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11383 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11384 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11385 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11386 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11387 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11388 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11389 { }
11390};
11391
11392static struct hda_verb alc267_quanta_il1_verbs[] = {
11393 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11394 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11395 { }
11396};
11397
11398static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11399{
11400 unsigned int present;
11401
11402 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11403 & AC_PINSENSE_PRESENCE;
11404 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11405 present ? 0 : PIN_OUT);
11406}
11407
11408static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11409{
11410 unsigned int present;
11411
11412 present = snd_hda_codec_read(codec, 0x18, 0,
11413 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11414 snd_hda_codec_write(codec, 0x23, 0,
11415 AC_VERB_SET_CONNECT_SEL,
11416 present ? 0x00 : 0x01);
11417}
11418
11419static void alc267_quanta_il1_automute(struct hda_codec *codec)
11420{
11421 alc267_quanta_il1_hp_automute(codec);
11422 alc267_quanta_il1_mic_automute(codec);
11423}
11424
11425static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11426 unsigned int res)
11427{
11428 switch (res >> 26) {
11429 case ALC880_HP_EVENT:
11430 alc267_quanta_il1_hp_automute(codec);
11431 break;
11432 case ALC880_MIC_EVENT:
11433 alc267_quanta_il1_mic_automute(codec);
11434 break;
11435 }
11436}
11437
Kailang Yanga361d842007-06-05 12:30:55 +020011438/*
11439 * generic initialization of ADC, input mixers and output mixers
11440 */
11441static struct hda_verb alc268_base_init_verbs[] = {
11442 /* Unmute DAC0-1 and set vol = 0 */
11443 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011444 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011445
11446 /*
11447 * Set up output mixers (0x0c - 0x0e)
11448 */
11449 /* set vol=0 to output mixers */
11450 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011451 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11452
11453 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11454 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11455
11456 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11457 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11458 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11459 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11460 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11461 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11462 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11463 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11464
11465 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11467 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11468 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011469 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011470
11471 /* set PCBEEP vol = 0, mute connections */
11472 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11473 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11474 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011475
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011476 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011477
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011478 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11479 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11480 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11481 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011482
Kailang Yanga361d842007-06-05 12:30:55 +020011483 { }
11484};
11485
11486/*
11487 * generic initialization of ADC, input mixers and output mixers
11488 */
11489static struct hda_verb alc268_volume_init_verbs[] = {
11490 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011491 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11492 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011493
11494 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11495 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11496 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11497 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11498 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11499
Kailang Yanga361d842007-06-05 12:30:55 +020011500 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011501 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11502 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11503
11504 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011505 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011506
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011507 /* set PCBEEP vol = 0, mute connections */
11508 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11509 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11510 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011511
11512 { }
11513};
11514
Kailang Yanga361d842007-06-05 12:30:55 +020011515static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11516 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11517 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11518 {
11519 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11520 /* The multiple "Capture Source" controls confuse alsamixer
11521 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011522 */
11523 /* .name = "Capture Source", */
11524 .name = "Input Source",
11525 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011526 .info = alc_mux_enum_info,
11527 .get = alc_mux_enum_get,
11528 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011529 },
11530 { } /* end */
11531};
11532
11533static struct snd_kcontrol_new alc268_capture_mixer[] = {
11534 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11535 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11536 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11537 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11538 {
11539 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11540 /* The multiple "Capture Source" controls confuse alsamixer
11541 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011542 */
11543 /* .name = "Capture Source", */
11544 .name = "Input Source",
11545 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011546 .info = alc_mux_enum_info,
11547 .get = alc_mux_enum_get,
11548 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011549 },
11550 { } /* end */
11551};
11552
11553static struct hda_input_mux alc268_capture_source = {
11554 .num_items = 4,
11555 .items = {
11556 { "Mic", 0x0 },
11557 { "Front Mic", 0x1 },
11558 { "Line", 0x2 },
11559 { "CD", 0x3 },
11560 },
11561};
11562
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011563static struct hda_input_mux alc268_acer_capture_source = {
11564 .num_items = 3,
11565 .items = {
11566 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011567 { "Internal Mic", 0x1 },
11568 { "Line", 0x2 },
11569 },
11570};
11571
11572static struct hda_input_mux alc268_acer_dmic_capture_source = {
11573 .num_items = 3,
11574 .items = {
11575 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011576 { "Internal Mic", 0x6 },
11577 { "Line", 0x2 },
11578 },
11579};
11580
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011581#ifdef CONFIG_SND_DEBUG
11582static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011583 /* Volume widgets */
11584 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11585 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11586 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11587 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11588 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11589 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11590 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11591 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11592 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11593 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11594 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11595 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11596 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011597 /* The below appears problematic on some hardwares */
11598 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011599 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11600 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11601 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11602 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11603
11604 /* Modes for retasking pin widgets */
11605 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11606 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11607 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11608 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11609
11610 /* Controls for GPIO pins, assuming they are configured as outputs */
11611 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11612 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11613 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11614 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11615
11616 /* Switches to allow the digital SPDIF output pin to be enabled.
11617 * The ALC268 does not have an SPDIF input.
11618 */
11619 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11620
11621 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11622 * this output to turn on an external amplifier.
11623 */
11624 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11625 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11626
11627 { } /* end */
11628};
11629#endif
11630
Kailang Yanga361d842007-06-05 12:30:55 +020011631/* create input playback/capture controls for the given pin */
11632static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11633 const char *ctlname, int idx)
11634{
11635 char name[32];
11636 int err;
11637
11638 sprintf(name, "%s Playback Volume", ctlname);
11639 if (nid == 0x14) {
11640 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11641 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11642 HDA_OUTPUT));
11643 if (err < 0)
11644 return err;
11645 } else if (nid == 0x15) {
11646 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11647 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11648 HDA_OUTPUT));
11649 if (err < 0)
11650 return err;
11651 } else
11652 return -1;
11653 sprintf(name, "%s Playback Switch", ctlname);
11654 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11655 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11656 if (err < 0)
11657 return err;
11658 return 0;
11659}
11660
11661/* add playback controls from the parsed DAC table */
11662static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11663 const struct auto_pin_cfg *cfg)
11664{
11665 hda_nid_t nid;
11666 int err;
11667
11668 spec->multiout.num_dacs = 2; /* only use one dac */
11669 spec->multiout.dac_nids = spec->private_dac_nids;
11670 spec->multiout.dac_nids[0] = 2;
11671 spec->multiout.dac_nids[1] = 3;
11672
11673 nid = cfg->line_out_pins[0];
11674 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011675 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011676
11677 nid = cfg->speaker_pins[0];
11678 if (nid == 0x1d) {
11679 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11680 "Speaker Playback Volume",
11681 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11682 if (err < 0)
11683 return err;
11684 }
11685 nid = cfg->hp_pins[0];
11686 if (nid)
11687 alc268_new_analog_output(spec, nid, "Headphone", 0);
11688
11689 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11690 if (nid == 0x16) {
11691 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11692 "Mono Playback Switch",
11693 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11694 if (err < 0)
11695 return err;
11696 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011697 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011698}
11699
11700/* create playback/capture controls for input pins */
11701static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11702 const struct auto_pin_cfg *cfg)
11703{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011704 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011705 int i, idx1;
11706
11707 for (i = 0; i < AUTO_PIN_LAST; i++) {
11708 switch(cfg->input_pins[i]) {
11709 case 0x18:
11710 idx1 = 0; /* Mic 1 */
11711 break;
11712 case 0x19:
11713 idx1 = 1; /* Mic 2 */
11714 break;
11715 case 0x1a:
11716 idx1 = 2; /* Line In */
11717 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011718 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011719 idx1 = 3; /* CD */
11720 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011721 case 0x12:
11722 case 0x13:
11723 idx1 = 6; /* digital mics */
11724 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011725 default:
11726 continue;
11727 }
11728 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11729 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011730 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011731 }
11732 return 0;
11733}
11734
11735static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11736{
11737 struct alc_spec *spec = codec->spec;
11738 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11739 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11740 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11741 unsigned int dac_vol1, dac_vol2;
11742
11743 if (speaker_nid) {
11744 snd_hda_codec_write(codec, speaker_nid, 0,
11745 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11746 snd_hda_codec_write(codec, 0x0f, 0,
11747 AC_VERB_SET_AMP_GAIN_MUTE,
11748 AMP_IN_UNMUTE(1));
11749 snd_hda_codec_write(codec, 0x10, 0,
11750 AC_VERB_SET_AMP_GAIN_MUTE,
11751 AMP_IN_UNMUTE(1));
11752 } else {
11753 snd_hda_codec_write(codec, 0x0f, 0,
11754 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11755 snd_hda_codec_write(codec, 0x10, 0,
11756 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11757 }
11758
11759 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011760 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011761 dac_vol2 = AMP_OUT_ZERO;
11762 else if (line_nid == 0x15)
11763 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011764 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011765 dac_vol2 = AMP_OUT_ZERO;
11766 else if (hp_nid == 0x15)
11767 dac_vol1 = AMP_OUT_ZERO;
11768 if (line_nid != 0x16 || hp_nid != 0x16 ||
11769 spec->autocfg.line_out_pins[1] != 0x16 ||
11770 spec->autocfg.line_out_pins[2] != 0x16)
11771 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11772
11773 snd_hda_codec_write(codec, 0x02, 0,
11774 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11775 snd_hda_codec_write(codec, 0x03, 0,
11776 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11777}
11778
11779/* pcm configuration: identiacal with ALC880 */
11780#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11781#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011782#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011783#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11784
11785/*
11786 * BIOS auto configuration
11787 */
11788static int alc268_parse_auto_config(struct hda_codec *codec)
11789{
11790 struct alc_spec *spec = codec->spec;
11791 int err;
11792 static hda_nid_t alc268_ignore[] = { 0 };
11793
11794 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11795 alc268_ignore);
11796 if (err < 0)
11797 return err;
11798 if (!spec->autocfg.line_outs)
11799 return 0; /* can't find valid BIOS pin config */
11800
11801 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11802 if (err < 0)
11803 return err;
11804 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11805 if (err < 0)
11806 return err;
11807
11808 spec->multiout.max_channels = 2;
11809
11810 /* digital only support output */
11811 if (spec->autocfg.dig_out_pin)
11812 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11813
Takashi Iwai603c4012008-07-30 15:01:44 +020011814 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011815 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011816
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011817 if (spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011818 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011819
Takashi Iwaid88897e2008-10-31 15:01:37 +010011820 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011821 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011822 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011823
Takashi Iwai776e1842007-08-29 15:07:11 +020011824 err = alc_auto_add_mic_boost(codec);
11825 if (err < 0)
11826 return err;
11827
Takashi Iwaie044c392008-10-27 16:56:24 +010011828 store_pin_configs(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011829 return 1;
11830}
11831
11832#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11833#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11834#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11835
11836/* init callback for auto-configuration model -- overriding the default init */
11837static void alc268_auto_init(struct hda_codec *codec)
11838{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011839 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011840 alc268_auto_init_multi_out(codec);
11841 alc268_auto_init_hp_out(codec);
11842 alc268_auto_init_mono_speaker_out(codec);
11843 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011844 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011845 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011846}
11847
11848/*
11849 * configuration and preset
11850 */
11851static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011852 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011853 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011854 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011855 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011856 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011857 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011858 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011859 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011860#ifdef CONFIG_SND_DEBUG
11861 [ALC268_TEST] = "test",
11862#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011863 [ALC268_AUTO] = "auto",
11864};
11865
11866static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011867 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011868 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011869 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011870 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011871 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011872 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11873 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011874 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010011875 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011876 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011877 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011878 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011879 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011880 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011881 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011882 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011883 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011884 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011885 {}
11886};
11887
11888static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011889 [ALC267_QUANTA_IL1] = {
11890 .mixers = { alc267_quanta_il1_mixer },
11891 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11892 alc267_quanta_il1_verbs },
11893 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11894 .dac_nids = alc268_dac_nids,
11895 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11896 .adc_nids = alc268_adc_nids_alt,
11897 .hp_nid = 0x03,
11898 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11899 .channel_mode = alc268_modes,
11900 .input_mux = &alc268_capture_source,
11901 .unsol_event = alc267_quanta_il1_unsol_event,
11902 .init_hook = alc267_quanta_il1_automute,
11903 },
Kailang Yanga361d842007-06-05 12:30:55 +020011904 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011905 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11906 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011907 .init_verbs = { alc268_base_init_verbs },
11908 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11909 .dac_nids = alc268_dac_nids,
11910 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11911 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011912 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011913 .hp_nid = 0x03,
11914 .dig_out_nid = ALC268_DIGOUT_NID,
11915 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11916 .channel_mode = alc268_modes,
11917 .input_mux = &alc268_capture_source,
11918 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011919 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011920 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11921 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011922 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11923 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011924 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11925 .dac_nids = alc268_dac_nids,
11926 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11927 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011928 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011929 .hp_nid = 0x03,
11930 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11931 .channel_mode = alc268_modes,
11932 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011933 .unsol_event = alc268_toshiba_unsol_event,
11934 .init_hook = alc268_toshiba_automute,
11935 },
11936 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011937 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11938 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011939 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11940 alc268_acer_verbs },
11941 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11942 .dac_nids = alc268_dac_nids,
11943 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11944 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011945 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011946 .hp_nid = 0x02,
11947 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11948 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011949 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011950 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011951 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011952 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011953 [ALC268_ACER_DMIC] = {
11954 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
11955 alc268_beep_mixer },
11956 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11957 alc268_acer_verbs },
11958 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11959 .dac_nids = alc268_dac_nids,
11960 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11961 .adc_nids = alc268_adc_nids_alt,
11962 .capsrc_nids = alc268_capsrc_nids,
11963 .hp_nid = 0x02,
11964 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11965 .channel_mode = alc268_modes,
11966 .input_mux = &alc268_acer_dmic_capture_source,
11967 .unsol_event = alc268_acer_unsol_event,
11968 .init_hook = alc268_acer_init_hook,
11969 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011970 [ALC268_ACER_ASPIRE_ONE] = {
11971 .mixers = { alc268_acer_aspire_one_mixer,
11972 alc268_capture_alt_mixer },
11973 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11974 alc268_acer_aspire_one_verbs },
11975 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11976 .dac_nids = alc268_dac_nids,
11977 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11978 .adc_nids = alc268_adc_nids_alt,
11979 .capsrc_nids = alc268_capsrc_nids,
11980 .hp_nid = 0x03,
11981 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11982 .channel_mode = alc268_modes,
11983 .input_mux = &alc268_acer_lc_capture_source,
11984 .unsol_event = alc268_acer_lc_unsol_event,
11985 .init_hook = alc268_acer_lc_init_hook,
11986 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011987 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011988 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011989 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11990 alc268_dell_verbs },
11991 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11992 .dac_nids = alc268_dac_nids,
11993 .hp_nid = 0x02,
11994 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11995 .channel_mode = alc268_modes,
11996 .unsol_event = alc268_dell_unsol_event,
11997 .init_hook = alc268_dell_init_hook,
11998 .input_mux = &alc268_capture_source,
11999 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012000 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012001 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12002 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012003 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12004 alc268_toshiba_verbs },
12005 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12006 .dac_nids = alc268_dac_nids,
12007 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12008 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012009 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012010 .hp_nid = 0x03,
12011 .dig_out_nid = ALC268_DIGOUT_NID,
12012 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12013 .channel_mode = alc268_modes,
12014 .input_mux = &alc268_capture_source,
12015 .unsol_event = alc268_toshiba_unsol_event,
12016 .init_hook = alc268_toshiba_automute
12017 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012018#ifdef CONFIG_SND_DEBUG
12019 [ALC268_TEST] = {
12020 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12021 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12022 alc268_volume_init_verbs },
12023 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12024 .dac_nids = alc268_dac_nids,
12025 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12026 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012027 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012028 .hp_nid = 0x03,
12029 .dig_out_nid = ALC268_DIGOUT_NID,
12030 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12031 .channel_mode = alc268_modes,
12032 .input_mux = &alc268_capture_source,
12033 },
12034#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012035};
12036
12037static int patch_alc268(struct hda_codec *codec)
12038{
12039 struct alc_spec *spec;
12040 int board_config;
12041 int err;
12042
12043 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12044 if (spec == NULL)
12045 return -ENOMEM;
12046
12047 codec->spec = spec;
12048
12049 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12050 alc268_models,
12051 alc268_cfg_tbl);
12052
12053 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12054 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12055 "trying auto-probe from BIOS...\n");
12056 board_config = ALC268_AUTO;
12057 }
12058
12059 if (board_config == ALC268_AUTO) {
12060 /* automatic parse from the BIOS config */
12061 err = alc268_parse_auto_config(codec);
12062 if (err < 0) {
12063 alc_free(codec);
12064 return err;
12065 } else if (!err) {
12066 printk(KERN_INFO
12067 "hda_codec: Cannot set up configuration "
12068 "from BIOS. Using base mode...\n");
12069 board_config = ALC268_3ST;
12070 }
12071 }
12072
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012073 err = snd_hda_attach_beep_device(codec, 0x1);
12074 if (err < 0) {
12075 alc_free(codec);
12076 return err;
12077 }
12078
Kailang Yanga361d842007-06-05 12:30:55 +020012079 if (board_config != ALC268_AUTO)
12080 setup_preset(spec, &alc268_presets[board_config]);
12081
Kailang Yang2f893282008-05-27 12:14:47 +020012082 if (codec->vendor_id == 0x10ec0267) {
12083 spec->stream_name_analog = "ALC267 Analog";
12084 spec->stream_name_digital = "ALC267 Digital";
12085 } else {
12086 spec->stream_name_analog = "ALC268 Analog";
12087 spec->stream_name_digital = "ALC268 Digital";
12088 }
12089
Kailang Yanga361d842007-06-05 12:30:55 +020012090 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12091 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012092 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012093
Kailang Yanga361d842007-06-05 12:30:55 +020012094 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12095
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012096 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12097 /* override the amp caps for beep generator */
12098 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
12099 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12100 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12101 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12102 (0 << AC_AMPCAP_MUTE_SHIFT));
12103
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012104 if (!spec->adc_nids && spec->input_mux) {
12105 /* check whether NID 0x07 is valid */
12106 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012107 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012108
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012109 /* get type */
12110 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012111 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012112 spec->adc_nids = alc268_adc_nids_alt;
12113 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012114 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012115 } else {
12116 spec->adc_nids = alc268_adc_nids;
12117 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012118 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012119 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012120 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012121 /* set default input source */
12122 for (i = 0; i < spec->num_adc_nids; i++)
12123 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12124 0, AC_VERB_SET_CONNECT_SEL,
12125 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012126 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012127
12128 spec->vmaster_nid = 0x02;
12129
Kailang Yanga361d842007-06-05 12:30:55 +020012130 codec->patch_ops = alc_patch_ops;
12131 if (board_config == ALC268_AUTO)
12132 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012133
Takashi Iwaidaead532008-11-28 12:55:36 +010012134 codec->proc_widget_hook = print_realtek_coef;
12135
Kailang Yanga361d842007-06-05 12:30:55 +020012136 return 0;
12137}
12138
12139/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012140 * ALC269 channel source setting (2 channel)
12141 */
12142#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12143
12144#define alc269_dac_nids alc260_dac_nids
12145
12146static hda_nid_t alc269_adc_nids[1] = {
12147 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012148 0x08,
12149};
12150
Takashi Iwaie01bf502008-08-21 16:25:07 +020012151static hda_nid_t alc269_capsrc_nids[1] = {
12152 0x23,
12153};
12154
12155/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12156 * not a mux!
12157 */
12158
Kailang Yangf53281e2008-07-18 12:36:43 +020012159static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12160 .num_items = 2,
12161 .items = {
12162 { "i-Mic", 0x5 },
12163 { "e-Mic", 0x0 },
12164 },
12165};
12166
12167static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12168 .num_items = 2,
12169 .items = {
12170 { "i-Mic", 0x1 },
12171 { "e-Mic", 0x0 },
12172 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012173};
12174
12175#define alc269_modes alc260_modes
12176#define alc269_capture_source alc880_lg_lw_capture_source
12177
12178static struct snd_kcontrol_new alc269_base_mixer[] = {
12179 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12180 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12181 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12182 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12183 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12184 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12185 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12186 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12187 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12188 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12189 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12190 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12191 { } /* end */
12192};
12193
Kailang Yang60db6b52008-08-26 13:13:00 +020012194static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12195 /* output mixer control */
12196 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12197 {
12198 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12199 .name = "Master Playback Switch",
12200 .info = snd_hda_mixer_amp_switch_info,
12201 .get = snd_hda_mixer_amp_switch_get,
12202 .put = alc268_acer_master_sw_put,
12203 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12204 },
12205 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12206 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12207 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12208 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12209 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12210 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012211 { }
12212};
12213
Tony Vroon64154832008-11-06 15:08:49 +000012214static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12215 /* output mixer control */
12216 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12217 {
12218 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12219 .name = "Master Playback Switch",
12220 .info = snd_hda_mixer_amp_switch_info,
12221 .get = snd_hda_mixer_amp_switch_get,
12222 .put = alc268_acer_master_sw_put,
12223 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12224 },
12225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12226 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12227 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12228 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12229 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12230 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12231 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12232 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12233 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012234 { }
12235};
12236
Kailang Yangf53281e2008-07-18 12:36:43 +020012237/* bind volumes of both NID 0x0c and 0x0d */
12238static struct hda_bind_ctls alc269_epc_bind_vol = {
12239 .ops = &snd_hda_bind_vol,
12240 .values = {
12241 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12242 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12243 0
12244 },
12245};
12246
12247static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12248 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12249 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12250 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12251 { } /* end */
12252};
12253
Kailang Yangf6a92242007-12-13 16:52:54 +010012254/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012255static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12256 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12257 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012258 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12259 { } /* end */
12260};
12261
12262/* FSC amilo */
12263static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12264 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12265 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12266 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012267 { } /* end */
12268};
12269
Kailang Yang60db6b52008-08-26 13:13:00 +020012270static struct hda_verb alc269_quanta_fl1_verbs[] = {
12271 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12272 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12273 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12274 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12275 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12276 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12277 { }
12278};
12279
Tony Vroon64154832008-11-06 15:08:49 +000012280static struct hda_verb alc269_lifebook_verbs[] = {
12281 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12282 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12283 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12284 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12285 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12286 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12287 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12288 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12289 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12290 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12291 { }
12292};
12293
Kailang Yang60db6b52008-08-26 13:13:00 +020012294/* toggle speaker-output according to the hp-jack state */
12295static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12296{
12297 unsigned int present;
12298 unsigned char bits;
12299
12300 present = snd_hda_codec_read(codec, 0x15, 0,
12301 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12302 bits = present ? AMP_IN_MUTE(0) : 0;
12303 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12304 AMP_IN_MUTE(0), bits);
12305 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12306 AMP_IN_MUTE(0), bits);
12307
12308 snd_hda_codec_write(codec, 0x20, 0,
12309 AC_VERB_SET_COEF_INDEX, 0x0c);
12310 snd_hda_codec_write(codec, 0x20, 0,
12311 AC_VERB_SET_PROC_COEF, 0x680);
12312
12313 snd_hda_codec_write(codec, 0x20, 0,
12314 AC_VERB_SET_COEF_INDEX, 0x0c);
12315 snd_hda_codec_write(codec, 0x20, 0,
12316 AC_VERB_SET_PROC_COEF, 0x480);
12317}
12318
Tony Vroon64154832008-11-06 15:08:49 +000012319/* toggle speaker-output according to the hp-jacks state */
12320static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12321{
12322 unsigned int present;
12323 unsigned char bits;
12324
12325 /* Check laptop headphone socket */
12326 present = snd_hda_codec_read(codec, 0x15, 0,
12327 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12328
12329 /* Check port replicator headphone socket */
12330 present |= snd_hda_codec_read(codec, 0x1a, 0,
12331 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12332
12333 bits = present ? AMP_IN_MUTE(0) : 0;
12334 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12335 AMP_IN_MUTE(0), bits);
12336 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12337 AMP_IN_MUTE(0), bits);
12338
12339 snd_hda_codec_write(codec, 0x20, 0,
12340 AC_VERB_SET_COEF_INDEX, 0x0c);
12341 snd_hda_codec_write(codec, 0x20, 0,
12342 AC_VERB_SET_PROC_COEF, 0x680);
12343
12344 snd_hda_codec_write(codec, 0x20, 0,
12345 AC_VERB_SET_COEF_INDEX, 0x0c);
12346 snd_hda_codec_write(codec, 0x20, 0,
12347 AC_VERB_SET_PROC_COEF, 0x480);
12348}
12349
Kailang Yang60db6b52008-08-26 13:13:00 +020012350static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12351{
12352 unsigned int present;
12353
12354 present = snd_hda_codec_read(codec, 0x18, 0,
12355 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12356 snd_hda_codec_write(codec, 0x23, 0,
12357 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12358}
12359
Tony Vroon64154832008-11-06 15:08:49 +000012360static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12361{
12362 unsigned int present_laptop;
12363 unsigned int present_dock;
12364
12365 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12366 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12367
12368 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12369 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12370
12371 /* Laptop mic port overrides dock mic port, design decision */
12372 if (present_dock)
12373 snd_hda_codec_write(codec, 0x23, 0,
12374 AC_VERB_SET_CONNECT_SEL, 0x3);
12375 if (present_laptop)
12376 snd_hda_codec_write(codec, 0x23, 0,
12377 AC_VERB_SET_CONNECT_SEL, 0x0);
12378 if (!present_dock && !present_laptop)
12379 snd_hda_codec_write(codec, 0x23, 0,
12380 AC_VERB_SET_CONNECT_SEL, 0x1);
12381}
12382
Kailang Yang60db6b52008-08-26 13:13:00 +020012383static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12384 unsigned int res)
12385{
12386 if ((res >> 26) == ALC880_HP_EVENT)
12387 alc269_quanta_fl1_speaker_automute(codec);
12388 if ((res >> 26) == ALC880_MIC_EVENT)
12389 alc269_quanta_fl1_mic_automute(codec);
12390}
12391
Tony Vroon64154832008-11-06 15:08:49 +000012392static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12393 unsigned int res)
12394{
12395 if ((res >> 26) == ALC880_HP_EVENT)
12396 alc269_lifebook_speaker_automute(codec);
12397 if ((res >> 26) == ALC880_MIC_EVENT)
12398 alc269_lifebook_mic_autoswitch(codec);
12399}
12400
Kailang Yang60db6b52008-08-26 13:13:00 +020012401static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12402{
12403 alc269_quanta_fl1_speaker_automute(codec);
12404 alc269_quanta_fl1_mic_automute(codec);
12405}
12406
Tony Vroon64154832008-11-06 15:08:49 +000012407static void alc269_lifebook_init_hook(struct hda_codec *codec)
12408{
12409 alc269_lifebook_speaker_automute(codec);
12410 alc269_lifebook_mic_autoswitch(codec);
12411}
12412
Kailang Yang60db6b52008-08-26 13:13:00 +020012413static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12414 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12415 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12416 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12417 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12418 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12419 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12420 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12421 {}
12422};
12423
12424static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12425 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12426 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12427 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12428 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12429 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12430 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12431 {}
12432};
12433
12434/* toggle speaker-output according to the hp-jack state */
12435static void alc269_speaker_automute(struct hda_codec *codec)
12436{
12437 unsigned int present;
12438 unsigned char bits;
12439
12440 present = snd_hda_codec_read(codec, 0x15, 0,
12441 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12442 bits = present ? AMP_IN_MUTE(0) : 0;
12443 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12444 AMP_IN_MUTE(0), bits);
12445 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12446 AMP_IN_MUTE(0), bits);
12447}
12448
12449static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12450{
12451 unsigned int present;
12452
12453 present = snd_hda_codec_read(codec, 0x18, 0,
12454 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12455 snd_hda_codec_write(codec, 0x23, 0,
12456 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12457}
12458
12459static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12460{
12461 unsigned int present;
12462
12463 present = snd_hda_codec_read(codec, 0x18, 0,
12464 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12465 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12466 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12467 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12468 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12469}
12470
12471/* unsolicited event for HP jack sensing */
12472static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12473 unsigned int res)
12474{
12475 if ((res >> 26) == ALC880_HP_EVENT)
12476 alc269_speaker_automute(codec);
12477
12478 if ((res >> 26) == ALC880_MIC_EVENT)
12479 alc269_eeepc_dmic_automute(codec);
12480}
12481
12482static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12483{
12484 alc269_speaker_automute(codec);
12485 alc269_eeepc_dmic_automute(codec);
12486}
12487
12488/* unsolicited event for HP jack sensing */
12489static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12490 unsigned int res)
12491{
12492 if ((res >> 26) == ALC880_HP_EVENT)
12493 alc269_speaker_automute(codec);
12494
12495 if ((res >> 26) == ALC880_MIC_EVENT)
12496 alc269_eeepc_amic_automute(codec);
12497}
12498
12499static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12500{
12501 alc269_speaker_automute(codec);
12502 alc269_eeepc_amic_automute(codec);
12503}
12504
Kailang Yangf6a92242007-12-13 16:52:54 +010012505/*
12506 * generic initialization of ADC, input mixers and output mixers
12507 */
12508static struct hda_verb alc269_init_verbs[] = {
12509 /*
12510 * Unmute ADC0 and set the default input to mic-in
12511 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012512 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012513
12514 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12515 * analog-loopback mixer widget
12516 * Note: PASD motherboards uses the Line In 2 as the input for
12517 * front panel mic (mic 2)
12518 */
12519 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12523 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12524 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12525
12526 /*
12527 * Set up output mixers (0x0c - 0x0e)
12528 */
12529 /* set vol=0 to output mixers */
12530 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12531 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12532
12533 /* set up input amps for analog loopback */
12534 /* Amp Indices: DAC = 0, mixer = 1 */
12535 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12537 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12540 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12541
12542 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12543 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12544 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12545 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12546 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12547 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12548 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12549
12550 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12551 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12552 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12553 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12554 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12555 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12556 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12557
12558 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12559 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12560
12561 /* FIXME: use matrix-type input source selection */
12562 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12563 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012564 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12565 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012566 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12567 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12568
12569 /* set EAPD */
12570 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12571 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12572 { }
12573};
12574
12575/* add playback controls from the parsed DAC table */
12576static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12577 const struct auto_pin_cfg *cfg)
12578{
12579 hda_nid_t nid;
12580 int err;
12581
12582 spec->multiout.num_dacs = 1; /* only use one dac */
12583 spec->multiout.dac_nids = spec->private_dac_nids;
12584 spec->multiout.dac_nids[0] = 2;
12585
12586 nid = cfg->line_out_pins[0];
12587 if (nid) {
12588 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12589 "Front Playback Volume",
12590 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12591 if (err < 0)
12592 return err;
12593 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12594 "Front Playback Switch",
12595 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12596 if (err < 0)
12597 return err;
12598 }
12599
12600 nid = cfg->speaker_pins[0];
12601 if (nid) {
12602 if (!cfg->line_out_pins[0]) {
12603 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12604 "Speaker Playback Volume",
12605 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12606 HDA_OUTPUT));
12607 if (err < 0)
12608 return err;
12609 }
12610 if (nid == 0x16) {
12611 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12612 "Speaker Playback Switch",
12613 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12614 HDA_OUTPUT));
12615 if (err < 0)
12616 return err;
12617 } else {
12618 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12619 "Speaker Playback Switch",
12620 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12621 HDA_OUTPUT));
12622 if (err < 0)
12623 return err;
12624 }
12625 }
12626 nid = cfg->hp_pins[0];
12627 if (nid) {
12628 /* spec->multiout.hp_nid = 2; */
12629 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12630 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12631 "Headphone Playback Volume",
12632 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12633 HDA_OUTPUT));
12634 if (err < 0)
12635 return err;
12636 }
12637 if (nid == 0x16) {
12638 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12639 "Headphone Playback Switch",
12640 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12641 HDA_OUTPUT));
12642 if (err < 0)
12643 return err;
12644 } else {
12645 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12646 "Headphone Playback Switch",
12647 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12648 HDA_OUTPUT));
12649 if (err < 0)
12650 return err;
12651 }
12652 }
12653 return 0;
12654}
12655
Takashi Iwaiee956e02008-10-31 17:16:31 +010012656static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12657 const struct auto_pin_cfg *cfg)
12658{
12659 int err;
12660
12661 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12662 if (err < 0)
12663 return err;
12664 /* digital-mic input pin is excluded in alc880_auto_create..()
12665 * because it's under 0x18
12666 */
12667 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12668 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012669 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012670 imux->items[imux->num_items].label = "Int Mic";
12671 imux->items[imux->num_items].index = 0x05;
12672 imux->num_items++;
12673 }
12674 return 0;
12675}
Kailang Yangf6a92242007-12-13 16:52:54 +010012676
12677#ifdef CONFIG_SND_HDA_POWER_SAVE
12678#define alc269_loopbacks alc880_loopbacks
12679#endif
12680
12681/* pcm configuration: identiacal with ALC880 */
12682#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12683#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12684#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12685#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12686
12687/*
12688 * BIOS auto configuration
12689 */
12690static int alc269_parse_auto_config(struct hda_codec *codec)
12691{
12692 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012693 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012694 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12695
12696 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12697 alc269_ignore);
12698 if (err < 0)
12699 return err;
12700
12701 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12702 if (err < 0)
12703 return err;
12704 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12705 if (err < 0)
12706 return err;
12707
12708 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12709
12710 if (spec->autocfg.dig_out_pin)
12711 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12712
Takashi Iwai603c4012008-07-30 15:01:44 +020012713 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012714 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012715
Takashi Iwaid88897e2008-10-31 15:01:37 +010012716 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012717 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012718 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012719 /* set default input source */
12720 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12721 0, AC_VERB_SET_CONNECT_SEL,
12722 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012723
12724 err = alc_auto_add_mic_boost(codec);
12725 if (err < 0)
12726 return err;
12727
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012728 if (!spec->cap_mixer)
12729 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012730
Takashi Iwaie044c392008-10-27 16:56:24 +010012731 store_pin_configs(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012732 return 1;
12733}
12734
12735#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12736#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12737#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12738
12739
12740/* init callback for auto-configuration model -- overriding the default init */
12741static void alc269_auto_init(struct hda_codec *codec)
12742{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012743 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012744 alc269_auto_init_multi_out(codec);
12745 alc269_auto_init_hp_out(codec);
12746 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012747 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012748 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012749}
12750
12751/*
12752 * configuration and preset
12753 */
12754static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012755 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012756 [ALC269_QUANTA_FL1] = "quanta",
12757 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012758 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012759 [ALC269_FUJITSU] = "fujitsu",
12760 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012761};
12762
12763static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012764 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012765 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12766 ALC269_ASUS_EEEPC_P703),
12767 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12768 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012769 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12770 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012771 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012772 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012773 {}
12774};
12775
12776static struct alc_config_preset alc269_presets[] = {
12777 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012778 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012779 .init_verbs = { alc269_init_verbs },
12780 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12781 .dac_nids = alc269_dac_nids,
12782 .hp_nid = 0x03,
12783 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12784 .channel_mode = alc269_modes,
12785 .input_mux = &alc269_capture_source,
12786 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012787 [ALC269_QUANTA_FL1] = {
12788 .mixers = { alc269_quanta_fl1_mixer },
12789 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12790 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12791 .dac_nids = alc269_dac_nids,
12792 .hp_nid = 0x03,
12793 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12794 .channel_mode = alc269_modes,
12795 .input_mux = &alc269_capture_source,
12796 .unsol_event = alc269_quanta_fl1_unsol_event,
12797 .init_hook = alc269_quanta_fl1_init_hook,
12798 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012799 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012800 .mixers = { alc269_eeepc_mixer },
12801 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012802 .init_verbs = { alc269_init_verbs,
12803 alc269_eeepc_amic_init_verbs },
12804 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12805 .dac_nids = alc269_dac_nids,
12806 .hp_nid = 0x03,
12807 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12808 .channel_mode = alc269_modes,
12809 .input_mux = &alc269_eeepc_amic_capture_source,
12810 .unsol_event = alc269_eeepc_amic_unsol_event,
12811 .init_hook = alc269_eeepc_amic_inithook,
12812 },
12813 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012814 .mixers = { alc269_eeepc_mixer },
12815 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012816 .init_verbs = { alc269_init_verbs,
12817 alc269_eeepc_dmic_init_verbs },
12818 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12819 .dac_nids = alc269_dac_nids,
12820 .hp_nid = 0x03,
12821 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12822 .channel_mode = alc269_modes,
12823 .input_mux = &alc269_eeepc_dmic_capture_source,
12824 .unsol_event = alc269_eeepc_dmic_unsol_event,
12825 .init_hook = alc269_eeepc_dmic_inithook,
12826 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012827 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012828 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012829 .cap_mixer = alc269_epc_capture_mixer,
12830 .init_verbs = { alc269_init_verbs,
12831 alc269_eeepc_dmic_init_verbs },
12832 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12833 .dac_nids = alc269_dac_nids,
12834 .hp_nid = 0x03,
12835 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12836 .channel_mode = alc269_modes,
12837 .input_mux = &alc269_eeepc_dmic_capture_source,
12838 .unsol_event = alc269_eeepc_dmic_unsol_event,
12839 .init_hook = alc269_eeepc_dmic_inithook,
12840 },
Tony Vroon64154832008-11-06 15:08:49 +000012841 [ALC269_LIFEBOOK] = {
12842 .mixers = { alc269_lifebook_mixer },
12843 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12844 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12845 .dac_nids = alc269_dac_nids,
12846 .hp_nid = 0x03,
12847 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12848 .channel_mode = alc269_modes,
12849 .input_mux = &alc269_capture_source,
12850 .unsol_event = alc269_lifebook_unsol_event,
12851 .init_hook = alc269_lifebook_init_hook,
12852 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012853};
12854
12855static int patch_alc269(struct hda_codec *codec)
12856{
12857 struct alc_spec *spec;
12858 int board_config;
12859 int err;
12860
12861 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12862 if (spec == NULL)
12863 return -ENOMEM;
12864
12865 codec->spec = spec;
12866
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012867 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12868
Kailang Yangf6a92242007-12-13 16:52:54 +010012869 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12870 alc269_models,
12871 alc269_cfg_tbl);
12872
12873 if (board_config < 0) {
12874 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12875 "trying auto-probe from BIOS...\n");
12876 board_config = ALC269_AUTO;
12877 }
12878
12879 if (board_config == ALC269_AUTO) {
12880 /* automatic parse from the BIOS config */
12881 err = alc269_parse_auto_config(codec);
12882 if (err < 0) {
12883 alc_free(codec);
12884 return err;
12885 } else if (!err) {
12886 printk(KERN_INFO
12887 "hda_codec: Cannot set up configuration "
12888 "from BIOS. Using base mode...\n");
12889 board_config = ALC269_BASIC;
12890 }
12891 }
12892
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012893 err = snd_hda_attach_beep_device(codec, 0x1);
12894 if (err < 0) {
12895 alc_free(codec);
12896 return err;
12897 }
12898
Kailang Yangf6a92242007-12-13 16:52:54 +010012899 if (board_config != ALC269_AUTO)
12900 setup_preset(spec, &alc269_presets[board_config]);
12901
12902 spec->stream_name_analog = "ALC269 Analog";
12903 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12904 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12905
12906 spec->stream_name_digital = "ALC269 Digital";
12907 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12908 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12909
12910 spec->adc_nids = alc269_adc_nids;
12911 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012912 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012913 if (!spec->cap_mixer)
12914 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012915 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010012916
12917 codec->patch_ops = alc_patch_ops;
12918 if (board_config == ALC269_AUTO)
12919 spec->init_hook = alc269_auto_init;
12920#ifdef CONFIG_SND_HDA_POWER_SAVE
12921 if (!spec->loopback.amplist)
12922 spec->loopback.amplist = alc269_loopbacks;
12923#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010012924 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010012925
12926 return 0;
12927}
12928
12929/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012930 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12931 */
12932
12933/*
12934 * set the path ways for 2 channel output
12935 * need to set the codec line out and mic 1 pin widgets to inputs
12936 */
12937static struct hda_verb alc861_threestack_ch2_init[] = {
12938 /* set pin widget 1Ah (line in) for input */
12939 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012940 /* set pin widget 18h (mic1/2) for input, for mic also enable
12941 * the vref
12942 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012943 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12944
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012945 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12946#if 0
12947 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12948 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12949#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012950 { } /* end */
12951};
12952/*
12953 * 6ch mode
12954 * need to set the codec line out and mic 1 pin widgets to outputs
12955 */
12956static struct hda_verb alc861_threestack_ch6_init[] = {
12957 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12958 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12959 /* set pin widget 18h (mic1) for output (CLFE)*/
12960 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12961
12962 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012963 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012964
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012965 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12966#if 0
12967 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12968 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12969#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012970 { } /* end */
12971};
12972
12973static struct hda_channel_mode alc861_threestack_modes[2] = {
12974 { 2, alc861_threestack_ch2_init },
12975 { 6, alc861_threestack_ch6_init },
12976};
Takashi Iwai22309c32006-08-09 16:57:28 +020012977/* Set mic1 as input and unmute the mixer */
12978static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12979 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12980 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12981 { } /* end */
12982};
12983/* Set mic1 as output and mute mixer */
12984static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
12985 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12986 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12987 { } /* end */
12988};
12989
12990static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
12991 { 2, alc861_uniwill_m31_ch2_init },
12992 { 4, alc861_uniwill_m31_ch4_init },
12993};
Kailang Yangdf694da2005-12-05 19:42:22 +010012994
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012995/* Set mic1 and line-in as input and unmute the mixer */
12996static struct hda_verb alc861_asus_ch2_init[] = {
12997 /* set pin widget 1Ah (line in) for input */
12998 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012999 /* set pin widget 18h (mic1/2) for input, for mic also enable
13000 * the vref
13001 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013002 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13003
13004 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13005#if 0
13006 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13007 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13008#endif
13009 { } /* end */
13010};
13011/* Set mic1 nad line-in as output and mute mixer */
13012static struct hda_verb alc861_asus_ch6_init[] = {
13013 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13014 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13015 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13016 /* set pin widget 18h (mic1) for output (CLFE)*/
13017 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13018 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13019 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13020 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13021
13022 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13023#if 0
13024 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13025 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13026#endif
13027 { } /* end */
13028};
13029
13030static struct hda_channel_mode alc861_asus_modes[2] = {
13031 { 2, alc861_asus_ch2_init },
13032 { 6, alc861_asus_ch6_init },
13033};
13034
Kailang Yangdf694da2005-12-05 19:42:22 +010013035/* patch-ALC861 */
13036
13037static struct snd_kcontrol_new alc861_base_mixer[] = {
13038 /* output mixer control */
13039 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13040 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13041 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13042 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13043 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13044
13045 /*Input mixer control */
13046 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13047 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13048 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13049 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13050 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13051 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13052 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13053 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13054 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13055 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013056
Kailang Yangdf694da2005-12-05 19:42:22 +010013057 { } /* end */
13058};
13059
13060static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13061 /* output mixer control */
13062 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13063 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13064 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13065 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13066 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13067
13068 /* Input mixer control */
13069 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13070 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13071 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13072 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13073 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13074 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13076 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13077 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13078 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013079
Kailang Yangdf694da2005-12-05 19:42:22 +010013080 {
13081 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13082 .name = "Channel Mode",
13083 .info = alc_ch_mode_info,
13084 .get = alc_ch_mode_get,
13085 .put = alc_ch_mode_put,
13086 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13087 },
13088 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013089};
13090
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013091static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013092 /* output mixer control */
13093 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13094 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13095 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013096
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013097 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013098};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013099
Takashi Iwai22309c32006-08-09 16:57:28 +020013100static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13101 /* output mixer control */
13102 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13103 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13104 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13105 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13106 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13107
13108 /* Input mixer control */
13109 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13110 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13111 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13112 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13113 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13114 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13115 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13116 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13117 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13118 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013119
Takashi Iwai22309c32006-08-09 16:57:28 +020013120 {
13121 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13122 .name = "Channel Mode",
13123 .info = alc_ch_mode_info,
13124 .get = alc_ch_mode_get,
13125 .put = alc_ch_mode_put,
13126 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13127 },
13128 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013129};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013130
13131static struct snd_kcontrol_new alc861_asus_mixer[] = {
13132 /* output mixer control */
13133 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13134 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13135 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13136 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13137 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13138
13139 /* Input mixer control */
13140 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13141 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13142 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13143 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13144 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13145 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13146 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13147 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13148 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013149 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13150
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013151 {
13152 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13153 .name = "Channel Mode",
13154 .info = alc_ch_mode_info,
13155 .get = alc_ch_mode_get,
13156 .put = alc_ch_mode_put,
13157 .private_value = ARRAY_SIZE(alc861_asus_modes),
13158 },
13159 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013160};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013161
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013162/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013163static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013164 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13165 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013166 { }
13167};
13168
Kailang Yangdf694da2005-12-05 19:42:22 +010013169/*
13170 * generic initialization of ADC, input mixers and output mixers
13171 */
13172static struct hda_verb alc861_base_init_verbs[] = {
13173 /*
13174 * Unmute ADC0 and set the default input to mic-in
13175 */
13176 /* port-A for surround (rear panel) */
13177 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13178 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13179 /* port-B for mic-in (rear panel) with vref */
13180 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13181 /* port-C for line-in (rear panel) */
13182 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13183 /* port-D for Front */
13184 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13185 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13186 /* port-E for HP out (front panel) */
13187 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13188 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013189 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013190 /* port-F for mic-in (front panel) with vref */
13191 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13192 /* port-G for CLFE (rear panel) */
13193 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13194 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13195 /* port-H for side (rear panel) */
13196 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13197 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13198 /* CD-in */
13199 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13200 /* route front mic to ADC1*/
13201 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13202 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013203
Kailang Yangdf694da2005-12-05 19:42:22 +010013204 /* Unmute DAC0~3 & spdif out*/
13205 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13206 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13207 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13208 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13209 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013210
Kailang Yangdf694da2005-12-05 19:42:22 +010013211 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13212 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13213 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13214 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13215 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013216
Kailang Yangdf694da2005-12-05 19:42:22 +010013217 /* Unmute Stereo Mixer 15 */
13218 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13219 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013222
13223 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13224 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13225 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13226 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13227 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13228 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13229 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13230 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013231 /* hp used DAC 3 (Front) */
13232 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013233 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13234
13235 { }
13236};
13237
13238static struct hda_verb alc861_threestack_init_verbs[] = {
13239 /*
13240 * Unmute ADC0 and set the default input to mic-in
13241 */
13242 /* port-A for surround (rear panel) */
13243 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13244 /* port-B for mic-in (rear panel) with vref */
13245 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13246 /* port-C for line-in (rear panel) */
13247 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13248 /* port-D for Front */
13249 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13250 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13251 /* port-E for HP out (front panel) */
13252 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13253 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013254 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013255 /* port-F for mic-in (front panel) with vref */
13256 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13257 /* port-G for CLFE (rear panel) */
13258 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13259 /* port-H for side (rear panel) */
13260 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13261 /* CD-in */
13262 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13263 /* route front mic to ADC1*/
13264 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13265 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13266 /* Unmute DAC0~3 & spdif out*/
13267 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13268 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13269 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13270 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13271 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013272
Kailang Yangdf694da2005-12-05 19:42:22 +010013273 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13274 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13275 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13276 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13277 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013278
Kailang Yangdf694da2005-12-05 19:42:22 +010013279 /* Unmute Stereo Mixer 15 */
13280 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13281 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13282 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013284
13285 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13286 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13287 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13288 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13289 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13290 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13291 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13292 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013293 /* hp used DAC 3 (Front) */
13294 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013295 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13296 { }
13297};
Takashi Iwai22309c32006-08-09 16:57:28 +020013298
13299static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13300 /*
13301 * Unmute ADC0 and set the default input to mic-in
13302 */
13303 /* port-A for surround (rear panel) */
13304 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13305 /* port-B for mic-in (rear panel) with vref */
13306 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13307 /* port-C for line-in (rear panel) */
13308 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13309 /* port-D for Front */
13310 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13311 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13312 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013313 /* this has to be set to VREF80 */
13314 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013315 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013316 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013317 /* port-F for mic-in (front panel) with vref */
13318 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13319 /* port-G for CLFE (rear panel) */
13320 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13321 /* port-H for side (rear panel) */
13322 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13323 /* CD-in */
13324 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13325 /* route front mic to ADC1*/
13326 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13327 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13328 /* Unmute DAC0~3 & spdif out*/
13329 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13330 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13331 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13332 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013334
Takashi Iwai22309c32006-08-09 16:57:28 +020013335 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13336 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13337 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13338 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13339 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013340
Takashi Iwai22309c32006-08-09 16:57:28 +020013341 /* Unmute Stereo Mixer 15 */
13342 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13343 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13344 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013345 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013346
13347 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13348 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13349 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13350 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13351 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13352 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13353 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13354 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013355 /* hp used DAC 3 (Front) */
13356 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013357 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13358 { }
13359};
13360
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013361static struct hda_verb alc861_asus_init_verbs[] = {
13362 /*
13363 * Unmute ADC0 and set the default input to mic-in
13364 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013365 /* port-A for surround (rear panel)
13366 * according to codec#0 this is the HP jack
13367 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013368 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13369 /* route front PCM to HP */
13370 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13371 /* port-B for mic-in (rear panel) with vref */
13372 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13373 /* port-C for line-in (rear panel) */
13374 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13375 /* port-D for Front */
13376 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13377 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13378 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013379 /* this has to be set to VREF80 */
13380 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013381 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013382 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013383 /* port-F for mic-in (front panel) with vref */
13384 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13385 /* port-G for CLFE (rear panel) */
13386 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13387 /* port-H for side (rear panel) */
13388 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13389 /* CD-in */
13390 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13391 /* route front mic to ADC1*/
13392 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13393 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13394 /* Unmute DAC0~3 & spdif out*/
13395 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13396 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13397 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13398 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13399 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13400 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13401 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13402 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13403 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13404 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013405
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013406 /* Unmute Stereo Mixer 15 */
13407 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13408 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13409 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013410 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013411
13412 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13413 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13414 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13415 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13416 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13417 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13418 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13419 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013420 /* hp used DAC 3 (Front) */
13421 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013422 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13423 { }
13424};
13425
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013426/* additional init verbs for ASUS laptops */
13427static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13428 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13429 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13430 { }
13431};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013432
Kailang Yangdf694da2005-12-05 19:42:22 +010013433/*
13434 * generic initialization of ADC, input mixers and output mixers
13435 */
13436static struct hda_verb alc861_auto_init_verbs[] = {
13437 /*
13438 * Unmute ADC0 and set the default input to mic-in
13439 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013440 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013441 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013442
Kailang Yangdf694da2005-12-05 19:42:22 +010013443 /* Unmute DAC0~3 & spdif out*/
13444 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13445 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13446 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13447 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13448 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013449
Kailang Yangdf694da2005-12-05 19:42:22 +010013450 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13451 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13452 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13453 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13454 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013455
Kailang Yangdf694da2005-12-05 19:42:22 +010013456 /* Unmute Stereo Mixer 15 */
13457 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13458 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13459 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13460 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13461
13462 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13463 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13464 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13465 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13466 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13467 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13468 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13469 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13470
13471 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13472 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013473 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13474 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013475 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13476 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013477 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13478 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013479
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013480 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013481
13482 { }
13483};
13484
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013485static struct hda_verb alc861_toshiba_init_verbs[] = {
13486 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013487
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013488 { }
13489};
13490
13491/* toggle speaker-output according to the hp-jack state */
13492static void alc861_toshiba_automute(struct hda_codec *codec)
13493{
13494 unsigned int present;
13495
13496 present = snd_hda_codec_read(codec, 0x0f, 0,
13497 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013498 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13499 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13500 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13501 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013502}
13503
13504static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13505 unsigned int res)
13506{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013507 if ((res >> 26) == ALC880_HP_EVENT)
13508 alc861_toshiba_automute(codec);
13509}
13510
Kailang Yangdf694da2005-12-05 19:42:22 +010013511/* pcm configuration: identiacal with ALC880 */
13512#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13513#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13514#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13515#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13516
13517
13518#define ALC861_DIGOUT_NID 0x07
13519
13520static struct hda_channel_mode alc861_8ch_modes[1] = {
13521 { 8, NULL }
13522};
13523
13524static hda_nid_t alc861_dac_nids[4] = {
13525 /* front, surround, clfe, side */
13526 0x03, 0x06, 0x05, 0x04
13527};
13528
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013529static hda_nid_t alc660_dac_nids[3] = {
13530 /* front, clfe, surround */
13531 0x03, 0x05, 0x06
13532};
13533
Kailang Yangdf694da2005-12-05 19:42:22 +010013534static hda_nid_t alc861_adc_nids[1] = {
13535 /* ADC0-2 */
13536 0x08,
13537};
13538
13539static struct hda_input_mux alc861_capture_source = {
13540 .num_items = 5,
13541 .items = {
13542 { "Mic", 0x0 },
13543 { "Front Mic", 0x3 },
13544 { "Line", 0x1 },
13545 { "CD", 0x4 },
13546 { "Mixer", 0x5 },
13547 },
13548};
13549
13550/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013551static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13552 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013553{
13554 int i;
13555 hda_nid_t nid;
13556
13557 spec->multiout.dac_nids = spec->private_dac_nids;
13558 for (i = 0; i < cfg->line_outs; i++) {
13559 nid = cfg->line_out_pins[i];
13560 if (nid) {
13561 if (i >= ARRAY_SIZE(alc861_dac_nids))
13562 continue;
13563 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13564 }
13565 }
13566 spec->multiout.num_dacs = cfg->line_outs;
13567 return 0;
13568}
13569
13570/* add playback controls from the parsed DAC table */
13571static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13572 const struct auto_pin_cfg *cfg)
13573{
13574 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013575 static const char *chname[4] = {
13576 "Front", "Surround", NULL /*CLFE*/, "Side"
13577 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013578 hda_nid_t nid;
13579 int i, idx, err;
13580
13581 for (i = 0; i < cfg->line_outs; i++) {
13582 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013583 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013584 continue;
13585 if (nid == 0x05) {
13586 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013587 err = add_control(spec, ALC_CTL_BIND_MUTE,
13588 "Center Playback Switch",
13589 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13590 HDA_OUTPUT));
13591 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013592 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013593 err = add_control(spec, ALC_CTL_BIND_MUTE,
13594 "LFE Playback Switch",
13595 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13596 HDA_OUTPUT));
13597 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013598 return err;
13599 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013600 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13601 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013602 if (nid == alc861_dac_nids[idx])
13603 break;
13604 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013605 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13606 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13607 HDA_OUTPUT));
13608 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013609 return err;
13610 }
13611 }
13612 return 0;
13613}
13614
13615static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13616{
13617 int err;
13618 hda_nid_t nid;
13619
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013620 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013621 return 0;
13622
13623 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13624 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013625 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13626 "Headphone Playback Switch",
13627 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13628 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013629 return err;
13630 spec->multiout.hp_nid = nid;
13631 }
13632 return 0;
13633}
13634
13635/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013636static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13637 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013638{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013639 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013640 int i, err, idx, idx1;
13641
13642 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013643 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013644 case 0x0c:
13645 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013646 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013647 break;
13648 case 0x0f:
13649 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013650 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013651 break;
13652 case 0x0d:
13653 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013654 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013655 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013656 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013657 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013658 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013659 break;
13660 case 0x11:
13661 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013662 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013663 break;
13664 default:
13665 continue;
13666 }
13667
Takashi Iwai4a471b72005-12-07 13:56:29 +010013668 err = new_analog_input(spec, cfg->input_pins[i],
13669 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013670 if (err < 0)
13671 return err;
13672
Takashi Iwai4a471b72005-12-07 13:56:29 +010013673 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013674 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013675 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013676 }
13677 return 0;
13678}
13679
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013680static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13681 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013682 int pin_type, int dac_idx)
13683{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013684 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13685 pin_type);
13686 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13687 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013688}
13689
13690static void alc861_auto_init_multi_out(struct hda_codec *codec)
13691{
13692 struct alc_spec *spec = codec->spec;
13693 int i;
13694
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013695 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013696 for (i = 0; i < spec->autocfg.line_outs; i++) {
13697 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013698 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013699 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013700 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013701 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013702 }
13703}
13704
13705static void alc861_auto_init_hp_out(struct hda_codec *codec)
13706{
13707 struct alc_spec *spec = codec->spec;
13708 hda_nid_t pin;
13709
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013710 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013711 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013712 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13713 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013714 pin = spec->autocfg.speaker_pins[0];
13715 if (pin)
13716 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013717}
13718
13719static void alc861_auto_init_analog_input(struct hda_codec *codec)
13720{
13721 struct alc_spec *spec = codec->spec;
13722 int i;
13723
13724 for (i = 0; i < AUTO_PIN_LAST; i++) {
13725 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013726 if (nid >= 0x0c && nid <= 0x11) {
13727 snd_hda_codec_write(codec, nid, 0,
13728 AC_VERB_SET_PIN_WIDGET_CONTROL,
13729 i <= AUTO_PIN_FRONT_MIC ?
13730 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013731 }
13732 }
13733}
13734
13735/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013736/* return 1 if successful, 0 if the proper config is not found,
13737 * or a negative error code
13738 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013739static int alc861_parse_auto_config(struct hda_codec *codec)
13740{
13741 struct alc_spec *spec = codec->spec;
13742 int err;
13743 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13744
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013745 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13746 alc861_ignore);
13747 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013748 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013749 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013750 return 0; /* can't find valid BIOS pin config */
13751
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013752 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13753 if (err < 0)
13754 return err;
13755 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13756 if (err < 0)
13757 return err;
13758 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13759 if (err < 0)
13760 return err;
13761 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13762 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013763 return err;
13764
13765 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13766
13767 if (spec->autocfg.dig_out_pin)
13768 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13769
Takashi Iwai603c4012008-07-30 15:01:44 +020013770 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013771 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013772
Takashi Iwaid88897e2008-10-31 15:01:37 +010013773 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013774
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013775 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013776 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013777
13778 spec->adc_nids = alc861_adc_nids;
13779 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013780 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013781
Takashi Iwaie044c392008-10-27 16:56:24 +010013782 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013783 return 1;
13784}
13785
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013786/* additional initialization for auto-configuration model */
13787static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013788{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013789 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013790 alc861_auto_init_multi_out(codec);
13791 alc861_auto_init_hp_out(codec);
13792 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013793 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013794 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013795}
13796
Takashi Iwaicb53c622007-08-10 17:21:45 +020013797#ifdef CONFIG_SND_HDA_POWER_SAVE
13798static struct hda_amp_list alc861_loopbacks[] = {
13799 { 0x15, HDA_INPUT, 0 },
13800 { 0x15, HDA_INPUT, 1 },
13801 { 0x15, HDA_INPUT, 2 },
13802 { 0x15, HDA_INPUT, 3 },
13803 { } /* end */
13804};
13805#endif
13806
Kailang Yangdf694da2005-12-05 19:42:22 +010013807
13808/*
13809 * configuration and preset
13810 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013811static const char *alc861_models[ALC861_MODEL_LAST] = {
13812 [ALC861_3ST] = "3stack",
13813 [ALC660_3ST] = "3stack-660",
13814 [ALC861_3ST_DIG] = "3stack-dig",
13815 [ALC861_6ST_DIG] = "6stack-dig",
13816 [ALC861_UNIWILL_M31] = "uniwill-m31",
13817 [ALC861_TOSHIBA] = "toshiba",
13818 [ALC861_ASUS] = "asus",
13819 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13820 [ALC861_AUTO] = "auto",
13821};
13822
13823static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013824 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013825 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13826 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13827 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013828 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013829 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013830 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013831 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13832 * Any other models that need this preset?
13833 */
13834 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013835 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13836 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013837 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13838 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13839 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13840 /* FIXME: the below seems conflict */
13841 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13842 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13843 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013844 {}
13845};
13846
13847static struct alc_config_preset alc861_presets[] = {
13848 [ALC861_3ST] = {
13849 .mixers = { alc861_3ST_mixer },
13850 .init_verbs = { alc861_threestack_init_verbs },
13851 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13852 .dac_nids = alc861_dac_nids,
13853 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13854 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013855 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013856 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13857 .adc_nids = alc861_adc_nids,
13858 .input_mux = &alc861_capture_source,
13859 },
13860 [ALC861_3ST_DIG] = {
13861 .mixers = { alc861_base_mixer },
13862 .init_verbs = { alc861_threestack_init_verbs },
13863 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13864 .dac_nids = alc861_dac_nids,
13865 .dig_out_nid = ALC861_DIGOUT_NID,
13866 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13867 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013868 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013869 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13870 .adc_nids = alc861_adc_nids,
13871 .input_mux = &alc861_capture_source,
13872 },
13873 [ALC861_6ST_DIG] = {
13874 .mixers = { alc861_base_mixer },
13875 .init_verbs = { alc861_base_init_verbs },
13876 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13877 .dac_nids = alc861_dac_nids,
13878 .dig_out_nid = ALC861_DIGOUT_NID,
13879 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13880 .channel_mode = alc861_8ch_modes,
13881 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13882 .adc_nids = alc861_adc_nids,
13883 .input_mux = &alc861_capture_source,
13884 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013885 [ALC660_3ST] = {
13886 .mixers = { alc861_3ST_mixer },
13887 .init_verbs = { alc861_threestack_init_verbs },
13888 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13889 .dac_nids = alc660_dac_nids,
13890 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13891 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013892 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013893 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13894 .adc_nids = alc861_adc_nids,
13895 .input_mux = &alc861_capture_source,
13896 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013897 [ALC861_UNIWILL_M31] = {
13898 .mixers = { alc861_uniwill_m31_mixer },
13899 .init_verbs = { alc861_uniwill_m31_init_verbs },
13900 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13901 .dac_nids = alc861_dac_nids,
13902 .dig_out_nid = ALC861_DIGOUT_NID,
13903 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13904 .channel_mode = alc861_uniwill_m31_modes,
13905 .need_dac_fix = 1,
13906 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13907 .adc_nids = alc861_adc_nids,
13908 .input_mux = &alc861_capture_source,
13909 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013910 [ALC861_TOSHIBA] = {
13911 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013912 .init_verbs = { alc861_base_init_verbs,
13913 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013914 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13915 .dac_nids = alc861_dac_nids,
13916 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13917 .channel_mode = alc883_3ST_2ch_modes,
13918 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13919 .adc_nids = alc861_adc_nids,
13920 .input_mux = &alc861_capture_source,
13921 .unsol_event = alc861_toshiba_unsol_event,
13922 .init_hook = alc861_toshiba_automute,
13923 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013924 [ALC861_ASUS] = {
13925 .mixers = { alc861_asus_mixer },
13926 .init_verbs = { alc861_asus_init_verbs },
13927 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13928 .dac_nids = alc861_dac_nids,
13929 .dig_out_nid = ALC861_DIGOUT_NID,
13930 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13931 .channel_mode = alc861_asus_modes,
13932 .need_dac_fix = 1,
13933 .hp_nid = 0x06,
13934 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13935 .adc_nids = alc861_adc_nids,
13936 .input_mux = &alc861_capture_source,
13937 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013938 [ALC861_ASUS_LAPTOP] = {
13939 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13940 .init_verbs = { alc861_asus_init_verbs,
13941 alc861_asus_laptop_init_verbs },
13942 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13943 .dac_nids = alc861_dac_nids,
13944 .dig_out_nid = ALC861_DIGOUT_NID,
13945 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13946 .channel_mode = alc883_3ST_2ch_modes,
13947 .need_dac_fix = 1,
13948 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13949 .adc_nids = alc861_adc_nids,
13950 .input_mux = &alc861_capture_source,
13951 },
13952};
Kailang Yangdf694da2005-12-05 19:42:22 +010013953
13954
13955static int patch_alc861(struct hda_codec *codec)
13956{
13957 struct alc_spec *spec;
13958 int board_config;
13959 int err;
13960
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013961 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013962 if (spec == NULL)
13963 return -ENOMEM;
13964
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013965 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013966
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013967 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13968 alc861_models,
13969 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013970
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013971 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013972 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13973 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013974 board_config = ALC861_AUTO;
13975 }
13976
13977 if (board_config == ALC861_AUTO) {
13978 /* automatic parse from the BIOS config */
13979 err = alc861_parse_auto_config(codec);
13980 if (err < 0) {
13981 alc_free(codec);
13982 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013983 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013984 printk(KERN_INFO
13985 "hda_codec: Cannot set up configuration "
13986 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013987 board_config = ALC861_3ST_DIG;
13988 }
13989 }
13990
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013991 err = snd_hda_attach_beep_device(codec, 0x23);
13992 if (err < 0) {
13993 alc_free(codec);
13994 return err;
13995 }
13996
Kailang Yangdf694da2005-12-05 19:42:22 +010013997 if (board_config != ALC861_AUTO)
13998 setup_preset(spec, &alc861_presets[board_config]);
13999
14000 spec->stream_name_analog = "ALC861 Analog";
14001 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14002 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14003
14004 spec->stream_name_digital = "ALC861 Digital";
14005 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14006 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14007
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014008 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14009
Takashi Iwai2134ea42008-01-10 16:53:55 +010014010 spec->vmaster_nid = 0x03;
14011
Kailang Yangdf694da2005-12-05 19:42:22 +010014012 codec->patch_ops = alc_patch_ops;
14013 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014014 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014015#ifdef CONFIG_SND_HDA_POWER_SAVE
14016 if (!spec->loopback.amplist)
14017 spec->loopback.amplist = alc861_loopbacks;
14018#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014019 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014020
Kailang Yangdf694da2005-12-05 19:42:22 +010014021 return 0;
14022}
14023
14024/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014025 * ALC861-VD support
14026 *
14027 * Based on ALC882
14028 *
14029 * In addition, an independent DAC
14030 */
14031#define ALC861VD_DIGOUT_NID 0x06
14032
14033static hda_nid_t alc861vd_dac_nids[4] = {
14034 /* front, surr, clfe, side surr */
14035 0x02, 0x03, 0x04, 0x05
14036};
14037
14038/* dac_nids for ALC660vd are in a different order - according to
14039 * Realtek's driver.
14040 * This should probably tesult in a different mixer for 6stack models
14041 * of ALC660vd codecs, but for now there is only 3stack mixer
14042 * - and it is the same as in 861vd.
14043 * adc_nids in ALC660vd are (is) the same as in 861vd
14044 */
14045static hda_nid_t alc660vd_dac_nids[3] = {
14046 /* front, rear, clfe, rear_surr */
14047 0x02, 0x04, 0x03
14048};
14049
14050static hda_nid_t alc861vd_adc_nids[1] = {
14051 /* ADC0 */
14052 0x09,
14053};
14054
Takashi Iwaie1406342008-02-11 18:32:32 +010014055static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14056
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014057/* input MUX */
14058/* FIXME: should be a matrix-type input source selection */
14059static struct hda_input_mux alc861vd_capture_source = {
14060 .num_items = 4,
14061 .items = {
14062 { "Mic", 0x0 },
14063 { "Front Mic", 0x1 },
14064 { "Line", 0x2 },
14065 { "CD", 0x4 },
14066 },
14067};
14068
Kailang Yang272a5272007-05-14 11:00:38 +020014069static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014070 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014071 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014072 { "Ext Mic", 0x0 },
14073 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014074 },
14075};
14076
Kailang Yangd1a991a2007-08-15 16:21:59 +020014077static struct hda_input_mux alc861vd_hp_capture_source = {
14078 .num_items = 2,
14079 .items = {
14080 { "Front Mic", 0x0 },
14081 { "ATAPI Mic", 0x1 },
14082 },
14083};
14084
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014085/*
14086 * 2ch mode
14087 */
14088static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14089 { 2, NULL }
14090};
14091
14092/*
14093 * 6ch mode
14094 */
14095static struct hda_verb alc861vd_6stack_ch6_init[] = {
14096 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14097 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14098 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14099 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14100 { } /* end */
14101};
14102
14103/*
14104 * 8ch mode
14105 */
14106static struct hda_verb alc861vd_6stack_ch8_init[] = {
14107 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14108 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14109 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14110 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14111 { } /* end */
14112};
14113
14114static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14115 { 6, alc861vd_6stack_ch6_init },
14116 { 8, alc861vd_6stack_ch8_init },
14117};
14118
14119static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14120 {
14121 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14122 .name = "Channel Mode",
14123 .info = alc_ch_mode_info,
14124 .get = alc_ch_mode_get,
14125 .put = alc_ch_mode_put,
14126 },
14127 { } /* end */
14128};
14129
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014130/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14131 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14132 */
14133static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14134 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14135 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14136
14137 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14138 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14139
14140 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14141 HDA_OUTPUT),
14142 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14143 HDA_OUTPUT),
14144 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14145 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14146
14147 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14148 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14149
14150 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14151
14152 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14153 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14155
14156 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14157 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14158 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14159
14160 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14161 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14162
14163 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14164 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14165
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014166 { } /* end */
14167};
14168
14169static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14170 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14171 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14172
14173 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14174
14175 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14177 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14178
14179 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14180 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14181 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14182
14183 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14184 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14185
14186 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14187 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14188
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014189 { } /* end */
14190};
14191
Kailang Yangbdd148a2007-05-08 15:19:08 +020014192static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14193 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14194 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14195 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14196
14197 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14198
14199 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14200 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14202
14203 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14204 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14205 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14206
14207 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14208 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14209
14210 { } /* end */
14211};
14212
Tobin Davisb419f342008-03-07 11:57:51 +010014213/* Pin assignment: Speaker=0x14, HP = 0x15,
14214 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014215 */
14216static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014217 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14218 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014219 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14220 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014221 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14222 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14223 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14224 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14225 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14226 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014227 { } /* end */
14228};
14229
Kailang Yangd1a991a2007-08-15 16:21:59 +020014230/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14231 * Front Mic=0x18, ATAPI Mic = 0x19,
14232 */
14233static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14234 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14235 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14236 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14237 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14238 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14239 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14240 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14241 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014242
Kailang Yangd1a991a2007-08-15 16:21:59 +020014243 { } /* end */
14244};
14245
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014246/*
14247 * generic initialization of ADC, input mixers and output mixers
14248 */
14249static struct hda_verb alc861vd_volume_init_verbs[] = {
14250 /*
14251 * Unmute ADC0 and set the default input to mic-in
14252 */
14253 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14254 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14255
14256 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14257 * the analog-loopback mixer widget
14258 */
14259 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014260 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14261 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14263 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14264 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014265
14266 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14269 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014270 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014271
14272 /*
14273 * Set up output mixers (0x02 - 0x05)
14274 */
14275 /* set vol=0 to output mixers */
14276 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14277 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14278 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14279 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14280
14281 /* set up input amps for analog loopback */
14282 /* Amp Indices: DAC = 0, mixer = 1 */
14283 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14284 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14285 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14286 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14287 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14288 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14289 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14290 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14291
14292 { }
14293};
14294
14295/*
14296 * 3-stack pin configuration:
14297 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14298 */
14299static struct hda_verb alc861vd_3stack_init_verbs[] = {
14300 /*
14301 * Set pin mode and muting
14302 */
14303 /* set front pin widgets 0x14 for output */
14304 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14305 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14306 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14307
14308 /* Mic (rear) pin: input vref at 80% */
14309 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14310 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14311 /* Front Mic pin: input vref at 80% */
14312 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14313 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14314 /* Line In pin: input */
14315 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14316 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14317 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14318 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14319 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14320 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14321 /* CD pin widget for input */
14322 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14323
14324 { }
14325};
14326
14327/*
14328 * 6-stack pin configuration:
14329 */
14330static struct hda_verb alc861vd_6stack_init_verbs[] = {
14331 /*
14332 * Set pin mode and muting
14333 */
14334 /* set front pin widgets 0x14 for output */
14335 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14336 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14337 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14338
14339 /* Rear Pin: output 1 (0x0d) */
14340 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14341 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14342 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14343 /* CLFE Pin: output 2 (0x0e) */
14344 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14345 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14346 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14347 /* Side Pin: output 3 (0x0f) */
14348 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14349 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14350 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14351
14352 /* Mic (rear) pin: input vref at 80% */
14353 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14354 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14355 /* Front Mic pin: input vref at 80% */
14356 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14357 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14358 /* Line In pin: input */
14359 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14360 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14361 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14362 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14363 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14364 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14365 /* CD pin widget for input */
14366 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14367
14368 { }
14369};
14370
Kailang Yangbdd148a2007-05-08 15:19:08 +020014371static struct hda_verb alc861vd_eapd_verbs[] = {
14372 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14373 { }
14374};
14375
Kailang Yangf9423e72008-05-27 12:32:25 +020014376static struct hda_verb alc660vd_eapd_verbs[] = {
14377 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14378 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14379 { }
14380};
14381
Kailang Yangbdd148a2007-05-08 15:19:08 +020014382static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14384 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14385 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14386 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014387 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014388 {}
14389};
14390
14391/* toggle speaker-output according to the hp-jack state */
14392static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14393{
14394 unsigned int present;
14395 unsigned char bits;
14396
14397 present = snd_hda_codec_read(codec, 0x1b, 0,
14398 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014399 bits = present ? HDA_AMP_MUTE : 0;
14400 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14401 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014402}
14403
14404static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14405{
14406 unsigned int present;
14407 unsigned char bits;
14408
14409 present = snd_hda_codec_read(codec, 0x18, 0,
14410 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014411 bits = present ? HDA_AMP_MUTE : 0;
14412 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14413 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014414}
14415
14416static void alc861vd_lenovo_automute(struct hda_codec *codec)
14417{
14418 alc861vd_lenovo_hp_automute(codec);
14419 alc861vd_lenovo_mic_automute(codec);
14420}
14421
14422static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14423 unsigned int res)
14424{
14425 switch (res >> 26) {
14426 case ALC880_HP_EVENT:
14427 alc861vd_lenovo_hp_automute(codec);
14428 break;
14429 case ALC880_MIC_EVENT:
14430 alc861vd_lenovo_mic_automute(codec);
14431 break;
14432 }
14433}
14434
Kailang Yang272a5272007-05-14 11:00:38 +020014435static struct hda_verb alc861vd_dallas_verbs[] = {
14436 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14437 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14438 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14439 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14440
14441 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14442 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14443 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14444 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14445 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14446 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14447 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14448 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014449
Kailang Yang272a5272007-05-14 11:00:38 +020014450 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14451 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14452 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14453 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14454 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14455 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14456 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14457 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14458
14459 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14460 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14461 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14462 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14463 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14464 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14465 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14466 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14467
14468 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14470 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14471 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14472
14473 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014474 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014475 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14476
14477 { } /* end */
14478};
14479
14480/* toggle speaker-output according to the hp-jack state */
14481static void alc861vd_dallas_automute(struct hda_codec *codec)
14482{
14483 unsigned int present;
14484
14485 present = snd_hda_codec_read(codec, 0x15, 0,
14486 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014487 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14488 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014489}
14490
14491static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14492{
14493 if ((res >> 26) == ALC880_HP_EVENT)
14494 alc861vd_dallas_automute(codec);
14495}
14496
Takashi Iwaicb53c622007-08-10 17:21:45 +020014497#ifdef CONFIG_SND_HDA_POWER_SAVE
14498#define alc861vd_loopbacks alc880_loopbacks
14499#endif
14500
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014501/* pcm configuration: identiacal with ALC880 */
14502#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14503#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14504#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14505#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14506
14507/*
14508 * configuration and preset
14509 */
14510static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14511 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014512 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014513 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014514 [ALC861VD_3ST] = "3stack",
14515 [ALC861VD_3ST_DIG] = "3stack-digout",
14516 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014517 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014518 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014519 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014520 [ALC861VD_AUTO] = "auto",
14521};
14522
14523static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014524 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14525 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014526 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014527 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014528 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014529 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014530 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014531 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014532 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014533 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014534 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014535 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014536 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014537 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
14538 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020014539 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014540 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014541 {}
14542};
14543
14544static struct alc_config_preset alc861vd_presets[] = {
14545 [ALC660VD_3ST] = {
14546 .mixers = { alc861vd_3st_mixer },
14547 .init_verbs = { alc861vd_volume_init_verbs,
14548 alc861vd_3stack_init_verbs },
14549 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14550 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014551 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14552 .channel_mode = alc861vd_3stack_2ch_modes,
14553 .input_mux = &alc861vd_capture_source,
14554 },
Mike Crash6963f842007-06-25 12:12:51 +020014555 [ALC660VD_3ST_DIG] = {
14556 .mixers = { alc861vd_3st_mixer },
14557 .init_verbs = { alc861vd_volume_init_verbs,
14558 alc861vd_3stack_init_verbs },
14559 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14560 .dac_nids = alc660vd_dac_nids,
14561 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014562 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14563 .channel_mode = alc861vd_3stack_2ch_modes,
14564 .input_mux = &alc861vd_capture_source,
14565 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014566 [ALC861VD_3ST] = {
14567 .mixers = { alc861vd_3st_mixer },
14568 .init_verbs = { alc861vd_volume_init_verbs,
14569 alc861vd_3stack_init_verbs },
14570 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14571 .dac_nids = alc861vd_dac_nids,
14572 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14573 .channel_mode = alc861vd_3stack_2ch_modes,
14574 .input_mux = &alc861vd_capture_source,
14575 },
14576 [ALC861VD_3ST_DIG] = {
14577 .mixers = { alc861vd_3st_mixer },
14578 .init_verbs = { alc861vd_volume_init_verbs,
14579 alc861vd_3stack_init_verbs },
14580 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14581 .dac_nids = alc861vd_dac_nids,
14582 .dig_out_nid = ALC861VD_DIGOUT_NID,
14583 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14584 .channel_mode = alc861vd_3stack_2ch_modes,
14585 .input_mux = &alc861vd_capture_source,
14586 },
14587 [ALC861VD_6ST_DIG] = {
14588 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14589 .init_verbs = { alc861vd_volume_init_verbs,
14590 alc861vd_6stack_init_verbs },
14591 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14592 .dac_nids = alc861vd_dac_nids,
14593 .dig_out_nid = ALC861VD_DIGOUT_NID,
14594 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14595 .channel_mode = alc861vd_6stack_modes,
14596 .input_mux = &alc861vd_capture_source,
14597 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014598 [ALC861VD_LENOVO] = {
14599 .mixers = { alc861vd_lenovo_mixer },
14600 .init_verbs = { alc861vd_volume_init_verbs,
14601 alc861vd_3stack_init_verbs,
14602 alc861vd_eapd_verbs,
14603 alc861vd_lenovo_unsol_verbs },
14604 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14605 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014606 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14607 .channel_mode = alc861vd_3stack_2ch_modes,
14608 .input_mux = &alc861vd_capture_source,
14609 .unsol_event = alc861vd_lenovo_unsol_event,
14610 .init_hook = alc861vd_lenovo_automute,
14611 },
Kailang Yang272a5272007-05-14 11:00:38 +020014612 [ALC861VD_DALLAS] = {
14613 .mixers = { alc861vd_dallas_mixer },
14614 .init_verbs = { alc861vd_dallas_verbs },
14615 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14616 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014617 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14618 .channel_mode = alc861vd_3stack_2ch_modes,
14619 .input_mux = &alc861vd_dallas_capture_source,
14620 .unsol_event = alc861vd_dallas_unsol_event,
14621 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014622 },
14623 [ALC861VD_HP] = {
14624 .mixers = { alc861vd_hp_mixer },
14625 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14626 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14627 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014628 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014629 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14630 .channel_mode = alc861vd_3stack_2ch_modes,
14631 .input_mux = &alc861vd_hp_capture_source,
14632 .unsol_event = alc861vd_dallas_unsol_event,
14633 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014634 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014635 [ALC660VD_ASUS_V1S] = {
14636 .mixers = { alc861vd_lenovo_mixer },
14637 .init_verbs = { alc861vd_volume_init_verbs,
14638 alc861vd_3stack_init_verbs,
14639 alc861vd_eapd_verbs,
14640 alc861vd_lenovo_unsol_verbs },
14641 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14642 .dac_nids = alc660vd_dac_nids,
14643 .dig_out_nid = ALC861VD_DIGOUT_NID,
14644 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14645 .channel_mode = alc861vd_3stack_2ch_modes,
14646 .input_mux = &alc861vd_capture_source,
14647 .unsol_event = alc861vd_lenovo_unsol_event,
14648 .init_hook = alc861vd_lenovo_automute,
14649 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014650};
14651
14652/*
14653 * BIOS auto configuration
14654 */
14655static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14656 hda_nid_t nid, int pin_type, int dac_idx)
14657{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014658 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014659}
14660
14661static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14662{
14663 struct alc_spec *spec = codec->spec;
14664 int i;
14665
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014666 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014667 for (i = 0; i <= HDA_SIDE; i++) {
14668 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014669 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014670 if (nid)
14671 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014672 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014673 }
14674}
14675
14676
14677static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14678{
14679 struct alc_spec *spec = codec->spec;
14680 hda_nid_t pin;
14681
14682 pin = spec->autocfg.hp_pins[0];
14683 if (pin) /* connect to front and use dac 0 */
14684 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014685 pin = spec->autocfg.speaker_pins[0];
14686 if (pin)
14687 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014688}
14689
14690#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14691#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14692
14693static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14694{
14695 struct alc_spec *spec = codec->spec;
14696 int i;
14697
14698 for (i = 0; i < AUTO_PIN_LAST; i++) {
14699 hda_nid_t nid = spec->autocfg.input_pins[i];
14700 if (alc861vd_is_input_pin(nid)) {
14701 snd_hda_codec_write(codec, nid, 0,
14702 AC_VERB_SET_PIN_WIDGET_CONTROL,
14703 i <= AUTO_PIN_FRONT_MIC ?
14704 PIN_VREF80 : PIN_IN);
14705 if (nid != ALC861VD_PIN_CD_NID)
14706 snd_hda_codec_write(codec, nid, 0,
14707 AC_VERB_SET_AMP_GAIN_MUTE,
14708 AMP_OUT_MUTE);
14709 }
14710 }
14711}
14712
Takashi Iwaif511b012008-08-15 16:46:42 +020014713#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14714
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014715#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14716#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14717
14718/* add playback controls from the parsed DAC table */
14719/* Based on ALC880 version. But ALC861VD has separate,
14720 * different NIDs for mute/unmute switch and volume control */
14721static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14722 const struct auto_pin_cfg *cfg)
14723{
14724 char name[32];
14725 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14726 hda_nid_t nid_v, nid_s;
14727 int i, err;
14728
14729 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014730 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014731 continue;
14732 nid_v = alc861vd_idx_to_mixer_vol(
14733 alc880_dac_to_idx(
14734 spec->multiout.dac_nids[i]));
14735 nid_s = alc861vd_idx_to_mixer_switch(
14736 alc880_dac_to_idx(
14737 spec->multiout.dac_nids[i]));
14738
14739 if (i == 2) {
14740 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014741 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14742 "Center Playback Volume",
14743 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14744 HDA_OUTPUT));
14745 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014746 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014747 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14748 "LFE Playback Volume",
14749 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14750 HDA_OUTPUT));
14751 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014752 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014753 err = add_control(spec, ALC_CTL_BIND_MUTE,
14754 "Center Playback Switch",
14755 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14756 HDA_INPUT));
14757 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014758 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014759 err = add_control(spec, ALC_CTL_BIND_MUTE,
14760 "LFE Playback Switch",
14761 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14762 HDA_INPUT));
14763 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014764 return err;
14765 } else {
14766 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014767 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14768 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14769 HDA_OUTPUT));
14770 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014771 return err;
14772 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014773 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014774 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014775 HDA_INPUT));
14776 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014777 return err;
14778 }
14779 }
14780 return 0;
14781}
14782
14783/* add playback controls for speaker and HP outputs */
14784/* Based on ALC880 version. But ALC861VD has separate,
14785 * different NIDs for mute/unmute switch and volume control */
14786static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14787 hda_nid_t pin, const char *pfx)
14788{
14789 hda_nid_t nid_v, nid_s;
14790 int err;
14791 char name[32];
14792
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014793 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014794 return 0;
14795
14796 if (alc880_is_fixed_pin(pin)) {
14797 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14798 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014799 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014800 spec->multiout.hp_nid = nid_v;
14801 else
14802 spec->multiout.extra_out_nid[0] = nid_v;
14803 /* control HP volume/switch on the output mixer amp */
14804 nid_v = alc861vd_idx_to_mixer_vol(
14805 alc880_fixed_pin_idx(pin));
14806 nid_s = alc861vd_idx_to_mixer_switch(
14807 alc880_fixed_pin_idx(pin));
14808
14809 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014810 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14811 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14812 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014813 return err;
14814 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014815 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14816 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14817 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014818 return err;
14819 } else if (alc880_is_multi_pin(pin)) {
14820 /* set manual connection */
14821 /* we have only a switch on HP-out PIN */
14822 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014823 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14824 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14825 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014826 return err;
14827 }
14828 return 0;
14829}
14830
14831/* parse the BIOS configuration and set up the alc_spec
14832 * return 1 if successful, 0 if the proper config is not found,
14833 * or a negative error code
14834 * Based on ALC880 version - had to change it to override
14835 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14836static int alc861vd_parse_auto_config(struct hda_codec *codec)
14837{
14838 struct alc_spec *spec = codec->spec;
14839 int err;
14840 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14841
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014842 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14843 alc861vd_ignore);
14844 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014845 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014846 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014847 return 0; /* can't find valid BIOS pin config */
14848
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014849 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14850 if (err < 0)
14851 return err;
14852 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14853 if (err < 0)
14854 return err;
14855 err = alc861vd_auto_create_extra_out(spec,
14856 spec->autocfg.speaker_pins[0],
14857 "Speaker");
14858 if (err < 0)
14859 return err;
14860 err = alc861vd_auto_create_extra_out(spec,
14861 spec->autocfg.hp_pins[0],
14862 "Headphone");
14863 if (err < 0)
14864 return err;
14865 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14866 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014867 return err;
14868
14869 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14870
14871 if (spec->autocfg.dig_out_pin)
14872 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14873
Takashi Iwai603c4012008-07-30 15:01:44 +020014874 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014875 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014876
Takashi Iwaid88897e2008-10-31 15:01:37 +010014877 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014878
14879 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014880 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014881
Takashi Iwai776e1842007-08-29 15:07:11 +020014882 err = alc_auto_add_mic_boost(codec);
14883 if (err < 0)
14884 return err;
14885
Takashi Iwaie044c392008-10-27 16:56:24 +010014886 store_pin_configs(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014887 return 1;
14888}
14889
14890/* additional initialization for auto-configuration model */
14891static void alc861vd_auto_init(struct hda_codec *codec)
14892{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014893 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014894 alc861vd_auto_init_multi_out(codec);
14895 alc861vd_auto_init_hp_out(codec);
14896 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014897 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014898 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014899 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014900}
14901
14902static int patch_alc861vd(struct hda_codec *codec)
14903{
14904 struct alc_spec *spec;
14905 int err, board_config;
14906
14907 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14908 if (spec == NULL)
14909 return -ENOMEM;
14910
14911 codec->spec = spec;
14912
14913 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14914 alc861vd_models,
14915 alc861vd_cfg_tbl);
14916
14917 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14918 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14919 "ALC861VD, trying auto-probe from BIOS...\n");
14920 board_config = ALC861VD_AUTO;
14921 }
14922
14923 if (board_config == ALC861VD_AUTO) {
14924 /* automatic parse from the BIOS config */
14925 err = alc861vd_parse_auto_config(codec);
14926 if (err < 0) {
14927 alc_free(codec);
14928 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014929 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014930 printk(KERN_INFO
14931 "hda_codec: Cannot set up configuration "
14932 "from BIOS. Using base mode...\n");
14933 board_config = ALC861VD_3ST;
14934 }
14935 }
14936
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014937 err = snd_hda_attach_beep_device(codec, 0x23);
14938 if (err < 0) {
14939 alc_free(codec);
14940 return err;
14941 }
14942
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014943 if (board_config != ALC861VD_AUTO)
14944 setup_preset(spec, &alc861vd_presets[board_config]);
14945
Kailang Yang2f893282008-05-27 12:14:47 +020014946 if (codec->vendor_id == 0x10ec0660) {
14947 spec->stream_name_analog = "ALC660-VD Analog";
14948 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014949 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010014950 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020014951 } else {
14952 spec->stream_name_analog = "ALC861VD Analog";
14953 spec->stream_name_digital = "ALC861VD Digital";
14954 }
14955
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014956 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14957 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14958
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014959 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14960 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14961
14962 spec->adc_nids = alc861vd_adc_nids;
14963 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014964 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014965 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014966
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014967 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014968 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014969
Takashi Iwai2134ea42008-01-10 16:53:55 +010014970 spec->vmaster_nid = 0x02;
14971
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014972 codec->patch_ops = alc_patch_ops;
14973
14974 if (board_config == ALC861VD_AUTO)
14975 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014976#ifdef CONFIG_SND_HDA_POWER_SAVE
14977 if (!spec->loopback.amplist)
14978 spec->loopback.amplist = alc861vd_loopbacks;
14979#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014980 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014981
14982 return 0;
14983}
14984
14985/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014986 * ALC662 support
14987 *
14988 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14989 * configuration. Each pin widget can choose any input DACs and a mixer.
14990 * Each ADC is connected from a mixer of all inputs. This makes possible
14991 * 6-channel independent captures.
14992 *
14993 * In addition, an independent DAC for the multi-playback (not used in this
14994 * driver yet).
14995 */
14996#define ALC662_DIGOUT_NID 0x06
14997#define ALC662_DIGIN_NID 0x0a
14998
14999static hda_nid_t alc662_dac_nids[4] = {
15000 /* front, rear, clfe, rear_surr */
15001 0x02, 0x03, 0x04
15002};
15003
15004static hda_nid_t alc662_adc_nids[1] = {
15005 /* ADC1-2 */
15006 0x09,
15007};
Takashi Iwaie1406342008-02-11 18:32:32 +010015008
Kailang Yang77a261b2008-02-19 11:38:05 +010015009static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010015010
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015011/* input MUX */
15012/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015013static struct hda_input_mux alc662_capture_source = {
15014 .num_items = 4,
15015 .items = {
15016 { "Mic", 0x0 },
15017 { "Front Mic", 0x1 },
15018 { "Line", 0x2 },
15019 { "CD", 0x4 },
15020 },
15021};
15022
15023static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15024 .num_items = 2,
15025 .items = {
15026 { "Mic", 0x1 },
15027 { "Line", 0x2 },
15028 },
15029};
Kailang Yang291702f2007-10-16 14:28:03 +020015030
15031static struct hda_input_mux alc662_eeepc_capture_source = {
15032 .num_items = 2,
15033 .items = {
15034 { "i-Mic", 0x1 },
15035 { "e-Mic", 0x0 },
15036 },
15037};
15038
Kailang Yang6dda9f42008-05-27 12:05:31 +020015039static struct hda_input_mux alc663_capture_source = {
15040 .num_items = 3,
15041 .items = {
15042 { "Mic", 0x0 },
15043 { "Front Mic", 0x1 },
15044 { "Line", 0x2 },
15045 },
15046};
15047
15048static struct hda_input_mux alc663_m51va_capture_source = {
15049 .num_items = 2,
15050 .items = {
15051 { "Ext-Mic", 0x0 },
15052 { "D-Mic", 0x9 },
15053 },
15054};
15055
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015056/*
15057 * 2ch mode
15058 */
15059static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15060 { 2, NULL }
15061};
15062
15063/*
15064 * 2ch mode
15065 */
15066static struct hda_verb alc662_3ST_ch2_init[] = {
15067 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15068 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15069 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15070 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15071 { } /* end */
15072};
15073
15074/*
15075 * 6ch mode
15076 */
15077static struct hda_verb alc662_3ST_ch6_init[] = {
15078 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15079 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15080 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15081 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15082 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15083 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15084 { } /* end */
15085};
15086
15087static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15088 { 2, alc662_3ST_ch2_init },
15089 { 6, alc662_3ST_ch6_init },
15090};
15091
15092/*
15093 * 2ch mode
15094 */
15095static struct hda_verb alc662_sixstack_ch6_init[] = {
15096 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15097 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15098 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15099 { } /* end */
15100};
15101
15102/*
15103 * 6ch mode
15104 */
15105static struct hda_verb alc662_sixstack_ch8_init[] = {
15106 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15107 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15108 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15109 { } /* end */
15110};
15111
15112static struct hda_channel_mode alc662_5stack_modes[2] = {
15113 { 2, alc662_sixstack_ch6_init },
15114 { 6, alc662_sixstack_ch8_init },
15115};
15116
15117/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15118 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15119 */
15120
15121static struct snd_kcontrol_new alc662_base_mixer[] = {
15122 /* output mixer control */
15123 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015124 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015125 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015126 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015127 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15128 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015129 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15130 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015131 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15132
15133 /*Input mixer control */
15134 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15135 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15136 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15137 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15138 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15139 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15140 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15141 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015142 { } /* end */
15143};
15144
15145static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15146 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015147 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015148 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15149 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15150 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15151 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15152 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15153 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15155 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15156 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015157 { } /* end */
15158};
15159
15160static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15161 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015162 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015163 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015164 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015165 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15166 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015167 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15168 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015169 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15170 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15171 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15172 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15173 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15174 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15175 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15176 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15177 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015178 { } /* end */
15179};
15180
15181static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15182 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15183 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015184 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15185 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015186 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15187 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15188 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15189 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15190 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015191 { } /* end */
15192};
15193
Kailang Yang291702f2007-10-16 14:28:03 +020015194static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015195 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015196
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015197 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15198 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015199
15200 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15201 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15202 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15203
15204 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15205 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15206 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15207 { } /* end */
15208};
15209
Kailang Yang8c427222008-01-10 13:03:59 +010015210static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015211 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15212 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015213 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15214 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15215 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15216 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15217 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15218 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015219 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015220 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15221 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15222 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15223 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15224 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15225 { } /* end */
15226};
15227
Kailang Yangf1d4e282008-08-26 14:03:29 +020015228static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15229 .ops = &snd_hda_bind_vol,
15230 .values = {
15231 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15232 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15233 0
15234 },
15235};
15236
15237static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15238 .ops = &snd_hda_bind_sw,
15239 .values = {
15240 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15241 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15242 0
15243 },
15244};
15245
Kailang Yang6dda9f42008-05-27 12:05:31 +020015246static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015247 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15248 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15249 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15250 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15251 { } /* end */
15252};
15253
15254static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15255 .ops = &snd_hda_bind_sw,
15256 .values = {
15257 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15258 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15259 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15260 0
15261 },
15262};
15263
15264static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15265 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15266 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15267 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15268 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15269 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15270 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15271
15272 { } /* end */
15273};
15274
15275static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15276 .ops = &snd_hda_bind_sw,
15277 .values = {
15278 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15279 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15280 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15281 0
15282 },
15283};
15284
15285static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15286 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15287 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15289 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15290 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15291 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15292 { } /* end */
15293};
15294
15295static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015296 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15297 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015298 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15299 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15300 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15301 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15302 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15303 { } /* end */
15304};
15305
15306static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15307 .ops = &snd_hda_bind_vol,
15308 .values = {
15309 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15310 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15311 0
15312 },
15313};
15314
15315static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15316 .ops = &snd_hda_bind_sw,
15317 .values = {
15318 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15319 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15320 0
15321 },
15322};
15323
15324static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15325 HDA_BIND_VOL("Master Playback Volume",
15326 &alc663_asus_two_bind_master_vol),
15327 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15328 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015329 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15330 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15331 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015332 { } /* end */
15333};
15334
15335static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15336 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15337 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15338 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15339 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15340 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15341 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015342 { } /* end */
15343};
15344
15345static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15346 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15347 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15348 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15349 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15350 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15351
15352 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15353 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15354 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15355 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15356 { } /* end */
15357};
15358
15359static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15360 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15361 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15362 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15363
15364 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15365 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15366 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15367 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15368 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15369 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15370 { } /* end */
15371};
15372
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015373static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15374 {
15375 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15376 .name = "Channel Mode",
15377 .info = alc_ch_mode_info,
15378 .get = alc_ch_mode_get,
15379 .put = alc_ch_mode_put,
15380 },
15381 { } /* end */
15382};
15383
15384static struct hda_verb alc662_init_verbs[] = {
15385 /* ADC: mute amp left and right */
15386 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15387 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15388 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15389
Takashi Iwaicb53c622007-08-10 17:21:45 +020015390 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15391 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15392 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15393 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15394 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015395
Kailang Yangb60dd392007-09-20 12:50:29 +020015396 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15397 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15398 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15399 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15400 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15401 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015402
15403 /* Front Pin: output 0 (0x0c) */
15404 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15405 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15406
15407 /* Rear Pin: output 1 (0x0d) */
15408 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15409 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15410
15411 /* CLFE Pin: output 2 (0x0e) */
15412 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15413 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15414
15415 /* Mic (rear) pin: input vref at 80% */
15416 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15417 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15418 /* Front Mic pin: input vref at 80% */
15419 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15420 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15421 /* Line In pin: input */
15422 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15423 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15424 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15425 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15426 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15427 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15428 /* CD pin widget for input */
15429 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15430
15431 /* FIXME: use matrix-type input source selection */
15432 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15433 /* Input mixer */
15434 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15435 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15436 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15437 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015438
15439 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15440 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15441 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15442 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015443
15444 /* always trun on EAPD */
15445 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15446 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15447
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015448 { }
15449};
15450
15451static struct hda_verb alc662_sue_init_verbs[] = {
15452 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15453 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015454 {}
15455};
15456
15457static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15458 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15459 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15460 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015461};
15462
Kailang Yang8c427222008-01-10 13:03:59 +010015463/* Set Unsolicited Event*/
15464static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15465 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15466 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15467 {}
15468};
15469
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015470/*
15471 * generic initialization of ADC, input mixers and output mixers
15472 */
15473static struct hda_verb alc662_auto_init_verbs[] = {
15474 /*
15475 * Unmute ADC and set the default input to mic-in
15476 */
15477 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15478 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15479
15480 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15481 * mixer widget
15482 * Note: PASD motherboards uses the Line In 2 as the input for front
15483 * panel mic (mic 2)
15484 */
15485 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015486 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15487 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15488 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15489 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15490 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015491
15492 /*
15493 * Set up output mixers (0x0c - 0x0f)
15494 */
15495 /* set vol=0 to output mixers */
15496 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15497 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15498 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15499
15500 /* set up input amps for analog loopback */
15501 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015502 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15504 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15506 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015508
15509
15510 /* FIXME: use matrix-type input source selection */
15511 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15512 /* Input mixer */
15513 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015514 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015515 { }
15516};
15517
Takashi Iwai24fb9172008-09-02 14:48:20 +020015518/* additional verbs for ALC663 */
15519static struct hda_verb alc663_auto_init_verbs[] = {
15520 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15521 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15522 { }
15523};
15524
Kailang Yang6dda9f42008-05-27 12:05:31 +020015525static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015526 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15527 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015528 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15529 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015530 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015533 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15534 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15535 {}
15536};
15537
Kailang Yangf1d4e282008-08-26 14:03:29 +020015538static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15539 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15540 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15541 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15542 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15543 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15544 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15545 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15546 {}
15547};
15548
15549static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15550 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15551 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15552 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15553 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15554 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15555 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15556 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15557 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15558 {}
15559};
15560
15561static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15562 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15563 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15564 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15565 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15566 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15567 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15568 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15569 {}
15570};
15571
15572static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15573 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15574 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15575 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15576 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15577 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15578 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15579 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15580 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15581 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15582 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15583 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15584 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15585 {}
15586};
15587
15588static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15589 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15590 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15591 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15592 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15593 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15594 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15595 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15596 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15598 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15599 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15600 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15601 {}
15602};
15603
Kailang Yang6dda9f42008-05-27 12:05:31 +020015604static struct hda_verb alc663_g71v_init_verbs[] = {
15605 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15606 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15607 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15608
15609 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15610 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15611 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15612
15613 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15614 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15615 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15616 {}
15617};
15618
15619static struct hda_verb alc663_g50v_init_verbs[] = {
15620 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15621 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15622 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15623
15624 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15625 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15626 {}
15627};
15628
Kailang Yangf1d4e282008-08-26 14:03:29 +020015629static struct hda_verb alc662_ecs_init_verbs[] = {
15630 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15631 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15632 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15633 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15634 {}
15635};
15636
Kailang Yangf1d4e282008-08-26 14:03:29 +020015637static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15638 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15639 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15640 { } /* end */
15641};
15642
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015643static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15644{
15645 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015646 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015647
15648 present = snd_hda_codec_read(codec, 0x14, 0,
15649 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015650 bits = present ? HDA_AMP_MUTE : 0;
15651 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15652 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015653}
15654
15655static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15656{
15657 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015658 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015659
15660 present = snd_hda_codec_read(codec, 0x1b, 0,
15661 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015662 bits = present ? HDA_AMP_MUTE : 0;
15663 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15664 HDA_AMP_MUTE, bits);
15665 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15666 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015667}
15668
15669static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15670 unsigned int res)
15671{
15672 if ((res >> 26) == ALC880_HP_EVENT)
15673 alc662_lenovo_101e_all_automute(codec);
15674 if ((res >> 26) == ALC880_FRONT_EVENT)
15675 alc662_lenovo_101e_ispeaker_automute(codec);
15676}
15677
Kailang Yang291702f2007-10-16 14:28:03 +020015678static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15679{
15680 unsigned int present;
15681
15682 present = snd_hda_codec_read(codec, 0x18, 0,
15683 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15684 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15685 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15686 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15687 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15688 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15689 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15690 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15691 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15692}
15693
15694/* unsolicited event for HP jack sensing */
15695static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15696 unsigned int res)
15697{
15698 if ((res >> 26) == ALC880_HP_EVENT)
15699 alc262_hippo1_automute( codec );
15700
15701 if ((res >> 26) == ALC880_MIC_EVENT)
15702 alc662_eeepc_mic_automute(codec);
15703}
15704
15705static void alc662_eeepc_inithook(struct hda_codec *codec)
15706{
15707 alc262_hippo1_automute( codec );
15708 alc662_eeepc_mic_automute(codec);
15709}
15710
Kailang Yang8c427222008-01-10 13:03:59 +010015711static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15712{
15713 unsigned int mute;
15714 unsigned int present;
15715
15716 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15717 present = snd_hda_codec_read(codec, 0x14, 0,
15718 AC_VERB_GET_PIN_SENSE, 0);
15719 present = (present & 0x80000000) != 0;
15720 if (present) {
15721 /* mute internal speaker */
15722 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015723 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015724 } else {
15725 /* unmute internal speaker if necessary */
15726 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15727 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015728 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015729 }
15730}
15731
15732/* unsolicited event for HP jack sensing */
15733static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15734 unsigned int res)
15735{
15736 if ((res >> 26) == ALC880_HP_EVENT)
15737 alc662_eeepc_ep20_automute(codec);
15738}
15739
15740static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15741{
15742 alc662_eeepc_ep20_automute(codec);
15743}
15744
Kailang Yang6dda9f42008-05-27 12:05:31 +020015745static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15746{
15747 unsigned int present;
15748 unsigned char bits;
15749
15750 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015751 AC_VERB_GET_PIN_SENSE, 0)
15752 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015753 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015754 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15755 AMP_IN_MUTE(0), bits);
15756 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15757 AMP_IN_MUTE(0), bits);
15758}
15759
15760static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15761{
15762 unsigned int present;
15763 unsigned char bits;
15764
15765 present = snd_hda_codec_read(codec, 0x21, 0,
15766 AC_VERB_GET_PIN_SENSE, 0)
15767 & AC_PINSENSE_PRESENCE;
15768 bits = present ? HDA_AMP_MUTE : 0;
15769 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15770 AMP_IN_MUTE(0), bits);
15771 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15772 AMP_IN_MUTE(0), bits);
15773 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15774 AMP_IN_MUTE(0), bits);
15775 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15776 AMP_IN_MUTE(0), bits);
15777}
15778
15779static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15780{
15781 unsigned int present;
15782 unsigned char bits;
15783
15784 present = snd_hda_codec_read(codec, 0x15, 0,
15785 AC_VERB_GET_PIN_SENSE, 0)
15786 & AC_PINSENSE_PRESENCE;
15787 bits = present ? HDA_AMP_MUTE : 0;
15788 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15789 AMP_IN_MUTE(0), bits);
15790 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15791 AMP_IN_MUTE(0), bits);
15792 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15793 AMP_IN_MUTE(0), bits);
15794 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15795 AMP_IN_MUTE(0), bits);
15796}
15797
15798static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15799{
15800 unsigned int present;
15801 unsigned char bits;
15802
15803 present = snd_hda_codec_read(codec, 0x1b, 0,
15804 AC_VERB_GET_PIN_SENSE, 0)
15805 & AC_PINSENSE_PRESENCE;
15806 bits = present ? 0 : PIN_OUT;
15807 snd_hda_codec_write(codec, 0x14, 0,
15808 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15809}
15810
15811static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15812{
15813 unsigned int present1, present2;
15814
15815 present1 = snd_hda_codec_read(codec, 0x21, 0,
15816 AC_VERB_GET_PIN_SENSE, 0)
15817 & AC_PINSENSE_PRESENCE;
15818 present2 = snd_hda_codec_read(codec, 0x15, 0,
15819 AC_VERB_GET_PIN_SENSE, 0)
15820 & AC_PINSENSE_PRESENCE;
15821
15822 if (present1 || present2) {
15823 snd_hda_codec_write_cache(codec, 0x14, 0,
15824 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15825 } else {
15826 snd_hda_codec_write_cache(codec, 0x14, 0,
15827 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15828 }
15829}
15830
15831static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15832{
15833 unsigned int present1, present2;
15834
15835 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15836 AC_VERB_GET_PIN_SENSE, 0)
15837 & AC_PINSENSE_PRESENCE;
15838 present2 = snd_hda_codec_read(codec, 0x15, 0,
15839 AC_VERB_GET_PIN_SENSE, 0)
15840 & AC_PINSENSE_PRESENCE;
15841
15842 if (present1 || present2) {
15843 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15844 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15845 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15846 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15847 } else {
15848 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15849 AMP_IN_MUTE(0), 0);
15850 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15851 AMP_IN_MUTE(0), 0);
15852 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015853}
15854
15855static void alc663_m51va_mic_automute(struct hda_codec *codec)
15856{
15857 unsigned int present;
15858
15859 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015860 AC_VERB_GET_PIN_SENSE, 0)
15861 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015862 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015863 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015864 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015865 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015866 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015867 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015868 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015869 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015870}
15871
15872static void alc663_m51va_unsol_event(struct hda_codec *codec,
15873 unsigned int res)
15874{
15875 switch (res >> 26) {
15876 case ALC880_HP_EVENT:
15877 alc663_m51va_speaker_automute(codec);
15878 break;
15879 case ALC880_MIC_EVENT:
15880 alc663_m51va_mic_automute(codec);
15881 break;
15882 }
15883}
15884
15885static void alc663_m51va_inithook(struct hda_codec *codec)
15886{
15887 alc663_m51va_speaker_automute(codec);
15888 alc663_m51va_mic_automute(codec);
15889}
15890
Kailang Yangf1d4e282008-08-26 14:03:29 +020015891/* ***************** Mode1 ******************************/
15892static void alc663_mode1_unsol_event(struct hda_codec *codec,
15893 unsigned int res)
15894{
15895 switch (res >> 26) {
15896 case ALC880_HP_EVENT:
15897 alc663_m51va_speaker_automute(codec);
15898 break;
15899 case ALC880_MIC_EVENT:
15900 alc662_eeepc_mic_automute(codec);
15901 break;
15902 }
15903}
15904
15905static void alc663_mode1_inithook(struct hda_codec *codec)
15906{
15907 alc663_m51va_speaker_automute(codec);
15908 alc662_eeepc_mic_automute(codec);
15909}
15910/* ***************** Mode2 ******************************/
15911static void alc662_mode2_unsol_event(struct hda_codec *codec,
15912 unsigned int res)
15913{
15914 switch (res >> 26) {
15915 case ALC880_HP_EVENT:
15916 alc662_f5z_speaker_automute(codec);
15917 break;
15918 case ALC880_MIC_EVENT:
15919 alc662_eeepc_mic_automute(codec);
15920 break;
15921 }
15922}
15923
15924static void alc662_mode2_inithook(struct hda_codec *codec)
15925{
15926 alc662_f5z_speaker_automute(codec);
15927 alc662_eeepc_mic_automute(codec);
15928}
15929/* ***************** Mode3 ******************************/
15930static void alc663_mode3_unsol_event(struct hda_codec *codec,
15931 unsigned int res)
15932{
15933 switch (res >> 26) {
15934 case ALC880_HP_EVENT:
15935 alc663_two_hp_m1_speaker_automute(codec);
15936 break;
15937 case ALC880_MIC_EVENT:
15938 alc662_eeepc_mic_automute(codec);
15939 break;
15940 }
15941}
15942
15943static void alc663_mode3_inithook(struct hda_codec *codec)
15944{
15945 alc663_two_hp_m1_speaker_automute(codec);
15946 alc662_eeepc_mic_automute(codec);
15947}
15948/* ***************** Mode4 ******************************/
15949static void alc663_mode4_unsol_event(struct hda_codec *codec,
15950 unsigned int res)
15951{
15952 switch (res >> 26) {
15953 case ALC880_HP_EVENT:
15954 alc663_21jd_two_speaker_automute(codec);
15955 break;
15956 case ALC880_MIC_EVENT:
15957 alc662_eeepc_mic_automute(codec);
15958 break;
15959 }
15960}
15961
15962static void alc663_mode4_inithook(struct hda_codec *codec)
15963{
15964 alc663_21jd_two_speaker_automute(codec);
15965 alc662_eeepc_mic_automute(codec);
15966}
15967/* ***************** Mode5 ******************************/
15968static void alc663_mode5_unsol_event(struct hda_codec *codec,
15969 unsigned int res)
15970{
15971 switch (res >> 26) {
15972 case ALC880_HP_EVENT:
15973 alc663_15jd_two_speaker_automute(codec);
15974 break;
15975 case ALC880_MIC_EVENT:
15976 alc662_eeepc_mic_automute(codec);
15977 break;
15978 }
15979}
15980
15981static void alc663_mode5_inithook(struct hda_codec *codec)
15982{
15983 alc663_15jd_two_speaker_automute(codec);
15984 alc662_eeepc_mic_automute(codec);
15985}
15986/* ***************** Mode6 ******************************/
15987static void alc663_mode6_unsol_event(struct hda_codec *codec,
15988 unsigned int res)
15989{
15990 switch (res >> 26) {
15991 case ALC880_HP_EVENT:
15992 alc663_two_hp_m2_speaker_automute(codec);
15993 break;
15994 case ALC880_MIC_EVENT:
15995 alc662_eeepc_mic_automute(codec);
15996 break;
15997 }
15998}
15999
16000static void alc663_mode6_inithook(struct hda_codec *codec)
16001{
16002 alc663_two_hp_m2_speaker_automute(codec);
16003 alc662_eeepc_mic_automute(codec);
16004}
16005
Kailang Yang6dda9f42008-05-27 12:05:31 +020016006static void alc663_g71v_hp_automute(struct hda_codec *codec)
16007{
16008 unsigned int present;
16009 unsigned char bits;
16010
16011 present = snd_hda_codec_read(codec, 0x21, 0,
16012 AC_VERB_GET_PIN_SENSE, 0)
16013 & AC_PINSENSE_PRESENCE;
16014 bits = present ? HDA_AMP_MUTE : 0;
16015 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16016 HDA_AMP_MUTE, bits);
16017 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16018 HDA_AMP_MUTE, bits);
16019}
16020
16021static void alc663_g71v_front_automute(struct hda_codec *codec)
16022{
16023 unsigned int present;
16024 unsigned char bits;
16025
16026 present = snd_hda_codec_read(codec, 0x15, 0,
16027 AC_VERB_GET_PIN_SENSE, 0)
16028 & AC_PINSENSE_PRESENCE;
16029 bits = present ? HDA_AMP_MUTE : 0;
16030 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16031 HDA_AMP_MUTE, bits);
16032}
16033
16034static void alc663_g71v_unsol_event(struct hda_codec *codec,
16035 unsigned int res)
16036{
16037 switch (res >> 26) {
16038 case ALC880_HP_EVENT:
16039 alc663_g71v_hp_automute(codec);
16040 break;
16041 case ALC880_FRONT_EVENT:
16042 alc663_g71v_front_automute(codec);
16043 break;
16044 case ALC880_MIC_EVENT:
16045 alc662_eeepc_mic_automute(codec);
16046 break;
16047 }
16048}
16049
16050static void alc663_g71v_inithook(struct hda_codec *codec)
16051{
16052 alc663_g71v_front_automute(codec);
16053 alc663_g71v_hp_automute(codec);
16054 alc662_eeepc_mic_automute(codec);
16055}
16056
16057static void alc663_g50v_unsol_event(struct hda_codec *codec,
16058 unsigned int res)
16059{
16060 switch (res >> 26) {
16061 case ALC880_HP_EVENT:
16062 alc663_m51va_speaker_automute(codec);
16063 break;
16064 case ALC880_MIC_EVENT:
16065 alc662_eeepc_mic_automute(codec);
16066 break;
16067 }
16068}
16069
16070static void alc663_g50v_inithook(struct hda_codec *codec)
16071{
16072 alc663_m51va_speaker_automute(codec);
16073 alc662_eeepc_mic_automute(codec);
16074}
16075
Kailang Yangf1d4e282008-08-26 14:03:29 +020016076/* bind hp and internal speaker mute (with plug check) */
16077static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16078 struct snd_ctl_elem_value *ucontrol)
16079{
16080 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16081 long *valp = ucontrol->value.integer.value;
16082 int change;
16083
16084 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16085 HDA_AMP_MUTE,
16086 valp[0] ? 0 : HDA_AMP_MUTE);
16087 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16088 HDA_AMP_MUTE,
16089 valp[1] ? 0 : HDA_AMP_MUTE);
16090 if (change)
16091 alc262_hippo1_automute(codec);
16092 return change;
16093}
16094
16095static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16096 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16097 {
16098 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16099 .name = "Master Playback Switch",
16100 .info = snd_hda_mixer_amp_switch_info,
16101 .get = snd_hda_mixer_amp_switch_get,
16102 .put = alc662_ecs_master_sw_put,
16103 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16104 },
16105
16106 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16107 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16108 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16109
16110 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16111 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16112 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16113 { } /* end */
16114};
16115
Takashi Iwaicb53c622007-08-10 17:21:45 +020016116#ifdef CONFIG_SND_HDA_POWER_SAVE
16117#define alc662_loopbacks alc880_loopbacks
16118#endif
16119
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016120
16121/* pcm configuration: identiacal with ALC880 */
16122#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16123#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16124#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16125#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16126
16127/*
16128 * configuration and preset
16129 */
16130static const char *alc662_models[ALC662_MODEL_LAST] = {
16131 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16132 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16133 [ALC662_3ST_6ch] = "3stack-6ch",
16134 [ALC662_5ST_DIG] = "6stack-dig",
16135 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016136 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016137 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016138 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016139 [ALC663_ASUS_M51VA] = "m51va",
16140 [ALC663_ASUS_G71V] = "g71v",
16141 [ALC663_ASUS_H13] = "h13",
16142 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016143 [ALC663_ASUS_MODE1] = "asus-mode1",
16144 [ALC662_ASUS_MODE2] = "asus-mode2",
16145 [ALC663_ASUS_MODE3] = "asus-mode3",
16146 [ALC663_ASUS_MODE4] = "asus-mode4",
16147 [ALC663_ASUS_MODE5] = "asus-mode5",
16148 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016149 [ALC662_AUTO] = "auto",
16150};
16151
16152static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016153 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Kailang Yang80ffe862008-10-15 11:23:27 +020016154 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016155 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016156 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016157 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016158 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16159 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
16160 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16161 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16162 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16163 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
16164 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16165 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16166 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016167 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016168 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16169 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16170 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16171 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16172 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16173 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16174 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
16175 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16176 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16177 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16178 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16179 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16180 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16181 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16182 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16183 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16184 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16185 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
16186 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16187 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16188 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16189 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016190 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16191 ALC662_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016192 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016193 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16194 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016195 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16196 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016197 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai238713d2008-10-05 10:57:39 +020016198 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016199 ALC662_3ST_6ch_DIG),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016200 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
16201 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
16202 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016203 {}
16204};
16205
16206static struct alc_config_preset alc662_presets[] = {
16207 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016208 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016209 .init_verbs = { alc662_init_verbs },
16210 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16211 .dac_nids = alc662_dac_nids,
16212 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016213 .dig_in_nid = ALC662_DIGIN_NID,
16214 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16215 .channel_mode = alc662_3ST_2ch_modes,
16216 .input_mux = &alc662_capture_source,
16217 },
16218 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016219 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016220 .init_verbs = { alc662_init_verbs },
16221 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16222 .dac_nids = alc662_dac_nids,
16223 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016224 .dig_in_nid = ALC662_DIGIN_NID,
16225 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16226 .channel_mode = alc662_3ST_6ch_modes,
16227 .need_dac_fix = 1,
16228 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016229 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016230 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016231 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016232 .init_verbs = { alc662_init_verbs },
16233 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16234 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016235 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16236 .channel_mode = alc662_3ST_6ch_modes,
16237 .need_dac_fix = 1,
16238 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016239 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016240 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016241 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016242 .init_verbs = { alc662_init_verbs },
16243 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16244 .dac_nids = alc662_dac_nids,
16245 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016246 .dig_in_nid = ALC662_DIGIN_NID,
16247 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16248 .channel_mode = alc662_5stack_modes,
16249 .input_mux = &alc662_capture_source,
16250 },
16251 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016252 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016253 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16254 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16255 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016256 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16257 .channel_mode = alc662_3ST_2ch_modes,
16258 .input_mux = &alc662_lenovo_101e_capture_source,
16259 .unsol_event = alc662_lenovo_101e_unsol_event,
16260 .init_hook = alc662_lenovo_101e_all_automute,
16261 },
Kailang Yang291702f2007-10-16 14:28:03 +020016262 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016263 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016264 .init_verbs = { alc662_init_verbs,
16265 alc662_eeepc_sue_init_verbs },
16266 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16267 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016268 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16269 .channel_mode = alc662_3ST_2ch_modes,
16270 .input_mux = &alc662_eeepc_capture_source,
16271 .unsol_event = alc662_eeepc_unsol_event,
16272 .init_hook = alc662_eeepc_inithook,
16273 },
Kailang Yang8c427222008-01-10 13:03:59 +010016274 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016275 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016276 alc662_chmode_mixer },
16277 .init_verbs = { alc662_init_verbs,
16278 alc662_eeepc_ep20_sue_init_verbs },
16279 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16280 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016281 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16282 .channel_mode = alc662_3ST_6ch_modes,
16283 .input_mux = &alc662_lenovo_101e_capture_source,
16284 .unsol_event = alc662_eeepc_ep20_unsol_event,
16285 .init_hook = alc662_eeepc_ep20_inithook,
16286 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016287 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016288 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016289 .init_verbs = { alc662_init_verbs,
16290 alc662_ecs_init_verbs },
16291 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16292 .dac_nids = alc662_dac_nids,
16293 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16294 .channel_mode = alc662_3ST_2ch_modes,
16295 .input_mux = &alc662_eeepc_capture_source,
16296 .unsol_event = alc662_eeepc_unsol_event,
16297 .init_hook = alc662_eeepc_inithook,
16298 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016299 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016300 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016301 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16302 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16303 .dac_nids = alc662_dac_nids,
16304 .dig_out_nid = ALC662_DIGOUT_NID,
16305 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16306 .channel_mode = alc662_3ST_2ch_modes,
16307 .input_mux = &alc663_m51va_capture_source,
16308 .unsol_event = alc663_m51va_unsol_event,
16309 .init_hook = alc663_m51va_inithook,
16310 },
16311 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016312 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016313 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16314 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16315 .dac_nids = alc662_dac_nids,
16316 .dig_out_nid = ALC662_DIGOUT_NID,
16317 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16318 .channel_mode = alc662_3ST_2ch_modes,
16319 .input_mux = &alc662_eeepc_capture_source,
16320 .unsol_event = alc663_g71v_unsol_event,
16321 .init_hook = alc663_g71v_inithook,
16322 },
16323 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016324 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016325 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16326 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16327 .dac_nids = alc662_dac_nids,
16328 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16329 .channel_mode = alc662_3ST_2ch_modes,
16330 .input_mux = &alc663_m51va_capture_source,
16331 .unsol_event = alc663_m51va_unsol_event,
16332 .init_hook = alc663_m51va_inithook,
16333 },
16334 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016335 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016336 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16337 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16338 .dac_nids = alc662_dac_nids,
16339 .dig_out_nid = ALC662_DIGOUT_NID,
16340 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16341 .channel_mode = alc662_3ST_6ch_modes,
16342 .input_mux = &alc663_capture_source,
16343 .unsol_event = alc663_g50v_unsol_event,
16344 .init_hook = alc663_g50v_inithook,
16345 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016346 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016347 .mixers = { alc663_m51va_mixer },
16348 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016349 .init_verbs = { alc662_init_verbs,
16350 alc663_21jd_amic_init_verbs },
16351 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16352 .hp_nid = 0x03,
16353 .dac_nids = alc662_dac_nids,
16354 .dig_out_nid = ALC662_DIGOUT_NID,
16355 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16356 .channel_mode = alc662_3ST_2ch_modes,
16357 .input_mux = &alc662_eeepc_capture_source,
16358 .unsol_event = alc663_mode1_unsol_event,
16359 .init_hook = alc663_mode1_inithook,
16360 },
16361 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016362 .mixers = { alc662_1bjd_mixer },
16363 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016364 .init_verbs = { alc662_init_verbs,
16365 alc662_1bjd_amic_init_verbs },
16366 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16367 .dac_nids = alc662_dac_nids,
16368 .dig_out_nid = ALC662_DIGOUT_NID,
16369 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16370 .channel_mode = alc662_3ST_2ch_modes,
16371 .input_mux = &alc662_eeepc_capture_source,
16372 .unsol_event = alc662_mode2_unsol_event,
16373 .init_hook = alc662_mode2_inithook,
16374 },
16375 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016376 .mixers = { alc663_two_hp_m1_mixer },
16377 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016378 .init_verbs = { alc662_init_verbs,
16379 alc663_two_hp_amic_m1_init_verbs },
16380 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16381 .hp_nid = 0x03,
16382 .dac_nids = alc662_dac_nids,
16383 .dig_out_nid = ALC662_DIGOUT_NID,
16384 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16385 .channel_mode = alc662_3ST_2ch_modes,
16386 .input_mux = &alc662_eeepc_capture_source,
16387 .unsol_event = alc663_mode3_unsol_event,
16388 .init_hook = alc663_mode3_inithook,
16389 },
16390 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016391 .mixers = { alc663_asus_21jd_clfe_mixer },
16392 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016393 .init_verbs = { alc662_init_verbs,
16394 alc663_21jd_amic_init_verbs},
16395 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16396 .hp_nid = 0x03,
16397 .dac_nids = alc662_dac_nids,
16398 .dig_out_nid = ALC662_DIGOUT_NID,
16399 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16400 .channel_mode = alc662_3ST_2ch_modes,
16401 .input_mux = &alc662_eeepc_capture_source,
16402 .unsol_event = alc663_mode4_unsol_event,
16403 .init_hook = alc663_mode4_inithook,
16404 },
16405 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016406 .mixers = { alc663_asus_15jd_clfe_mixer },
16407 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016408 .init_verbs = { alc662_init_verbs,
16409 alc663_15jd_amic_init_verbs },
16410 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16411 .hp_nid = 0x03,
16412 .dac_nids = alc662_dac_nids,
16413 .dig_out_nid = ALC662_DIGOUT_NID,
16414 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16415 .channel_mode = alc662_3ST_2ch_modes,
16416 .input_mux = &alc662_eeepc_capture_source,
16417 .unsol_event = alc663_mode5_unsol_event,
16418 .init_hook = alc663_mode5_inithook,
16419 },
16420 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016421 .mixers = { alc663_two_hp_m2_mixer },
16422 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016423 .init_verbs = { alc662_init_verbs,
16424 alc663_two_hp_amic_m2_init_verbs },
16425 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16426 .hp_nid = 0x03,
16427 .dac_nids = alc662_dac_nids,
16428 .dig_out_nid = ALC662_DIGOUT_NID,
16429 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16430 .channel_mode = alc662_3ST_2ch_modes,
16431 .input_mux = &alc662_eeepc_capture_source,
16432 .unsol_event = alc663_mode6_unsol_event,
16433 .init_hook = alc663_mode6_inithook,
16434 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016435};
16436
16437
16438/*
16439 * BIOS auto configuration
16440 */
16441
16442/* add playback controls from the parsed DAC table */
16443static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16444 const struct auto_pin_cfg *cfg)
16445{
16446 char name[32];
16447 static const char *chname[4] = {
16448 "Front", "Surround", NULL /*CLFE*/, "Side"
16449 };
16450 hda_nid_t nid;
16451 int i, err;
16452
16453 for (i = 0; i < cfg->line_outs; i++) {
16454 if (!spec->multiout.dac_nids[i])
16455 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016456 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016457 if (i == 2) {
16458 /* Center/LFE */
16459 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16460 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016461 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16462 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016463 if (err < 0)
16464 return err;
16465 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16466 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016467 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16468 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016469 if (err < 0)
16470 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016471 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016472 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016473 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016474 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016475 if (err < 0)
16476 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016477 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016478 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016479 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016480 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016481 if (err < 0)
16482 return err;
16483 } else {
16484 sprintf(name, "%s Playback Volume", chname[i]);
16485 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016486 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16487 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016488 if (err < 0)
16489 return err;
16490 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016491 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16492 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16493 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016494 if (err < 0)
16495 return err;
16496 }
16497 }
16498 return 0;
16499}
16500
16501/* add playback controls for speaker and HP outputs */
16502static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16503 const char *pfx)
16504{
16505 hda_nid_t nid;
16506 int err;
16507 char name[32];
16508
16509 if (!pin)
16510 return 0;
16511
Takashi Iwai24fb9172008-09-02 14:48:20 +020016512 if (pin == 0x17) {
16513 /* ALC663 has a mono output pin on 0x17 */
16514 sprintf(name, "%s Playback Switch", pfx);
16515 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16516 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16517 return err;
16518 }
16519
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016520 if (alc880_is_fixed_pin(pin)) {
16521 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016522 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016523 /* specify the DAC as the extra output */
16524 if (!spec->multiout.hp_nid)
16525 spec->multiout.hp_nid = nid;
16526 else
16527 spec->multiout.extra_out_nid[0] = nid;
16528 /* control HP volume/switch on the output mixer amp */
16529 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16530 sprintf(name, "%s Playback Volume", pfx);
16531 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16532 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16533 if (err < 0)
16534 return err;
16535 sprintf(name, "%s Playback Switch", pfx);
16536 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16537 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16538 if (err < 0)
16539 return err;
16540 } else if (alc880_is_multi_pin(pin)) {
16541 /* set manual connection */
16542 /* we have only a switch on HP-out PIN */
16543 sprintf(name, "%s Playback Switch", pfx);
16544 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16545 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16546 if (err < 0)
16547 return err;
16548 }
16549 return 0;
16550}
16551
16552/* create playback/capture controls for input pins */
16553static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16554 const struct auto_pin_cfg *cfg)
16555{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016556 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016557 int i, err, idx;
16558
16559 for (i = 0; i < AUTO_PIN_LAST; i++) {
16560 if (alc880_is_input_pin(cfg->input_pins[i])) {
16561 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16562 err = new_analog_input(spec, cfg->input_pins[i],
16563 auto_pin_cfg_labels[i],
16564 idx, 0x0b);
16565 if (err < 0)
16566 return err;
16567 imux->items[imux->num_items].label =
16568 auto_pin_cfg_labels[i];
16569 imux->items[imux->num_items].index =
16570 alc880_input_pin_idx(cfg->input_pins[i]);
16571 imux->num_items++;
16572 }
16573 }
16574 return 0;
16575}
16576
16577static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16578 hda_nid_t nid, int pin_type,
16579 int dac_idx)
16580{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016581 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016582 /* need the manual connection? */
16583 if (alc880_is_multi_pin(nid)) {
16584 struct alc_spec *spec = codec->spec;
16585 int idx = alc880_multi_pin_idx(nid);
16586 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16587 AC_VERB_SET_CONNECT_SEL,
16588 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16589 }
16590}
16591
16592static void alc662_auto_init_multi_out(struct hda_codec *codec)
16593{
16594 struct alc_spec *spec = codec->spec;
16595 int i;
16596
Kailang Yang8c427222008-01-10 13:03:59 +010016597 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016598 for (i = 0; i <= HDA_SIDE; i++) {
16599 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016600 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016601 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016602 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016603 i);
16604 }
16605}
16606
16607static void alc662_auto_init_hp_out(struct hda_codec *codec)
16608{
16609 struct alc_spec *spec = codec->spec;
16610 hda_nid_t pin;
16611
16612 pin = spec->autocfg.hp_pins[0];
16613 if (pin) /* connect to front */
16614 /* use dac 0 */
16615 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016616 pin = spec->autocfg.speaker_pins[0];
16617 if (pin)
16618 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016619}
16620
16621#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16622#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16623
16624static void alc662_auto_init_analog_input(struct hda_codec *codec)
16625{
16626 struct alc_spec *spec = codec->spec;
16627 int i;
16628
16629 for (i = 0; i < AUTO_PIN_LAST; i++) {
16630 hda_nid_t nid = spec->autocfg.input_pins[i];
16631 if (alc662_is_input_pin(nid)) {
16632 snd_hda_codec_write(codec, nid, 0,
16633 AC_VERB_SET_PIN_WIDGET_CONTROL,
16634 (i <= AUTO_PIN_FRONT_MIC ?
16635 PIN_VREF80 : PIN_IN));
16636 if (nid != ALC662_PIN_CD_NID)
16637 snd_hda_codec_write(codec, nid, 0,
16638 AC_VERB_SET_AMP_GAIN_MUTE,
16639 AMP_OUT_MUTE);
16640 }
16641 }
16642}
16643
Takashi Iwaif511b012008-08-15 16:46:42 +020016644#define alc662_auto_init_input_src alc882_auto_init_input_src
16645
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016646static int alc662_parse_auto_config(struct hda_codec *codec)
16647{
16648 struct alc_spec *spec = codec->spec;
16649 int err;
16650 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16651
16652 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16653 alc662_ignore);
16654 if (err < 0)
16655 return err;
16656 if (!spec->autocfg.line_outs)
16657 return 0; /* can't find valid BIOS pin config */
16658
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016659 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16660 if (err < 0)
16661 return err;
16662 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16663 if (err < 0)
16664 return err;
16665 err = alc662_auto_create_extra_out(spec,
16666 spec->autocfg.speaker_pins[0],
16667 "Speaker");
16668 if (err < 0)
16669 return err;
16670 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16671 "Headphone");
16672 if (err < 0)
16673 return err;
16674 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16675 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016676 return err;
16677
16678 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16679
16680 if (spec->autocfg.dig_out_pin)
16681 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16682
Takashi Iwai603c4012008-07-30 15:01:44 +020016683 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016684 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016685
16686 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016687 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016688
Takashi Iwaid88897e2008-10-31 15:01:37 +010016689 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016690 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016691 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016692
16693 err = alc_auto_add_mic_boost(codec);
16694 if (err < 0)
16695 return err;
16696
Takashi Iwaie044c392008-10-27 16:56:24 +010016697 store_pin_configs(codec);
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016698 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016699}
16700
16701/* additional initialization for auto-configuration model */
16702static void alc662_auto_init(struct hda_codec *codec)
16703{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016704 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016705 alc662_auto_init_multi_out(codec);
16706 alc662_auto_init_hp_out(codec);
16707 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016708 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016709 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016710 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016711}
16712
16713static int patch_alc662(struct hda_codec *codec)
16714{
16715 struct alc_spec *spec;
16716 int err, board_config;
16717
16718 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16719 if (!spec)
16720 return -ENOMEM;
16721
16722 codec->spec = spec;
16723
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016724 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16725
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016726 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16727 alc662_models,
16728 alc662_cfg_tbl);
16729 if (board_config < 0) {
16730 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16731 "trying auto-probe from BIOS...\n");
16732 board_config = ALC662_AUTO;
16733 }
16734
16735 if (board_config == ALC662_AUTO) {
16736 /* automatic parse from the BIOS config */
16737 err = alc662_parse_auto_config(codec);
16738 if (err < 0) {
16739 alc_free(codec);
16740 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016741 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016742 printk(KERN_INFO
16743 "hda_codec: Cannot set up configuration "
16744 "from BIOS. Using base mode...\n");
16745 board_config = ALC662_3ST_2ch_DIG;
16746 }
16747 }
16748
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016749 err = snd_hda_attach_beep_device(codec, 0x1);
16750 if (err < 0) {
16751 alc_free(codec);
16752 return err;
16753 }
16754
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016755 if (board_config != ALC662_AUTO)
16756 setup_preset(spec, &alc662_presets[board_config]);
16757
Kailang Yang6dda9f42008-05-27 12:05:31 +020016758 if (codec->vendor_id == 0x10ec0663) {
16759 spec->stream_name_analog = "ALC663 Analog";
16760 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016761 } else if (codec->vendor_id == 0x10ec0272) {
16762 spec->stream_name_analog = "ALC272 Analog";
16763 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016764 } else {
16765 spec->stream_name_analog = "ALC662 Analog";
16766 spec->stream_name_digital = "ALC662 Digital";
16767 }
16768
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016769 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16770 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16771
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016772 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16773 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16774
Takashi Iwaie1406342008-02-11 18:32:32 +010016775 spec->adc_nids = alc662_adc_nids;
16776 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16777 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016778 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016779
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016780 if (!spec->cap_mixer)
16781 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016782 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016783
Takashi Iwai2134ea42008-01-10 16:53:55 +010016784 spec->vmaster_nid = 0x02;
16785
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016786 codec->patch_ops = alc_patch_ops;
16787 if (board_config == ALC662_AUTO)
16788 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016789#ifdef CONFIG_SND_HDA_POWER_SAVE
16790 if (!spec->loopback.amplist)
16791 spec->loopback.amplist = alc662_loopbacks;
16792#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016793 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016794
16795 return 0;
16796}
16797
16798/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016799 * patch entries
16800 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016801static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016802 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016803 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016804 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016805 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016806 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016807 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016808 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016809 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016810 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16811 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16812 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016813 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16814 .patch = patch_alc883 },
16815 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16816 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016817 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016818 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016819 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016820 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016821 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16822 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016823 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016824 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016825 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016826 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016827 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16828 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080016829 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016830 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016831 {} /* terminator */
16832};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016833
16834MODULE_ALIAS("snd-hda-codec-id:10ec*");
16835
16836MODULE_LICENSE("GPL");
16837MODULE_DESCRIPTION("Realtek HD-audio codec");
16838
16839static struct hda_codec_preset_list realtek_list = {
16840 .preset = snd_hda_preset_realtek,
16841 .owner = THIS_MODULE,
16842};
16843
16844static int __init patch_realtek_init(void)
16845{
16846 return snd_hda_add_codec_preset(&realtek_list);
16847}
16848
16849static void __exit patch_realtek_exit(void)
16850{
16851 snd_hda_delete_codec_preset(&realtek_list);
16852}
16853
16854module_init(patch_realtek_init)
16855module_exit(patch_realtek_exit)