blob: 2306cca1b69fd6b4d816b1d96aae72ab310748ac [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 Iwaidea0a502009-02-09 17:14:52 +01003601 SND_PCI_QUIRK_VENDOR(0x1043, "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 Iwaidea0a502009-02-09 17:14:52 +01003644 /* default Intel */
3645 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003646 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3647 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003648 {}
3649};
3650
Takashi Iwai16ded522005-06-10 19:58:24 +02003651/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003652 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003653 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003654static struct alc_config_preset alc880_presets[] = {
3655 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003656 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003657 .init_verbs = { alc880_volume_init_verbs,
3658 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003659 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003660 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003661 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3662 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003663 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003664 .input_mux = &alc880_capture_source,
3665 },
3666 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003667 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003668 .init_verbs = { alc880_volume_init_verbs,
3669 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003670 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003671 .dac_nids = alc880_dac_nids,
3672 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003673 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3674 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003675 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003676 .input_mux = &alc880_capture_source,
3677 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003678 [ALC880_TCL_S700] = {
3679 .mixers = { alc880_tcl_s700_mixer },
3680 .init_verbs = { alc880_volume_init_verbs,
3681 alc880_pin_tcl_S700_init_verbs,
3682 alc880_gpio2_init_verbs },
3683 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3684 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003685 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3686 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003687 .hp_nid = 0x03,
3688 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3689 .channel_mode = alc880_2_jack_modes,
3690 .input_mux = &alc880_capture_source,
3691 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003692 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003693 .mixers = { alc880_three_stack_mixer,
3694 alc880_five_stack_mixer},
3695 .init_verbs = { alc880_volume_init_verbs,
3696 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003697 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3698 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003699 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3700 .channel_mode = alc880_fivestack_modes,
3701 .input_mux = &alc880_capture_source,
3702 },
3703 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003704 .mixers = { alc880_three_stack_mixer,
3705 alc880_five_stack_mixer },
3706 .init_verbs = { alc880_volume_init_verbs,
3707 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003708 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3709 .dac_nids = alc880_dac_nids,
3710 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003711 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3712 .channel_mode = alc880_fivestack_modes,
3713 .input_mux = &alc880_capture_source,
3714 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003715 [ALC880_6ST] = {
3716 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003717 .init_verbs = { alc880_volume_init_verbs,
3718 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003719 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3720 .dac_nids = alc880_6st_dac_nids,
3721 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3722 .channel_mode = alc880_sixstack_modes,
3723 .input_mux = &alc880_6stack_capture_source,
3724 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003725 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003726 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003727 .init_verbs = { alc880_volume_init_verbs,
3728 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003729 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3730 .dac_nids = alc880_6st_dac_nids,
3731 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003732 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3733 .channel_mode = alc880_sixstack_modes,
3734 .input_mux = &alc880_6stack_capture_source,
3735 },
3736 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003737 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003738 .init_verbs = { alc880_volume_init_verbs,
3739 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003740 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003741 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3742 .dac_nids = alc880_w810_dac_nids,
3743 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003744 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3745 .channel_mode = alc880_w810_modes,
3746 .input_mux = &alc880_capture_source,
3747 },
3748 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003749 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003750 .init_verbs = { alc880_volume_init_verbs,
3751 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003752 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3753 .dac_nids = alc880_z71v_dac_nids,
3754 .dig_out_nid = ALC880_DIGOUT_NID,
3755 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003756 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3757 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003758 .input_mux = &alc880_capture_source,
3759 },
3760 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003761 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003762 .init_verbs = { alc880_volume_init_verbs,
3763 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003764 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3765 .dac_nids = alc880_f1734_dac_nids,
3766 .hp_nid = 0x02,
3767 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3768 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003769 .input_mux = &alc880_f1734_capture_source,
3770 .unsol_event = alc880_uniwill_p53_unsol_event,
3771 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003772 },
3773 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003774 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003775 .init_verbs = { alc880_volume_init_verbs,
3776 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003777 alc880_gpio1_init_verbs },
3778 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3779 .dac_nids = alc880_asus_dac_nids,
3780 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3781 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003782 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003783 .input_mux = &alc880_capture_source,
3784 },
3785 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003786 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003787 .init_verbs = { alc880_volume_init_verbs,
3788 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003789 alc880_gpio1_init_verbs },
3790 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3791 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003792 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003793 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3794 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003795 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003796 .input_mux = &alc880_capture_source,
3797 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003798 [ALC880_ASUS_DIG2] = {
3799 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003800 .init_verbs = { alc880_volume_init_verbs,
3801 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003802 alc880_gpio2_init_verbs }, /* use GPIO2 */
3803 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3804 .dac_nids = alc880_asus_dac_nids,
3805 .dig_out_nid = ALC880_DIGOUT_NID,
3806 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3807 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003808 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003809 .input_mux = &alc880_capture_source,
3810 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003811 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003812 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003813 .init_verbs = { alc880_volume_init_verbs,
3814 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003815 alc880_gpio1_init_verbs },
3816 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3817 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003818 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003819 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3820 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003821 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003822 .input_mux = &alc880_capture_source,
3823 },
3824 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003825 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003826 .init_verbs = { alc880_volume_init_verbs,
3827 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003828 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3829 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003830 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003831 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3832 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003833 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003834 .input_mux = &alc880_capture_source,
3835 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003836 [ALC880_UNIWILL] = {
3837 .mixers = { alc880_uniwill_mixer },
3838 .init_verbs = { alc880_volume_init_verbs,
3839 alc880_uniwill_init_verbs },
3840 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3841 .dac_nids = alc880_asus_dac_nids,
3842 .dig_out_nid = ALC880_DIGOUT_NID,
3843 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3844 .channel_mode = alc880_threestack_modes,
3845 .need_dac_fix = 1,
3846 .input_mux = &alc880_capture_source,
3847 .unsol_event = alc880_uniwill_unsol_event,
3848 .init_hook = alc880_uniwill_automute,
3849 },
3850 [ALC880_UNIWILL_P53] = {
3851 .mixers = { alc880_uniwill_p53_mixer },
3852 .init_verbs = { alc880_volume_init_verbs,
3853 alc880_uniwill_p53_init_verbs },
3854 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3855 .dac_nids = alc880_asus_dac_nids,
3856 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003857 .channel_mode = alc880_threestack_modes,
3858 .input_mux = &alc880_capture_source,
3859 .unsol_event = alc880_uniwill_p53_unsol_event,
3860 .init_hook = alc880_uniwill_p53_hp_automute,
3861 },
3862 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003863 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003864 .init_verbs = { alc880_volume_init_verbs,
3865 alc880_uniwill_p53_init_verbs,
3866 alc880_beep_init_verbs },
3867 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3868 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003869 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003870 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3871 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003872 .input_mux = &alc880_capture_source,
3873 .unsol_event = alc880_uniwill_p53_unsol_event,
3874 .init_hook = alc880_uniwill_p53_hp_automute,
3875 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003876 [ALC880_CLEVO] = {
3877 .mixers = { alc880_three_stack_mixer },
3878 .init_verbs = { alc880_volume_init_verbs,
3879 alc880_pin_clevo_init_verbs },
3880 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3881 .dac_nids = alc880_dac_nids,
3882 .hp_nid = 0x03,
3883 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3884 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003885 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003886 .input_mux = &alc880_capture_source,
3887 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003888 [ALC880_LG] = {
3889 .mixers = { alc880_lg_mixer },
3890 .init_verbs = { alc880_volume_init_verbs,
3891 alc880_lg_init_verbs },
3892 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3893 .dac_nids = alc880_lg_dac_nids,
3894 .dig_out_nid = ALC880_DIGOUT_NID,
3895 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3896 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003897 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003898 .input_mux = &alc880_lg_capture_source,
3899 .unsol_event = alc880_lg_unsol_event,
3900 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003901#ifdef CONFIG_SND_HDA_POWER_SAVE
3902 .loopbacks = alc880_lg_loopbacks,
3903#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003904 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003905 [ALC880_LG_LW] = {
3906 .mixers = { alc880_lg_lw_mixer },
3907 .init_verbs = { alc880_volume_init_verbs,
3908 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003909 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003910 .dac_nids = alc880_dac_nids,
3911 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003912 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3913 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003914 .input_mux = &alc880_lg_lw_capture_source,
3915 .unsol_event = alc880_lg_lw_unsol_event,
3916 .init_hook = alc880_lg_lw_automute,
3917 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003918 [ALC880_MEDION_RIM] = {
3919 .mixers = { alc880_medion_rim_mixer },
3920 .init_verbs = { alc880_volume_init_verbs,
3921 alc880_medion_rim_init_verbs,
3922 alc_gpio2_init_verbs },
3923 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3924 .dac_nids = alc880_dac_nids,
3925 .dig_out_nid = ALC880_DIGOUT_NID,
3926 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3927 .channel_mode = alc880_2_jack_modes,
3928 .input_mux = &alc880_medion_rim_capture_source,
3929 .unsol_event = alc880_medion_rim_unsol_event,
3930 .init_hook = alc880_medion_rim_automute,
3931 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003932#ifdef CONFIG_SND_DEBUG
3933 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003934 .mixers = { alc880_test_mixer },
3935 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003936 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3937 .dac_nids = alc880_test_dac_nids,
3938 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003939 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3940 .channel_mode = alc880_test_modes,
3941 .input_mux = &alc880_test_capture_source,
3942 },
3943#endif
3944};
3945
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003946/*
3947 * Automatic parse of I/O pins from the BIOS configuration
3948 */
3949
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003950enum {
3951 ALC_CTL_WIDGET_VOL,
3952 ALC_CTL_WIDGET_MUTE,
3953 ALC_CTL_BIND_MUTE,
3954};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003955static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003956 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3957 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003958 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003959};
3960
3961/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003962static int add_control(struct alc_spec *spec, int type, const char *name,
3963 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003964{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003965 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003966
Takashi Iwai603c4012008-07-30 15:01:44 +02003967 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3968 knew = snd_array_new(&spec->kctls);
3969 if (!knew)
3970 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003971 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003972 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003973 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003974 return -ENOMEM;
3975 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003976 return 0;
3977}
3978
3979#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3980#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3981#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3982#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3983#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3984#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3985#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3986#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3987#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3988#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3989#define ALC880_PIN_CD_NID 0x1c
3990
3991/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003992static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3993 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003994{
3995 hda_nid_t nid;
3996 int assigned[4];
3997 int i, j;
3998
3999 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004000 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004001
4002 /* check the pins hardwired to audio widget */
4003 for (i = 0; i < cfg->line_outs; i++) {
4004 nid = cfg->line_out_pins[i];
4005 if (alc880_is_fixed_pin(nid)) {
4006 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004007 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004008 assigned[idx] = 1;
4009 }
4010 }
4011 /* left pins can be connect to any audio widget */
4012 for (i = 0; i < cfg->line_outs; i++) {
4013 nid = cfg->line_out_pins[i];
4014 if (alc880_is_fixed_pin(nid))
4015 continue;
4016 /* search for an empty channel */
4017 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004018 if (!assigned[j]) {
4019 spec->multiout.dac_nids[i] =
4020 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004021 assigned[j] = 1;
4022 break;
4023 }
4024 }
4025 }
4026 spec->multiout.num_dacs = cfg->line_outs;
4027 return 0;
4028}
4029
4030/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004031static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4032 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004033{
4034 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004035 static const char *chname[4] = {
4036 "Front", "Surround", NULL /*CLFE*/, "Side"
4037 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004038 hda_nid_t nid;
4039 int i, err;
4040
4041 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004042 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004043 continue;
4044 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4045 if (i == 2) {
4046 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004047 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4048 "Center Playback Volume",
4049 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4050 HDA_OUTPUT));
4051 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004052 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004053 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4054 "LFE Playback Volume",
4055 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4056 HDA_OUTPUT));
4057 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004058 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004059 err = add_control(spec, ALC_CTL_BIND_MUTE,
4060 "Center Playback Switch",
4061 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4062 HDA_INPUT));
4063 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004064 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004065 err = add_control(spec, ALC_CTL_BIND_MUTE,
4066 "LFE Playback Switch",
4067 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4068 HDA_INPUT));
4069 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004070 return err;
4071 } else {
4072 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004073 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4074 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4075 HDA_OUTPUT));
4076 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004077 return err;
4078 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004079 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4080 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4081 HDA_INPUT));
4082 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004083 return err;
4084 }
4085 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004086 return 0;
4087}
4088
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004089/* add playback controls for speaker and HP outputs */
4090static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4091 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004092{
4093 hda_nid_t nid;
4094 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004095 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004096
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004097 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004098 return 0;
4099
4100 if (alc880_is_fixed_pin(pin)) {
4101 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004102 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004103 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004104 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004105 else
4106 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004107 /* control HP volume/switch on the output mixer amp */
4108 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004109 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004110 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4111 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4112 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004113 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004114 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004115 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4116 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4117 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004118 return err;
4119 } else if (alc880_is_multi_pin(pin)) {
4120 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004121 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004122 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004123 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4124 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4125 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004126 return err;
4127 }
4128 return 0;
4129}
4130
4131/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004132static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4133 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004134 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004135{
4136 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004137 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004138
4139 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004140 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4141 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4142 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004143 return err;
4144 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004145 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4146 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4147 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004148 return err;
4149 return 0;
4150}
4151
4152/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004153static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4154 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004155{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004156 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004157 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004158
4159 for (i = 0; i < AUTO_PIN_LAST; i++) {
4160 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004161 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004162 err = new_analog_input(spec, cfg->input_pins[i],
4163 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004164 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004165 if (err < 0)
4166 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004167 imux->items[imux->num_items].label =
4168 auto_pin_cfg_labels[i];
4169 imux->items[imux->num_items].index =
4170 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004171 imux->num_items++;
4172 }
4173 }
4174 return 0;
4175}
4176
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004177static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4178 unsigned int pin_type)
4179{
4180 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4181 pin_type);
4182 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004183 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4184 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004185}
4186
Kailang Yangdf694da2005-12-05 19:42:22 +01004187static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4188 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004189 int dac_idx)
4190{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004191 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004192 /* need the manual connection? */
4193 if (alc880_is_multi_pin(nid)) {
4194 struct alc_spec *spec = codec->spec;
4195 int idx = alc880_multi_pin_idx(nid);
4196 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4197 AC_VERB_SET_CONNECT_SEL,
4198 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4199 }
4200}
4201
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004202static int get_pin_type(int line_out_type)
4203{
4204 if (line_out_type == AUTO_PIN_HP_OUT)
4205 return PIN_HP;
4206 else
4207 return PIN_OUT;
4208}
4209
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004210static void alc880_auto_init_multi_out(struct hda_codec *codec)
4211{
4212 struct alc_spec *spec = codec->spec;
4213 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004214
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004215 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004216 for (i = 0; i < spec->autocfg.line_outs; i++) {
4217 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004218 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4219 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004220 }
4221}
4222
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004223static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004224{
4225 struct alc_spec *spec = codec->spec;
4226 hda_nid_t pin;
4227
Takashi Iwai82bc9552006-03-21 11:24:42 +01004228 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004229 if (pin) /* connect to front */
4230 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004231 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004232 if (pin) /* connect to front */
4233 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4234}
4235
4236static void alc880_auto_init_analog_input(struct hda_codec *codec)
4237{
4238 struct alc_spec *spec = codec->spec;
4239 int i;
4240
4241 for (i = 0; i < AUTO_PIN_LAST; i++) {
4242 hda_nid_t nid = spec->autocfg.input_pins[i];
4243 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004244 snd_hda_codec_write(codec, nid, 0,
4245 AC_VERB_SET_PIN_WIDGET_CONTROL,
4246 i <= AUTO_PIN_FRONT_MIC ?
4247 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004248 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004249 snd_hda_codec_write(codec, nid, 0,
4250 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004251 AMP_OUT_MUTE);
4252 }
4253 }
4254}
4255
4256/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004257/* return 1 if successful, 0 if the proper config is not found,
4258 * or a negative error code
4259 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004260static int alc880_parse_auto_config(struct hda_codec *codec)
4261{
4262 struct alc_spec *spec = codec->spec;
4263 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004264 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004265
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004266 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4267 alc880_ignore);
4268 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004269 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004270 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004271 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004272
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004273 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4274 if (err < 0)
4275 return err;
4276 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4277 if (err < 0)
4278 return err;
4279 err = alc880_auto_create_extra_out(spec,
4280 spec->autocfg.speaker_pins[0],
4281 "Speaker");
4282 if (err < 0)
4283 return err;
4284 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4285 "Headphone");
4286 if (err < 0)
4287 return err;
4288 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4289 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004290 return err;
4291
4292 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4293
Takashi Iwai0852d7a2009-02-11 11:35:15 +01004294 if (spec->autocfg.dig_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004295 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
4296 if (spec->autocfg.dig_in_pin)
4297 spec->dig_in_nid = ALC880_DIGIN_NID;
4298
Takashi Iwai603c4012008-07-30 15:01:44 +02004299 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004300 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004301
Takashi Iwaid88897e2008-10-31 15:01:37 +01004302 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004303
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004304 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004305 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004306
Takashi Iwaie044c392008-10-27 16:56:24 +01004307 store_pin_configs(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004308 return 1;
4309}
4310
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004311/* additional initialization for auto-configuration model */
4312static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004313{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004314 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004315 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004316 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004317 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004318 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004319 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004320}
4321
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004322static void set_capture_mixer(struct alc_spec *spec)
4323{
4324 static struct snd_kcontrol_new *caps[3] = {
4325 alc_capture_mixer1,
4326 alc_capture_mixer2,
4327 alc_capture_mixer3,
4328 };
Takashi Iwai30d72e92008-11-27 15:25:34 +01004329 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004330 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4331}
4332
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004333#define set_beep_amp(spec, nid, idx, dir) \
4334 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4335
4336/*
4337 * OK, here we have finally the patch for ALC880
4338 */
4339
Linus Torvalds1da177e2005-04-16 15:20:36 -07004340static int patch_alc880(struct hda_codec *codec)
4341{
4342 struct alc_spec *spec;
4343 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004344 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004345
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004346 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004347 if (spec == NULL)
4348 return -ENOMEM;
4349
4350 codec->spec = spec;
4351
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004352 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4353 alc880_models,
4354 alc880_cfg_tbl);
4355 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004356 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4357 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004358 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004359 }
4360
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004361 if (board_config == ALC880_AUTO) {
4362 /* automatic parse from the BIOS config */
4363 err = alc880_parse_auto_config(codec);
4364 if (err < 0) {
4365 alc_free(codec);
4366 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004367 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004368 printk(KERN_INFO
4369 "hda_codec: Cannot set up configuration "
4370 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004371 board_config = ALC880_3ST;
4372 }
4373 }
4374
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004375 err = snd_hda_attach_beep_device(codec, 0x1);
4376 if (err < 0) {
4377 alc_free(codec);
4378 return err;
4379 }
4380
Kailang Yangdf694da2005-12-05 19:42:22 +01004381 if (board_config != ALC880_AUTO)
4382 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004383
4384 spec->stream_name_analog = "ALC880 Analog";
4385 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4386 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004387 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004388
4389 spec->stream_name_digital = "ALC880 Digital";
4390 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4391 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4392
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004393 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004394 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004395 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004396 /* get type */
4397 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004398 if (wcap != AC_WID_AUD_IN) {
4399 spec->adc_nids = alc880_adc_nids_alt;
4400 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004401 } else {
4402 spec->adc_nids = alc880_adc_nids;
4403 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004404 }
4405 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004406 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004407 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004408
Takashi Iwai2134ea42008-01-10 16:53:55 +01004409 spec->vmaster_nid = 0x0c;
4410
Linus Torvalds1da177e2005-04-16 15:20:36 -07004411 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004412 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004413 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004414#ifdef CONFIG_SND_HDA_POWER_SAVE
4415 if (!spec->loopback.amplist)
4416 spec->loopback.amplist = alc880_loopbacks;
4417#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004418 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004419
4420 return 0;
4421}
4422
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004423
Linus Torvalds1da177e2005-04-16 15:20:36 -07004424/*
4425 * ALC260 support
4426 */
4427
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004428static hda_nid_t alc260_dac_nids[1] = {
4429 /* front */
4430 0x02,
4431};
4432
4433static hda_nid_t alc260_adc_nids[1] = {
4434 /* ADC0 */
4435 0x04,
4436};
4437
Kailang Yangdf694da2005-12-05 19:42:22 +01004438static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004439 /* ADC1 */
4440 0x05,
4441};
4442
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004443/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4444 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4445 */
4446static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004447 /* ADC0, ADC1 */
4448 0x04, 0x05
4449};
4450
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004451#define ALC260_DIGOUT_NID 0x03
4452#define ALC260_DIGIN_NID 0x06
4453
4454static struct hda_input_mux alc260_capture_source = {
4455 .num_items = 4,
4456 .items = {
4457 { "Mic", 0x0 },
4458 { "Front Mic", 0x1 },
4459 { "Line", 0x2 },
4460 { "CD", 0x4 },
4461 },
4462};
4463
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004464/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004465 * headphone jack and the internal CD lines since these are the only pins at
4466 * which audio can appear. For flexibility, also allow the option of
4467 * recording the mixer output on the second ADC (ADC0 doesn't have a
4468 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004469 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004470static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4471 {
4472 .num_items = 3,
4473 .items = {
4474 { "Mic/Line", 0x0 },
4475 { "CD", 0x4 },
4476 { "Headphone", 0x2 },
4477 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004478 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004479 {
4480 .num_items = 4,
4481 .items = {
4482 { "Mic/Line", 0x0 },
4483 { "CD", 0x4 },
4484 { "Headphone", 0x2 },
4485 { "Mixer", 0x5 },
4486 },
4487 },
4488
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004489};
4490
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004491/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4492 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004493 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004494static struct hda_input_mux alc260_acer_capture_sources[2] = {
4495 {
4496 .num_items = 4,
4497 .items = {
4498 { "Mic", 0x0 },
4499 { "Line", 0x2 },
4500 { "CD", 0x4 },
4501 { "Headphone", 0x5 },
4502 },
4503 },
4504 {
4505 .num_items = 5,
4506 .items = {
4507 { "Mic", 0x0 },
4508 { "Line", 0x2 },
4509 { "CD", 0x4 },
4510 { "Headphone", 0x6 },
4511 { "Mixer", 0x5 },
4512 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004513 },
4514};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004515/*
4516 * This is just place-holder, so there's something for alc_build_pcms to look
4517 * at when it calculates the maximum number of channels. ALC260 has no mixer
4518 * element which allows changing the channel mode, so the verb list is
4519 * never used.
4520 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004521static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004522 { 2, NULL },
4523};
4524
Kailang Yangdf694da2005-12-05 19:42:22 +01004525
4526/* Mixer combinations
4527 *
4528 * basic: base_output + input + pc_beep + capture
4529 * HP: base_output + input + capture_alt
4530 * HP_3013: hp_3013 + input + capture
4531 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004532 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004533 */
4534
4535static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004536 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004537 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004538 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4539 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4540 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4541 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4542 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004543};
Kailang Yangdf694da2005-12-05 19:42:22 +01004544
4545static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004546 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4547 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4548 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4549 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4551 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4552 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4553 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004554 { } /* end */
4555};
4556
Takashi Iwaibec15c32008-01-28 18:16:30 +01004557/* update HP, line and mono out pins according to the master switch */
4558static void alc260_hp_master_update(struct hda_codec *codec,
4559 hda_nid_t hp, hda_nid_t line,
4560 hda_nid_t mono)
4561{
4562 struct alc_spec *spec = codec->spec;
4563 unsigned int val = spec->master_sw ? PIN_HP : 0;
4564 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004565 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004566 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004567 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004568 val);
4569 /* mono (speaker) depending on the HP jack sense */
4570 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004571 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004572 val);
4573}
4574
4575static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4576 struct snd_ctl_elem_value *ucontrol)
4577{
4578 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4579 struct alc_spec *spec = codec->spec;
4580 *ucontrol->value.integer.value = spec->master_sw;
4581 return 0;
4582}
4583
4584static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4585 struct snd_ctl_elem_value *ucontrol)
4586{
4587 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4588 struct alc_spec *spec = codec->spec;
4589 int val = !!*ucontrol->value.integer.value;
4590 hda_nid_t hp, line, mono;
4591
4592 if (val == spec->master_sw)
4593 return 0;
4594 spec->master_sw = val;
4595 hp = (kcontrol->private_value >> 16) & 0xff;
4596 line = (kcontrol->private_value >> 8) & 0xff;
4597 mono = kcontrol->private_value & 0xff;
4598 alc260_hp_master_update(codec, hp, line, mono);
4599 return 1;
4600}
4601
4602static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4603 {
4604 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4605 .name = "Master Playback Switch",
4606 .info = snd_ctl_boolean_mono_info,
4607 .get = alc260_hp_master_sw_get,
4608 .put = alc260_hp_master_sw_put,
4609 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4610 },
4611 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4612 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4613 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4614 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4615 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4616 HDA_OUTPUT),
4617 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4618 { } /* end */
4619};
4620
4621static struct hda_verb alc260_hp_unsol_verbs[] = {
4622 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4623 {},
4624};
4625
4626static void alc260_hp_automute(struct hda_codec *codec)
4627{
4628 struct alc_spec *spec = codec->spec;
4629 unsigned int present;
4630
4631 present = snd_hda_codec_read(codec, 0x10, 0,
4632 AC_VERB_GET_PIN_SENSE, 0);
4633 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4634 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4635}
4636
4637static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4638{
4639 if ((res >> 26) == ALC880_HP_EVENT)
4640 alc260_hp_automute(codec);
4641}
4642
Kailang Yangdf694da2005-12-05 19:42:22 +01004643static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004644 {
4645 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4646 .name = "Master Playback Switch",
4647 .info = snd_ctl_boolean_mono_info,
4648 .get = alc260_hp_master_sw_get,
4649 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004650 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004651 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004652 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4653 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4654 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4655 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4656 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4657 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004658 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4659 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004660 { } /* end */
4661};
4662
Kailang Yang3f878302008-08-26 13:02:23 +02004663static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4664 .ops = &snd_hda_bind_vol,
4665 .values = {
4666 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4667 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4668 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4669 0
4670 },
4671};
4672
4673static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4674 .ops = &snd_hda_bind_sw,
4675 .values = {
4676 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4677 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4678 0
4679 },
4680};
4681
4682static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4683 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4684 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4685 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4686 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4687 { } /* end */
4688};
4689
Takashi Iwaibec15c32008-01-28 18:16:30 +01004690static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4691 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4692 {},
4693};
4694
4695static void alc260_hp_3013_automute(struct hda_codec *codec)
4696{
4697 struct alc_spec *spec = codec->spec;
4698 unsigned int present;
4699
4700 present = snd_hda_codec_read(codec, 0x15, 0,
4701 AC_VERB_GET_PIN_SENSE, 0);
4702 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004703 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004704}
4705
4706static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4707 unsigned int res)
4708{
4709 if ((res >> 26) == ALC880_HP_EVENT)
4710 alc260_hp_3013_automute(codec);
4711}
4712
Kailang Yang3f878302008-08-26 13:02:23 +02004713static void alc260_hp_3012_automute(struct hda_codec *codec)
4714{
4715 unsigned int present, bits;
4716
4717 present = snd_hda_codec_read(codec, 0x10, 0,
4718 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4719
4720 bits = present ? 0 : PIN_OUT;
4721 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4722 bits);
4723 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4724 bits);
4725 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4726 bits);
4727}
4728
4729static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4730 unsigned int res)
4731{
4732 if ((res >> 26) == ALC880_HP_EVENT)
4733 alc260_hp_3012_automute(codec);
4734}
4735
4736/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004737 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4738 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004739static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004740 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004741 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004742 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004743 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4744 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4745 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4746 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004747 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004748 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4749 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004750 { } /* end */
4751};
4752
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004753/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4754 * versions of the ALC260 don't act on requests to enable mic bias from NID
4755 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4756 * datasheet doesn't mention this restriction. At this stage it's not clear
4757 * whether this behaviour is intentional or is a hardware bug in chip
4758 * revisions available in early 2006. Therefore for now allow the
4759 * "Headphone Jack Mode" control to span all choices, but if it turns out
4760 * that the lack of mic bias for this NID is intentional we could change the
4761 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4762 *
4763 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4764 * don't appear to make the mic bias available from the "line" jack, even
4765 * though the NID used for this jack (0x14) can supply it. The theory is
4766 * that perhaps Acer have included blocking capacitors between the ALC260
4767 * and the output jack. If this turns out to be the case for all such
4768 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4769 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004770 *
4771 * The C20x Tablet series have a mono internal speaker which is controlled
4772 * via the chip's Mono sum widget and pin complex, so include the necessary
4773 * controls for such models. On models without a "mono speaker" the control
4774 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004775 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004776static struct snd_kcontrol_new alc260_acer_mixer[] = {
4777 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4778 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004779 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004780 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004781 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004782 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004783 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004784 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4785 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4786 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4787 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4788 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4789 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4790 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4791 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004792 { } /* end */
4793};
4794
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004795/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4796 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4797 */
4798static struct snd_kcontrol_new alc260_will_mixer[] = {
4799 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4800 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4801 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4802 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4803 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4804 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4805 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4806 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4807 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4808 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004809 { } /* end */
4810};
4811
4812/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4813 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4814 */
4815static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4816 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4817 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4818 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4819 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4820 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4821 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4822 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4823 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4824 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4825 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4826 { } /* end */
4827};
4828
Kailang Yangdf694da2005-12-05 19:42:22 +01004829/*
4830 * initialization verbs
4831 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004832static struct hda_verb alc260_init_verbs[] = {
4833 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004834 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004835 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004836 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004837 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004838 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004839 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004840 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004841 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004842 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004843 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004844 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004845 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004846 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004847 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004848 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004849 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004850 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4851 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004852 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004853 /* set connection select to line in (default select for this ADC) */
4854 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004855 /* mute capture amp left and right */
4856 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4857 /* set connection select to line in (default select for this ADC) */
4858 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004859 /* set vol=0 Line-Out mixer amp left and right */
4860 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4861 /* unmute pin widget amp left and right (no gain on this amp) */
4862 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4863 /* set vol=0 HP mixer amp left and right */
4864 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4865 /* unmute pin widget amp left and right (no gain on this amp) */
4866 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4867 /* set vol=0 Mono mixer amp left and right */
4868 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4869 /* unmute pin widget amp left and right (no gain on this amp) */
4870 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4871 /* unmute LINE-2 out pin */
4872 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004873 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4874 * Line In 2 = 0x03
4875 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004876 /* mute analog inputs */
4877 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4878 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4879 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4880 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4881 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004882 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004883 /* mute Front out path */
4884 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4885 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4886 /* mute Headphone out path */
4887 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4888 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4889 /* mute Mono out path */
4890 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4891 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004892 { }
4893};
4894
Takashi Iwai474167d2006-05-17 17:17:43 +02004895#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004896static struct hda_verb alc260_hp_init_verbs[] = {
4897 /* Headphone and output */
4898 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4899 /* mono output */
4900 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4901 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4902 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4903 /* Mic2 (front panel) pin widget for input and vref at 80% */
4904 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4905 /* Line In pin widget for input */
4906 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4907 /* Line-2 pin widget for output */
4908 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4909 /* CD pin widget for input */
4910 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4911 /* unmute amp left and right */
4912 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4913 /* set connection select to line in (default select for this ADC) */
4914 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4915 /* unmute Line-Out mixer amp left and right (volume = 0) */
4916 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4917 /* mute pin widget amp left and right (no gain on this amp) */
4918 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4919 /* unmute HP mixer amp left and right (volume = 0) */
4920 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4921 /* mute pin widget amp left and right (no gain on this amp) */
4922 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004923 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4924 * Line In 2 = 0x03
4925 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004926 /* mute analog inputs */
4927 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4928 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4929 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4930 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4931 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004932 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4933 /* Unmute Front out path */
4934 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4935 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4936 /* Unmute Headphone out path */
4937 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4938 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4939 /* Unmute Mono out path */
4940 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4941 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4942 { }
4943};
Takashi Iwai474167d2006-05-17 17:17:43 +02004944#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004945
4946static struct hda_verb alc260_hp_3013_init_verbs[] = {
4947 /* Line out and output */
4948 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4949 /* mono output */
4950 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4951 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4952 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4953 /* Mic2 (front panel) pin widget for input and vref at 80% */
4954 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4955 /* Line In pin widget for input */
4956 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4957 /* Headphone pin widget for output */
4958 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4959 /* CD pin widget for input */
4960 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4961 /* unmute amp left and right */
4962 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4963 /* set connection select to line in (default select for this ADC) */
4964 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4965 /* unmute Line-Out mixer amp left and right (volume = 0) */
4966 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4967 /* mute pin widget amp left and right (no gain on this amp) */
4968 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4969 /* unmute HP mixer amp left and right (volume = 0) */
4970 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4971 /* mute pin widget amp left and right (no gain on this amp) */
4972 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004973 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4974 * Line In 2 = 0x03
4975 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004976 /* mute analog inputs */
4977 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4978 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4979 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4980 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4981 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004982 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4983 /* Unmute Front out path */
4984 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4985 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4986 /* Unmute Headphone out path */
4987 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4988 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4989 /* Unmute Mono out path */
4990 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4991 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4992 { }
4993};
4994
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004995/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004996 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4997 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004998 */
4999static struct hda_verb alc260_fujitsu_init_verbs[] = {
5000 /* Disable all GPIOs */
5001 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5002 /* Internal speaker is connected to headphone pin */
5003 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5004 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5005 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005006 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5007 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5008 /* Ensure all other unused pins are disabled and muted. */
5009 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5010 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005011 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005012 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005013 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005014 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5015 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5016 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005017
Jonathan Woithef7ace402006-02-28 11:46:14 +01005018 /* Disable digital (SPDIF) pins */
5019 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5020 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005021
Kailang Yangea1fb292008-08-26 12:58:38 +02005022 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005023 * when acting as an output.
5024 */
5025 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5026
5027 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005028 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5029 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5030 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5031 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5032 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5033 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5034 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5035 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5036 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005037
Jonathan Woithef7ace402006-02-28 11:46:14 +01005038 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5039 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5040 /* Unmute Line1 pin widget output buffer since it starts as an output.
5041 * If the pin mode is changed by the user the pin mode control will
5042 * take care of enabling the pin's input/output buffers as needed.
5043 * Therefore there's no need to enable the input buffer at this
5044 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005045 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005046 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005047 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005048 * mixer ctrl)
5049 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005050 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005051
Jonathan Woithef7ace402006-02-28 11:46:14 +01005052 /* Mute capture amp left and right */
5053 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005054 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005055 * in (on mic1 pin)
5056 */
5057 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005058
Jonathan Woithef7ace402006-02-28 11:46:14 +01005059 /* Do the same for the second ADC: mute capture input amp and
5060 * set ADC connection to line in (on mic1 pin)
5061 */
5062 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5063 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005064
Jonathan Woithef7ace402006-02-28 11:46:14 +01005065 /* Mute all inputs to mixer widget (even unconnected ones) */
5066 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5067 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5068 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5069 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5070 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5071 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5072 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5073 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005074
5075 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005076};
5077
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005078/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5079 * similar laptops (adapted from Fujitsu init verbs).
5080 */
5081static struct hda_verb alc260_acer_init_verbs[] = {
5082 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5083 * the headphone jack. Turn this on and rely on the standard mute
5084 * methods whenever the user wants to turn these outputs off.
5085 */
5086 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5087 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5088 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5089 /* Internal speaker/Headphone jack is connected to Line-out pin */
5090 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5091 /* Internal microphone/Mic jack is connected to Mic1 pin */
5092 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5093 /* Line In jack is connected to Line1 pin */
5094 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005095 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5096 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005097 /* Ensure all other unused pins are disabled and muted. */
5098 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5099 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005100 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5101 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5102 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5103 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5104 /* Disable digital (SPDIF) pins */
5105 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5106 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5107
Kailang Yangea1fb292008-08-26 12:58:38 +02005108 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005109 * bus when acting as outputs.
5110 */
5111 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5112 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5113
5114 /* Start with output sum widgets muted and their output gains at min */
5115 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5116 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5117 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5118 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5119 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5120 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5121 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5122 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5123 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5124
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005125 /* Unmute Line-out pin widget amp left and right
5126 * (no equiv mixer ctrl)
5127 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005128 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005129 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5130 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005131 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5132 * inputs. If the pin mode is changed by the user the pin mode control
5133 * will take care of enabling the pin's input/output buffers as needed.
5134 * Therefore there's no need to enable the input buffer at this
5135 * stage.
5136 */
5137 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5138 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5139
5140 /* Mute capture amp left and right */
5141 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5142 /* Set ADC connection select to match default mixer setting - mic
5143 * (on mic1 pin)
5144 */
5145 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5146
5147 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005148 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005149 */
5150 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005151 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005152
5153 /* Mute all inputs to mixer widget (even unconnected ones) */
5154 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5155 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5156 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5158 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5159 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5160 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5161 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5162
5163 { }
5164};
5165
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005166static struct hda_verb alc260_will_verbs[] = {
5167 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5168 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5169 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5170 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5171 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5172 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5173 {}
5174};
5175
5176static struct hda_verb alc260_replacer_672v_verbs[] = {
5177 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5178 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5179 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5180
5181 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5182 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5183 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5184
5185 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5186 {}
5187};
5188
5189/* toggle speaker-output according to the hp-jack state */
5190static void alc260_replacer_672v_automute(struct hda_codec *codec)
5191{
5192 unsigned int present;
5193
5194 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5195 present = snd_hda_codec_read(codec, 0x0f, 0,
5196 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5197 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005198 snd_hda_codec_write_cache(codec, 0x01, 0,
5199 AC_VERB_SET_GPIO_DATA, 1);
5200 snd_hda_codec_write_cache(codec, 0x0f, 0,
5201 AC_VERB_SET_PIN_WIDGET_CONTROL,
5202 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005203 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005204 snd_hda_codec_write_cache(codec, 0x01, 0,
5205 AC_VERB_SET_GPIO_DATA, 0);
5206 snd_hda_codec_write_cache(codec, 0x0f, 0,
5207 AC_VERB_SET_PIN_WIDGET_CONTROL,
5208 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005209 }
5210}
5211
5212static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5213 unsigned int res)
5214{
5215 if ((res >> 26) == ALC880_HP_EVENT)
5216 alc260_replacer_672v_automute(codec);
5217}
5218
Kailang Yang3f878302008-08-26 13:02:23 +02005219static struct hda_verb alc260_hp_dc7600_verbs[] = {
5220 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5221 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5222 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5223 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5224 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5225 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5226 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5227 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5228 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5229 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5230 {}
5231};
5232
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005233/* Test configuration for debugging, modelled after the ALC880 test
5234 * configuration.
5235 */
5236#ifdef CONFIG_SND_DEBUG
5237static hda_nid_t alc260_test_dac_nids[1] = {
5238 0x02,
5239};
5240static hda_nid_t alc260_test_adc_nids[2] = {
5241 0x04, 0x05,
5242};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005243/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005244 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005245 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005246 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005247static struct hda_input_mux alc260_test_capture_sources[2] = {
5248 {
5249 .num_items = 7,
5250 .items = {
5251 { "MIC1 pin", 0x0 },
5252 { "MIC2 pin", 0x1 },
5253 { "LINE1 pin", 0x2 },
5254 { "LINE2 pin", 0x3 },
5255 { "CD pin", 0x4 },
5256 { "LINE-OUT pin", 0x5 },
5257 { "HP-OUT pin", 0x6 },
5258 },
5259 },
5260 {
5261 .num_items = 8,
5262 .items = {
5263 { "MIC1 pin", 0x0 },
5264 { "MIC2 pin", 0x1 },
5265 { "LINE1 pin", 0x2 },
5266 { "LINE2 pin", 0x3 },
5267 { "CD pin", 0x4 },
5268 { "Mixer", 0x5 },
5269 { "LINE-OUT pin", 0x6 },
5270 { "HP-OUT pin", 0x7 },
5271 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005272 },
5273};
5274static struct snd_kcontrol_new alc260_test_mixer[] = {
5275 /* Output driver widgets */
5276 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5277 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5278 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5279 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5280 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5281 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5282
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005283 /* Modes for retasking pin widgets
5284 * Note: the ALC260 doesn't seem to act on requests to enable mic
5285 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5286 * mention this restriction. At this stage it's not clear whether
5287 * this behaviour is intentional or is a hardware bug in chip
5288 * revisions available at least up until early 2006. Therefore for
5289 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5290 * choices, but if it turns out that the lack of mic bias for these
5291 * NIDs is intentional we could change their modes from
5292 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5293 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005294 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5295 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5296 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5297 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5298 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5299 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5300
5301 /* Loopback mixer controls */
5302 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5303 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5304 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5305 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5306 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5307 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5308 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5309 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5310 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5311 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005312 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5313 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5314 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5315 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005316
5317 /* Controls for GPIO pins, assuming they are configured as outputs */
5318 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5319 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5320 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5321 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5322
Jonathan Woithe92621f12006-02-28 11:47:47 +01005323 /* Switches to allow the digital IO pins to be enabled. The datasheet
5324 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005325 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005326 */
5327 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5328 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5329
Jonathan Woithef8225f62008-01-08 12:16:54 +01005330 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5331 * this output to turn on an external amplifier.
5332 */
5333 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5334 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5335
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005336 { } /* end */
5337};
5338static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005339 /* Enable all GPIOs as outputs with an initial value of 0 */
5340 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5341 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5342 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5343
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005344 /* Enable retasking pins as output, initially without power amp */
5345 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5346 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5347 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5348 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5349 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5350 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5351
Jonathan Woithe92621f12006-02-28 11:47:47 +01005352 /* Disable digital (SPDIF) pins initially, but users can enable
5353 * them via a mixer switch. In the case of SPDIF-out, this initverb
5354 * payload also sets the generation to 0, output to be in "consumer"
5355 * PCM format, copyright asserted, no pre-emphasis and no validity
5356 * control.
5357 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005358 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5359 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5360
Kailang Yangea1fb292008-08-26 12:58:38 +02005361 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005362 * OUT1 sum bus when acting as an output.
5363 */
5364 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5365 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5366 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5367 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5368
5369 /* Start with output sum widgets muted and their output gains at min */
5370 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5371 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5372 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5373 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5374 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5375 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5376 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5377 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5378 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5379
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005380 /* Unmute retasking pin widget output buffers since the default
5381 * state appears to be output. As the pin mode is changed by the
5382 * user the pin mode control will take care of enabling the pin's
5383 * input/output buffers as needed.
5384 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005385 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5386 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5387 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5388 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5389 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5390 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5391 /* Also unmute the mono-out pin widget */
5392 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5393
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005394 /* Mute capture amp left and right */
5395 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005396 /* Set ADC connection select to match default mixer setting (mic1
5397 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005398 */
5399 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5400
5401 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005402 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005403 */
5404 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5405 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5406
5407 /* Mute all inputs to mixer widget (even unconnected ones) */
5408 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5409 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5410 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5411 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5412 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5413 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5414 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5415 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5416
5417 { }
5418};
5419#endif
5420
Takashi Iwai63300792008-01-24 15:31:36 +01005421#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5422#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005423
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005424#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5425#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5426
Kailang Yangdf694da2005-12-05 19:42:22 +01005427/*
5428 * for BIOS auto-configuration
5429 */
5430
5431static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005432 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005433{
5434 hda_nid_t nid_vol;
5435 unsigned long vol_val, sw_val;
5436 char name[32];
5437 int err;
5438
5439 if (nid >= 0x0f && nid < 0x11) {
5440 nid_vol = nid - 0x7;
5441 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5442 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5443 } else if (nid == 0x11) {
5444 nid_vol = nid - 0x7;
5445 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5446 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5447 } else if (nid >= 0x12 && nid <= 0x15) {
5448 nid_vol = 0x08;
5449 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5450 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5451 } else
5452 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005453
Takashi Iwai863b4512008-10-21 17:01:47 +02005454 if (!(*vol_bits & (1 << nid_vol))) {
5455 /* first control for the volume widget */
5456 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5457 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5458 if (err < 0)
5459 return err;
5460 *vol_bits |= (1 << nid_vol);
5461 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005462 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005463 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5464 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005465 return err;
5466 return 1;
5467}
5468
5469/* add playback controls from the parsed DAC table */
5470static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5471 const struct auto_pin_cfg *cfg)
5472{
5473 hda_nid_t nid;
5474 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005475 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005476
5477 spec->multiout.num_dacs = 1;
5478 spec->multiout.dac_nids = spec->private_dac_nids;
5479 spec->multiout.dac_nids[0] = 0x02;
5480
5481 nid = cfg->line_out_pins[0];
5482 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005483 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005484 if (err < 0)
5485 return err;
5486 }
5487
Takashi Iwai82bc9552006-03-21 11:24:42 +01005488 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005489 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005490 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005491 if (err < 0)
5492 return err;
5493 }
5494
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005495 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005496 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005497 err = alc260_add_playback_controls(spec, nid, "Headphone",
5498 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005499 if (err < 0)
5500 return err;
5501 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005502 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005503}
5504
5505/* create playback/capture controls for input pins */
5506static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5507 const struct auto_pin_cfg *cfg)
5508{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005509 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005510 int i, err, idx;
5511
5512 for (i = 0; i < AUTO_PIN_LAST; i++) {
5513 if (cfg->input_pins[i] >= 0x12) {
5514 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005515 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005516 auto_pin_cfg_labels[i], idx,
5517 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005518 if (err < 0)
5519 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005520 imux->items[imux->num_items].label =
5521 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005522 imux->items[imux->num_items].index = idx;
5523 imux->num_items++;
5524 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005525 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005526 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005527 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005528 auto_pin_cfg_labels[i], idx,
5529 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005530 if (err < 0)
5531 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005532 imux->items[imux->num_items].label =
5533 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005534 imux->items[imux->num_items].index = idx;
5535 imux->num_items++;
5536 }
5537 }
5538 return 0;
5539}
5540
5541static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5542 hda_nid_t nid, int pin_type,
5543 int sel_idx)
5544{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005545 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005546 /* need the manual connection? */
5547 if (nid >= 0x12) {
5548 int idx = nid - 0x12;
5549 snd_hda_codec_write(codec, idx + 0x0b, 0,
5550 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005551 }
5552}
5553
5554static void alc260_auto_init_multi_out(struct hda_codec *codec)
5555{
5556 struct alc_spec *spec = codec->spec;
5557 hda_nid_t nid;
5558
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005559 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005560 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005561 if (nid) {
5562 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5563 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5564 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005565
Takashi Iwai82bc9552006-03-21 11:24:42 +01005566 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005567 if (nid)
5568 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5569
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005570 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005571 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005572 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005573}
Kailang Yangdf694da2005-12-05 19:42:22 +01005574
5575#define ALC260_PIN_CD_NID 0x16
5576static void alc260_auto_init_analog_input(struct hda_codec *codec)
5577{
5578 struct alc_spec *spec = codec->spec;
5579 int i;
5580
5581 for (i = 0; i < AUTO_PIN_LAST; i++) {
5582 hda_nid_t nid = spec->autocfg.input_pins[i];
5583 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005584 snd_hda_codec_write(codec, nid, 0,
5585 AC_VERB_SET_PIN_WIDGET_CONTROL,
5586 i <= AUTO_PIN_FRONT_MIC ?
5587 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005588 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005589 snd_hda_codec_write(codec, nid, 0,
5590 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005591 AMP_OUT_MUTE);
5592 }
5593 }
5594}
5595
5596/*
5597 * generic initialization of ADC, input mixers and output mixers
5598 */
5599static struct hda_verb alc260_volume_init_verbs[] = {
5600 /*
5601 * Unmute ADC0-1 and set the default input to mic-in
5602 */
5603 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5604 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5605 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5606 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005607
Kailang Yangdf694da2005-12-05 19:42:22 +01005608 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5609 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005610 * Note: PASD motherboards uses the Line In 2 as the input for
5611 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005612 */
5613 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005614 /* mute analog inputs */
5615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5618 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5619 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005620
5621 /*
5622 * Set up output mixers (0x08 - 0x0a)
5623 */
5624 /* set vol=0 to output mixers */
5625 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5626 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5627 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5628 /* set up input amps for analog loopback */
5629 /* Amp Indices: DAC = 0, mixer = 1 */
5630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5631 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5632 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5633 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5634 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5635 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005636
Kailang Yangdf694da2005-12-05 19:42:22 +01005637 { }
5638};
5639
5640static int alc260_parse_auto_config(struct hda_codec *codec)
5641{
5642 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005643 int err;
5644 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5645
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005646 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5647 alc260_ignore);
5648 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005649 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005650 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5651 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005652 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005653 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005654 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005655 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5656 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005657 return err;
5658
5659 spec->multiout.max_channels = 2;
5660
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005661 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005662 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005663 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005664 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005665
Takashi Iwaid88897e2008-10-31 15:01:37 +01005666 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005667
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005668 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005669 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005670
Takashi Iwaie044c392008-10-27 16:56:24 +01005671 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005672 return 1;
5673}
5674
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005675/* additional initialization for auto-configuration model */
5676static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005677{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005678 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005679 alc260_auto_init_multi_out(codec);
5680 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005681 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005682 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005683}
5684
Takashi Iwaicb53c622007-08-10 17:21:45 +02005685#ifdef CONFIG_SND_HDA_POWER_SAVE
5686static struct hda_amp_list alc260_loopbacks[] = {
5687 { 0x07, HDA_INPUT, 0 },
5688 { 0x07, HDA_INPUT, 1 },
5689 { 0x07, HDA_INPUT, 2 },
5690 { 0x07, HDA_INPUT, 3 },
5691 { 0x07, HDA_INPUT, 4 },
5692 { } /* end */
5693};
5694#endif
5695
Kailang Yangdf694da2005-12-05 19:42:22 +01005696/*
5697 * ALC260 configurations
5698 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005699static const char *alc260_models[ALC260_MODEL_LAST] = {
5700 [ALC260_BASIC] = "basic",
5701 [ALC260_HP] = "hp",
5702 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005703 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005704 [ALC260_FUJITSU_S702X] = "fujitsu",
5705 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005706 [ALC260_WILL] = "will",
5707 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005708#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005709 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005710#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005711 [ALC260_AUTO] = "auto",
5712};
5713
5714static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005715 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005716 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005717 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005718 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005719 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005720 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005721 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005722 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5723 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5724 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5725 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5726 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5727 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5728 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5729 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5730 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005731 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005732 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005733 {}
5734};
5735
Kailang Yangdf694da2005-12-05 19:42:22 +01005736static struct alc_config_preset alc260_presets[] = {
5737 [ALC260_BASIC] = {
5738 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005739 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005740 .init_verbs = { alc260_init_verbs },
5741 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5742 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005743 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005744 .adc_nids = alc260_adc_nids,
5745 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5746 .channel_mode = alc260_modes,
5747 .input_mux = &alc260_capture_source,
5748 },
5749 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005750 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005751 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005752 .init_verbs = { alc260_init_verbs,
5753 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005754 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5755 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005756 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5757 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005758 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5759 .channel_mode = alc260_modes,
5760 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005761 .unsol_event = alc260_hp_unsol_event,
5762 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005763 },
Kailang Yang3f878302008-08-26 13:02:23 +02005764 [ALC260_HP_DC7600] = {
5765 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005766 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005767 .init_verbs = { alc260_init_verbs,
5768 alc260_hp_dc7600_verbs },
5769 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5770 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005771 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5772 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005773 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5774 .channel_mode = alc260_modes,
5775 .input_mux = &alc260_capture_source,
5776 .unsol_event = alc260_hp_3012_unsol_event,
5777 .init_hook = alc260_hp_3012_automute,
5778 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005779 [ALC260_HP_3013] = {
5780 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005781 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005782 .init_verbs = { alc260_hp_3013_init_verbs,
5783 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005784 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5785 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005786 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5787 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005788 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5789 .channel_mode = alc260_modes,
5790 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005791 .unsol_event = alc260_hp_3013_unsol_event,
5792 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005793 },
5794 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005795 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005796 .init_verbs = { alc260_fujitsu_init_verbs },
5797 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5798 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005799 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5800 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005801 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5802 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005803 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5804 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005805 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005806 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005807 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005808 .init_verbs = { alc260_acer_init_verbs },
5809 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5810 .dac_nids = alc260_dac_nids,
5811 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5812 .adc_nids = alc260_dual_adc_nids,
5813 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5814 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005815 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5816 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005817 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005818 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005819 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005820 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5821 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5822 .dac_nids = alc260_dac_nids,
5823 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5824 .adc_nids = alc260_adc_nids,
5825 .dig_out_nid = ALC260_DIGOUT_NID,
5826 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5827 .channel_mode = alc260_modes,
5828 .input_mux = &alc260_capture_source,
5829 },
5830 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005831 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005832 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5833 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5834 .dac_nids = alc260_dac_nids,
5835 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5836 .adc_nids = alc260_adc_nids,
5837 .dig_out_nid = ALC260_DIGOUT_NID,
5838 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5839 .channel_mode = alc260_modes,
5840 .input_mux = &alc260_capture_source,
5841 .unsol_event = alc260_replacer_672v_unsol_event,
5842 .init_hook = alc260_replacer_672v_automute,
5843 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005844#ifdef CONFIG_SND_DEBUG
5845 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005846 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005847 .init_verbs = { alc260_test_init_verbs },
5848 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5849 .dac_nids = alc260_test_dac_nids,
5850 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5851 .adc_nids = alc260_test_adc_nids,
5852 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5853 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005854 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5855 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005856 },
5857#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005858};
5859
Linus Torvalds1da177e2005-04-16 15:20:36 -07005860static int patch_alc260(struct hda_codec *codec)
5861{
5862 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005863 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005864
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005865 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005866 if (spec == NULL)
5867 return -ENOMEM;
5868
5869 codec->spec = spec;
5870
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005871 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5872 alc260_models,
5873 alc260_cfg_tbl);
5874 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005875 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5876 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005877 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005878 }
5879
Kailang Yangdf694da2005-12-05 19:42:22 +01005880 if (board_config == ALC260_AUTO) {
5881 /* automatic parse from the BIOS config */
5882 err = alc260_parse_auto_config(codec);
5883 if (err < 0) {
5884 alc_free(codec);
5885 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005886 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005887 printk(KERN_INFO
5888 "hda_codec: Cannot set up configuration "
5889 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005890 board_config = ALC260_BASIC;
5891 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005892 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005893
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005894 err = snd_hda_attach_beep_device(codec, 0x1);
5895 if (err < 0) {
5896 alc_free(codec);
5897 return err;
5898 }
5899
Kailang Yangdf694da2005-12-05 19:42:22 +01005900 if (board_config != ALC260_AUTO)
5901 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005902
5903 spec->stream_name_analog = "ALC260 Analog";
5904 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5905 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5906
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005907 spec->stream_name_digital = "ALC260 Digital";
5908 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5909 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5910
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01005911 if (!spec->adc_nids && spec->input_mux) {
5912 /* check whether NID 0x04 is valid */
5913 unsigned int wcap = get_wcaps(codec, 0x04);
5914 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5915 /* get type */
5916 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5917 spec->adc_nids = alc260_adc_nids_alt;
5918 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5919 } else {
5920 spec->adc_nids = alc260_adc_nids;
5921 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5922 }
5923 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005924 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005925 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005926
Takashi Iwai2134ea42008-01-10 16:53:55 +01005927 spec->vmaster_nid = 0x08;
5928
Linus Torvalds1da177e2005-04-16 15:20:36 -07005929 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005930 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005931 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005932#ifdef CONFIG_SND_HDA_POWER_SAVE
5933 if (!spec->loopback.amplist)
5934 spec->loopback.amplist = alc260_loopbacks;
5935#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01005936 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005937
5938 return 0;
5939}
5940
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005941
Linus Torvalds1da177e2005-04-16 15:20:36 -07005942/*
5943 * ALC882 support
5944 *
5945 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5946 * configuration. Each pin widget can choose any input DACs and a mixer.
5947 * Each ADC is connected from a mixer of all inputs. This makes possible
5948 * 6-channel independent captures.
5949 *
5950 * In addition, an independent DAC for the multi-playback (not used in this
5951 * driver yet).
5952 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005953#define ALC882_DIGOUT_NID 0x06
5954#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005955
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005956static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005957 { 8, NULL }
5958};
5959
5960static hda_nid_t alc882_dac_nids[4] = {
5961 /* front, rear, clfe, rear_surr */
5962 0x02, 0x03, 0x04, 0x05
5963};
5964
Kailang Yangdf694da2005-12-05 19:42:22 +01005965/* identical with ALC880 */
5966#define alc882_adc_nids alc880_adc_nids
5967#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005968
Takashi Iwaie1406342008-02-11 18:32:32 +01005969static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5970static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5971
Linus Torvalds1da177e2005-04-16 15:20:36 -07005972/* input MUX */
5973/* FIXME: should be a matrix-type input source selection */
5974
5975static struct hda_input_mux alc882_capture_source = {
5976 .num_items = 4,
5977 .items = {
5978 { "Mic", 0x0 },
5979 { "Front Mic", 0x1 },
5980 { "Line", 0x2 },
5981 { "CD", 0x4 },
5982 },
5983};
Kailang Yangdf694da2005-12-05 19:42:22 +01005984/*
Kailang Yang272a5272007-05-14 11:00:38 +02005985 * 2ch mode
5986 */
5987static struct hda_verb alc882_3ST_ch2_init[] = {
5988 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5989 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5990 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5991 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5992 { } /* end */
5993};
5994
5995/*
5996 * 6ch mode
5997 */
5998static struct hda_verb alc882_3ST_ch6_init[] = {
5999 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6000 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6001 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6002 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6003 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6004 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6005 { } /* end */
6006};
6007
6008static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6009 { 2, alc882_3ST_ch2_init },
6010 { 6, alc882_3ST_ch6_init },
6011};
6012
6013/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006014 * 6ch mode
6015 */
6016static struct hda_verb alc882_sixstack_ch6_init[] = {
6017 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6018 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6019 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6020 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6021 { } /* end */
6022};
6023
6024/*
6025 * 8ch mode
6026 */
6027static struct hda_verb alc882_sixstack_ch8_init[] = {
6028 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6029 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6030 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6031 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6032 { } /* end */
6033};
6034
6035static struct hda_channel_mode alc882_sixstack_modes[2] = {
6036 { 6, alc882_sixstack_ch6_init },
6037 { 8, alc882_sixstack_ch8_init },
6038};
6039
Takashi Iwai87350ad2007-08-16 18:19:38 +02006040/*
6041 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6042 */
6043
6044/*
6045 * 2ch mode
6046 */
6047static struct hda_verb alc885_mbp_ch2_init[] = {
6048 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6049 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6050 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6051 { } /* end */
6052};
6053
6054/*
6055 * 6ch mode
6056 */
6057static struct hda_verb alc885_mbp_ch6_init[] = {
6058 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6059 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6060 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6061 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6062 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6063 { } /* end */
6064};
6065
6066static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6067 { 2, alc885_mbp_ch2_init },
6068 { 6, alc885_mbp_ch6_init },
6069};
6070
6071
Linus Torvalds1da177e2005-04-16 15:20:36 -07006072/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6073 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6074 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006075static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006076 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006077 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006078 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006079 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006080 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6081 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006082 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6083 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006084 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006085 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006086 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6087 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6088 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6089 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6090 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006092 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006093 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6094 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006095 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006096 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006097 { } /* end */
6098};
6099
Takashi Iwai87350ad2007-08-16 18:19:38 +02006100static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006101 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6102 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6103 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6104 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6105 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6106 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006107 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6108 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006109 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006110 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6111 { } /* end */
6112};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006113static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6114 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6115 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6116 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6117 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6118 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6119 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6120 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6121 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6122 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006123 { } /* end */
6124};
6125
Kailang Yang272a5272007-05-14 11:00:38 +02006126static struct snd_kcontrol_new alc882_targa_mixer[] = {
6127 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6128 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6129 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6130 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6131 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6132 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6133 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006136 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006137 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6138 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006139 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006140 { } /* end */
6141};
6142
6143/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6144 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6145 */
6146static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6147 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6148 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6149 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6150 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6151 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6152 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6153 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6154 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6155 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6156 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6157 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6158 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006159 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006160 { } /* end */
6161};
6162
Takashi Iwai914759b2007-09-06 14:52:04 +02006163static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6164 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6165 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6166 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6167 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6168 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6169 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6170 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6171 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6172 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6173 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006174 { } /* end */
6175};
6176
Kailang Yangdf694da2005-12-05 19:42:22 +01006177static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6178 {
6179 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6180 .name = "Channel Mode",
6181 .info = alc_ch_mode_info,
6182 .get = alc_ch_mode_get,
6183 .put = alc_ch_mode_put,
6184 },
6185 { } /* end */
6186};
6187
Linus Torvalds1da177e2005-04-16 15:20:36 -07006188static struct hda_verb alc882_init_verbs[] = {
6189 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006190 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6191 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6192 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006193 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006194 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6195 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6196 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006197 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006198 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6199 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6200 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006201 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006202 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6203 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6204 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006205
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006206 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006207 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006208 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006209 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006210 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006211 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006212 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006213 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006214 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006215 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006216 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006217 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006218 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006219 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006220 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006221 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006222 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006223 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006224 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6225 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006226 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006227 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6228 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006229 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006230 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6231 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6232 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6233 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6234 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006235 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006236 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006237
6238 /* FIXME: use matrix-type input source selection */
6239 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6240 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006241 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6242 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6243 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006245 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006246 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6247 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6248 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6249 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006250 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006251 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6252 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6253 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6254 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6255 /* ADC1: mute amp left and right */
6256 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006257 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006258 /* ADC2: mute amp left and right */
6259 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006260 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006261 /* ADC3: mute amp left and right */
6262 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006263 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006264
6265 { }
6266};
6267
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006268static struct hda_verb alc882_eapd_verbs[] = {
6269 /* change to EAPD mode */
6270 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006271 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006272 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006273};
6274
Tobin Davis9102cd12006-12-15 10:02:12 +01006275/* Mac Pro test */
6276static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6277 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6278 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6279 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6280 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6281 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006282 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006283 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6284 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006285 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006286 { } /* end */
6287};
6288
6289static struct hda_verb alc882_macpro_init_verbs[] = {
6290 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6291 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6292 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6293 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6294 /* Front Pin: output 0 (0x0c) */
6295 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6296 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6297 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6298 /* Front Mic pin: input vref at 80% */
6299 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6300 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6301 /* Speaker: output */
6302 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6303 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6304 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6305 /* Headphone output (output 0 - 0x0c) */
6306 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6307 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6308 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6309
6310 /* FIXME: use matrix-type input source selection */
6311 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6312 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6313 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6314 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6315 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6316 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6317 /* Input mixer2 */
6318 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6319 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6320 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6321 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6322 /* Input mixer3 */
6323 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6324 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6325 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6326 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6327 /* ADC1: mute amp left and right */
6328 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6329 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6330 /* ADC2: mute amp left and right */
6331 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6332 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6333 /* ADC3: mute amp left and right */
6334 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6335 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6336
6337 { }
6338};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006339
Takashi Iwai87350ad2007-08-16 18:19:38 +02006340/* Macbook Pro rev3 */
6341static struct hda_verb alc885_mbp3_init_verbs[] = {
6342 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6343 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6346 /* Rear mixer */
6347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6348 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6349 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6350 /* Front Pin: output 0 (0x0c) */
6351 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6352 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6353 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6354 /* HP Pin: output 0 (0x0d) */
6355 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6356 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6357 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6358 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6359 /* Mic (rear) pin: input vref at 80% */
6360 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6361 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6362 /* Front Mic pin: input vref at 80% */
6363 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6364 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6365 /* Line In pin: use output 1 when in LineOut mode */
6366 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6367 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6368 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6369
6370 /* FIXME: use matrix-type input source selection */
6371 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6372 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6373 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6374 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6375 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6376 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6377 /* Input mixer2 */
6378 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6379 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6380 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6381 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6382 /* Input mixer3 */
6383 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6384 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6385 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6386 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6387 /* ADC1: mute amp left and right */
6388 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6389 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6390 /* ADC2: mute amp left and right */
6391 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6392 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6393 /* ADC3: mute amp left and right */
6394 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6395 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6396
6397 { }
6398};
6399
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006400/* iMac 24 mixer. */
6401static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6402 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6403 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6404 { } /* end */
6405};
6406
6407/* iMac 24 init verbs. */
6408static struct hda_verb alc885_imac24_init_verbs[] = {
6409 /* Internal speakers: output 0 (0x0c) */
6410 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6411 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6412 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6413 /* Internal speakers: output 0 (0x0c) */
6414 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6415 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6416 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6417 /* Headphone: output 0 (0x0c) */
6418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6419 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6420 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6421 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6422 /* Front Mic: input vref at 80% */
6423 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6424 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6425 { }
6426};
6427
6428/* Toggle speaker-output according to the hp-jack state */
6429static void alc885_imac24_automute(struct hda_codec *codec)
6430{
6431 unsigned int present;
6432
6433 present = snd_hda_codec_read(codec, 0x14, 0,
6434 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006435 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6436 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6437 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6438 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006439}
6440
6441/* Processes unsolicited events. */
6442static void alc885_imac24_unsol_event(struct hda_codec *codec,
6443 unsigned int res)
6444{
6445 /* Headphone insertion or removal. */
6446 if ((res >> 26) == ALC880_HP_EVENT)
6447 alc885_imac24_automute(codec);
6448}
6449
Takashi Iwai87350ad2007-08-16 18:19:38 +02006450static void alc885_mbp3_automute(struct hda_codec *codec)
6451{
6452 unsigned int present;
6453
6454 present = snd_hda_codec_read(codec, 0x15, 0,
6455 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6456 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6457 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6458 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6459 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6460
6461}
6462static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6463 unsigned int res)
6464{
6465 /* Headphone insertion or removal. */
6466 if ((res >> 26) == ALC880_HP_EVENT)
6467 alc885_mbp3_automute(codec);
6468}
6469
6470
Kailang Yang272a5272007-05-14 11:00:38 +02006471static struct hda_verb alc882_targa_verbs[] = {
6472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6473 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6474
6475 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6476 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006477
Kailang Yang272a5272007-05-14 11:00:38 +02006478 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6479 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6480 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6481
6482 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6483 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6484 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6485 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6486 { } /* end */
6487};
6488
6489/* toggle speaker-output according to the hp-jack state */
6490static void alc882_targa_automute(struct hda_codec *codec)
6491{
6492 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006493
Kailang Yang272a5272007-05-14 11:00:38 +02006494 present = snd_hda_codec_read(codec, 0x14, 0,
6495 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006496 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6497 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006498 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6499 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006500}
6501
6502static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6503{
6504 /* Looks like the unsol event is incompatible with the standard
6505 * definition. 4bit tag is placed at 26 bit!
6506 */
6507 if (((res >> 26) == ALC880_HP_EVENT)) {
6508 alc882_targa_automute(codec);
6509 }
6510}
6511
6512static struct hda_verb alc882_asus_a7j_verbs[] = {
6513 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6514 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6515
6516 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6517 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6518 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006519
Kailang Yang272a5272007-05-14 11:00:38 +02006520 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6521 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6522 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6523
6524 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6525 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6526 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6527 { } /* end */
6528};
6529
Takashi Iwai914759b2007-09-06 14:52:04 +02006530static struct hda_verb alc882_asus_a7m_verbs[] = {
6531 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6532 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6533
6534 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6535 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6536 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006537
Takashi Iwai914759b2007-09-06 14:52:04 +02006538 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6539 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6540 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6541
6542 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6543 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6544 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6545 { } /* end */
6546};
6547
Tobin Davis9102cd12006-12-15 10:02:12 +01006548static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6549{
6550 unsigned int gpiostate, gpiomask, gpiodir;
6551
6552 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6553 AC_VERB_GET_GPIO_DATA, 0);
6554
6555 if (!muted)
6556 gpiostate |= (1 << pin);
6557 else
6558 gpiostate &= ~(1 << pin);
6559
6560 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6561 AC_VERB_GET_GPIO_MASK, 0);
6562 gpiomask |= (1 << pin);
6563
6564 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6565 AC_VERB_GET_GPIO_DIRECTION, 0);
6566 gpiodir |= (1 << pin);
6567
6568
6569 snd_hda_codec_write(codec, codec->afg, 0,
6570 AC_VERB_SET_GPIO_MASK, gpiomask);
6571 snd_hda_codec_write(codec, codec->afg, 0,
6572 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6573
6574 msleep(1);
6575
6576 snd_hda_codec_write(codec, codec->afg, 0,
6577 AC_VERB_SET_GPIO_DATA, gpiostate);
6578}
6579
Takashi Iwai7debbe52007-08-16 15:01:03 +02006580/* set up GPIO at initialization */
6581static void alc885_macpro_init_hook(struct hda_codec *codec)
6582{
6583 alc882_gpio_mute(codec, 0, 0);
6584 alc882_gpio_mute(codec, 1, 0);
6585}
6586
6587/* set up GPIO and update auto-muting at initialization */
6588static void alc885_imac24_init_hook(struct hda_codec *codec)
6589{
6590 alc885_macpro_init_hook(codec);
6591 alc885_imac24_automute(codec);
6592}
6593
Kailang Yangdf694da2005-12-05 19:42:22 +01006594/*
6595 * generic initialization of ADC, input mixers and output mixers
6596 */
6597static struct hda_verb alc882_auto_init_verbs[] = {
6598 /*
6599 * Unmute ADC0-2 and set the default input to mic-in
6600 */
6601 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6602 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6603 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6604 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6605 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6606 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6607
Takashi Iwaicb53c622007-08-10 17:21:45 +02006608 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006609 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006610 * Note: PASD motherboards uses the Line In 2 as the input for
6611 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006612 */
6613 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006614 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6615 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6616 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6617 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6618 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006619
6620 /*
6621 * Set up output mixers (0x0c - 0x0f)
6622 */
6623 /* set vol=0 to output mixers */
6624 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6625 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6626 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6627 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6628 /* set up input amps for analog loopback */
6629 /* Amp Indices: DAC = 0, mixer = 1 */
6630 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6631 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6632 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6633 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6634 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6635 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6636 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6637 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6638 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6639 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6640
6641 /* FIXME: use matrix-type input source selection */
6642 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6643 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6644 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6645 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6646 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6647 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6648 /* Input mixer2 */
6649 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6650 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6651 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6653 /* Input mixer3 */
6654 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6655 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6656 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6657 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6658
6659 { }
6660};
6661
Takashi Iwaicb53c622007-08-10 17:21:45 +02006662#ifdef CONFIG_SND_HDA_POWER_SAVE
6663#define alc882_loopbacks alc880_loopbacks
6664#endif
6665
Kailang Yangdf694da2005-12-05 19:42:22 +01006666/* pcm configuration: identiacal with ALC880 */
6667#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6668#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6669#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6670#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6671
6672/*
6673 * configuration and preset
6674 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006675static const char *alc882_models[ALC882_MODEL_LAST] = {
6676 [ALC882_3ST_DIG] = "3stack-dig",
6677 [ALC882_6ST_DIG] = "6stack-dig",
6678 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006679 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006680 [ALC882_TARGA] = "targa",
6681 [ALC882_ASUS_A7J] = "asus-a7j",
6682 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006683 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006684 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006685 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006686 [ALC882_AUTO] = "auto",
6687};
6688
6689static struct snd_pci_quirk alc882_cfg_tbl[] = {
6690 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006691 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006692 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006693 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006694 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006695 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006696 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006697 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006698 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006699 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6700 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6701 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006702 {}
6703};
6704
6705static struct alc_config_preset alc882_presets[] = {
6706 [ALC882_3ST_DIG] = {
6707 .mixers = { alc882_base_mixer },
6708 .init_verbs = { alc882_init_verbs },
6709 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6710 .dac_nids = alc882_dac_nids,
6711 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006712 .dig_in_nid = ALC882_DIGIN_NID,
6713 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6714 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006715 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006716 .input_mux = &alc882_capture_source,
6717 },
6718 [ALC882_6ST_DIG] = {
6719 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6720 .init_verbs = { alc882_init_verbs },
6721 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6722 .dac_nids = alc882_dac_nids,
6723 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006724 .dig_in_nid = ALC882_DIGIN_NID,
6725 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6726 .channel_mode = alc882_sixstack_modes,
6727 .input_mux = &alc882_capture_source,
6728 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006729 [ALC882_ARIMA] = {
6730 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6731 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6732 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6733 .dac_nids = alc882_dac_nids,
6734 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6735 .channel_mode = alc882_sixstack_modes,
6736 .input_mux = &alc882_capture_source,
6737 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006738 [ALC882_W2JC] = {
6739 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6740 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6741 alc880_gpio1_init_verbs },
6742 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6743 .dac_nids = alc882_dac_nids,
6744 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6745 .channel_mode = alc880_threestack_modes,
6746 .need_dac_fix = 1,
6747 .input_mux = &alc882_capture_source,
6748 .dig_out_nid = ALC882_DIGOUT_NID,
6749 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006750 [ALC885_MBP3] = {
6751 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6752 .init_verbs = { alc885_mbp3_init_verbs,
6753 alc880_gpio1_init_verbs },
6754 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6755 .dac_nids = alc882_dac_nids,
6756 .channel_mode = alc885_mbp_6ch_modes,
6757 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6758 .input_mux = &alc882_capture_source,
6759 .dig_out_nid = ALC882_DIGOUT_NID,
6760 .dig_in_nid = ALC882_DIGIN_NID,
6761 .unsol_event = alc885_mbp3_unsol_event,
6762 .init_hook = alc885_mbp3_automute,
6763 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006764 [ALC885_MACPRO] = {
6765 .mixers = { alc882_macpro_mixer },
6766 .init_verbs = { alc882_macpro_init_verbs },
6767 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6768 .dac_nids = alc882_dac_nids,
6769 .dig_out_nid = ALC882_DIGOUT_NID,
6770 .dig_in_nid = ALC882_DIGIN_NID,
6771 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6772 .channel_mode = alc882_ch_modes,
6773 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006774 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006775 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006776 [ALC885_IMAC24] = {
6777 .mixers = { alc885_imac24_mixer },
6778 .init_verbs = { alc885_imac24_init_verbs },
6779 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6780 .dac_nids = alc882_dac_nids,
6781 .dig_out_nid = ALC882_DIGOUT_NID,
6782 .dig_in_nid = ALC882_DIGIN_NID,
6783 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6784 .channel_mode = alc882_ch_modes,
6785 .input_mux = &alc882_capture_source,
6786 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006787 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006788 },
Kailang Yang272a5272007-05-14 11:00:38 +02006789 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006790 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006791 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6792 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6793 .dac_nids = alc882_dac_nids,
6794 .dig_out_nid = ALC882_DIGOUT_NID,
6795 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6796 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006797 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006798 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6799 .channel_mode = alc882_3ST_6ch_modes,
6800 .need_dac_fix = 1,
6801 .input_mux = &alc882_capture_source,
6802 .unsol_event = alc882_targa_unsol_event,
6803 .init_hook = alc882_targa_automute,
6804 },
6805 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006806 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006807 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6808 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6809 .dac_nids = alc882_dac_nids,
6810 .dig_out_nid = ALC882_DIGOUT_NID,
6811 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6812 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006813 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006814 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6815 .channel_mode = alc882_3ST_6ch_modes,
6816 .need_dac_fix = 1,
6817 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006818 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006819 [ALC882_ASUS_A7M] = {
6820 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6821 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6822 alc880_gpio1_init_verbs,
6823 alc882_asus_a7m_verbs },
6824 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6825 .dac_nids = alc882_dac_nids,
6826 .dig_out_nid = ALC882_DIGOUT_NID,
6827 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6828 .channel_mode = alc880_threestack_modes,
6829 .need_dac_fix = 1,
6830 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006831 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006832};
6833
6834
6835/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006836 * Pin config fixes
6837 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006838enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006839 PINFIX_ABIT_AW9D_MAX
6840};
6841
6842static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6843 { 0x15, 0x01080104 }, /* side */
6844 { 0x16, 0x01011012 }, /* rear */
6845 { 0x17, 0x01016011 }, /* clfe */
6846 { }
6847};
6848
6849static const struct alc_pincfg *alc882_pin_fixes[] = {
6850 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6851};
6852
6853static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6854 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6855 {}
6856};
6857
6858/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006859 * BIOS auto configuration
6860 */
6861static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6862 hda_nid_t nid, int pin_type,
6863 int dac_idx)
6864{
6865 /* set as output */
6866 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006867 int idx;
6868
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006869 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006870 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6871 idx = 4;
6872 else
6873 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006874 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6875
6876}
6877
6878static void alc882_auto_init_multi_out(struct hda_codec *codec)
6879{
6880 struct alc_spec *spec = codec->spec;
6881 int i;
6882
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006883 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006884 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006885 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006886 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006887 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006888 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006889 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006890 }
6891}
6892
6893static void alc882_auto_init_hp_out(struct hda_codec *codec)
6894{
6895 struct alc_spec *spec = codec->spec;
6896 hda_nid_t pin;
6897
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006898 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006899 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006900 /* use dac 0 */
6901 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006902 pin = spec->autocfg.speaker_pins[0];
6903 if (pin)
6904 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006905}
6906
6907#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6908#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6909
6910static void alc882_auto_init_analog_input(struct hda_codec *codec)
6911{
6912 struct alc_spec *spec = codec->spec;
6913 int i;
6914
6915 for (i = 0; i < AUTO_PIN_LAST; i++) {
6916 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006917 unsigned int vref;
6918 if (!nid)
6919 continue;
6920 vref = PIN_IN;
6921 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006922 unsigned int pincap;
6923 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6924 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006925 AC_PINCAP_VREF_80)
6926 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006927 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006928 snd_hda_codec_write(codec, nid, 0,
6929 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6930 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6931 snd_hda_codec_write(codec, nid, 0,
6932 AC_VERB_SET_AMP_GAIN_MUTE,
6933 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006934 }
6935}
6936
Takashi Iwaif511b012008-08-15 16:46:42 +02006937static void alc882_auto_init_input_src(struct hda_codec *codec)
6938{
6939 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02006940 int c;
6941
6942 for (c = 0; c < spec->num_adc_nids; c++) {
6943 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6944 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02006945 unsigned int mux_idx;
6946 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02006947 int conns, mute, idx, item;
6948
6949 conns = snd_hda_get_connections(codec, nid, conn_list,
6950 ARRAY_SIZE(conn_list));
6951 if (conns < 0)
6952 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02006953 mux_idx = c >= spec->num_mux_defs ? 0 : c;
6954 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02006955 for (idx = 0; idx < conns; idx++) {
6956 /* if the current connection is the selected one,
6957 * unmute it as default - otherwise mute it
6958 */
6959 mute = AMP_IN_MUTE(idx);
6960 for (item = 0; item < imux->num_items; item++) {
6961 if (imux->items[item].index == idx) {
6962 if (spec->cur_mux[c] == item)
6963 mute = AMP_IN_UNMUTE(idx);
6964 break;
6965 }
6966 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02006967 /* check if we have a selector or mixer
6968 * we could check for the widget type instead, but
6969 * just check for Amp-In presence (in case of mixer
6970 * without amp-in there is something wrong, this
6971 * function shouldn't be used or capsrc nid is wrong)
6972 */
6973 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
6974 snd_hda_codec_write(codec, nid, 0,
6975 AC_VERB_SET_AMP_GAIN_MUTE,
6976 mute);
6977 else if (mute != AMP_IN_MUTE(idx))
6978 snd_hda_codec_write(codec, nid, 0,
6979 AC_VERB_SET_CONNECT_SEL,
6980 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02006981 }
6982 }
6983}
6984
Takashi Iwai776e1842007-08-29 15:07:11 +02006985/* add mic boosts if needed */
6986static int alc_auto_add_mic_boost(struct hda_codec *codec)
6987{
6988 struct alc_spec *spec = codec->spec;
6989 int err;
6990 hda_nid_t nid;
6991
6992 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006993 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006994 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6995 "Mic Boost",
6996 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6997 if (err < 0)
6998 return err;
6999 }
7000 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007001 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007002 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7003 "Front Mic Boost",
7004 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7005 if (err < 0)
7006 return err;
7007 }
7008 return 0;
7009}
7010
Kailang Yangdf694da2005-12-05 19:42:22 +01007011/* almost identical with ALC880 parser... */
7012static int alc882_parse_auto_config(struct hda_codec *codec)
7013{
7014 struct alc_spec *spec = codec->spec;
7015 int err = alc880_parse_auto_config(codec);
7016
7017 if (err < 0)
7018 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007019 else if (!err)
7020 return 0; /* no config found */
7021
7022 err = alc_auto_add_mic_boost(codec);
7023 if (err < 0)
7024 return err;
7025
7026 /* hack - override the init verbs */
7027 spec->init_verbs[0] = alc882_auto_init_verbs;
7028
7029 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007030}
7031
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007032/* additional initialization for auto-configuration model */
7033static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007034{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007035 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007036 alc882_auto_init_multi_out(codec);
7037 alc882_auto_init_hp_out(codec);
7038 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007039 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007040 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007041 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007042}
7043
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007044static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7045
Linus Torvalds1da177e2005-04-16 15:20:36 -07007046static int patch_alc882(struct hda_codec *codec)
7047{
7048 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007049 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007050
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007051 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007052 if (spec == NULL)
7053 return -ENOMEM;
7054
Linus Torvalds1da177e2005-04-16 15:20:36 -07007055 codec->spec = spec;
7056
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007057 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7058 alc882_models,
7059 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007060
Kailang Yangdf694da2005-12-05 19:42:22 +01007061 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007062 /* Pick up systems that don't supply PCI SSID */
7063 switch (codec->subsystem_id) {
7064 case 0x106b0c00: /* Mac Pro */
7065 board_config = ALC885_MACPRO;
7066 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007067 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007068 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007069 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007070 board_config = ALC885_IMAC24;
7071 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02007072 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007073 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007074 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007075 case 0x106b3600: /* Macbook 3.1 */
Luke Yelavich2a884642009-01-28 15:58:38 +11007076 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007077 board_config = ALC885_MBP3;
7078 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007079 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007080 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007081 if (codec->revision_id == 0x100101 ||
7082 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007083 alc_free(codec);
7084 return patch_alc883(codec);
7085 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007086 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7087 "trying auto-probe from BIOS...\n");
7088 board_config = ALC882_AUTO;
7089 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007090 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007091
Takashi Iwaif95474e2007-07-10 00:47:43 +02007092 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7093
Kailang Yangdf694da2005-12-05 19:42:22 +01007094 if (board_config == ALC882_AUTO) {
7095 /* automatic parse from the BIOS config */
7096 err = alc882_parse_auto_config(codec);
7097 if (err < 0) {
7098 alc_free(codec);
7099 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007100 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007101 printk(KERN_INFO
7102 "hda_codec: Cannot set up configuration "
7103 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007104 board_config = ALC882_3ST_DIG;
7105 }
7106 }
7107
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007108 err = snd_hda_attach_beep_device(codec, 0x1);
7109 if (err < 0) {
7110 alc_free(codec);
7111 return err;
7112 }
7113
Kailang Yangdf694da2005-12-05 19:42:22 +01007114 if (board_config != ALC882_AUTO)
7115 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007116
Kailang Yang2f893282008-05-27 12:14:47 +02007117 if (codec->vendor_id == 0x10ec0885) {
7118 spec->stream_name_analog = "ALC885 Analog";
7119 spec->stream_name_digital = "ALC885 Digital";
7120 } else {
7121 spec->stream_name_analog = "ALC882 Analog";
7122 spec->stream_name_digital = "ALC882 Digital";
7123 }
7124
Kailang Yangdf694da2005-12-05 19:42:22 +01007125 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7126 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007127 /* FIXME: setup DAC5 */
7128 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7129 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007130
Kailang Yangdf694da2005-12-05 19:42:22 +01007131 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7132 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007133
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007134 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007135 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007136 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007137 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007138 /* get type */
7139 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007140 if (wcap != AC_WID_AUD_IN) {
7141 spec->adc_nids = alc882_adc_nids_alt;
7142 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007143 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007144 } else {
7145 spec->adc_nids = alc882_adc_nids;
7146 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007147 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007148 }
7149 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007150 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007151 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007152
Takashi Iwai2134ea42008-01-10 16:53:55 +01007153 spec->vmaster_nid = 0x0c;
7154
Linus Torvalds1da177e2005-04-16 15:20:36 -07007155 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007156 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007157 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007158#ifdef CONFIG_SND_HDA_POWER_SAVE
7159 if (!spec->loopback.amplist)
7160 spec->loopback.amplist = alc882_loopbacks;
7161#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007162 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007163
7164 return 0;
7165}
7166
7167/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007168 * ALC883 support
7169 *
7170 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7171 * configuration. Each pin widget can choose any input DACs and a mixer.
7172 * Each ADC is connected from a mixer of all inputs. This makes possible
7173 * 6-channel independent captures.
7174 *
7175 * In addition, an independent DAC for the multi-playback (not used in this
7176 * driver yet).
7177 */
7178#define ALC883_DIGOUT_NID 0x06
7179#define ALC883_DIGIN_NID 0x0a
7180
Wu Fengguang3ab90932008-11-17 09:51:09 +01007181#define ALC1200_DIGOUT_NID 0x10
7182
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007183static hda_nid_t alc883_dac_nids[4] = {
7184 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007185 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007186};
7187
7188static hda_nid_t alc883_adc_nids[2] = {
7189 /* ADC1-2 */
7190 0x08, 0x09,
7191};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007192
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007193static hda_nid_t alc883_adc_nids_alt[1] = {
7194 /* ADC1 */
7195 0x08,
7196};
7197
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007198static hda_nid_t alc883_adc_nids_rev[2] = {
7199 /* ADC2-1 */
7200 0x09, 0x08
7201};
7202
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007203#define alc889_adc_nids alc880_adc_nids
7204
Takashi Iwaie1406342008-02-11 18:32:32 +01007205static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7206
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007207static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7208
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007209#define alc889_capsrc_nids alc882_capsrc_nids
7210
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007211/* input MUX */
7212/* FIXME: should be a matrix-type input source selection */
7213
7214static struct hda_input_mux alc883_capture_source = {
7215 .num_items = 4,
7216 .items = {
7217 { "Mic", 0x0 },
7218 { "Front Mic", 0x1 },
7219 { "Line", 0x2 },
7220 { "CD", 0x4 },
7221 },
7222};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007223
Jiang zhe17bba1b2008-06-04 12:11:07 +02007224static struct hda_input_mux alc883_3stack_6ch_intel = {
7225 .num_items = 4,
7226 .items = {
7227 { "Mic", 0x1 },
7228 { "Front Mic", 0x0 },
7229 { "Line", 0x2 },
7230 { "CD", 0x4 },
7231 },
7232};
7233
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007234static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7235 .num_items = 2,
7236 .items = {
7237 { "Mic", 0x1 },
7238 { "Line", 0x2 },
7239 },
7240};
7241
Kailang Yang272a5272007-05-14 11:00:38 +02007242static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7243 .num_items = 4,
7244 .items = {
7245 { "Mic", 0x0 },
7246 { "iMic", 0x1 },
7247 { "Line", 0x2 },
7248 { "CD", 0x4 },
7249 },
7250};
7251
Jiang zhefb97dc62008-03-06 11:07:11 +01007252static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7253 .num_items = 2,
7254 .items = {
7255 { "Mic", 0x0 },
7256 { "Int Mic", 0x1 },
7257 },
7258};
7259
Kailang Yange2757d52008-08-26 13:17:46 +02007260static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7261 .num_items = 3,
7262 .items = {
7263 { "Mic", 0x0 },
7264 { "Front Mic", 0x1 },
7265 { "Line", 0x4 },
7266 },
7267};
7268
7269static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7270 .num_items = 2,
7271 .items = {
7272 { "Mic", 0x0 },
7273 { "Line", 0x2 },
7274 },
7275};
7276
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007277/*
7278 * 2ch mode
7279 */
7280static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7281 { 2, NULL }
7282};
7283
7284/*
7285 * 2ch mode
7286 */
7287static struct hda_verb alc883_3ST_ch2_init[] = {
7288 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7289 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7290 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7291 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7292 { } /* end */
7293};
7294
7295/*
Tobin Davisb2011312007-09-17 12:45:11 +02007296 * 4ch mode
7297 */
7298static struct hda_verb alc883_3ST_ch4_init[] = {
7299 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7300 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7301 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7302 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7303 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7304 { } /* end */
7305};
7306
7307/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007308 * 6ch mode
7309 */
7310static struct hda_verb alc883_3ST_ch6_init[] = {
7311 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7312 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7313 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7314 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7315 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7316 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7317 { } /* end */
7318};
7319
Tobin Davisb2011312007-09-17 12:45:11 +02007320static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007321 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007322 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007323 { 6, alc883_3ST_ch6_init },
7324};
7325
7326/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007327 * 2ch mode
7328 */
7329static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7330 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7331 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7332 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7333 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7334 { } /* end */
7335};
7336
7337/*
7338 * 4ch mode
7339 */
7340static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7341 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7342 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7343 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7344 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7345 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7346 { } /* end */
7347};
7348
7349/*
7350 * 6ch mode
7351 */
7352static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7353 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7354 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7355 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7356 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7357 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7358 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7359 { } /* end */
7360};
7361
7362static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7363 { 2, alc883_3ST_ch2_intel_init },
7364 { 4, alc883_3ST_ch4_intel_init },
7365 { 6, alc883_3ST_ch6_intel_init },
7366};
7367
7368/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007369 * 6ch mode
7370 */
7371static struct hda_verb alc883_sixstack_ch6_init[] = {
7372 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7373 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7374 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7375 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7376 { } /* end */
7377};
7378
7379/*
7380 * 8ch mode
7381 */
7382static struct hda_verb alc883_sixstack_ch8_init[] = {
7383 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7384 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7385 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7386 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7387 { } /* end */
7388};
7389
7390static struct hda_channel_mode alc883_sixstack_modes[2] = {
7391 { 6, alc883_sixstack_ch6_init },
7392 { 8, alc883_sixstack_ch8_init },
7393};
7394
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007395static struct hda_verb alc883_medion_eapd_verbs[] = {
7396 /* eanable EAPD on medion laptop */
7397 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7398 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7399 { }
7400};
7401
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007402/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7403 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7404 */
7405
7406static struct snd_kcontrol_new alc883_base_mixer[] = {
7407 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7408 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7409 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7410 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7411 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7412 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7413 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7414 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7415 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7416 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7417 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7418 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7419 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7420 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7421 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7422 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007423 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007424 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7425 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007426 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007427 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007428 { } /* end */
7429};
7430
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007431static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7432 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7433 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7434 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7435 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7436 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7437 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7438 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7439 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7440 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7441 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7442 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7443 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7444 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007445 { } /* end */
7446};
7447
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007448static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007449 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7450 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7451 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7452 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7454 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7455 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7456 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7457 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7458 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007459 { } /* end */
7460};
7461
Jiang zhefb97dc62008-03-06 11:07:11 +01007462static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7463 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7464 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7465 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7466 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7467 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7468 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7469 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7470 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7471 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7472 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007473 { } /* end */
7474};
7475
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007476static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7477 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7478 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7479 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7480 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7481 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7482 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7483 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007485 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007486 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7487 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007488 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007489 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007490 { } /* end */
7491};
7492
7493static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7494 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7495 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7496 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7497 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7498 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7499 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7500 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7501 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7502 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7503 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7504 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7505 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7506 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7507 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007508 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007509 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7510 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007511 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007512 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007513 { } /* end */
7514};
7515
Jiang zhe17bba1b2008-06-04 12:11:07 +02007516static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7517 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7518 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7519 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7520 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7521 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7522 HDA_OUTPUT),
7523 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7524 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7525 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7526 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7527 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7528 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7529 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7530 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7531 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7532 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7533 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7534 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7535 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7536 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007537 { } /* end */
7538};
7539
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007540static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007541 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007542 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007543 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007544 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007545 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7546 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007547 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7548 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007549 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7550 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7551 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7552 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7553 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7554 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007555 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007556 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7557 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007558 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007559 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007560 { } /* end */
7561};
7562
Kailang Yangccc656c2006-10-17 12:32:26 +02007563static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7564 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7565 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7566 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7567 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7568 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7569 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7570 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7571 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7572 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7573 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7574 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7575 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7576 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7577 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007578 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007579 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007580 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007581};
Kailang Yangccc656c2006-10-17 12:32:26 +02007582
7583static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7584 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7585 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7586 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7587 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7588 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007590 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007591 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007592 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7593 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7594 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007595 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007596};
Kailang Yangccc656c2006-10-17 12:32:26 +02007597
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007598static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7599 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7600 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007601 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7602 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007603 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7604 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7605 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7606 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007607 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007608};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007609
Kailang Yang272a5272007-05-14 11:00:38 +02007610static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7611 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7612 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7613 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7614 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7615 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7617 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7618 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7619 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007620 { } /* end */
7621};
7622
7623static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7624 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7625 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7626 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7627 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7628 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7629 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7630 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7631 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7632 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007633 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007634};
Kailang Yang272a5272007-05-14 11:00:38 +02007635
Tobin Davis2880a862007-08-07 11:50:26 +02007636static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007637 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7638 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007639 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007640 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7641 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007642 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7643 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7644 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007645 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007646};
Tobin Davis2880a862007-08-07 11:50:26 +02007647
Kailang Yange2757d52008-08-26 13:17:46 +02007648static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7649 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7650 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7651 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7652 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7653 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7654 0x0d, 1, 0x0, HDA_OUTPUT),
7655 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7656 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7657 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7658 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7659 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7660 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7661 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7662 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7663 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7664 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7665 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7667 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7669 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7670 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7671 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007672 { } /* end */
7673};
7674
7675static struct hda_bind_ctls alc883_bind_cap_vol = {
7676 .ops = &snd_hda_bind_vol,
7677 .values = {
7678 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7679 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7680 0
7681 },
7682};
7683
7684static struct hda_bind_ctls alc883_bind_cap_switch = {
7685 .ops = &snd_hda_bind_sw,
7686 .values = {
7687 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7688 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7689 0
7690 },
7691};
7692
7693static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7694 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7695 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7696 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7697 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7698 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7699 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7700 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7701 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007702 { } /* end */
7703};
7704
7705static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007706 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7707 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7708 {
7709 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7710 /* .name = "Capture Source", */
7711 .name = "Input Source",
7712 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007713 .info = alc_mux_enum_info,
7714 .get = alc_mux_enum_get,
7715 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007716 },
7717 { } /* end */
7718};
7719
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007720static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7721 {
7722 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7723 .name = "Channel Mode",
7724 .info = alc_ch_mode_info,
7725 .get = alc_ch_mode_get,
7726 .put = alc_ch_mode_put,
7727 },
7728 { } /* end */
7729};
7730
7731static struct hda_verb alc883_init_verbs[] = {
7732 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007733 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007734 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7735 /* ADC2: mute amp left and right */
7736 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7737 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7738 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7739 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7742 /* Rear mixer */
7743 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7744 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7745 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7746 /* CLFE mixer */
7747 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7748 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7749 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7750 /* Side mixer */
7751 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7752 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7753 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7754
Takashi Iwaicb53c622007-08-10 17:21:45 +02007755 /* mute analog input loopbacks */
7756 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7757 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7758 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7759 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7760 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007761
7762 /* Front Pin: output 0 (0x0c) */
7763 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7764 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7765 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7766 /* Rear Pin: output 1 (0x0d) */
7767 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7768 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7769 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7770 /* CLFE Pin: output 2 (0x0e) */
7771 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7772 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7773 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7774 /* Side Pin: output 3 (0x0f) */
7775 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7776 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7777 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7778 /* Mic (rear) pin: input vref at 80% */
7779 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7780 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7781 /* Front Mic pin: input vref at 80% */
7782 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7783 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7784 /* Line In pin: input */
7785 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7786 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7787 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7788 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7789 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7790 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7791 /* CD pin widget for input */
7792 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7793
7794 /* FIXME: use matrix-type input source selection */
7795 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7796 /* Input mixer2 */
7797 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007798 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7799 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7800 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007801 /* Input mixer3 */
7802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7804 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7805 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007806 { }
7807};
7808
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007809/* toggle speaker-output according to the hp-jack state */
7810static void alc883_mitac_hp_automute(struct hda_codec *codec)
7811{
7812 unsigned int present;
7813
7814 present = snd_hda_codec_read(codec, 0x15, 0,
7815 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7816 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7817 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7818 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7819 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7820}
7821
7822/* auto-toggle front mic */
7823/*
7824static void alc883_mitac_mic_automute(struct hda_codec *codec)
7825{
7826 unsigned int present;
7827 unsigned char bits;
7828
7829 present = snd_hda_codec_read(codec, 0x18, 0,
7830 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7831 bits = present ? HDA_AMP_MUTE : 0;
7832 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7833}
7834*/
7835
7836static void alc883_mitac_automute(struct hda_codec *codec)
7837{
7838 alc883_mitac_hp_automute(codec);
7839 /* alc883_mitac_mic_automute(codec); */
7840}
7841
7842static void alc883_mitac_unsol_event(struct hda_codec *codec,
7843 unsigned int res)
7844{
7845 switch (res >> 26) {
7846 case ALC880_HP_EVENT:
7847 alc883_mitac_hp_automute(codec);
7848 break;
7849 case ALC880_MIC_EVENT:
7850 /* alc883_mitac_mic_automute(codec); */
7851 break;
7852 }
7853}
7854
7855static struct hda_verb alc883_mitac_verbs[] = {
7856 /* HP */
7857 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7858 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7859 /* Subwoofer */
7860 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7861 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7862
7863 /* enable unsolicited event */
7864 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7865 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7866
7867 { } /* end */
7868};
7869
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007870static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007871 /* HP */
7872 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7873 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7874 /* Int speaker */
7875 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7876 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7877
7878 /* enable unsolicited event */
7879 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007880 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007881
7882 { } /* end */
7883};
7884
Jiang zhefb97dc62008-03-06 11:07:11 +01007885static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7886 /* HP */
7887 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7888 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7889 /* Subwoofer */
7890 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7891 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7892
7893 /* enable unsolicited event */
7894 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7895
7896 { } /* end */
7897};
7898
Kailang Yangccc656c2006-10-17 12:32:26 +02007899static struct hda_verb alc883_tagra_verbs[] = {
7900 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7901 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7902
7903 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7904 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007905
Kailang Yangccc656c2006-10-17 12:32:26 +02007906 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7907 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7908 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7909
7910 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007911 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7912 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7913 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007914
7915 { } /* end */
7916};
7917
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007918static struct hda_verb alc883_lenovo_101e_verbs[] = {
7919 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7920 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7921 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7922 { } /* end */
7923};
7924
Kailang Yang272a5272007-05-14 11:00:38 +02007925static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7926 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7927 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7928 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7929 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7930 { } /* end */
7931};
7932
7933static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7934 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7935 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7936 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7937 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7938 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7939 { } /* end */
7940};
7941
Kailang Yang189609a2007-08-20 11:31:23 +02007942static struct hda_verb alc883_haier_w66_verbs[] = {
7943 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7944 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7945
7946 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7947
7948 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7949 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7950 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7951 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7952 { } /* end */
7953};
7954
Kailang Yange2757d52008-08-26 13:17:46 +02007955static struct hda_verb alc888_lenovo_sky_verbs[] = {
7956 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7957 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7958 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7959 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7960 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7961 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7962 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7963 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7964 { } /* end */
7965};
7966
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007967static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007968 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007969 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7970 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007971 { }
7972};
7973
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007974static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007975 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7976 { }
7977};
7978
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007979static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007980 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7981 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7982 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7983 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7984 { }
7985};
7986
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007987static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007988 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7989 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7990 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7991 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7992 { }
7993};
7994
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007995static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7996 { 2, alc888_3st_hp_2ch_init },
7997 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007998};
7999
Kailang Yang272a5272007-05-14 11:00:38 +02008000/* toggle front-jack and RCA according to the hp-jack state */
8001static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8002{
8003 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008004
Kailang Yang272a5272007-05-14 11:00:38 +02008005 present = snd_hda_codec_read(codec, 0x1b, 0,
8006 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008007 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8008 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8009 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8010 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008011}
8012
8013/* toggle RCA according to the front-jack state */
8014static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8015{
8016 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008017
Kailang Yang272a5272007-05-14 11:00:38 +02008018 present = snd_hda_codec_read(codec, 0x14, 0,
8019 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008020 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8021 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008022}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008023
Kailang Yang272a5272007-05-14 11:00:38 +02008024static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8025 unsigned int res)
8026{
8027 if ((res >> 26) == ALC880_HP_EVENT)
8028 alc888_lenovo_ms7195_front_automute(codec);
8029 if ((res >> 26) == ALC880_FRONT_EVENT)
8030 alc888_lenovo_ms7195_rca_automute(codec);
8031}
8032
8033static struct hda_verb alc883_medion_md2_verbs[] = {
8034 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8035 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8036
8037 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8038
8039 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8040 { } /* end */
8041};
8042
8043/* toggle speaker-output according to the hp-jack state */
8044static void alc883_medion_md2_automute(struct hda_codec *codec)
8045{
8046 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008047
Kailang Yang272a5272007-05-14 11:00:38 +02008048 present = snd_hda_codec_read(codec, 0x14, 0,
8049 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008050 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8051 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008052}
8053
8054static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8055 unsigned int res)
8056{
8057 if ((res >> 26) == ALC880_HP_EVENT)
8058 alc883_medion_md2_automute(codec);
8059}
8060
Kailang Yangccc656c2006-10-17 12:32:26 +02008061/* toggle speaker-output according to the hp-jack state */
8062static void alc883_tagra_automute(struct hda_codec *codec)
8063{
8064 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008065 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02008066
8067 present = snd_hda_codec_read(codec, 0x14, 0,
8068 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008069 bits = present ? HDA_AMP_MUTE : 0;
8070 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8071 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008072 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8073 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02008074}
8075
8076static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8077{
8078 if ((res >> 26) == ALC880_HP_EVENT)
8079 alc883_tagra_automute(codec);
8080}
8081
Jiang zhe368c7a92008-03-04 11:20:33 +01008082/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008083static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01008084{
8085 unsigned int present;
8086 unsigned char bits;
8087
8088 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8089 & AC_PINSENSE_PRESENCE;
8090 bits = present ? HDA_AMP_MUTE : 0;
8091 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8092 HDA_AMP_MUTE, bits);
8093}
8094
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008095static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8096{
8097 unsigned int present;
8098
8099 present = snd_hda_codec_read(codec, 0x18, 0,
8100 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8101 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8102 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8103}
8104
8105static void alc883_clevo_m720_automute(struct hda_codec *codec)
8106{
8107 alc883_clevo_m720_hp_automute(codec);
8108 alc883_clevo_m720_mic_automute(codec);
8109}
8110
8111static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008112 unsigned int res)
8113{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008114 switch (res >> 26) {
8115 case ALC880_HP_EVENT:
8116 alc883_clevo_m720_hp_automute(codec);
8117 break;
8118 case ALC880_MIC_EVENT:
8119 alc883_clevo_m720_mic_automute(codec);
8120 break;
8121 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008122}
8123
Jiang zhefb97dc62008-03-06 11:07:11 +01008124/* toggle speaker-output according to the hp-jack state */
8125static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8126{
8127 unsigned int present;
8128 unsigned char bits;
8129
8130 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8131 & AC_PINSENSE_PRESENCE;
8132 bits = present ? HDA_AMP_MUTE : 0;
8133 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8134 HDA_AMP_MUTE, bits);
8135}
8136
8137static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8138 unsigned int res)
8139{
8140 if ((res >> 26) == ALC880_HP_EVENT)
8141 alc883_2ch_fujitsu_pi2515_automute(codec);
8142}
8143
Kailang Yang189609a2007-08-20 11:31:23 +02008144static void alc883_haier_w66_automute(struct hda_codec *codec)
8145{
8146 unsigned int present;
8147 unsigned char bits;
8148
8149 present = snd_hda_codec_read(codec, 0x1b, 0,
8150 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8151 bits = present ? 0x80 : 0;
8152 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8153 0x80, bits);
8154}
8155
8156static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8157 unsigned int res)
8158{
8159 if ((res >> 26) == ALC880_HP_EVENT)
8160 alc883_haier_w66_automute(codec);
8161}
8162
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008163static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8164{
8165 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008166 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008167
8168 present = snd_hda_codec_read(codec, 0x14, 0,
8169 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008170 bits = present ? HDA_AMP_MUTE : 0;
8171 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8172 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008173}
8174
8175static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8176{
8177 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008178 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008179
8180 present = snd_hda_codec_read(codec, 0x1b, 0,
8181 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008182 bits = present ? HDA_AMP_MUTE : 0;
8183 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8184 HDA_AMP_MUTE, bits);
8185 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8186 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008187}
8188
8189static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8190 unsigned int res)
8191{
8192 if ((res >> 26) == ALC880_HP_EVENT)
8193 alc883_lenovo_101e_all_automute(codec);
8194 if ((res >> 26) == ALC880_FRONT_EVENT)
8195 alc883_lenovo_101e_ispeaker_automute(codec);
8196}
8197
Takashi Iwai676a9b52007-08-16 15:23:35 +02008198/* toggle speaker-output according to the hp-jack state */
8199static void alc883_acer_aspire_automute(struct hda_codec *codec)
8200{
8201 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008202
Takashi Iwai676a9b52007-08-16 15:23:35 +02008203 present = snd_hda_codec_read(codec, 0x14, 0,
8204 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8205 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8206 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8207 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8208 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8209}
8210
8211static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8212 unsigned int res)
8213{
8214 if ((res >> 26) == ALC880_HP_EVENT)
8215 alc883_acer_aspire_automute(codec);
8216}
8217
Kailang Yangd1a991a2007-08-15 16:21:59 +02008218static struct hda_verb alc883_acer_eapd_verbs[] = {
8219 /* HP Pin: output 0 (0x0c) */
8220 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8222 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8223 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008224 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8225 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008226 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008227 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8228 /* eanable EAPD on medion laptop */
8229 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8230 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008231 /* enable unsolicited event */
8232 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008233 { }
8234};
8235
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008236static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8237{
8238 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008239
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008240 present = snd_hda_codec_read(codec, 0x1b, 0,
8241 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8242 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8243 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8244 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8245 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8246 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8247 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8248 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8249 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8250}
8251
8252static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8253 unsigned int res)
8254{
8255 switch (res >> 26) {
8256 case ALC880_HP_EVENT:
Takashi Iwai939778a2009-02-05 15:57:55 +01008257 /* printk(KERN_DEBUG "hp_event\n"); */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008258 alc888_6st_dell_front_automute(codec);
8259 break;
8260 }
8261}
8262
Kailang Yange2757d52008-08-26 13:17:46 +02008263static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8264{
8265 unsigned int mute;
8266 unsigned int present;
8267
8268 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8269 present = snd_hda_codec_read(codec, 0x1b, 0,
8270 AC_VERB_GET_PIN_SENSE, 0);
8271 present = (present & 0x80000000) != 0;
8272 if (present) {
8273 /* mute internal speaker */
8274 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8275 HDA_AMP_MUTE, HDA_AMP_MUTE);
8276 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8277 HDA_AMP_MUTE, HDA_AMP_MUTE);
8278 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8279 HDA_AMP_MUTE, HDA_AMP_MUTE);
8280 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8281 HDA_AMP_MUTE, HDA_AMP_MUTE);
8282 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8283 HDA_AMP_MUTE, HDA_AMP_MUTE);
8284 } else {
8285 /* unmute internal speaker if necessary */
8286 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8287 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8288 HDA_AMP_MUTE, mute);
8289 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8290 HDA_AMP_MUTE, mute);
8291 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8292 HDA_AMP_MUTE, mute);
8293 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8294 HDA_AMP_MUTE, mute);
8295 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8296 HDA_AMP_MUTE, mute);
8297 }
8298}
8299
8300static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8301 unsigned int res)
8302{
8303 if ((res >> 26) == ALC880_HP_EVENT)
8304 alc888_lenovo_sky_front_automute(codec);
8305}
8306
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008307/*
8308 * generic initialization of ADC, input mixers and output mixers
8309 */
8310static struct hda_verb alc883_auto_init_verbs[] = {
8311 /*
8312 * Unmute ADC0-2 and set the default input to mic-in
8313 */
8314 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8315 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8316 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8317 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8318
Takashi Iwaicb53c622007-08-10 17:21:45 +02008319 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008320 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008321 * Note: PASD motherboards uses the Line In 2 as the input for
8322 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008323 */
8324 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008325 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8326 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8327 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8328 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008330
8331 /*
8332 * Set up output mixers (0x0c - 0x0f)
8333 */
8334 /* set vol=0 to output mixers */
8335 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8336 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8337 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8338 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8339 /* set up input amps for analog loopback */
8340 /* Amp Indices: DAC = 0, mixer = 1 */
8341 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8342 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8343 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8344 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8345 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8346 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8347 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8348 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8349 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8350 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8351
8352 /* FIXME: use matrix-type input source selection */
8353 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8354 /* Input mixer1 */
8355 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8356 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8357 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008358 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008359 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8360 /* Input mixer2 */
8361 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8363 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008364 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008365 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008366
8367 { }
8368};
8369
Kailang Yange2757d52008-08-26 13:17:46 +02008370static struct hda_verb alc888_asus_m90v_verbs[] = {
8371 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8374 /* enable unsolicited event */
8375 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8376 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8377 { } /* end */
8378};
8379
8380static void alc883_nb_mic_automute(struct hda_codec *codec)
8381{
8382 unsigned int present;
8383
8384 present = snd_hda_codec_read(codec, 0x18, 0,
8385 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8386 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8387 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8388 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8389 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8390}
8391
8392static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8393{
8394 unsigned int present;
8395 unsigned char bits;
8396
8397 present = snd_hda_codec_read(codec, 0x1b, 0,
8398 AC_VERB_GET_PIN_SENSE, 0)
8399 & AC_PINSENSE_PRESENCE;
8400 bits = present ? 0 : PIN_OUT;
8401 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8402 bits);
8403 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8404 bits);
8405 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8406 bits);
8407}
8408
8409static void alc883_mode2_unsol_event(struct hda_codec *codec,
8410 unsigned int res)
8411{
8412 switch (res >> 26) {
8413 case ALC880_HP_EVENT:
8414 alc883_M90V_speaker_automute(codec);
8415 break;
8416 case ALC880_MIC_EVENT:
8417 alc883_nb_mic_automute(codec);
8418 break;
8419 }
8420}
8421
8422static void alc883_mode2_inithook(struct hda_codec *codec)
8423{
8424 alc883_M90V_speaker_automute(codec);
8425 alc883_nb_mic_automute(codec);
8426}
8427
8428static struct hda_verb alc888_asus_eee1601_verbs[] = {
8429 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8430 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8431 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8432 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8433 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8434 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8435 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8436 /* enable unsolicited event */
8437 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8438 { } /* end */
8439};
8440
8441static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8442{
8443 unsigned int present;
8444 unsigned char bits;
8445
8446 present = snd_hda_codec_read(codec, 0x14, 0,
8447 AC_VERB_GET_PIN_SENSE, 0)
8448 & AC_PINSENSE_PRESENCE;
8449 bits = present ? 0 : PIN_OUT;
8450 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8451 bits);
8452}
8453
8454static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8455 unsigned int res)
8456{
8457 switch (res >> 26) {
8458 case ALC880_HP_EVENT:
8459 alc883_eee1601_speaker_automute(codec);
8460 break;
8461 }
8462}
8463
8464static void alc883_eee1601_inithook(struct hda_codec *codec)
8465{
8466 alc883_eee1601_speaker_automute(codec);
8467}
8468
Takashi Iwaicb53c622007-08-10 17:21:45 +02008469#ifdef CONFIG_SND_HDA_POWER_SAVE
8470#define alc883_loopbacks alc880_loopbacks
8471#endif
8472
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008473/* pcm configuration: identiacal with ALC880 */
8474#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8475#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008476#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008477#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8478#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8479
8480/*
8481 * configuration and preset
8482 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008483static const char *alc883_models[ALC883_MODEL_LAST] = {
8484 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8485 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8486 [ALC883_3ST_6ch] = "3stack-6ch",
8487 [ALC883_6ST_DIG] = "6stack-dig",
8488 [ALC883_TARGA_DIG] = "targa-dig",
8489 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008490 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008491 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008492 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008493 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008494 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008495 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008496 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008497 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8498 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008499 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008500 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008501 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008502 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008503 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008504 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008505 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008506 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008507 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008508 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008509 [ALC883_AUTO] = "auto",
8510};
8511
8512static struct snd_pci_quirk alc883_cfg_tbl[] = {
8513 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008514 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008515 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008516 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8517 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008518 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008519 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8520 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008521 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8522 ALC888_ACER_ASPIRE_4930G),
Takashi Iwai94683502009-02-13 09:31:20 +01008523 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008524 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8525 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008526 /* default Acer */
8527 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008528 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008529 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008530 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8531 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008532 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008533 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008534 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008535 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008536 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008537 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008538 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008539 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008540 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008541 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008542 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8543 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008544 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008545 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008546 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008547 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8548 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8549 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008550 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008551 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008552 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008553 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8554 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8555 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8556 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8557 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8558 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8559 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8560 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8561 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008562 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8563 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008564 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008565 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008566 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008567 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008568 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008569 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008570 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008571 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8572 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008573 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008574 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008575 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaif67d8172009-02-04 23:30:19 +01008576 SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550",
8577 ALC883_FUJITSU_PI2515),
Jiang zhefb97dc62008-03-06 11:07:11 +01008578 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008579 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8580 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008581 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008582 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008583 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8584 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008585 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008586 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008587 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008588 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008589 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008590 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8591 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008592 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008593 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008594 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008595 {}
8596};
8597
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008598static hda_nid_t alc1200_slave_dig_outs[] = {
8599 ALC883_DIGOUT_NID, 0,
8600};
8601
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008602static struct alc_config_preset alc883_presets[] = {
8603 [ALC883_3ST_2ch_DIG] = {
8604 .mixers = { alc883_3ST_2ch_mixer },
8605 .init_verbs = { alc883_init_verbs },
8606 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8607 .dac_nids = alc883_dac_nids,
8608 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008609 .dig_in_nid = ALC883_DIGIN_NID,
8610 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8611 .channel_mode = alc883_3ST_2ch_modes,
8612 .input_mux = &alc883_capture_source,
8613 },
8614 [ALC883_3ST_6ch_DIG] = {
8615 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8616 .init_verbs = { alc883_init_verbs },
8617 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8618 .dac_nids = alc883_dac_nids,
8619 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008620 .dig_in_nid = ALC883_DIGIN_NID,
8621 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8622 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008623 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008624 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008625 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008626 [ALC883_3ST_6ch] = {
8627 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8628 .init_verbs = { alc883_init_verbs },
8629 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8630 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008631 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8632 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008633 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008634 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008635 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008636 [ALC883_3ST_6ch_INTEL] = {
8637 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8638 .init_verbs = { alc883_init_verbs },
8639 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8640 .dac_nids = alc883_dac_nids,
8641 .dig_out_nid = ALC883_DIGOUT_NID,
8642 .dig_in_nid = ALC883_DIGIN_NID,
8643 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8644 .channel_mode = alc883_3ST_6ch_intel_modes,
8645 .need_dac_fix = 1,
8646 .input_mux = &alc883_3stack_6ch_intel,
8647 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008648 [ALC883_6ST_DIG] = {
8649 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8650 .init_verbs = { alc883_init_verbs },
8651 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8652 .dac_nids = alc883_dac_nids,
8653 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008654 .dig_in_nid = ALC883_DIGIN_NID,
8655 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8656 .channel_mode = alc883_sixstack_modes,
8657 .input_mux = &alc883_capture_source,
8658 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008659 [ALC883_TARGA_DIG] = {
8660 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8661 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8662 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8663 .dac_nids = alc883_dac_nids,
8664 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008665 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8666 .channel_mode = alc883_3ST_6ch_modes,
8667 .need_dac_fix = 1,
8668 .input_mux = &alc883_capture_source,
8669 .unsol_event = alc883_tagra_unsol_event,
8670 .init_hook = alc883_tagra_automute,
8671 },
8672 [ALC883_TARGA_2ch_DIG] = {
8673 .mixers = { alc883_tagra_2ch_mixer},
8674 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8675 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8676 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008677 .adc_nids = alc883_adc_nids_alt,
8678 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008679 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008680 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8681 .channel_mode = alc883_3ST_2ch_modes,
8682 .input_mux = &alc883_capture_source,
8683 .unsol_event = alc883_tagra_unsol_event,
8684 .init_hook = alc883_tagra_automute,
8685 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008686 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008687 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008688 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8689 * and the headphone jack. Turn this on and rely on the
8690 * standard mute methods whenever the user wants to turn
8691 * these outputs off.
8692 */
8693 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8694 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8695 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008696 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8697 .channel_mode = alc883_3ST_2ch_modes,
8698 .input_mux = &alc883_capture_source,
8699 },
Tobin Davis2880a862007-08-07 11:50:26 +02008700 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008701 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008702 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008703 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8704 .dac_nids = alc883_dac_nids,
8705 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008706 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8707 .channel_mode = alc883_3ST_2ch_modes,
8708 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008709 .unsol_event = alc883_acer_aspire_unsol_event,
8710 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008711 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008712 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008713 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008714 alc883_chmode_mixer },
8715 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8716 alc888_acer_aspire_4930g_verbs },
8717 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8718 .dac_nids = alc883_dac_nids,
8719 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8720 .adc_nids = alc883_adc_nids_rev,
8721 .capsrc_nids = alc883_capsrc_nids_rev,
8722 .dig_out_nid = ALC883_DIGOUT_NID,
8723 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8724 .channel_mode = alc883_3ST_6ch_modes,
8725 .need_dac_fix = 1,
8726 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008727 ARRAY_SIZE(alc888_2_capture_sources),
8728 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008729 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8730 .init_hook = alc888_acer_aspire_4930g_automute,
8731 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008732 [ALC883_MEDION] = {
8733 .mixers = { alc883_fivestack_mixer,
8734 alc883_chmode_mixer },
8735 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008736 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008737 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8738 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008739 .adc_nids = alc883_adc_nids_alt,
8740 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008741 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8742 .channel_mode = alc883_sixstack_modes,
8743 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008744 },
Kailang Yang272a5272007-05-14 11:00:38 +02008745 [ALC883_MEDION_MD2] = {
8746 .mixers = { alc883_medion_md2_mixer},
8747 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8748 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8749 .dac_nids = alc883_dac_nids,
8750 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008751 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8752 .channel_mode = alc883_3ST_2ch_modes,
8753 .input_mux = &alc883_capture_source,
8754 .unsol_event = alc883_medion_md2_unsol_event,
8755 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008756 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008757 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008758 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008759 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8760 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8761 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008762 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8763 .channel_mode = alc883_3ST_2ch_modes,
8764 .input_mux = &alc883_capture_source,
8765 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008766 [ALC883_CLEVO_M720] = {
8767 .mixers = { alc883_clevo_m720_mixer },
8768 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008769 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8770 .dac_nids = alc883_dac_nids,
8771 .dig_out_nid = ALC883_DIGOUT_NID,
8772 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8773 .channel_mode = alc883_3ST_2ch_modes,
8774 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008775 .unsol_event = alc883_clevo_m720_unsol_event,
8776 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008777 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008778 [ALC883_LENOVO_101E_2ch] = {
8779 .mixers = { alc883_lenovo_101e_2ch_mixer},
8780 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8781 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8782 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008783 .adc_nids = alc883_adc_nids_alt,
8784 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008785 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8786 .channel_mode = alc883_3ST_2ch_modes,
8787 .input_mux = &alc883_lenovo_101e_capture_source,
8788 .unsol_event = alc883_lenovo_101e_unsol_event,
8789 .init_hook = alc883_lenovo_101e_all_automute,
8790 },
Kailang Yang272a5272007-05-14 11:00:38 +02008791 [ALC883_LENOVO_NB0763] = {
8792 .mixers = { alc883_lenovo_nb0763_mixer },
8793 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8794 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8795 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008796 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8797 .channel_mode = alc883_3ST_2ch_modes,
8798 .need_dac_fix = 1,
8799 .input_mux = &alc883_lenovo_nb0763_capture_source,
8800 .unsol_event = alc883_medion_md2_unsol_event,
8801 .init_hook = alc883_medion_md2_automute,
8802 },
8803 [ALC888_LENOVO_MS7195_DIG] = {
8804 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8805 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8806 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8807 .dac_nids = alc883_dac_nids,
8808 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008809 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8810 .channel_mode = alc883_3ST_6ch_modes,
8811 .need_dac_fix = 1,
8812 .input_mux = &alc883_capture_source,
8813 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8814 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008815 },
8816 [ALC883_HAIER_W66] = {
8817 .mixers = { alc883_tagra_2ch_mixer},
8818 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8819 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8820 .dac_nids = alc883_dac_nids,
8821 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008822 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8823 .channel_mode = alc883_3ST_2ch_modes,
8824 .input_mux = &alc883_capture_source,
8825 .unsol_event = alc883_haier_w66_unsol_event,
8826 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008827 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008828 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008829 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008830 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008831 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8832 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008833 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8834 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008835 .need_dac_fix = 1,
8836 .input_mux = &alc883_capture_source,
8837 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008838 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008839 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008840 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8841 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8842 .dac_nids = alc883_dac_nids,
8843 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008844 .dig_in_nid = ALC883_DIGIN_NID,
8845 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8846 .channel_mode = alc883_sixstack_modes,
8847 .input_mux = &alc883_capture_source,
8848 .unsol_event = alc888_6st_dell_unsol_event,
8849 .init_hook = alc888_6st_dell_front_automute,
8850 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008851 [ALC883_MITAC] = {
8852 .mixers = { alc883_mitac_mixer },
8853 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8854 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8855 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008856 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8857 .channel_mode = alc883_3ST_2ch_modes,
8858 .input_mux = &alc883_capture_source,
8859 .unsol_event = alc883_mitac_unsol_event,
8860 .init_hook = alc883_mitac_automute,
8861 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008862 [ALC883_FUJITSU_PI2515] = {
8863 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8864 .init_verbs = { alc883_init_verbs,
8865 alc883_2ch_fujitsu_pi2515_verbs},
8866 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8867 .dac_nids = alc883_dac_nids,
8868 .dig_out_nid = ALC883_DIGOUT_NID,
8869 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8870 .channel_mode = alc883_3ST_2ch_modes,
8871 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8872 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8873 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8874 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008875 [ALC888_FUJITSU_XA3530] = {
8876 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8877 .init_verbs = { alc883_init_verbs,
8878 alc888_fujitsu_xa3530_verbs },
8879 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8880 .dac_nids = alc883_dac_nids,
8881 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8882 .adc_nids = alc883_adc_nids_rev,
8883 .capsrc_nids = alc883_capsrc_nids_rev,
8884 .dig_out_nid = ALC883_DIGOUT_NID,
8885 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8886 .channel_mode = alc888_4ST_8ch_intel_modes,
8887 .num_mux_defs =
8888 ARRAY_SIZE(alc888_2_capture_sources),
8889 .input_mux = alc888_2_capture_sources,
8890 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
8891 .init_hook = alc888_fujitsu_xa3530_automute,
8892 },
Kailang Yange2757d52008-08-26 13:17:46 +02008893 [ALC888_LENOVO_SKY] = {
8894 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8895 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8896 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8897 .dac_nids = alc883_dac_nids,
8898 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02008899 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8900 .channel_mode = alc883_sixstack_modes,
8901 .need_dac_fix = 1,
8902 .input_mux = &alc883_lenovo_sky_capture_source,
8903 .unsol_event = alc883_lenovo_sky_unsol_event,
8904 .init_hook = alc888_lenovo_sky_front_automute,
8905 },
8906 [ALC888_ASUS_M90V] = {
8907 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8908 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8909 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8910 .dac_nids = alc883_dac_nids,
8911 .dig_out_nid = ALC883_DIGOUT_NID,
8912 .dig_in_nid = ALC883_DIGIN_NID,
8913 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8914 .channel_mode = alc883_3ST_6ch_modes,
8915 .need_dac_fix = 1,
8916 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8917 .unsol_event = alc883_mode2_unsol_event,
8918 .init_hook = alc883_mode2_inithook,
8919 },
8920 [ALC888_ASUS_EEE1601] = {
8921 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008922 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02008923 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8924 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8925 .dac_nids = alc883_dac_nids,
8926 .dig_out_nid = ALC883_DIGOUT_NID,
8927 .dig_in_nid = ALC883_DIGIN_NID,
8928 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8929 .channel_mode = alc883_3ST_2ch_modes,
8930 .need_dac_fix = 1,
8931 .input_mux = &alc883_asus_eee1601_capture_source,
8932 .unsol_event = alc883_eee1601_unsol_event,
8933 .init_hook = alc883_eee1601_inithook,
8934 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01008935 [ALC1200_ASUS_P5Q] = {
8936 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8937 .init_verbs = { alc883_init_verbs },
8938 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8939 .dac_nids = alc883_dac_nids,
8940 .dig_out_nid = ALC1200_DIGOUT_NID,
8941 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008942 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01008943 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8944 .channel_mode = alc883_sixstack_modes,
8945 .input_mux = &alc883_capture_source,
8946 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008947};
8948
8949
8950/*
8951 * BIOS auto configuration
8952 */
8953static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8954 hda_nid_t nid, int pin_type,
8955 int dac_idx)
8956{
8957 /* set as output */
8958 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008959 int idx;
8960
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008961 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008962 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8963 idx = 4;
8964 else
8965 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008966 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8967
8968}
8969
8970static void alc883_auto_init_multi_out(struct hda_codec *codec)
8971{
8972 struct alc_spec *spec = codec->spec;
8973 int i;
8974
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008975 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008976 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008977 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008978 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008979 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008980 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008981 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008982 }
8983}
8984
8985static void alc883_auto_init_hp_out(struct hda_codec *codec)
8986{
8987 struct alc_spec *spec = codec->spec;
8988 hda_nid_t pin;
8989
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008990 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008991 if (pin) /* connect to front */
8992 /* use dac 0 */
8993 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008994 pin = spec->autocfg.speaker_pins[0];
8995 if (pin)
8996 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008997}
8998
8999#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9000#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9001
9002static void alc883_auto_init_analog_input(struct hda_codec *codec)
9003{
9004 struct alc_spec *spec = codec->spec;
9005 int i;
9006
9007 for (i = 0; i < AUTO_PIN_LAST; i++) {
9008 hda_nid_t nid = spec->autocfg.input_pins[i];
9009 if (alc883_is_input_pin(nid)) {
9010 snd_hda_codec_write(codec, nid, 0,
9011 AC_VERB_SET_PIN_WIDGET_CONTROL,
9012 (i <= AUTO_PIN_FRONT_MIC ?
9013 PIN_VREF80 : PIN_IN));
9014 if (nid != ALC883_PIN_CD_NID)
9015 snd_hda_codec_write(codec, nid, 0,
9016 AC_VERB_SET_AMP_GAIN_MUTE,
9017 AMP_OUT_MUTE);
9018 }
9019 }
9020}
9021
Takashi Iwaif511b012008-08-15 16:46:42 +02009022#define alc883_auto_init_input_src alc882_auto_init_input_src
9023
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009024/* almost identical with ALC880 parser... */
9025static int alc883_parse_auto_config(struct hda_codec *codec)
9026{
9027 struct alc_spec *spec = codec->spec;
9028 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009029 struct auto_pin_cfg *cfg = &spec->autocfg;
9030 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009031
9032 if (err < 0)
9033 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009034 else if (!err)
9035 return 0; /* no config found */
9036
9037 err = alc_auto_add_mic_boost(codec);
9038 if (err < 0)
9039 return err;
9040
9041 /* hack - override the init verbs */
9042 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009043
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009044 /* setup input_mux for ALC889 */
9045 if (codec->vendor_id == 0x10ec0889) {
9046 /* digital-mic input pin is excluded in alc880_auto_create..()
9047 * because it's under 0x18
9048 */
9049 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9050 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9051 struct hda_input_mux *imux = &spec->private_imux[0];
9052 for (i = 1; i < 3; i++)
9053 memcpy(&spec->private_imux[i],
9054 &spec->private_imux[0],
9055 sizeof(spec->private_imux[0]));
9056 imux->items[imux->num_items].label = "Int DMic";
9057 imux->items[imux->num_items].index = 0x0b;
9058 imux->num_items++;
9059 spec->num_mux_defs = 3;
9060 spec->input_mux = spec->private_imux;
9061 }
9062 }
9063
Takashi Iwai776e1842007-08-29 15:07:11 +02009064 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009065}
9066
9067/* additional initialization for auto-configuration model */
9068static void alc883_auto_init(struct hda_codec *codec)
9069{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009070 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009071 alc883_auto_init_multi_out(codec);
9072 alc883_auto_init_hp_out(codec);
9073 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009074 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009075 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009076 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009077}
9078
9079static int patch_alc883(struct hda_codec *codec)
9080{
9081 struct alc_spec *spec;
9082 int err, board_config;
9083
9084 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9085 if (spec == NULL)
9086 return -ENOMEM;
9087
9088 codec->spec = spec;
9089
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009090 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9091
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009092 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9093 alc883_models,
9094 alc883_cfg_tbl);
9095 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009096 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9097 "trying auto-probe from BIOS...\n");
9098 board_config = ALC883_AUTO;
9099 }
9100
9101 if (board_config == ALC883_AUTO) {
9102 /* automatic parse from the BIOS config */
9103 err = alc883_parse_auto_config(codec);
9104 if (err < 0) {
9105 alc_free(codec);
9106 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009107 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009108 printk(KERN_INFO
9109 "hda_codec: Cannot set up configuration "
9110 "from BIOS. Using base mode...\n");
9111 board_config = ALC883_3ST_2ch_DIG;
9112 }
9113 }
9114
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009115 err = snd_hda_attach_beep_device(codec, 0x1);
9116 if (err < 0) {
9117 alc_free(codec);
9118 return err;
9119 }
9120
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009121 if (board_config != ALC883_AUTO)
9122 setup_preset(spec, &alc883_presets[board_config]);
9123
Kailang Yang2f893282008-05-27 12:14:47 +02009124 switch (codec->vendor_id) {
9125 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009126 if (codec->revision_id == 0x100101) {
9127 spec->stream_name_analog = "ALC1200 Analog";
9128 spec->stream_name_digital = "ALC1200 Digital";
9129 } else {
9130 spec->stream_name_analog = "ALC888 Analog";
9131 spec->stream_name_digital = "ALC888 Digital";
9132 }
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009133 if (!spec->num_adc_nids) {
9134 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9135 spec->adc_nids = alc883_adc_nids;
9136 }
9137 if (!spec->capsrc_nids)
9138 spec->capsrc_nids = alc883_capsrc_nids;
9139 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009140 break;
9141 case 0x10ec0889:
9142 spec->stream_name_analog = "ALC889 Analog";
9143 spec->stream_name_digital = "ALC889 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009144 if (!spec->num_adc_nids) {
9145 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9146 spec->adc_nids = alc889_adc_nids;
9147 }
9148 if (!spec->capsrc_nids)
9149 spec->capsrc_nids = alc889_capsrc_nids;
9150 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9151 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009152 break;
9153 default:
9154 spec->stream_name_analog = "ALC883 Analog";
9155 spec->stream_name_digital = "ALC883 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009156 if (!spec->num_adc_nids) {
9157 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9158 spec->adc_nids = alc883_adc_nids;
9159 }
9160 if (!spec->capsrc_nids)
9161 spec->capsrc_nids = alc883_capsrc_nids;
9162 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009163 break;
9164 }
9165
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009166 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9167 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009168 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009169
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009170 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9171 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9172
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009173 if (!spec->cap_mixer)
9174 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009175 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009176
Takashi Iwai2134ea42008-01-10 16:53:55 +01009177 spec->vmaster_nid = 0x0c;
9178
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009179 codec->patch_ops = alc_patch_ops;
9180 if (board_config == ALC883_AUTO)
9181 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009182
Takashi Iwaicb53c622007-08-10 17:21:45 +02009183#ifdef CONFIG_SND_HDA_POWER_SAVE
9184 if (!spec->loopback.amplist)
9185 spec->loopback.amplist = alc883_loopbacks;
9186#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009187 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009188
9189 return 0;
9190}
9191
9192/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009193 * ALC262 support
9194 */
9195
9196#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9197#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9198
9199#define alc262_dac_nids alc260_dac_nids
9200#define alc262_adc_nids alc882_adc_nids
9201#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009202#define alc262_capsrc_nids alc882_capsrc_nids
9203#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009204
9205#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009206#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009207
Kailang Yang4e555fe2008-08-26 13:05:55 +02009208static hda_nid_t alc262_dmic_adc_nids[1] = {
9209 /* ADC0 */
9210 0x09
9211};
9212
9213static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9214
Kailang Yangdf694da2005-12-05 19:42:22 +01009215static struct snd_kcontrol_new alc262_base_mixer[] = {
9216 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9217 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9218 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9219 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9220 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9221 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9222 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9223 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009224 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009225 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9226 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009227 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009228 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9229 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9230 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9231 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009232 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009233};
9234
Kailang Yangccc656c2006-10-17 12:32:26 +02009235static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9236 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9237 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9238 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9239 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9240 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9241 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9243 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009244 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009245 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9246 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009247 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009248 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9249 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9250 { } /* end */
9251};
9252
Takashi Iwaice875f02008-01-28 18:17:43 +01009253/* update HP, line and mono-out pins according to the master switch */
9254static void alc262_hp_master_update(struct hda_codec *codec)
9255{
9256 struct alc_spec *spec = codec->spec;
9257 int val = spec->master_sw;
9258
9259 /* HP & line-out */
9260 snd_hda_codec_write_cache(codec, 0x1b, 0,
9261 AC_VERB_SET_PIN_WIDGET_CONTROL,
9262 val ? PIN_HP : 0);
9263 snd_hda_codec_write_cache(codec, 0x15, 0,
9264 AC_VERB_SET_PIN_WIDGET_CONTROL,
9265 val ? PIN_HP : 0);
9266 /* mono (speaker) depending on the HP jack sense */
9267 val = val && !spec->jack_present;
9268 snd_hda_codec_write_cache(codec, 0x16, 0,
9269 AC_VERB_SET_PIN_WIDGET_CONTROL,
9270 val ? PIN_OUT : 0);
9271}
9272
9273static void alc262_hp_bpc_automute(struct hda_codec *codec)
9274{
9275 struct alc_spec *spec = codec->spec;
9276 unsigned int presence;
9277 presence = snd_hda_codec_read(codec, 0x1b, 0,
9278 AC_VERB_GET_PIN_SENSE, 0);
9279 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9280 alc262_hp_master_update(codec);
9281}
9282
9283static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9284{
9285 if ((res >> 26) != ALC880_HP_EVENT)
9286 return;
9287 alc262_hp_bpc_automute(codec);
9288}
9289
9290static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9291{
9292 struct alc_spec *spec = codec->spec;
9293 unsigned int presence;
9294 presence = snd_hda_codec_read(codec, 0x15, 0,
9295 AC_VERB_GET_PIN_SENSE, 0);
9296 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9297 alc262_hp_master_update(codec);
9298}
9299
9300static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9301 unsigned int res)
9302{
9303 if ((res >> 26) != ALC880_HP_EVENT)
9304 return;
9305 alc262_hp_wildwest_automute(codec);
9306}
9307
9308static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9309 struct snd_ctl_elem_value *ucontrol)
9310{
9311 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9312 struct alc_spec *spec = codec->spec;
9313 *ucontrol->value.integer.value = spec->master_sw;
9314 return 0;
9315}
9316
9317static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9318 struct snd_ctl_elem_value *ucontrol)
9319{
9320 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9321 struct alc_spec *spec = codec->spec;
9322 int val = !!*ucontrol->value.integer.value;
9323
9324 if (val == spec->master_sw)
9325 return 0;
9326 spec->master_sw = val;
9327 alc262_hp_master_update(codec);
9328 return 1;
9329}
9330
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009331static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009332 {
9333 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9334 .name = "Master Playback Switch",
9335 .info = snd_ctl_boolean_mono_info,
9336 .get = alc262_hp_master_sw_get,
9337 .put = alc262_hp_master_sw_put,
9338 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009339 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9340 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9341 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009342 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9343 HDA_OUTPUT),
9344 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9345 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009346 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9347 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009348 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009349 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9350 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009351 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009352 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9353 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9354 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9355 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009356 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9357 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9358 { } /* end */
9359};
9360
Kailang Yangcd7509a2007-01-26 18:33:17 +01009361static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009362 {
9363 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9364 .name = "Master Playback Switch",
9365 .info = snd_ctl_boolean_mono_info,
9366 .get = alc262_hp_master_sw_get,
9367 .put = alc262_hp_master_sw_put,
9368 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009369 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9370 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9371 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9372 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009373 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9374 HDA_OUTPUT),
9375 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9376 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009377 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9378 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009379 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009380 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9381 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9382 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9383 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009384 { } /* end */
9385};
9386
9387static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9388 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9389 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009390 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009391 { } /* end */
9392};
9393
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009394/* mute/unmute internal speaker according to the hp jack and mute state */
9395static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9396{
9397 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009398
9399 if (force || !spec->sense_updated) {
9400 unsigned int present;
9401 present = snd_hda_codec_read(codec, 0x15, 0,
9402 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009403 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009404 spec->sense_updated = 1;
9405 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009406 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9407 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009408}
9409
9410static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9411 unsigned int res)
9412{
9413 if ((res >> 26) != ALC880_HP_EVENT)
9414 return;
9415 alc262_hp_t5735_automute(codec, 1);
9416}
9417
9418static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9419{
9420 alc262_hp_t5735_automute(codec, 1);
9421}
9422
9423static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009424 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9425 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009426 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9427 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9428 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9429 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9430 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9431 { } /* end */
9432};
9433
9434static struct hda_verb alc262_hp_t5735_verbs[] = {
9435 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9436 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9437
9438 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9439 { }
9440};
9441
Kailang Yang8c427222008-01-10 13:03:59 +01009442static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009443 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9444 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009445 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9446 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009447 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9448 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9449 { } /* end */
9450};
9451
9452static struct hda_verb alc262_hp_rp5700_verbs[] = {
9453 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9454 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9455 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9456 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9457 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9458 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9459 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9460 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9461 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9462 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9463 {}
9464};
9465
9466static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9467 .num_items = 1,
9468 .items = {
9469 { "Line", 0x1 },
9470 },
9471};
9472
Takashi Iwai0724ea22007-08-23 00:31:43 +02009473/* bind hp and internal speaker mute (with plug check) */
9474static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9475 struct snd_ctl_elem_value *ucontrol)
9476{
9477 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9478 long *valp = ucontrol->value.integer.value;
9479 int change;
9480
9481 /* change hp mute */
9482 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9483 HDA_AMP_MUTE,
9484 valp[0] ? 0 : HDA_AMP_MUTE);
9485 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9486 HDA_AMP_MUTE,
9487 valp[1] ? 0 : HDA_AMP_MUTE);
9488 if (change) {
9489 /* change speaker according to HP jack state */
9490 struct alc_spec *spec = codec->spec;
9491 unsigned int mute;
9492 if (spec->jack_present)
9493 mute = HDA_AMP_MUTE;
9494 else
9495 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9496 HDA_OUTPUT, 0);
9497 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9498 HDA_AMP_MUTE, mute);
9499 }
9500 return change;
9501}
Takashi Iwai5b319542007-07-26 11:49:22 +02009502
Kailang Yang272a5272007-05-14 11:00:38 +02009503static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009504 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9505 {
9506 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9507 .name = "Master Playback Switch",
9508 .info = snd_hda_mixer_amp_switch_info,
9509 .get = snd_hda_mixer_amp_switch_get,
9510 .put = alc262_sony_master_sw_put,
9511 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9512 },
Kailang Yang272a5272007-05-14 11:00:38 +02009513 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9514 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9515 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9516 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9517 { } /* end */
9518};
9519
Kailang Yang83c34212007-07-05 11:43:05 +02009520static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9521 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9522 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9523 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9524 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9525 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9526 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9527 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9528 { } /* end */
9529};
Kailang Yang272a5272007-05-14 11:00:38 +02009530
Tony Vroonba340e82009-02-02 19:01:30 +00009531static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9532 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9533 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9534 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9535 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9536 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9537 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9539 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9540 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9541 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9542 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9543 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9544 { } /* end */
9545};
9546
9547static struct hda_verb alc262_tyan_verbs[] = {
9548 /* Headphone automute */
9549 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9550 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9551 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9552
9553 /* P11 AUX_IN, white 4-pin connector */
9554 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9555 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9556 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9557 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9558
9559 {}
9560};
9561
9562/* unsolicited event for HP jack sensing */
9563static void alc262_tyan_automute(struct hda_codec *codec)
9564{
9565 unsigned int mute;
9566 unsigned int present;
9567
9568 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9569 present = snd_hda_codec_read(codec, 0x1b, 0,
9570 AC_VERB_GET_PIN_SENSE, 0);
9571 present = (present & 0x80000000) != 0;
9572 if (present) {
9573 /* mute line output on ATX panel */
9574 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9575 HDA_AMP_MUTE, HDA_AMP_MUTE);
9576 } else {
9577 /* unmute line output if necessary */
9578 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9579 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9580 HDA_AMP_MUTE, mute);
9581 }
9582}
9583
9584static void alc262_tyan_unsol_event(struct hda_codec *codec,
9585 unsigned int res)
9586{
9587 if ((res >> 26) != ALC880_HP_EVENT)
9588 return;
9589 alc262_tyan_automute(codec);
9590}
9591
Kailang Yangdf694da2005-12-05 19:42:22 +01009592#define alc262_capture_mixer alc882_capture_mixer
9593#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9594
9595/*
9596 * generic initialization of ADC, input mixers and output mixers
9597 */
9598static struct hda_verb alc262_init_verbs[] = {
9599 /*
9600 * Unmute ADC0-2 and set the default input to mic-in
9601 */
9602 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9603 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9604 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9605 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9606 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9607 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9608
Takashi Iwaicb53c622007-08-10 17:21:45 +02009609 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009610 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009611 * Note: PASD motherboards uses the Line In 2 as the input for
9612 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009613 */
9614 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009615 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9616 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9617 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9618 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9619 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009620
9621 /*
9622 * Set up output mixers (0x0c - 0x0e)
9623 */
9624 /* set vol=0 to output mixers */
9625 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9626 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9627 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9628 /* set up input amps for analog loopback */
9629 /* Amp Indices: DAC = 0, mixer = 1 */
9630 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9631 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9632 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9633 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9634 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9635 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9636
9637 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9638 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9639 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9640 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9641 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9642 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9643
9644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9645 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9646 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9647 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9648 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009649
Kailang Yangdf694da2005-12-05 19:42:22 +01009650 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9651 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009652
Kailang Yangdf694da2005-12-05 19:42:22 +01009653 /* FIXME: use matrix-type input source selection */
9654 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9655 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9656 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9657 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9658 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9659 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9660 /* Input mixer2 */
9661 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9662 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9663 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9665 /* Input mixer3 */
9666 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9667 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9668 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009669 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009670
9671 { }
9672};
9673
Kailang Yang4e555fe2008-08-26 13:05:55 +02009674static struct hda_verb alc262_eapd_verbs[] = {
9675 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9676 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9677 { }
9678};
9679
Kailang Yangccc656c2006-10-17 12:32:26 +02009680static struct hda_verb alc262_hippo_unsol_verbs[] = {
9681 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9682 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9683 {}
9684};
9685
9686static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9687 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9688 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9689 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9690
9691 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9692 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9693 {}
9694};
9695
Kailang Yang272a5272007-05-14 11:00:38 +02009696static struct hda_verb alc262_sony_unsol_verbs[] = {
9697 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9698 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9699 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9700
9701 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9702 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009703 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009704};
9705
Kailang Yang4e555fe2008-08-26 13:05:55 +02009706static struct hda_input_mux alc262_dmic_capture_source = {
9707 .num_items = 2,
9708 .items = {
9709 { "Int DMic", 0x9 },
9710 { "Mic", 0x0 },
9711 },
9712};
9713
9714static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9715 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9716 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9717 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9719 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009720 { } /* end */
9721};
9722
9723static struct hda_verb alc262_toshiba_s06_verbs[] = {
9724 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9725 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9726 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9727 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9728 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9729 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9730 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9731 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9732 {}
9733};
9734
9735static void alc262_dmic_automute(struct hda_codec *codec)
9736{
9737 unsigned int present;
9738
9739 present = snd_hda_codec_read(codec, 0x18, 0,
9740 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9741 snd_hda_codec_write(codec, 0x22, 0,
9742 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9743}
9744
9745/* toggle speaker-output according to the hp-jack state */
9746static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9747{
9748 unsigned int present;
9749 unsigned char bits;
9750
9751 present = snd_hda_codec_read(codec, 0x15, 0,
9752 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9753 bits = present ? 0 : PIN_OUT;
9754 snd_hda_codec_write(codec, 0x14, 0,
9755 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9756}
9757
9758
9759
9760/* unsolicited event for HP jack sensing */
9761static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9762 unsigned int res)
9763{
9764 if ((res >> 26) == ALC880_HP_EVENT)
9765 alc262_toshiba_s06_speaker_automute(codec);
9766 if ((res >> 26) == ALC880_MIC_EVENT)
9767 alc262_dmic_automute(codec);
9768
9769}
9770
9771static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9772{
9773 alc262_toshiba_s06_speaker_automute(codec);
9774 alc262_dmic_automute(codec);
9775}
9776
Kailang Yangccc656c2006-10-17 12:32:26 +02009777/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009778static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009779{
9780 struct alc_spec *spec = codec->spec;
9781 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009782 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009783
Takashi Iwai5b319542007-07-26 11:49:22 +02009784 /* need to execute and sync at first */
9785 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9786 present = snd_hda_codec_read(codec, 0x15, 0,
9787 AC_VERB_GET_PIN_SENSE, 0);
9788 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009789 if (spec->jack_present) {
9790 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009791 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9792 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009793 } else {
9794 /* unmute internal speaker if necessary */
9795 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009796 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9797 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009798 }
9799}
9800
9801/* unsolicited event for HP jack sensing */
9802static void alc262_hippo_unsol_event(struct hda_codec *codec,
9803 unsigned int res)
9804{
9805 if ((res >> 26) != ALC880_HP_EVENT)
9806 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009807 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009808}
9809
Takashi Iwai5b319542007-07-26 11:49:22 +02009810static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009811{
Kailang Yangccc656c2006-10-17 12:32:26 +02009812 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009813 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009814
Takashi Iwai5b319542007-07-26 11:49:22 +02009815 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9816 present = snd_hda_codec_read(codec, 0x1b, 0,
9817 AC_VERB_GET_PIN_SENSE, 0);
9818 present = (present & 0x80000000) != 0;
9819 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009820 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009821 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9822 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009823 } else {
9824 /* unmute internal speaker if necessary */
9825 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009826 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9827 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009828 }
9829}
9830
9831/* unsolicited event for HP jack sensing */
9832static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9833 unsigned int res)
9834{
9835 if ((res >> 26) != ALC880_HP_EVENT)
9836 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009837 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009838}
9839
Takashi Iwai834be882006-03-01 14:16:17 +01009840/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009841 * nec model
9842 * 0x15 = headphone
9843 * 0x16 = internal speaker
9844 * 0x18 = external mic
9845 */
9846
9847static struct snd_kcontrol_new alc262_nec_mixer[] = {
9848 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9849 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9850
9851 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9852 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9853 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9854
9855 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9856 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9857 { } /* end */
9858};
9859
9860static struct hda_verb alc262_nec_verbs[] = {
9861 /* Unmute Speaker */
9862 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9863
9864 /* Headphone */
9865 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9866 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9867
9868 /* External mic to headphone */
9869 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9870 /* External mic to speaker */
9871 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9872 {}
9873};
9874
9875/*
Takashi Iwai834be882006-03-01 14:16:17 +01009876 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009877 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9878 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009879 */
9880
9881#define ALC_HP_EVENT 0x37
9882
9883static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9884 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9885 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009886 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9887 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009888 {}
9889};
9890
Jiang zhe0e31daf2008-03-20 12:12:39 +01009891static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9892 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9893 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9894 {}
9895};
9896
Takashi Iwai834be882006-03-01 14:16:17 +01009897static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009898 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009899 .items = {
9900 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009901 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009902 { "CD", 0x4 },
9903 },
9904};
9905
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009906static struct hda_input_mux alc262_HP_capture_source = {
9907 .num_items = 5,
9908 .items = {
9909 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009910 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009911 { "Line", 0x2 },
9912 { "CD", 0x4 },
9913 { "AUX IN", 0x6 },
9914 },
9915};
9916
zhejiangaccbe492007-08-31 12:36:05 +02009917static struct hda_input_mux alc262_HP_D7000_capture_source = {
9918 .num_items = 4,
9919 .items = {
9920 { "Mic", 0x0 },
9921 { "Front Mic", 0x2 },
9922 { "Line", 0x1 },
9923 { "CD", 0x4 },
9924 },
9925};
9926
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009927/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009928static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9929{
9930 struct alc_spec *spec = codec->spec;
9931 unsigned int mute;
9932
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009933 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009934 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009935 /* need to execute and sync at first */
9936 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009937 /* check laptop HP jack */
9938 present = snd_hda_codec_read(codec, 0x14, 0,
9939 AC_VERB_GET_PIN_SENSE, 0);
9940 /* need to execute and sync at first */
9941 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9942 /* check docking HP jack */
9943 present |= snd_hda_codec_read(codec, 0x1b, 0,
9944 AC_VERB_GET_PIN_SENSE, 0);
9945 if (present & AC_PINSENSE_PRESENCE)
9946 spec->jack_present = 1;
9947 else
9948 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009949 spec->sense_updated = 1;
9950 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009951 /* unmute internal speaker only if both HPs are unplugged and
9952 * master switch is on
9953 */
9954 if (spec->jack_present)
9955 mute = HDA_AMP_MUTE;
9956 else
Takashi Iwai834be882006-03-01 14:16:17 +01009957 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009958 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9959 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009960}
9961
9962/* unsolicited event for HP jack sensing */
9963static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9964 unsigned int res)
9965{
9966 if ((res >> 26) != ALC_HP_EVENT)
9967 return;
9968 alc262_fujitsu_automute(codec, 1);
9969}
9970
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009971static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9972{
9973 alc262_fujitsu_automute(codec, 1);
9974}
9975
Takashi Iwai834be882006-03-01 14:16:17 +01009976/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009977static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9978 .ops = &snd_hda_bind_vol,
9979 .values = {
9980 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9981 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9982 0
9983 },
9984};
Takashi Iwai834be882006-03-01 14:16:17 +01009985
Jiang zhe0e31daf2008-03-20 12:12:39 +01009986/* mute/unmute internal speaker according to the hp jack and mute state */
9987static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9988{
9989 struct alc_spec *spec = codec->spec;
9990 unsigned int mute;
9991
9992 if (force || !spec->sense_updated) {
9993 unsigned int present_int_hp;
9994 /* need to execute and sync at first */
9995 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9996 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9997 AC_VERB_GET_PIN_SENSE, 0);
9998 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9999 spec->sense_updated = 1;
10000 }
10001 if (spec->jack_present) {
10002 /* mute internal speaker */
10003 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10004 HDA_AMP_MUTE, HDA_AMP_MUTE);
10005 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10006 HDA_AMP_MUTE, HDA_AMP_MUTE);
10007 } else {
10008 /* unmute internal speaker if necessary */
10009 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10010 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10011 HDA_AMP_MUTE, mute);
10012 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10013 HDA_AMP_MUTE, mute);
10014 }
10015}
10016
10017/* unsolicited event for HP jack sensing */
10018static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10019 unsigned int res)
10020{
10021 if ((res >> 26) != ALC_HP_EVENT)
10022 return;
10023 alc262_lenovo_3000_automute(codec, 1);
10024}
10025
Takashi Iwai834be882006-03-01 14:16:17 +010010026/* bind hp and internal speaker mute (with plug check) */
10027static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10028 struct snd_ctl_elem_value *ucontrol)
10029{
10030 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10031 long *valp = ucontrol->value.integer.value;
10032 int change;
10033
Tony Vroon5d9fab22008-03-14 17:09:18 +010010034 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10035 HDA_AMP_MUTE,
10036 valp ? 0 : HDA_AMP_MUTE);
10037 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10038 HDA_AMP_MUTE,
10039 valp ? 0 : HDA_AMP_MUTE);
10040
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010041 if (change)
10042 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010043 return change;
10044}
10045
10046static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010047 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010048 {
10049 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10050 .name = "Master Playback Switch",
10051 .info = snd_hda_mixer_amp_switch_info,
10052 .get = snd_hda_mixer_amp_switch_get,
10053 .put = alc262_fujitsu_master_sw_put,
10054 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10055 },
10056 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10057 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10058 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10060 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010061 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10062 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10063 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010064 { } /* end */
10065};
10066
Jiang zhe0e31daf2008-03-20 12:12:39 +010010067/* bind hp and internal speaker mute (with plug check) */
10068static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10069 struct snd_ctl_elem_value *ucontrol)
10070{
10071 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10072 long *valp = ucontrol->value.integer.value;
10073 int change;
10074
10075 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10076 HDA_AMP_MUTE,
10077 valp ? 0 : HDA_AMP_MUTE);
10078
10079 if (change)
10080 alc262_lenovo_3000_automute(codec, 0);
10081 return change;
10082}
10083
10084static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10085 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10086 {
10087 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10088 .name = "Master Playback Switch",
10089 .info = snd_hda_mixer_amp_switch_info,
10090 .get = snd_hda_mixer_amp_switch_get,
10091 .put = alc262_lenovo_3000_master_sw_put,
10092 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10093 },
10094 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10095 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10096 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10097 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10098 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10099 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10100 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10101 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10102 { } /* end */
10103};
10104
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010105static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10106 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10107 {
10108 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10109 .name = "Master Playback Switch",
10110 .info = snd_hda_mixer_amp_switch_info,
10111 .get = snd_hda_mixer_amp_switch_get,
10112 .put = alc262_sony_master_sw_put,
10113 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
10114 },
10115 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10116 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10117 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10118 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10119 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10120 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10121 { } /* end */
10122};
10123
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010124/* additional init verbs for Benq laptops */
10125static struct hda_verb alc262_EAPD_verbs[] = {
10126 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10127 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10128 {}
10129};
10130
Kailang Yang83c34212007-07-05 11:43:05 +020010131static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10132 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10133 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10134
10135 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10136 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10137 {}
10138};
10139
Tobin Davisf651b502007-10-26 12:40:47 +020010140/* Samsung Q1 Ultra Vista model setup */
10141static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010142 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10143 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10146 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010147 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010148 { } /* end */
10149};
10150
10151static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010152 /* output mixer */
10153 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10154 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10155 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10156 /* speaker */
10157 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10158 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10159 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10160 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10161 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010162 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010163 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10164 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10165 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10166 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10167 /* internal mic */
10168 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10169 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10170 /* ADC, choose mic */
10171 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10172 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10173 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10174 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10175 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10176 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10177 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10178 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10179 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10180 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010181 {}
10182};
10183
Tobin Davisf651b502007-10-26 12:40:47 +020010184/* mute/unmute internal speaker according to the hp jack and mute state */
10185static void alc262_ultra_automute(struct hda_codec *codec)
10186{
10187 struct alc_spec *spec = codec->spec;
10188 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010189
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010190 mute = 0;
10191 /* auto-mute only when HP is used as HP */
10192 if (!spec->cur_mux[0]) {
10193 unsigned int present;
10194 /* need to execute and sync at first */
10195 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10196 present = snd_hda_codec_read(codec, 0x15, 0,
10197 AC_VERB_GET_PIN_SENSE, 0);
10198 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10199 if (spec->jack_present)
10200 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010201 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010202 /* mute/unmute internal speaker */
10203 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10204 HDA_AMP_MUTE, mute);
10205 /* mute/unmute HP */
10206 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10207 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010208}
10209
10210/* unsolicited event for HP jack sensing */
10211static void alc262_ultra_unsol_event(struct hda_codec *codec,
10212 unsigned int res)
10213{
10214 if ((res >> 26) != ALC880_HP_EVENT)
10215 return;
10216 alc262_ultra_automute(codec);
10217}
10218
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010219static struct hda_input_mux alc262_ultra_capture_source = {
10220 .num_items = 2,
10221 .items = {
10222 { "Mic", 0x1 },
10223 { "Headphone", 0x7 },
10224 },
10225};
10226
10227static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10228 struct snd_ctl_elem_value *ucontrol)
10229{
10230 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10231 struct alc_spec *spec = codec->spec;
10232 int ret;
10233
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010234 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010235 if (!ret)
10236 return 0;
10237 /* reprogram the HP pin as mic or HP according to the input source */
10238 snd_hda_codec_write_cache(codec, 0x15, 0,
10239 AC_VERB_SET_PIN_WIDGET_CONTROL,
10240 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10241 alc262_ultra_automute(codec); /* mute/unmute HP */
10242 return ret;
10243}
10244
10245static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10246 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10247 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10248 {
10249 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10250 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010251 .info = alc_mux_enum_info,
10252 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010253 .put = alc262_ultra_mux_enum_put,
10254 },
10255 { } /* end */
10256};
10257
Kailang Yangdf694da2005-12-05 19:42:22 +010010258/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010259static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10260 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010261{
10262 hda_nid_t nid;
10263 int err;
10264
10265 spec->multiout.num_dacs = 1; /* only use one dac */
10266 spec->multiout.dac_nids = spec->private_dac_nids;
10267 spec->multiout.dac_nids[0] = 2;
10268
10269 nid = cfg->line_out_pins[0];
10270 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010271 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10272 "Front Playback Volume",
10273 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10274 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010275 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010276 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10277 "Front Playback Switch",
10278 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10279 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010280 return err;
10281 }
10282
Takashi Iwai82bc9552006-03-21 11:24:42 +010010283 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010284 if (nid) {
10285 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010286 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10287 "Speaker Playback Volume",
10288 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10289 HDA_OUTPUT));
10290 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010291 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010292 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10293 "Speaker Playback Switch",
10294 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10295 HDA_OUTPUT));
10296 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010297 return err;
10298 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010299 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10300 "Speaker Playback Switch",
10301 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10302 HDA_OUTPUT));
10303 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010304 return err;
10305 }
10306 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010307 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010308 if (nid) {
10309 /* spec->multiout.hp_nid = 2; */
10310 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010311 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10312 "Headphone Playback Volume",
10313 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10314 HDA_OUTPUT));
10315 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010316 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010317 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10318 "Headphone Playback Switch",
10319 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10320 HDA_OUTPUT));
10321 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010322 return err;
10323 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010324 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10325 "Headphone Playback Switch",
10326 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10327 HDA_OUTPUT));
10328 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010329 return err;
10330 }
10331 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010332 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010333}
10334
10335/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010336#define alc262_auto_create_analog_input_ctls \
10337 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010338
10339/*
10340 * generic initialization of ADC, input mixers and output mixers
10341 */
10342static struct hda_verb alc262_volume_init_verbs[] = {
10343 /*
10344 * Unmute ADC0-2 and set the default input to mic-in
10345 */
10346 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10347 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10348 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10349 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10350 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10351 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10352
Takashi Iwaicb53c622007-08-10 17:21:45 +020010353 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010354 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010355 * Note: PASD motherboards uses the Line In 2 as the input for
10356 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010357 */
10358 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010359 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10360 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10361 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10362 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10363 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010364
10365 /*
10366 * Set up output mixers (0x0c - 0x0f)
10367 */
10368 /* set vol=0 to output mixers */
10369 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10370 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10371 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010372
Kailang Yangdf694da2005-12-05 19:42:22 +010010373 /* set up input amps for analog loopback */
10374 /* Amp Indices: DAC = 0, mixer = 1 */
10375 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10377 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10378 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10379 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10380 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10381
10382 /* FIXME: use matrix-type input source selection */
10383 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10384 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10385 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10386 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10387 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10388 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10389 /* Input mixer2 */
10390 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10391 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10392 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10393 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10394 /* Input mixer3 */
10395 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10396 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10397 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10398 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10399
10400 { }
10401};
10402
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010403static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10404 /*
10405 * Unmute ADC0-2 and set the default input to mic-in
10406 */
10407 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10408 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10409 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10410 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10411 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10412 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10413
Takashi Iwaicb53c622007-08-10 17:21:45 +020010414 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010415 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010416 * Note: PASD motherboards uses the Line In 2 as the input for
10417 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010418 */
10419 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010420 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10421 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10422 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10423 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10424 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10425 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10426 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010427
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010428 /*
10429 * Set up output mixers (0x0c - 0x0e)
10430 */
10431 /* set vol=0 to output mixers */
10432 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10433 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10434 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10435
10436 /* set up input amps for analog loopback */
10437 /* Amp Indices: DAC = 0, mixer = 1 */
10438 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10439 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10440 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10441 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10442 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10443 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10444
Takashi Iwaice875f02008-01-28 18:17:43 +010010445 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010446 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10447 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10448
10449 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10451
10452 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10453 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10454
10455 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10456 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10457 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10458 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10459 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10460
10461 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10462 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10463 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10464 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10465 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10466 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10467
10468
10469 /* FIXME: use matrix-type input source selection */
10470 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10471 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10472 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10473 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10474 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10475 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10476 /* Input mixer2 */
10477 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10478 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10479 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10480 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10481 /* Input mixer3 */
10482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10483 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10484 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10485 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10486
Takashi Iwaice875f02008-01-28 18:17:43 +010010487 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10488
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010489 { }
10490};
10491
Kailang Yangcd7509a2007-01-26 18:33:17 +010010492static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10493 /*
10494 * Unmute ADC0-2 and set the default input to mic-in
10495 */
10496 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10497 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10498 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10499 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10500 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10501 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10502
Takashi Iwaicb53c622007-08-10 17:21:45 +020010503 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010504 * mixer widget
10505 * Note: PASD motherboards uses the Line In 2 as the input for front
10506 * panel mic (mic 2)
10507 */
10508 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010509 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10510 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10511 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10512 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10513 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10514 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10515 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010517 /*
10518 * Set up output mixers (0x0c - 0x0e)
10519 */
10520 /* set vol=0 to output mixers */
10521 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10522 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10523 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10524
10525 /* set up input amps for analog loopback */
10526 /* Amp Indices: DAC = 0, mixer = 1 */
10527 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10529 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10530 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10531 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10532 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10533
10534
10535 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10536 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10537 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10538 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10539 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10540 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10541 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10542
10543 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10544 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10545
10546 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10547 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10548
10549 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10550 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10551 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10552 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10553 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10554 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10555
10556 /* FIXME: use matrix-type input source selection */
10557 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10558 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10559 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10560 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10561 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10562 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10563 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10564 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10565 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10566 /* Input mixer2 */
10567 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10568 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10569 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10570 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10571 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10572 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10573 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10574 /* Input mixer3 */
10575 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10580 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10581 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10582
Takashi Iwaice875f02008-01-28 18:17:43 +010010583 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10584
Kailang Yangcd7509a2007-01-26 18:33:17 +010010585 { }
10586};
10587
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010588static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10589
10590 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10591 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10592 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10593
10594 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10595 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10596 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10597 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10598
10599 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10600 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10601 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10602 {}
10603};
10604
10605
Takashi Iwaicb53c622007-08-10 17:21:45 +020010606#ifdef CONFIG_SND_HDA_POWER_SAVE
10607#define alc262_loopbacks alc880_loopbacks
10608#endif
10609
Kailang Yangdf694da2005-12-05 19:42:22 +010010610/* pcm configuration: identiacal with ALC880 */
10611#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10612#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10613#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10614#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10615
10616/*
10617 * BIOS auto configuration
10618 */
10619static int alc262_parse_auto_config(struct hda_codec *codec)
10620{
10621 struct alc_spec *spec = codec->spec;
10622 int err;
10623 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10624
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010625 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10626 alc262_ignore);
10627 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010628 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010629 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010630 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010631 spec->multiout.max_channels = 2;
10632 spec->no_analog = 1;
10633 goto dig_only;
10634 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010635 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010636 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010637 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10638 if (err < 0)
10639 return err;
10640 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10641 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010642 return err;
10643
10644 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10645
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010646 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010647 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010648 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010649 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010650 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010651 if (spec->autocfg.dig_in_pin)
10652 spec->dig_in_nid = ALC262_DIGIN_NID;
10653
Takashi Iwai603c4012008-07-30 15:01:44 +020010654 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010655 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010656
Takashi Iwaid88897e2008-10-31 15:01:37 +010010657 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010658 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010659 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010660
Takashi Iwai776e1842007-08-29 15:07:11 +020010661 err = alc_auto_add_mic_boost(codec);
10662 if (err < 0)
10663 return err;
10664
Takashi Iwaie044c392008-10-27 16:56:24 +010010665 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010666 return 1;
10667}
10668
10669#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10670#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10671#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010672#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010673
10674
10675/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010676static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010677{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010678 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010679 alc262_auto_init_multi_out(codec);
10680 alc262_auto_init_hp_out(codec);
10681 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010682 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010683 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010684 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010685}
10686
10687/*
10688 * configuration and preset
10689 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010690static const char *alc262_models[ALC262_MODEL_LAST] = {
10691 [ALC262_BASIC] = "basic",
10692 [ALC262_HIPPO] = "hippo",
10693 [ALC262_HIPPO_1] = "hippo_1",
10694 [ALC262_FUJITSU] = "fujitsu",
10695 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010696 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010697 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010698 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010699 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010700 [ALC262_BENQ_T31] = "benq-t31",
10701 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010702 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010703 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010704 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010705 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010706 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010707 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010708 [ALC262_AUTO] = "auto",
10709};
10710
10711static struct snd_pci_quirk alc262_cfg_tbl[] = {
10712 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010713 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010714 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10715 ALC262_HP_BPC),
10716 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10717 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 Iwaidea0a502009-02-09 17:14:52 +010010745 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10746 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 */
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011811 if (spec->autocfg.dig_outs)
Kailang Yanga361d842007-06-05 12:30:55 +020011812 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] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010011890 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011891 .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,
Takashi Iwai22971e32009-02-10 11:56:44 +010011972 alc268_beep_mixer,
11973 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011974 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11975 alc268_acer_aspire_one_verbs },
11976 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11977 .dac_nids = alc268_dac_nids,
11978 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11979 .adc_nids = alc268_adc_nids_alt,
11980 .capsrc_nids = alc268_capsrc_nids,
11981 .hp_nid = 0x03,
11982 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11983 .channel_mode = alc268_modes,
11984 .input_mux = &alc268_acer_lc_capture_source,
11985 .unsol_event = alc268_acer_lc_unsol_event,
11986 .init_hook = alc268_acer_lc_init_hook,
11987 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011988 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011989 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011990 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11991 alc268_dell_verbs },
11992 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11993 .dac_nids = alc268_dac_nids,
11994 .hp_nid = 0x02,
11995 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11996 .channel_mode = alc268_modes,
11997 .unsol_event = alc268_dell_unsol_event,
11998 .init_hook = alc268_dell_init_hook,
11999 .input_mux = &alc268_capture_source,
12000 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012001 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012002 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12003 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012004 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12005 alc268_toshiba_verbs },
12006 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12007 .dac_nids = alc268_dac_nids,
12008 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12009 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012010 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012011 .hp_nid = 0x03,
12012 .dig_out_nid = ALC268_DIGOUT_NID,
12013 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12014 .channel_mode = alc268_modes,
12015 .input_mux = &alc268_capture_source,
12016 .unsol_event = alc268_toshiba_unsol_event,
12017 .init_hook = alc268_toshiba_automute
12018 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012019#ifdef CONFIG_SND_DEBUG
12020 [ALC268_TEST] = {
12021 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12022 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12023 alc268_volume_init_verbs },
12024 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12025 .dac_nids = alc268_dac_nids,
12026 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12027 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012028 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012029 .hp_nid = 0x03,
12030 .dig_out_nid = ALC268_DIGOUT_NID,
12031 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12032 .channel_mode = alc268_modes,
12033 .input_mux = &alc268_capture_source,
12034 },
12035#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012036};
12037
12038static int patch_alc268(struct hda_codec *codec)
12039{
12040 struct alc_spec *spec;
12041 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012042 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012043
12044 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12045 if (spec == NULL)
12046 return -ENOMEM;
12047
12048 codec->spec = spec;
12049
12050 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12051 alc268_models,
12052 alc268_cfg_tbl);
12053
12054 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12055 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12056 "trying auto-probe from BIOS...\n");
12057 board_config = ALC268_AUTO;
12058 }
12059
12060 if (board_config == ALC268_AUTO) {
12061 /* automatic parse from the BIOS config */
12062 err = alc268_parse_auto_config(codec);
12063 if (err < 0) {
12064 alc_free(codec);
12065 return err;
12066 } else if (!err) {
12067 printk(KERN_INFO
12068 "hda_codec: Cannot set up configuration "
12069 "from BIOS. Using base mode...\n");
12070 board_config = ALC268_3ST;
12071 }
12072 }
12073
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012074 err = snd_hda_attach_beep_device(codec, 0x1);
12075 if (err < 0) {
12076 alc_free(codec);
12077 return err;
12078 }
12079
Kailang Yanga361d842007-06-05 12:30:55 +020012080 if (board_config != ALC268_AUTO)
12081 setup_preset(spec, &alc268_presets[board_config]);
12082
Kailang Yang2f893282008-05-27 12:14:47 +020012083 if (codec->vendor_id == 0x10ec0267) {
12084 spec->stream_name_analog = "ALC267 Analog";
12085 spec->stream_name_digital = "ALC267 Digital";
12086 } else {
12087 spec->stream_name_analog = "ALC268 Analog";
12088 spec->stream_name_digital = "ALC268 Digital";
12089 }
12090
Kailang Yanga361d842007-06-05 12:30:55 +020012091 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12092 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012093 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012094
Kailang Yanga361d842007-06-05 12:30:55 +020012095 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12096
Takashi Iwai22971e32009-02-10 11:56:44 +010012097 has_beep = 0;
12098 for (i = 0; i < spec->num_mixers; i++) {
12099 if (spec->mixers[i] == alc268_beep_mixer) {
12100 has_beep = 1;
12101 break;
12102 }
12103 }
12104
12105 if (has_beep) {
12106 err = snd_hda_attach_beep_device(codec, 0x1);
12107 if (err < 0) {
12108 alc_free(codec);
12109 return err;
12110 }
12111 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12112 /* override the amp caps for beep generator */
12113 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012114 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12115 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12116 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12117 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012118 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012119
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012120 if (!spec->adc_nids && spec->input_mux) {
12121 /* check whether NID 0x07 is valid */
12122 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012123 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012124
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012125 /* get type */
12126 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012127 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012128 spec->adc_nids = alc268_adc_nids_alt;
12129 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012130 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012131 } else {
12132 spec->adc_nids = alc268_adc_nids;
12133 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012134 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012135 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012136 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012137 /* set default input source */
12138 for (i = 0; i < spec->num_adc_nids; i++)
12139 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12140 0, AC_VERB_SET_CONNECT_SEL,
12141 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012142 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012143
12144 spec->vmaster_nid = 0x02;
12145
Kailang Yanga361d842007-06-05 12:30:55 +020012146 codec->patch_ops = alc_patch_ops;
12147 if (board_config == ALC268_AUTO)
12148 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012149
Takashi Iwaidaead532008-11-28 12:55:36 +010012150 codec->proc_widget_hook = print_realtek_coef;
12151
Kailang Yanga361d842007-06-05 12:30:55 +020012152 return 0;
12153}
12154
12155/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012156 * ALC269 channel source setting (2 channel)
12157 */
12158#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12159
12160#define alc269_dac_nids alc260_dac_nids
12161
12162static hda_nid_t alc269_adc_nids[1] = {
12163 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012164 0x08,
12165};
12166
Takashi Iwaie01bf502008-08-21 16:25:07 +020012167static hda_nid_t alc269_capsrc_nids[1] = {
12168 0x23,
12169};
12170
12171/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12172 * not a mux!
12173 */
12174
Kailang Yangf53281e2008-07-18 12:36:43 +020012175static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12176 .num_items = 2,
12177 .items = {
12178 { "i-Mic", 0x5 },
12179 { "e-Mic", 0x0 },
12180 },
12181};
12182
12183static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12184 .num_items = 2,
12185 .items = {
12186 { "i-Mic", 0x1 },
12187 { "e-Mic", 0x0 },
12188 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012189};
12190
12191#define alc269_modes alc260_modes
12192#define alc269_capture_source alc880_lg_lw_capture_source
12193
12194static struct snd_kcontrol_new alc269_base_mixer[] = {
12195 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12196 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12197 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12198 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12200 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12201 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12202 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12203 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12204 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12205 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12206 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12207 { } /* end */
12208};
12209
Kailang Yang60db6b52008-08-26 13:13:00 +020012210static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12211 /* output mixer control */
12212 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12213 {
12214 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12215 .name = "Master Playback Switch",
12216 .info = snd_hda_mixer_amp_switch_info,
12217 .get = snd_hda_mixer_amp_switch_get,
12218 .put = alc268_acer_master_sw_put,
12219 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12220 },
12221 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12222 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12223 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12224 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12225 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12226 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012227 { }
12228};
12229
Tony Vroon64154832008-11-06 15:08:49 +000012230static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12231 /* output mixer control */
12232 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12233 {
12234 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12235 .name = "Master Playback Switch",
12236 .info = snd_hda_mixer_amp_switch_info,
12237 .get = snd_hda_mixer_amp_switch_get,
12238 .put = alc268_acer_master_sw_put,
12239 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12240 },
12241 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12242 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12243 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12244 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12245 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12246 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12247 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12248 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12249 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012250 { }
12251};
12252
Kailang Yangf53281e2008-07-18 12:36:43 +020012253/* bind volumes of both NID 0x0c and 0x0d */
12254static struct hda_bind_ctls alc269_epc_bind_vol = {
12255 .ops = &snd_hda_bind_vol,
12256 .values = {
12257 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12258 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12259 0
12260 },
12261};
12262
12263static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12264 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12265 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12266 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12267 { } /* end */
12268};
12269
Kailang Yangf6a92242007-12-13 16:52:54 +010012270/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012271static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12272 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12273 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012274 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12275 { } /* end */
12276};
12277
12278/* FSC amilo */
12279static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12280 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12281 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12282 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012283 { } /* end */
12284};
12285
Kailang Yang60db6b52008-08-26 13:13:00 +020012286static struct hda_verb alc269_quanta_fl1_verbs[] = {
12287 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12288 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12289 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12290 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12291 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12292 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12293 { }
12294};
12295
Tony Vroon64154832008-11-06 15:08:49 +000012296static struct hda_verb alc269_lifebook_verbs[] = {
12297 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12298 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12299 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12300 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12301 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12302 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12303 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12304 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12305 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12306 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12307 { }
12308};
12309
Kailang Yang60db6b52008-08-26 13:13:00 +020012310/* toggle speaker-output according to the hp-jack state */
12311static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12312{
12313 unsigned int present;
12314 unsigned char bits;
12315
12316 present = snd_hda_codec_read(codec, 0x15, 0,
12317 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12318 bits = present ? AMP_IN_MUTE(0) : 0;
12319 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12320 AMP_IN_MUTE(0), bits);
12321 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12322 AMP_IN_MUTE(0), bits);
12323
12324 snd_hda_codec_write(codec, 0x20, 0,
12325 AC_VERB_SET_COEF_INDEX, 0x0c);
12326 snd_hda_codec_write(codec, 0x20, 0,
12327 AC_VERB_SET_PROC_COEF, 0x680);
12328
12329 snd_hda_codec_write(codec, 0x20, 0,
12330 AC_VERB_SET_COEF_INDEX, 0x0c);
12331 snd_hda_codec_write(codec, 0x20, 0,
12332 AC_VERB_SET_PROC_COEF, 0x480);
12333}
12334
Tony Vroon64154832008-11-06 15:08:49 +000012335/* toggle speaker-output according to the hp-jacks state */
12336static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12337{
12338 unsigned int present;
12339 unsigned char bits;
12340
12341 /* Check laptop headphone socket */
12342 present = snd_hda_codec_read(codec, 0x15, 0,
12343 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12344
12345 /* Check port replicator headphone socket */
12346 present |= snd_hda_codec_read(codec, 0x1a, 0,
12347 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12348
12349 bits = present ? AMP_IN_MUTE(0) : 0;
12350 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12351 AMP_IN_MUTE(0), bits);
12352 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12353 AMP_IN_MUTE(0), bits);
12354
12355 snd_hda_codec_write(codec, 0x20, 0,
12356 AC_VERB_SET_COEF_INDEX, 0x0c);
12357 snd_hda_codec_write(codec, 0x20, 0,
12358 AC_VERB_SET_PROC_COEF, 0x680);
12359
12360 snd_hda_codec_write(codec, 0x20, 0,
12361 AC_VERB_SET_COEF_INDEX, 0x0c);
12362 snd_hda_codec_write(codec, 0x20, 0,
12363 AC_VERB_SET_PROC_COEF, 0x480);
12364}
12365
Kailang Yang60db6b52008-08-26 13:13:00 +020012366static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12367{
12368 unsigned int present;
12369
12370 present = snd_hda_codec_read(codec, 0x18, 0,
12371 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12372 snd_hda_codec_write(codec, 0x23, 0,
12373 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12374}
12375
Tony Vroon64154832008-11-06 15:08:49 +000012376static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12377{
12378 unsigned int present_laptop;
12379 unsigned int present_dock;
12380
12381 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12382 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12383
12384 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12385 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12386
12387 /* Laptop mic port overrides dock mic port, design decision */
12388 if (present_dock)
12389 snd_hda_codec_write(codec, 0x23, 0,
12390 AC_VERB_SET_CONNECT_SEL, 0x3);
12391 if (present_laptop)
12392 snd_hda_codec_write(codec, 0x23, 0,
12393 AC_VERB_SET_CONNECT_SEL, 0x0);
12394 if (!present_dock && !present_laptop)
12395 snd_hda_codec_write(codec, 0x23, 0,
12396 AC_VERB_SET_CONNECT_SEL, 0x1);
12397}
12398
Kailang Yang60db6b52008-08-26 13:13:00 +020012399static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12400 unsigned int res)
12401{
12402 if ((res >> 26) == ALC880_HP_EVENT)
12403 alc269_quanta_fl1_speaker_automute(codec);
12404 if ((res >> 26) == ALC880_MIC_EVENT)
12405 alc269_quanta_fl1_mic_automute(codec);
12406}
12407
Tony Vroon64154832008-11-06 15:08:49 +000012408static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12409 unsigned int res)
12410{
12411 if ((res >> 26) == ALC880_HP_EVENT)
12412 alc269_lifebook_speaker_automute(codec);
12413 if ((res >> 26) == ALC880_MIC_EVENT)
12414 alc269_lifebook_mic_autoswitch(codec);
12415}
12416
Kailang Yang60db6b52008-08-26 13:13:00 +020012417static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12418{
12419 alc269_quanta_fl1_speaker_automute(codec);
12420 alc269_quanta_fl1_mic_automute(codec);
12421}
12422
Tony Vroon64154832008-11-06 15:08:49 +000012423static void alc269_lifebook_init_hook(struct hda_codec *codec)
12424{
12425 alc269_lifebook_speaker_automute(codec);
12426 alc269_lifebook_mic_autoswitch(codec);
12427}
12428
Kailang Yang60db6b52008-08-26 13:13:00 +020012429static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12430 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12431 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12432 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12433 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12434 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12435 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12436 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12437 {}
12438};
12439
12440static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12441 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12442 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12443 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12444 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12445 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12446 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12447 {}
12448};
12449
12450/* toggle speaker-output according to the hp-jack state */
12451static void alc269_speaker_automute(struct hda_codec *codec)
12452{
12453 unsigned int present;
12454 unsigned char bits;
12455
12456 present = snd_hda_codec_read(codec, 0x15, 0,
12457 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12458 bits = present ? AMP_IN_MUTE(0) : 0;
12459 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12460 AMP_IN_MUTE(0), bits);
12461 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12462 AMP_IN_MUTE(0), bits);
12463}
12464
12465static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12466{
12467 unsigned int present;
12468
12469 present = snd_hda_codec_read(codec, 0x18, 0,
12470 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12471 snd_hda_codec_write(codec, 0x23, 0,
12472 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12473}
12474
12475static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12476{
12477 unsigned int present;
12478
12479 present = snd_hda_codec_read(codec, 0x18, 0,
12480 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12481 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12482 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12483 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12484 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12485}
12486
12487/* unsolicited event for HP jack sensing */
12488static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12489 unsigned int res)
12490{
12491 if ((res >> 26) == ALC880_HP_EVENT)
12492 alc269_speaker_automute(codec);
12493
12494 if ((res >> 26) == ALC880_MIC_EVENT)
12495 alc269_eeepc_dmic_automute(codec);
12496}
12497
12498static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12499{
12500 alc269_speaker_automute(codec);
12501 alc269_eeepc_dmic_automute(codec);
12502}
12503
12504/* unsolicited event for HP jack sensing */
12505static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12506 unsigned int res)
12507{
12508 if ((res >> 26) == ALC880_HP_EVENT)
12509 alc269_speaker_automute(codec);
12510
12511 if ((res >> 26) == ALC880_MIC_EVENT)
12512 alc269_eeepc_amic_automute(codec);
12513}
12514
12515static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12516{
12517 alc269_speaker_automute(codec);
12518 alc269_eeepc_amic_automute(codec);
12519}
12520
Kailang Yangf6a92242007-12-13 16:52:54 +010012521/*
12522 * generic initialization of ADC, input mixers and output mixers
12523 */
12524static struct hda_verb alc269_init_verbs[] = {
12525 /*
12526 * Unmute ADC0 and set the default input to mic-in
12527 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012529
12530 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12531 * analog-loopback mixer widget
12532 * Note: PASD motherboards uses the Line In 2 as the input for
12533 * front panel mic (mic 2)
12534 */
12535 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12536 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12541
12542 /*
12543 * Set up output mixers (0x0c - 0x0e)
12544 */
12545 /* set vol=0 to output mixers */
12546 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12547 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12548
12549 /* set up input amps for analog loopback */
12550 /* Amp Indices: DAC = 0, mixer = 1 */
12551 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12553 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12554 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12555 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12556 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12557
12558 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12559 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12560 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12561 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12562 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12563 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12564 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12565
12566 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12567 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12568 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12569 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12570 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12571 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12572 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12573
12574 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12575 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12576
12577 /* FIXME: use matrix-type input source selection */
12578 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12579 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012580 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12581 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012582 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12583 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12584
12585 /* set EAPD */
12586 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12587 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12588 { }
12589};
12590
12591/* add playback controls from the parsed DAC table */
12592static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12593 const struct auto_pin_cfg *cfg)
12594{
12595 hda_nid_t nid;
12596 int err;
12597
12598 spec->multiout.num_dacs = 1; /* only use one dac */
12599 spec->multiout.dac_nids = spec->private_dac_nids;
12600 spec->multiout.dac_nids[0] = 2;
12601
12602 nid = cfg->line_out_pins[0];
12603 if (nid) {
12604 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12605 "Front Playback Volume",
12606 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12607 if (err < 0)
12608 return err;
12609 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12610 "Front Playback Switch",
12611 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12612 if (err < 0)
12613 return err;
12614 }
12615
12616 nid = cfg->speaker_pins[0];
12617 if (nid) {
12618 if (!cfg->line_out_pins[0]) {
12619 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12620 "Speaker Playback Volume",
12621 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12622 HDA_OUTPUT));
12623 if (err < 0)
12624 return err;
12625 }
12626 if (nid == 0x16) {
12627 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12628 "Speaker Playback Switch",
12629 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12630 HDA_OUTPUT));
12631 if (err < 0)
12632 return err;
12633 } else {
12634 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12635 "Speaker Playback Switch",
12636 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12637 HDA_OUTPUT));
12638 if (err < 0)
12639 return err;
12640 }
12641 }
12642 nid = cfg->hp_pins[0];
12643 if (nid) {
12644 /* spec->multiout.hp_nid = 2; */
12645 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12646 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12647 "Headphone Playback Volume",
12648 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12649 HDA_OUTPUT));
12650 if (err < 0)
12651 return err;
12652 }
12653 if (nid == 0x16) {
12654 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12655 "Headphone Playback Switch",
12656 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12657 HDA_OUTPUT));
12658 if (err < 0)
12659 return err;
12660 } else {
12661 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12662 "Headphone Playback Switch",
12663 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12664 HDA_OUTPUT));
12665 if (err < 0)
12666 return err;
12667 }
12668 }
12669 return 0;
12670}
12671
Takashi Iwaiee956e02008-10-31 17:16:31 +010012672static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12673 const struct auto_pin_cfg *cfg)
12674{
12675 int err;
12676
12677 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12678 if (err < 0)
12679 return err;
12680 /* digital-mic input pin is excluded in alc880_auto_create..()
12681 * because it's under 0x18
12682 */
12683 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12684 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012685 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012686 imux->items[imux->num_items].label = "Int Mic";
12687 imux->items[imux->num_items].index = 0x05;
12688 imux->num_items++;
12689 }
12690 return 0;
12691}
Kailang Yangf6a92242007-12-13 16:52:54 +010012692
12693#ifdef CONFIG_SND_HDA_POWER_SAVE
12694#define alc269_loopbacks alc880_loopbacks
12695#endif
12696
12697/* pcm configuration: identiacal with ALC880 */
12698#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12699#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12700#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12701#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12702
12703/*
12704 * BIOS auto configuration
12705 */
12706static int alc269_parse_auto_config(struct hda_codec *codec)
12707{
12708 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012709 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012710 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12711
12712 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12713 alc269_ignore);
12714 if (err < 0)
12715 return err;
12716
12717 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12718 if (err < 0)
12719 return err;
12720 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12721 if (err < 0)
12722 return err;
12723
12724 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12725
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012726 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012727 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12728
Takashi Iwai603c4012008-07-30 15:01:44 +020012729 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012730 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012731
Takashi Iwaid88897e2008-10-31 15:01:37 +010012732 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012733 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012734 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012735 /* set default input source */
12736 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12737 0, AC_VERB_SET_CONNECT_SEL,
12738 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012739
12740 err = alc_auto_add_mic_boost(codec);
12741 if (err < 0)
12742 return err;
12743
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012744 if (!spec->cap_mixer)
12745 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012746
Takashi Iwaie044c392008-10-27 16:56:24 +010012747 store_pin_configs(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012748 return 1;
12749}
12750
12751#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12752#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12753#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12754
12755
12756/* init callback for auto-configuration model -- overriding the default init */
12757static void alc269_auto_init(struct hda_codec *codec)
12758{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012759 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012760 alc269_auto_init_multi_out(codec);
12761 alc269_auto_init_hp_out(codec);
12762 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012763 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012764 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012765}
12766
12767/*
12768 * configuration and preset
12769 */
12770static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012771 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012772 [ALC269_QUANTA_FL1] = "quanta",
12773 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012774 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012775 [ALC269_FUJITSU] = "fujitsu",
12776 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012777};
12778
12779static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012780 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012781 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12782 ALC269_ASUS_EEEPC_P703),
12783 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12784 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012785 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12786 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012787 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012788 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012789 {}
12790};
12791
12792static struct alc_config_preset alc269_presets[] = {
12793 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012794 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012795 .init_verbs = { alc269_init_verbs },
12796 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12797 .dac_nids = alc269_dac_nids,
12798 .hp_nid = 0x03,
12799 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12800 .channel_mode = alc269_modes,
12801 .input_mux = &alc269_capture_source,
12802 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012803 [ALC269_QUANTA_FL1] = {
12804 .mixers = { alc269_quanta_fl1_mixer },
12805 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12806 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12807 .dac_nids = alc269_dac_nids,
12808 .hp_nid = 0x03,
12809 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12810 .channel_mode = alc269_modes,
12811 .input_mux = &alc269_capture_source,
12812 .unsol_event = alc269_quanta_fl1_unsol_event,
12813 .init_hook = alc269_quanta_fl1_init_hook,
12814 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012815 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012816 .mixers = { alc269_eeepc_mixer },
12817 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012818 .init_verbs = { alc269_init_verbs,
12819 alc269_eeepc_amic_init_verbs },
12820 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12821 .dac_nids = alc269_dac_nids,
12822 .hp_nid = 0x03,
12823 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12824 .channel_mode = alc269_modes,
12825 .input_mux = &alc269_eeepc_amic_capture_source,
12826 .unsol_event = alc269_eeepc_amic_unsol_event,
12827 .init_hook = alc269_eeepc_amic_inithook,
12828 },
12829 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012830 .mixers = { alc269_eeepc_mixer },
12831 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012832 .init_verbs = { alc269_init_verbs,
12833 alc269_eeepc_dmic_init_verbs },
12834 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12835 .dac_nids = alc269_dac_nids,
12836 .hp_nid = 0x03,
12837 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12838 .channel_mode = alc269_modes,
12839 .input_mux = &alc269_eeepc_dmic_capture_source,
12840 .unsol_event = alc269_eeepc_dmic_unsol_event,
12841 .init_hook = alc269_eeepc_dmic_inithook,
12842 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012843 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012844 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012845 .cap_mixer = alc269_epc_capture_mixer,
12846 .init_verbs = { alc269_init_verbs,
12847 alc269_eeepc_dmic_init_verbs },
12848 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12849 .dac_nids = alc269_dac_nids,
12850 .hp_nid = 0x03,
12851 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12852 .channel_mode = alc269_modes,
12853 .input_mux = &alc269_eeepc_dmic_capture_source,
12854 .unsol_event = alc269_eeepc_dmic_unsol_event,
12855 .init_hook = alc269_eeepc_dmic_inithook,
12856 },
Tony Vroon64154832008-11-06 15:08:49 +000012857 [ALC269_LIFEBOOK] = {
12858 .mixers = { alc269_lifebook_mixer },
12859 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12860 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12861 .dac_nids = alc269_dac_nids,
12862 .hp_nid = 0x03,
12863 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12864 .channel_mode = alc269_modes,
12865 .input_mux = &alc269_capture_source,
12866 .unsol_event = alc269_lifebook_unsol_event,
12867 .init_hook = alc269_lifebook_init_hook,
12868 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012869};
12870
12871static int patch_alc269(struct hda_codec *codec)
12872{
12873 struct alc_spec *spec;
12874 int board_config;
12875 int err;
12876
12877 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12878 if (spec == NULL)
12879 return -ENOMEM;
12880
12881 codec->spec = spec;
12882
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012883 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12884
Kailang Yangf6a92242007-12-13 16:52:54 +010012885 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12886 alc269_models,
12887 alc269_cfg_tbl);
12888
12889 if (board_config < 0) {
12890 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12891 "trying auto-probe from BIOS...\n");
12892 board_config = ALC269_AUTO;
12893 }
12894
12895 if (board_config == ALC269_AUTO) {
12896 /* automatic parse from the BIOS config */
12897 err = alc269_parse_auto_config(codec);
12898 if (err < 0) {
12899 alc_free(codec);
12900 return err;
12901 } else if (!err) {
12902 printk(KERN_INFO
12903 "hda_codec: Cannot set up configuration "
12904 "from BIOS. Using base mode...\n");
12905 board_config = ALC269_BASIC;
12906 }
12907 }
12908
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012909 err = snd_hda_attach_beep_device(codec, 0x1);
12910 if (err < 0) {
12911 alc_free(codec);
12912 return err;
12913 }
12914
Kailang Yangf6a92242007-12-13 16:52:54 +010012915 if (board_config != ALC269_AUTO)
12916 setup_preset(spec, &alc269_presets[board_config]);
12917
12918 spec->stream_name_analog = "ALC269 Analog";
12919 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12920 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12921
12922 spec->stream_name_digital = "ALC269 Digital";
12923 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12924 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12925
12926 spec->adc_nids = alc269_adc_nids;
12927 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012928 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012929 if (!spec->cap_mixer)
12930 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012931 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010012932
12933 codec->patch_ops = alc_patch_ops;
12934 if (board_config == ALC269_AUTO)
12935 spec->init_hook = alc269_auto_init;
12936#ifdef CONFIG_SND_HDA_POWER_SAVE
12937 if (!spec->loopback.amplist)
12938 spec->loopback.amplist = alc269_loopbacks;
12939#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010012940 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010012941
12942 return 0;
12943}
12944
12945/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012946 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12947 */
12948
12949/*
12950 * set the path ways for 2 channel output
12951 * need to set the codec line out and mic 1 pin widgets to inputs
12952 */
12953static struct hda_verb alc861_threestack_ch2_init[] = {
12954 /* set pin widget 1Ah (line in) for input */
12955 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012956 /* set pin widget 18h (mic1/2) for input, for mic also enable
12957 * the vref
12958 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012959 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12960
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012961 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12962#if 0
12963 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12964 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12965#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012966 { } /* end */
12967};
12968/*
12969 * 6ch mode
12970 * need to set the codec line out and mic 1 pin widgets to outputs
12971 */
12972static struct hda_verb alc861_threestack_ch6_init[] = {
12973 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12974 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12975 /* set pin widget 18h (mic1) for output (CLFE)*/
12976 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12977
12978 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012979 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012980
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012981 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12982#if 0
12983 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12984 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12985#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012986 { } /* end */
12987};
12988
12989static struct hda_channel_mode alc861_threestack_modes[2] = {
12990 { 2, alc861_threestack_ch2_init },
12991 { 6, alc861_threestack_ch6_init },
12992};
Takashi Iwai22309c32006-08-09 16:57:28 +020012993/* Set mic1 as input and unmute the mixer */
12994static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12995 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12996 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12997 { } /* end */
12998};
12999/* Set mic1 as output and mute mixer */
13000static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13001 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13002 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13003 { } /* end */
13004};
13005
13006static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13007 { 2, alc861_uniwill_m31_ch2_init },
13008 { 4, alc861_uniwill_m31_ch4_init },
13009};
Kailang Yangdf694da2005-12-05 19:42:22 +010013010
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013011/* Set mic1 and line-in as input and unmute the mixer */
13012static struct hda_verb alc861_asus_ch2_init[] = {
13013 /* set pin widget 1Ah (line in) for input */
13014 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013015 /* set pin widget 18h (mic1/2) for input, for mic also enable
13016 * the vref
13017 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013018 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13019
13020 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13021#if 0
13022 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13023 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13024#endif
13025 { } /* end */
13026};
13027/* Set mic1 nad line-in as output and mute mixer */
13028static struct hda_verb alc861_asus_ch6_init[] = {
13029 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13030 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13031 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13032 /* set pin widget 18h (mic1) for output (CLFE)*/
13033 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13034 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13035 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13036 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13037
13038 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13039#if 0
13040 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13041 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13042#endif
13043 { } /* end */
13044};
13045
13046static struct hda_channel_mode alc861_asus_modes[2] = {
13047 { 2, alc861_asus_ch2_init },
13048 { 6, alc861_asus_ch6_init },
13049};
13050
Kailang Yangdf694da2005-12-05 19:42:22 +010013051/* patch-ALC861 */
13052
13053static struct snd_kcontrol_new alc861_base_mixer[] = {
13054 /* output mixer control */
13055 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13056 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13057 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13058 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13059 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13060
13061 /*Input mixer control */
13062 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13063 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13064 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13065 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13066 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13067 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13068 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13069 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13070 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13071 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013072
Kailang Yangdf694da2005-12-05 19:42:22 +010013073 { } /* end */
13074};
13075
13076static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13077 /* output mixer control */
13078 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13079 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13080 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13081 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13082 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13083
13084 /* Input mixer control */
13085 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13086 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13087 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13088 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13089 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13090 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13091 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13092 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13093 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13094 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013095
Kailang Yangdf694da2005-12-05 19:42:22 +010013096 {
13097 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13098 .name = "Channel Mode",
13099 .info = alc_ch_mode_info,
13100 .get = alc_ch_mode_get,
13101 .put = alc_ch_mode_put,
13102 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13103 },
13104 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013105};
13106
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013107static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013108 /* output mixer control */
13109 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13111 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013112
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013113 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013114};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013115
Takashi Iwai22309c32006-08-09 16:57:28 +020013116static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13117 /* output mixer control */
13118 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13119 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13120 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13121 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13122 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13123
13124 /* Input mixer control */
13125 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13126 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13127 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13128 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13129 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13130 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13131 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13132 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13133 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13134 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013135
Takashi Iwai22309c32006-08-09 16:57:28 +020013136 {
13137 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13138 .name = "Channel Mode",
13139 .info = alc_ch_mode_info,
13140 .get = alc_ch_mode_get,
13141 .put = alc_ch_mode_put,
13142 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13143 },
13144 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013145};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013146
13147static struct snd_kcontrol_new alc861_asus_mixer[] = {
13148 /* output mixer control */
13149 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13150 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13151 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13152 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13153 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13154
13155 /* Input mixer control */
13156 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13157 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13158 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13159 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13160 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13161 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13163 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13164 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013165 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13166
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013167 {
13168 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13169 .name = "Channel Mode",
13170 .info = alc_ch_mode_info,
13171 .get = alc_ch_mode_get,
13172 .put = alc_ch_mode_put,
13173 .private_value = ARRAY_SIZE(alc861_asus_modes),
13174 },
13175 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013176};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013177
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013178/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013179static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013180 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13181 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013182 { }
13183};
13184
Kailang Yangdf694da2005-12-05 19:42:22 +010013185/*
13186 * generic initialization of ADC, input mixers and output mixers
13187 */
13188static struct hda_verb alc861_base_init_verbs[] = {
13189 /*
13190 * Unmute ADC0 and set the default input to mic-in
13191 */
13192 /* port-A for surround (rear panel) */
13193 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13194 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13195 /* port-B for mic-in (rear panel) with vref */
13196 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13197 /* port-C for line-in (rear panel) */
13198 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13199 /* port-D for Front */
13200 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13201 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13202 /* port-E for HP out (front panel) */
13203 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13204 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013205 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013206 /* port-F for mic-in (front panel) with vref */
13207 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13208 /* port-G for CLFE (rear panel) */
13209 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13210 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13211 /* port-H for side (rear panel) */
13212 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13213 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13214 /* CD-in */
13215 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13216 /* route front mic to ADC1*/
13217 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13218 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013219
Kailang Yangdf694da2005-12-05 19:42:22 +010013220 /* Unmute DAC0~3 & spdif out*/
13221 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13222 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13223 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13224 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13225 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013226
Kailang Yangdf694da2005-12-05 19:42:22 +010013227 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13228 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13229 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13230 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13231 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013232
Kailang Yangdf694da2005-12-05 19:42:22 +010013233 /* Unmute Stereo Mixer 15 */
13234 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13235 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013238
13239 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13240 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13241 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13242 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13243 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13244 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13245 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13246 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013247 /* hp used DAC 3 (Front) */
13248 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013249 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13250
13251 { }
13252};
13253
13254static struct hda_verb alc861_threestack_init_verbs[] = {
13255 /*
13256 * Unmute ADC0 and set the default input to mic-in
13257 */
13258 /* port-A for surround (rear panel) */
13259 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13260 /* port-B for mic-in (rear panel) with vref */
13261 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13262 /* port-C for line-in (rear panel) */
13263 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13264 /* port-D for Front */
13265 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13266 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13267 /* port-E for HP out (front panel) */
13268 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13269 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013270 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013271 /* port-F for mic-in (front panel) with vref */
13272 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13273 /* port-G for CLFE (rear panel) */
13274 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13275 /* port-H for side (rear panel) */
13276 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13277 /* CD-in */
13278 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13279 /* route front mic to ADC1*/
13280 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13281 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13282 /* Unmute DAC0~3 & spdif out*/
13283 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13284 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13285 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13286 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013288
Kailang Yangdf694da2005-12-05 19:42:22 +010013289 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13290 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13291 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13292 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13293 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013294
Kailang Yangdf694da2005-12-05 19:42:22 +010013295 /* Unmute Stereo Mixer 15 */
13296 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13297 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13298 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013299 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013300
13301 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13302 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13303 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13304 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13305 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13307 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13308 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013309 /* hp used DAC 3 (Front) */
13310 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013311 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13312 { }
13313};
Takashi Iwai22309c32006-08-09 16:57:28 +020013314
13315static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13316 /*
13317 * Unmute ADC0 and set the default input to mic-in
13318 */
13319 /* port-A for surround (rear panel) */
13320 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13321 /* port-B for mic-in (rear panel) with vref */
13322 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13323 /* port-C for line-in (rear panel) */
13324 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13325 /* port-D for Front */
13326 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13327 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13328 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013329 /* this has to be set to VREF80 */
13330 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013331 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013332 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013333 /* port-F for mic-in (front panel) with vref */
13334 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13335 /* port-G for CLFE (rear panel) */
13336 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13337 /* port-H for side (rear panel) */
13338 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13339 /* CD-in */
13340 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13341 /* route front mic to ADC1*/
13342 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13343 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13344 /* Unmute DAC0~3 & spdif out*/
13345 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13346 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13347 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13348 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13349 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013350
Takashi Iwai22309c32006-08-09 16:57:28 +020013351 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13352 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13353 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13354 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13355 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013356
Takashi Iwai22309c32006-08-09 16:57:28 +020013357 /* Unmute Stereo Mixer 15 */
13358 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13359 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013362
13363 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13364 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13365 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13366 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13367 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13368 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13369 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13370 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013371 /* hp used DAC 3 (Front) */
13372 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013373 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13374 { }
13375};
13376
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013377static struct hda_verb alc861_asus_init_verbs[] = {
13378 /*
13379 * Unmute ADC0 and set the default input to mic-in
13380 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013381 /* port-A for surround (rear panel)
13382 * according to codec#0 this is the HP jack
13383 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013384 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13385 /* route front PCM to HP */
13386 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13387 /* port-B for mic-in (rear panel) with vref */
13388 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13389 /* port-C for line-in (rear panel) */
13390 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13391 /* port-D for Front */
13392 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13393 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13394 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013395 /* this has to be set to VREF80 */
13396 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013397 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013398 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013399 /* port-F for mic-in (front panel) with vref */
13400 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13401 /* port-G for CLFE (rear panel) */
13402 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13403 /* port-H for side (rear panel) */
13404 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13405 /* CD-in */
13406 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13407 /* route front mic to ADC1*/
13408 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13409 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13410 /* Unmute DAC0~3 & spdif out*/
13411 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13412 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13413 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13414 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13415 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13416 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13417 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13418 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13419 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13420 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013421
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013422 /* Unmute Stereo Mixer 15 */
13423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13425 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013426 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013427
13428 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13429 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13430 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13431 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13432 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13433 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13434 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13435 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013436 /* hp used DAC 3 (Front) */
13437 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013438 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13439 { }
13440};
13441
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013442/* additional init verbs for ASUS laptops */
13443static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13444 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13445 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13446 { }
13447};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013448
Kailang Yangdf694da2005-12-05 19:42:22 +010013449/*
13450 * generic initialization of ADC, input mixers and output mixers
13451 */
13452static struct hda_verb alc861_auto_init_verbs[] = {
13453 /*
13454 * Unmute ADC0 and set the default input to mic-in
13455 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013456 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013457 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013458
Kailang Yangdf694da2005-12-05 19:42:22 +010013459 /* Unmute DAC0~3 & spdif out*/
13460 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13461 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13462 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13463 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013465
Kailang Yangdf694da2005-12-05 19:42:22 +010013466 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13467 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13468 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13469 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13470 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013471
Kailang Yangdf694da2005-12-05 19:42:22 +010013472 /* Unmute Stereo Mixer 15 */
13473 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13474 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13475 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13476 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13477
13478 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13479 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13480 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13481 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13482 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13483 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13484 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13485 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13486
13487 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13488 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013489 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13490 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013491 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13492 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013493 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13494 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013495
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013496 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013497
13498 { }
13499};
13500
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013501static struct hda_verb alc861_toshiba_init_verbs[] = {
13502 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013503
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013504 { }
13505};
13506
13507/* toggle speaker-output according to the hp-jack state */
13508static void alc861_toshiba_automute(struct hda_codec *codec)
13509{
13510 unsigned int present;
13511
13512 present = snd_hda_codec_read(codec, 0x0f, 0,
13513 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013514 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13515 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13516 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13517 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013518}
13519
13520static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13521 unsigned int res)
13522{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013523 if ((res >> 26) == ALC880_HP_EVENT)
13524 alc861_toshiba_automute(codec);
13525}
13526
Kailang Yangdf694da2005-12-05 19:42:22 +010013527/* pcm configuration: identiacal with ALC880 */
13528#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13529#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13530#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13531#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13532
13533
13534#define ALC861_DIGOUT_NID 0x07
13535
13536static struct hda_channel_mode alc861_8ch_modes[1] = {
13537 { 8, NULL }
13538};
13539
13540static hda_nid_t alc861_dac_nids[4] = {
13541 /* front, surround, clfe, side */
13542 0x03, 0x06, 0x05, 0x04
13543};
13544
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013545static hda_nid_t alc660_dac_nids[3] = {
13546 /* front, clfe, surround */
13547 0x03, 0x05, 0x06
13548};
13549
Kailang Yangdf694da2005-12-05 19:42:22 +010013550static hda_nid_t alc861_adc_nids[1] = {
13551 /* ADC0-2 */
13552 0x08,
13553};
13554
13555static struct hda_input_mux alc861_capture_source = {
13556 .num_items = 5,
13557 .items = {
13558 { "Mic", 0x0 },
13559 { "Front Mic", 0x3 },
13560 { "Line", 0x1 },
13561 { "CD", 0x4 },
13562 { "Mixer", 0x5 },
13563 },
13564};
13565
13566/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013567static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13568 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013569{
13570 int i;
13571 hda_nid_t nid;
13572
13573 spec->multiout.dac_nids = spec->private_dac_nids;
13574 for (i = 0; i < cfg->line_outs; i++) {
13575 nid = cfg->line_out_pins[i];
13576 if (nid) {
13577 if (i >= ARRAY_SIZE(alc861_dac_nids))
13578 continue;
13579 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13580 }
13581 }
13582 spec->multiout.num_dacs = cfg->line_outs;
13583 return 0;
13584}
13585
13586/* add playback controls from the parsed DAC table */
13587static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13588 const struct auto_pin_cfg *cfg)
13589{
13590 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013591 static const char *chname[4] = {
13592 "Front", "Surround", NULL /*CLFE*/, "Side"
13593 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013594 hda_nid_t nid;
13595 int i, idx, err;
13596
13597 for (i = 0; i < cfg->line_outs; i++) {
13598 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013599 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013600 continue;
13601 if (nid == 0x05) {
13602 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013603 err = add_control(spec, ALC_CTL_BIND_MUTE,
13604 "Center Playback Switch",
13605 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13606 HDA_OUTPUT));
13607 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013608 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013609 err = add_control(spec, ALC_CTL_BIND_MUTE,
13610 "LFE Playback Switch",
13611 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13612 HDA_OUTPUT));
13613 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013614 return err;
13615 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013616 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13617 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013618 if (nid == alc861_dac_nids[idx])
13619 break;
13620 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013621 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13622 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13623 HDA_OUTPUT));
13624 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013625 return err;
13626 }
13627 }
13628 return 0;
13629}
13630
13631static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13632{
13633 int err;
13634 hda_nid_t nid;
13635
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013636 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013637 return 0;
13638
13639 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13640 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013641 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13642 "Headphone Playback Switch",
13643 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13644 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013645 return err;
13646 spec->multiout.hp_nid = nid;
13647 }
13648 return 0;
13649}
13650
13651/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013652static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13653 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013654{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013655 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013656 int i, err, idx, idx1;
13657
13658 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013659 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013660 case 0x0c:
13661 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013662 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013663 break;
13664 case 0x0f:
13665 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013666 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013667 break;
13668 case 0x0d:
13669 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013670 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013671 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013672 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013673 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013674 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013675 break;
13676 case 0x11:
13677 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013678 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013679 break;
13680 default:
13681 continue;
13682 }
13683
Takashi Iwai4a471b72005-12-07 13:56:29 +010013684 err = new_analog_input(spec, cfg->input_pins[i],
13685 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013686 if (err < 0)
13687 return err;
13688
Takashi Iwai4a471b72005-12-07 13:56:29 +010013689 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013690 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013691 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013692 }
13693 return 0;
13694}
13695
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013696static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13697 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013698 int pin_type, int dac_idx)
13699{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013700 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13701 pin_type);
13702 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13703 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013704}
13705
13706static void alc861_auto_init_multi_out(struct hda_codec *codec)
13707{
13708 struct alc_spec *spec = codec->spec;
13709 int i;
13710
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013711 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013712 for (i = 0; i < spec->autocfg.line_outs; i++) {
13713 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013714 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013715 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013716 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013717 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013718 }
13719}
13720
13721static void alc861_auto_init_hp_out(struct hda_codec *codec)
13722{
13723 struct alc_spec *spec = codec->spec;
13724 hda_nid_t pin;
13725
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013726 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013727 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013728 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13729 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013730 pin = spec->autocfg.speaker_pins[0];
13731 if (pin)
13732 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013733}
13734
13735static void alc861_auto_init_analog_input(struct hda_codec *codec)
13736{
13737 struct alc_spec *spec = codec->spec;
13738 int i;
13739
13740 for (i = 0; i < AUTO_PIN_LAST; i++) {
13741 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013742 if (nid >= 0x0c && nid <= 0x11) {
13743 snd_hda_codec_write(codec, nid, 0,
13744 AC_VERB_SET_PIN_WIDGET_CONTROL,
13745 i <= AUTO_PIN_FRONT_MIC ?
13746 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013747 }
13748 }
13749}
13750
13751/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013752/* return 1 if successful, 0 if the proper config is not found,
13753 * or a negative error code
13754 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013755static int alc861_parse_auto_config(struct hda_codec *codec)
13756{
13757 struct alc_spec *spec = codec->spec;
13758 int err;
13759 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13760
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013761 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13762 alc861_ignore);
13763 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013764 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013765 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013766 return 0; /* can't find valid BIOS pin config */
13767
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013768 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13769 if (err < 0)
13770 return err;
13771 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13772 if (err < 0)
13773 return err;
13774 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13775 if (err < 0)
13776 return err;
13777 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13778 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013779 return err;
13780
13781 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13782
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013783 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013784 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13785
Takashi Iwai603c4012008-07-30 15:01:44 +020013786 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013787 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013788
Takashi Iwaid88897e2008-10-31 15:01:37 +010013789 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013790
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013791 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013792 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013793
13794 spec->adc_nids = alc861_adc_nids;
13795 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013796 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013797
Takashi Iwaie044c392008-10-27 16:56:24 +010013798 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013799 return 1;
13800}
13801
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013802/* additional initialization for auto-configuration model */
13803static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013804{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013805 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013806 alc861_auto_init_multi_out(codec);
13807 alc861_auto_init_hp_out(codec);
13808 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013809 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013810 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013811}
13812
Takashi Iwaicb53c622007-08-10 17:21:45 +020013813#ifdef CONFIG_SND_HDA_POWER_SAVE
13814static struct hda_amp_list alc861_loopbacks[] = {
13815 { 0x15, HDA_INPUT, 0 },
13816 { 0x15, HDA_INPUT, 1 },
13817 { 0x15, HDA_INPUT, 2 },
13818 { 0x15, HDA_INPUT, 3 },
13819 { } /* end */
13820};
13821#endif
13822
Kailang Yangdf694da2005-12-05 19:42:22 +010013823
13824/*
13825 * configuration and preset
13826 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013827static const char *alc861_models[ALC861_MODEL_LAST] = {
13828 [ALC861_3ST] = "3stack",
13829 [ALC660_3ST] = "3stack-660",
13830 [ALC861_3ST_DIG] = "3stack-dig",
13831 [ALC861_6ST_DIG] = "6stack-dig",
13832 [ALC861_UNIWILL_M31] = "uniwill-m31",
13833 [ALC861_TOSHIBA] = "toshiba",
13834 [ALC861_ASUS] = "asus",
13835 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13836 [ALC861_AUTO] = "auto",
13837};
13838
13839static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013840 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013841 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13842 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13843 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013844 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013845 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013846 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013847 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13848 * Any other models that need this preset?
13849 */
13850 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013851 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13852 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013853 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13854 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13855 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13856 /* FIXME: the below seems conflict */
13857 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13858 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13859 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013860 {}
13861};
13862
13863static struct alc_config_preset alc861_presets[] = {
13864 [ALC861_3ST] = {
13865 .mixers = { alc861_3ST_mixer },
13866 .init_verbs = { alc861_threestack_init_verbs },
13867 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13868 .dac_nids = alc861_dac_nids,
13869 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13870 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013871 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013872 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13873 .adc_nids = alc861_adc_nids,
13874 .input_mux = &alc861_capture_source,
13875 },
13876 [ALC861_3ST_DIG] = {
13877 .mixers = { alc861_base_mixer },
13878 .init_verbs = { alc861_threestack_init_verbs },
13879 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13880 .dac_nids = alc861_dac_nids,
13881 .dig_out_nid = ALC861_DIGOUT_NID,
13882 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13883 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013884 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013885 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13886 .adc_nids = alc861_adc_nids,
13887 .input_mux = &alc861_capture_source,
13888 },
13889 [ALC861_6ST_DIG] = {
13890 .mixers = { alc861_base_mixer },
13891 .init_verbs = { alc861_base_init_verbs },
13892 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13893 .dac_nids = alc861_dac_nids,
13894 .dig_out_nid = ALC861_DIGOUT_NID,
13895 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13896 .channel_mode = alc861_8ch_modes,
13897 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13898 .adc_nids = alc861_adc_nids,
13899 .input_mux = &alc861_capture_source,
13900 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013901 [ALC660_3ST] = {
13902 .mixers = { alc861_3ST_mixer },
13903 .init_verbs = { alc861_threestack_init_verbs },
13904 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13905 .dac_nids = alc660_dac_nids,
13906 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13907 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013908 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013909 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13910 .adc_nids = alc861_adc_nids,
13911 .input_mux = &alc861_capture_source,
13912 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013913 [ALC861_UNIWILL_M31] = {
13914 .mixers = { alc861_uniwill_m31_mixer },
13915 .init_verbs = { alc861_uniwill_m31_init_verbs },
13916 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13917 .dac_nids = alc861_dac_nids,
13918 .dig_out_nid = ALC861_DIGOUT_NID,
13919 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13920 .channel_mode = alc861_uniwill_m31_modes,
13921 .need_dac_fix = 1,
13922 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13923 .adc_nids = alc861_adc_nids,
13924 .input_mux = &alc861_capture_source,
13925 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013926 [ALC861_TOSHIBA] = {
13927 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013928 .init_verbs = { alc861_base_init_verbs,
13929 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013930 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13931 .dac_nids = alc861_dac_nids,
13932 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13933 .channel_mode = alc883_3ST_2ch_modes,
13934 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13935 .adc_nids = alc861_adc_nids,
13936 .input_mux = &alc861_capture_source,
13937 .unsol_event = alc861_toshiba_unsol_event,
13938 .init_hook = alc861_toshiba_automute,
13939 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013940 [ALC861_ASUS] = {
13941 .mixers = { alc861_asus_mixer },
13942 .init_verbs = { alc861_asus_init_verbs },
13943 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13944 .dac_nids = alc861_dac_nids,
13945 .dig_out_nid = ALC861_DIGOUT_NID,
13946 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13947 .channel_mode = alc861_asus_modes,
13948 .need_dac_fix = 1,
13949 .hp_nid = 0x06,
13950 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13951 .adc_nids = alc861_adc_nids,
13952 .input_mux = &alc861_capture_source,
13953 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013954 [ALC861_ASUS_LAPTOP] = {
13955 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13956 .init_verbs = { alc861_asus_init_verbs,
13957 alc861_asus_laptop_init_verbs },
13958 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13959 .dac_nids = alc861_dac_nids,
13960 .dig_out_nid = ALC861_DIGOUT_NID,
13961 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13962 .channel_mode = alc883_3ST_2ch_modes,
13963 .need_dac_fix = 1,
13964 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13965 .adc_nids = alc861_adc_nids,
13966 .input_mux = &alc861_capture_source,
13967 },
13968};
Kailang Yangdf694da2005-12-05 19:42:22 +010013969
13970
13971static int patch_alc861(struct hda_codec *codec)
13972{
13973 struct alc_spec *spec;
13974 int board_config;
13975 int err;
13976
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013977 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013978 if (spec == NULL)
13979 return -ENOMEM;
13980
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013981 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013982
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013983 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13984 alc861_models,
13985 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013986
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013987 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013988 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13989 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013990 board_config = ALC861_AUTO;
13991 }
13992
13993 if (board_config == ALC861_AUTO) {
13994 /* automatic parse from the BIOS config */
13995 err = alc861_parse_auto_config(codec);
13996 if (err < 0) {
13997 alc_free(codec);
13998 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013999 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014000 printk(KERN_INFO
14001 "hda_codec: Cannot set up configuration "
14002 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014003 board_config = ALC861_3ST_DIG;
14004 }
14005 }
14006
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014007 err = snd_hda_attach_beep_device(codec, 0x23);
14008 if (err < 0) {
14009 alc_free(codec);
14010 return err;
14011 }
14012
Kailang Yangdf694da2005-12-05 19:42:22 +010014013 if (board_config != ALC861_AUTO)
14014 setup_preset(spec, &alc861_presets[board_config]);
14015
14016 spec->stream_name_analog = "ALC861 Analog";
14017 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14018 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14019
14020 spec->stream_name_digital = "ALC861 Digital";
14021 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14022 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14023
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014024 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14025
Takashi Iwai2134ea42008-01-10 16:53:55 +010014026 spec->vmaster_nid = 0x03;
14027
Kailang Yangdf694da2005-12-05 19:42:22 +010014028 codec->patch_ops = alc_patch_ops;
14029 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014030 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014031#ifdef CONFIG_SND_HDA_POWER_SAVE
14032 if (!spec->loopback.amplist)
14033 spec->loopback.amplist = alc861_loopbacks;
14034#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014035 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014036
Kailang Yangdf694da2005-12-05 19:42:22 +010014037 return 0;
14038}
14039
14040/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014041 * ALC861-VD support
14042 *
14043 * Based on ALC882
14044 *
14045 * In addition, an independent DAC
14046 */
14047#define ALC861VD_DIGOUT_NID 0x06
14048
14049static hda_nid_t alc861vd_dac_nids[4] = {
14050 /* front, surr, clfe, side surr */
14051 0x02, 0x03, 0x04, 0x05
14052};
14053
14054/* dac_nids for ALC660vd are in a different order - according to
14055 * Realtek's driver.
14056 * This should probably tesult in a different mixer for 6stack models
14057 * of ALC660vd codecs, but for now there is only 3stack mixer
14058 * - and it is the same as in 861vd.
14059 * adc_nids in ALC660vd are (is) the same as in 861vd
14060 */
14061static hda_nid_t alc660vd_dac_nids[3] = {
14062 /* front, rear, clfe, rear_surr */
14063 0x02, 0x04, 0x03
14064};
14065
14066static hda_nid_t alc861vd_adc_nids[1] = {
14067 /* ADC0 */
14068 0x09,
14069};
14070
Takashi Iwaie1406342008-02-11 18:32:32 +010014071static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14072
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014073/* input MUX */
14074/* FIXME: should be a matrix-type input source selection */
14075static struct hda_input_mux alc861vd_capture_source = {
14076 .num_items = 4,
14077 .items = {
14078 { "Mic", 0x0 },
14079 { "Front Mic", 0x1 },
14080 { "Line", 0x2 },
14081 { "CD", 0x4 },
14082 },
14083};
14084
Kailang Yang272a5272007-05-14 11:00:38 +020014085static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014086 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014087 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014088 { "Ext Mic", 0x0 },
14089 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014090 },
14091};
14092
Kailang Yangd1a991a2007-08-15 16:21:59 +020014093static struct hda_input_mux alc861vd_hp_capture_source = {
14094 .num_items = 2,
14095 .items = {
14096 { "Front Mic", 0x0 },
14097 { "ATAPI Mic", 0x1 },
14098 },
14099};
14100
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014101/*
14102 * 2ch mode
14103 */
14104static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14105 { 2, NULL }
14106};
14107
14108/*
14109 * 6ch mode
14110 */
14111static struct hda_verb alc861vd_6stack_ch6_init[] = {
14112 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14113 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14114 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14115 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14116 { } /* end */
14117};
14118
14119/*
14120 * 8ch mode
14121 */
14122static struct hda_verb alc861vd_6stack_ch8_init[] = {
14123 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14124 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14125 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14126 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14127 { } /* end */
14128};
14129
14130static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14131 { 6, alc861vd_6stack_ch6_init },
14132 { 8, alc861vd_6stack_ch8_init },
14133};
14134
14135static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14136 {
14137 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14138 .name = "Channel Mode",
14139 .info = alc_ch_mode_info,
14140 .get = alc_ch_mode_get,
14141 .put = alc_ch_mode_put,
14142 },
14143 { } /* end */
14144};
14145
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014146/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14147 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14148 */
14149static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14150 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14151 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14152
14153 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14154 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14155
14156 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14157 HDA_OUTPUT),
14158 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14159 HDA_OUTPUT),
14160 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14161 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14162
14163 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14164 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14165
14166 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14167
14168 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14169 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14170 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14171
14172 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14173 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14174 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14175
14176 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14177 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14178
14179 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14180 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14181
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014182 { } /* end */
14183};
14184
14185static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14186 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14187 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14188
14189 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14190
14191 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14193 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14194
14195 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14196 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14197 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14198
14199 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14200 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14201
14202 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14203 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14204
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014205 { } /* end */
14206};
14207
Kailang Yangbdd148a2007-05-08 15:19:08 +020014208static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14209 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14210 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14211 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14212
14213 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14214
14215 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14217 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14218
14219 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14220 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14221 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14222
14223 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14224 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14225
14226 { } /* end */
14227};
14228
Tobin Davisb419f342008-03-07 11:57:51 +010014229/* Pin assignment: Speaker=0x14, HP = 0x15,
14230 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014231 */
14232static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014233 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14234 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014235 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14236 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014237 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14238 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14239 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14240 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14241 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14242 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014243 { } /* end */
14244};
14245
Kailang Yangd1a991a2007-08-15 16:21:59 +020014246/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14247 * Front Mic=0x18, ATAPI Mic = 0x19,
14248 */
14249static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14250 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14251 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14252 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14253 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14254 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14255 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14256 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14257 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014258
Kailang Yangd1a991a2007-08-15 16:21:59 +020014259 { } /* end */
14260};
14261
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014262/*
14263 * generic initialization of ADC, input mixers and output mixers
14264 */
14265static struct hda_verb alc861vd_volume_init_verbs[] = {
14266 /*
14267 * Unmute ADC0 and set the default input to mic-in
14268 */
14269 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14270 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14271
14272 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14273 * the analog-loopback mixer widget
14274 */
14275 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014276 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14277 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14278 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14279 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14280 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014281
14282 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014283 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014287
14288 /*
14289 * Set up output mixers (0x02 - 0x05)
14290 */
14291 /* set vol=0 to output mixers */
14292 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14293 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14294 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14295 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14296
14297 /* set up input amps for analog loopback */
14298 /* Amp Indices: DAC = 0, mixer = 1 */
14299 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14300 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14301 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14302 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14303 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14304 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14305 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14306 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14307
14308 { }
14309};
14310
14311/*
14312 * 3-stack pin configuration:
14313 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14314 */
14315static struct hda_verb alc861vd_3stack_init_verbs[] = {
14316 /*
14317 * Set pin mode and muting
14318 */
14319 /* set front pin widgets 0x14 for output */
14320 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14321 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14322 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14323
14324 /* Mic (rear) pin: input vref at 80% */
14325 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14326 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14327 /* Front Mic pin: input vref at 80% */
14328 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14329 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14330 /* Line In pin: input */
14331 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14332 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14333 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14334 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14335 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14336 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14337 /* CD pin widget for input */
14338 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14339
14340 { }
14341};
14342
14343/*
14344 * 6-stack pin configuration:
14345 */
14346static struct hda_verb alc861vd_6stack_init_verbs[] = {
14347 /*
14348 * Set pin mode and muting
14349 */
14350 /* set front pin widgets 0x14 for output */
14351 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14352 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14353 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14354
14355 /* Rear Pin: output 1 (0x0d) */
14356 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14357 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14358 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14359 /* CLFE Pin: output 2 (0x0e) */
14360 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14361 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14362 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14363 /* Side Pin: output 3 (0x0f) */
14364 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14365 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14366 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14367
14368 /* Mic (rear) pin: input vref at 80% */
14369 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14370 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14371 /* Front Mic pin: input vref at 80% */
14372 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14373 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14374 /* Line In pin: input */
14375 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14376 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14377 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14378 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14379 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14380 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14381 /* CD pin widget for input */
14382 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14383
14384 { }
14385};
14386
Kailang Yangbdd148a2007-05-08 15:19:08 +020014387static struct hda_verb alc861vd_eapd_verbs[] = {
14388 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14389 { }
14390};
14391
Kailang Yangf9423e72008-05-27 12:32:25 +020014392static struct hda_verb alc660vd_eapd_verbs[] = {
14393 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14394 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14395 { }
14396};
14397
Kailang Yangbdd148a2007-05-08 15:19:08 +020014398static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14399 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14400 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14401 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14402 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014403 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014404 {}
14405};
14406
14407/* toggle speaker-output according to the hp-jack state */
14408static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14409{
14410 unsigned int present;
14411 unsigned char bits;
14412
14413 present = snd_hda_codec_read(codec, 0x1b, 0,
14414 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014415 bits = present ? HDA_AMP_MUTE : 0;
14416 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14417 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014418}
14419
14420static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14421{
14422 unsigned int present;
14423 unsigned char bits;
14424
14425 present = snd_hda_codec_read(codec, 0x18, 0,
14426 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014427 bits = present ? HDA_AMP_MUTE : 0;
14428 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14429 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014430}
14431
14432static void alc861vd_lenovo_automute(struct hda_codec *codec)
14433{
14434 alc861vd_lenovo_hp_automute(codec);
14435 alc861vd_lenovo_mic_automute(codec);
14436}
14437
14438static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14439 unsigned int res)
14440{
14441 switch (res >> 26) {
14442 case ALC880_HP_EVENT:
14443 alc861vd_lenovo_hp_automute(codec);
14444 break;
14445 case ALC880_MIC_EVENT:
14446 alc861vd_lenovo_mic_automute(codec);
14447 break;
14448 }
14449}
14450
Kailang Yang272a5272007-05-14 11:00:38 +020014451static struct hda_verb alc861vd_dallas_verbs[] = {
14452 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14453 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14454 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14455 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14456
14457 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14459 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14460 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14461 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14462 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14463 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014465
Kailang Yang272a5272007-05-14 11:00:38 +020014466 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14467 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14468 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14469 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14470 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14471 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14472 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14473 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14474
14475 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14476 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14477 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14478 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14479 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14480 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14481 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14482 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14483
14484 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14485 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14486 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14487 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14488
14489 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014490 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014491 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14492
14493 { } /* end */
14494};
14495
14496/* toggle speaker-output according to the hp-jack state */
14497static void alc861vd_dallas_automute(struct hda_codec *codec)
14498{
14499 unsigned int present;
14500
14501 present = snd_hda_codec_read(codec, 0x15, 0,
14502 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014503 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14504 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014505}
14506
14507static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14508{
14509 if ((res >> 26) == ALC880_HP_EVENT)
14510 alc861vd_dallas_automute(codec);
14511}
14512
Takashi Iwaicb53c622007-08-10 17:21:45 +020014513#ifdef CONFIG_SND_HDA_POWER_SAVE
14514#define alc861vd_loopbacks alc880_loopbacks
14515#endif
14516
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014517/* pcm configuration: identiacal with ALC880 */
14518#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14519#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14520#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14521#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14522
14523/*
14524 * configuration and preset
14525 */
14526static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14527 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014528 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014529 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014530 [ALC861VD_3ST] = "3stack",
14531 [ALC861VD_3ST_DIG] = "3stack-digout",
14532 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014533 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014534 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014535 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014536 [ALC861VD_AUTO] = "auto",
14537};
14538
14539static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014540 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14541 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014542 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014543 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014544 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014545 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014546 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014547 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014548 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014549 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014550 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014551 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014552 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014553 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014554 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014555 {}
14556};
14557
14558static struct alc_config_preset alc861vd_presets[] = {
14559 [ALC660VD_3ST] = {
14560 .mixers = { alc861vd_3st_mixer },
14561 .init_verbs = { alc861vd_volume_init_verbs,
14562 alc861vd_3stack_init_verbs },
14563 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14564 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014565 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14566 .channel_mode = alc861vd_3stack_2ch_modes,
14567 .input_mux = &alc861vd_capture_source,
14568 },
Mike Crash6963f842007-06-25 12:12:51 +020014569 [ALC660VD_3ST_DIG] = {
14570 .mixers = { alc861vd_3st_mixer },
14571 .init_verbs = { alc861vd_volume_init_verbs,
14572 alc861vd_3stack_init_verbs },
14573 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14574 .dac_nids = alc660vd_dac_nids,
14575 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014576 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14577 .channel_mode = alc861vd_3stack_2ch_modes,
14578 .input_mux = &alc861vd_capture_source,
14579 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014580 [ALC861VD_3ST] = {
14581 .mixers = { alc861vd_3st_mixer },
14582 .init_verbs = { alc861vd_volume_init_verbs,
14583 alc861vd_3stack_init_verbs },
14584 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14585 .dac_nids = alc861vd_dac_nids,
14586 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14587 .channel_mode = alc861vd_3stack_2ch_modes,
14588 .input_mux = &alc861vd_capture_source,
14589 },
14590 [ALC861VD_3ST_DIG] = {
14591 .mixers = { alc861vd_3st_mixer },
14592 .init_verbs = { alc861vd_volume_init_verbs,
14593 alc861vd_3stack_init_verbs },
14594 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14595 .dac_nids = alc861vd_dac_nids,
14596 .dig_out_nid = ALC861VD_DIGOUT_NID,
14597 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14598 .channel_mode = alc861vd_3stack_2ch_modes,
14599 .input_mux = &alc861vd_capture_source,
14600 },
14601 [ALC861VD_6ST_DIG] = {
14602 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14603 .init_verbs = { alc861vd_volume_init_verbs,
14604 alc861vd_6stack_init_verbs },
14605 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14606 .dac_nids = alc861vd_dac_nids,
14607 .dig_out_nid = ALC861VD_DIGOUT_NID,
14608 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14609 .channel_mode = alc861vd_6stack_modes,
14610 .input_mux = &alc861vd_capture_source,
14611 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014612 [ALC861VD_LENOVO] = {
14613 .mixers = { alc861vd_lenovo_mixer },
14614 .init_verbs = { alc861vd_volume_init_verbs,
14615 alc861vd_3stack_init_verbs,
14616 alc861vd_eapd_verbs,
14617 alc861vd_lenovo_unsol_verbs },
14618 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14619 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014620 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14621 .channel_mode = alc861vd_3stack_2ch_modes,
14622 .input_mux = &alc861vd_capture_source,
14623 .unsol_event = alc861vd_lenovo_unsol_event,
14624 .init_hook = alc861vd_lenovo_automute,
14625 },
Kailang Yang272a5272007-05-14 11:00:38 +020014626 [ALC861VD_DALLAS] = {
14627 .mixers = { alc861vd_dallas_mixer },
14628 .init_verbs = { alc861vd_dallas_verbs },
14629 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14630 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014631 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14632 .channel_mode = alc861vd_3stack_2ch_modes,
14633 .input_mux = &alc861vd_dallas_capture_source,
14634 .unsol_event = alc861vd_dallas_unsol_event,
14635 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014636 },
14637 [ALC861VD_HP] = {
14638 .mixers = { alc861vd_hp_mixer },
14639 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14640 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14641 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014642 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014643 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14644 .channel_mode = alc861vd_3stack_2ch_modes,
14645 .input_mux = &alc861vd_hp_capture_source,
14646 .unsol_event = alc861vd_dallas_unsol_event,
14647 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014648 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014649 [ALC660VD_ASUS_V1S] = {
14650 .mixers = { alc861vd_lenovo_mixer },
14651 .init_verbs = { alc861vd_volume_init_verbs,
14652 alc861vd_3stack_init_verbs,
14653 alc861vd_eapd_verbs,
14654 alc861vd_lenovo_unsol_verbs },
14655 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14656 .dac_nids = alc660vd_dac_nids,
14657 .dig_out_nid = ALC861VD_DIGOUT_NID,
14658 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14659 .channel_mode = alc861vd_3stack_2ch_modes,
14660 .input_mux = &alc861vd_capture_source,
14661 .unsol_event = alc861vd_lenovo_unsol_event,
14662 .init_hook = alc861vd_lenovo_automute,
14663 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014664};
14665
14666/*
14667 * BIOS auto configuration
14668 */
14669static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14670 hda_nid_t nid, int pin_type, int dac_idx)
14671{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014672 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014673}
14674
14675static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14676{
14677 struct alc_spec *spec = codec->spec;
14678 int i;
14679
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014680 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014681 for (i = 0; i <= HDA_SIDE; i++) {
14682 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014683 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014684 if (nid)
14685 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014686 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014687 }
14688}
14689
14690
14691static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14692{
14693 struct alc_spec *spec = codec->spec;
14694 hda_nid_t pin;
14695
14696 pin = spec->autocfg.hp_pins[0];
14697 if (pin) /* connect to front and use dac 0 */
14698 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014699 pin = spec->autocfg.speaker_pins[0];
14700 if (pin)
14701 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014702}
14703
14704#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14705#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14706
14707static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14708{
14709 struct alc_spec *spec = codec->spec;
14710 int i;
14711
14712 for (i = 0; i < AUTO_PIN_LAST; i++) {
14713 hda_nid_t nid = spec->autocfg.input_pins[i];
14714 if (alc861vd_is_input_pin(nid)) {
14715 snd_hda_codec_write(codec, nid, 0,
14716 AC_VERB_SET_PIN_WIDGET_CONTROL,
14717 i <= AUTO_PIN_FRONT_MIC ?
14718 PIN_VREF80 : PIN_IN);
14719 if (nid != ALC861VD_PIN_CD_NID)
14720 snd_hda_codec_write(codec, nid, 0,
14721 AC_VERB_SET_AMP_GAIN_MUTE,
14722 AMP_OUT_MUTE);
14723 }
14724 }
14725}
14726
Takashi Iwaif511b012008-08-15 16:46:42 +020014727#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14728
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014729#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14730#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14731
14732/* add playback controls from the parsed DAC table */
14733/* Based on ALC880 version. But ALC861VD has separate,
14734 * different NIDs for mute/unmute switch and volume control */
14735static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14736 const struct auto_pin_cfg *cfg)
14737{
14738 char name[32];
14739 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14740 hda_nid_t nid_v, nid_s;
14741 int i, err;
14742
14743 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014744 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014745 continue;
14746 nid_v = alc861vd_idx_to_mixer_vol(
14747 alc880_dac_to_idx(
14748 spec->multiout.dac_nids[i]));
14749 nid_s = alc861vd_idx_to_mixer_switch(
14750 alc880_dac_to_idx(
14751 spec->multiout.dac_nids[i]));
14752
14753 if (i == 2) {
14754 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014755 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14756 "Center Playback Volume",
14757 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14758 HDA_OUTPUT));
14759 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014760 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014761 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14762 "LFE Playback Volume",
14763 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14764 HDA_OUTPUT));
14765 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014766 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014767 err = add_control(spec, ALC_CTL_BIND_MUTE,
14768 "Center Playback Switch",
14769 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14770 HDA_INPUT));
14771 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014772 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014773 err = add_control(spec, ALC_CTL_BIND_MUTE,
14774 "LFE Playback Switch",
14775 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14776 HDA_INPUT));
14777 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014778 return err;
14779 } else {
14780 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014781 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14782 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14783 HDA_OUTPUT));
14784 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014785 return err;
14786 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014787 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014788 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014789 HDA_INPUT));
14790 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014791 return err;
14792 }
14793 }
14794 return 0;
14795}
14796
14797/* add playback controls for speaker and HP outputs */
14798/* Based on ALC880 version. But ALC861VD has separate,
14799 * different NIDs for mute/unmute switch and volume control */
14800static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14801 hda_nid_t pin, const char *pfx)
14802{
14803 hda_nid_t nid_v, nid_s;
14804 int err;
14805 char name[32];
14806
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014807 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014808 return 0;
14809
14810 if (alc880_is_fixed_pin(pin)) {
14811 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14812 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014813 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014814 spec->multiout.hp_nid = nid_v;
14815 else
14816 spec->multiout.extra_out_nid[0] = nid_v;
14817 /* control HP volume/switch on the output mixer amp */
14818 nid_v = alc861vd_idx_to_mixer_vol(
14819 alc880_fixed_pin_idx(pin));
14820 nid_s = alc861vd_idx_to_mixer_switch(
14821 alc880_fixed_pin_idx(pin));
14822
14823 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014824 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14825 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14826 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014827 return err;
14828 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014829 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14830 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14831 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014832 return err;
14833 } else if (alc880_is_multi_pin(pin)) {
14834 /* set manual connection */
14835 /* we have only a switch on HP-out PIN */
14836 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014837 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14838 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14839 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014840 return err;
14841 }
14842 return 0;
14843}
14844
14845/* parse the BIOS configuration and set up the alc_spec
14846 * return 1 if successful, 0 if the proper config is not found,
14847 * or a negative error code
14848 * Based on ALC880 version - had to change it to override
14849 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14850static int alc861vd_parse_auto_config(struct hda_codec *codec)
14851{
14852 struct alc_spec *spec = codec->spec;
14853 int err;
14854 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14855
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014856 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14857 alc861vd_ignore);
14858 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014859 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014860 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014861 return 0; /* can't find valid BIOS pin config */
14862
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014863 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14864 if (err < 0)
14865 return err;
14866 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14867 if (err < 0)
14868 return err;
14869 err = alc861vd_auto_create_extra_out(spec,
14870 spec->autocfg.speaker_pins[0],
14871 "Speaker");
14872 if (err < 0)
14873 return err;
14874 err = alc861vd_auto_create_extra_out(spec,
14875 spec->autocfg.hp_pins[0],
14876 "Headphone");
14877 if (err < 0)
14878 return err;
14879 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14880 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014881 return err;
14882
14883 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14884
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014885 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014886 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14887
Takashi Iwai603c4012008-07-30 15:01:44 +020014888 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014889 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014890
Takashi Iwaid88897e2008-10-31 15:01:37 +010014891 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014892
14893 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014894 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014895
Takashi Iwai776e1842007-08-29 15:07:11 +020014896 err = alc_auto_add_mic_boost(codec);
14897 if (err < 0)
14898 return err;
14899
Takashi Iwaie044c392008-10-27 16:56:24 +010014900 store_pin_configs(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014901 return 1;
14902}
14903
14904/* additional initialization for auto-configuration model */
14905static void alc861vd_auto_init(struct hda_codec *codec)
14906{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014907 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014908 alc861vd_auto_init_multi_out(codec);
14909 alc861vd_auto_init_hp_out(codec);
14910 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014911 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014912 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014913 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014914}
14915
14916static int patch_alc861vd(struct hda_codec *codec)
14917{
14918 struct alc_spec *spec;
14919 int err, board_config;
14920
14921 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14922 if (spec == NULL)
14923 return -ENOMEM;
14924
14925 codec->spec = spec;
14926
14927 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14928 alc861vd_models,
14929 alc861vd_cfg_tbl);
14930
14931 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14932 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14933 "ALC861VD, trying auto-probe from BIOS...\n");
14934 board_config = ALC861VD_AUTO;
14935 }
14936
14937 if (board_config == ALC861VD_AUTO) {
14938 /* automatic parse from the BIOS config */
14939 err = alc861vd_parse_auto_config(codec);
14940 if (err < 0) {
14941 alc_free(codec);
14942 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014943 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014944 printk(KERN_INFO
14945 "hda_codec: Cannot set up configuration "
14946 "from BIOS. Using base mode...\n");
14947 board_config = ALC861VD_3ST;
14948 }
14949 }
14950
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014951 err = snd_hda_attach_beep_device(codec, 0x23);
14952 if (err < 0) {
14953 alc_free(codec);
14954 return err;
14955 }
14956
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014957 if (board_config != ALC861VD_AUTO)
14958 setup_preset(spec, &alc861vd_presets[board_config]);
14959
Kailang Yang2f893282008-05-27 12:14:47 +020014960 if (codec->vendor_id == 0x10ec0660) {
14961 spec->stream_name_analog = "ALC660-VD Analog";
14962 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014963 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010014964 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020014965 } else {
14966 spec->stream_name_analog = "ALC861VD Analog";
14967 spec->stream_name_digital = "ALC861VD Digital";
14968 }
14969
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014970 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14971 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14972
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014973 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14974 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14975
14976 spec->adc_nids = alc861vd_adc_nids;
14977 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014978 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014979 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014980
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014981 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014982 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014983
Takashi Iwai2134ea42008-01-10 16:53:55 +010014984 spec->vmaster_nid = 0x02;
14985
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014986 codec->patch_ops = alc_patch_ops;
14987
14988 if (board_config == ALC861VD_AUTO)
14989 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014990#ifdef CONFIG_SND_HDA_POWER_SAVE
14991 if (!spec->loopback.amplist)
14992 spec->loopback.amplist = alc861vd_loopbacks;
14993#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014994 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014995
14996 return 0;
14997}
14998
14999/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015000 * ALC662 support
15001 *
15002 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15003 * configuration. Each pin widget can choose any input DACs and a mixer.
15004 * Each ADC is connected from a mixer of all inputs. This makes possible
15005 * 6-channel independent captures.
15006 *
15007 * In addition, an independent DAC for the multi-playback (not used in this
15008 * driver yet).
15009 */
15010#define ALC662_DIGOUT_NID 0x06
15011#define ALC662_DIGIN_NID 0x0a
15012
15013static hda_nid_t alc662_dac_nids[4] = {
15014 /* front, rear, clfe, rear_surr */
15015 0x02, 0x03, 0x04
15016};
15017
15018static hda_nid_t alc662_adc_nids[1] = {
15019 /* ADC1-2 */
15020 0x09,
15021};
Takashi Iwaie1406342008-02-11 18:32:32 +010015022
Kailang Yang77a261b2008-02-19 11:38:05 +010015023static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010015024
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015025/* input MUX */
15026/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015027static struct hda_input_mux alc662_capture_source = {
15028 .num_items = 4,
15029 .items = {
15030 { "Mic", 0x0 },
15031 { "Front Mic", 0x1 },
15032 { "Line", 0x2 },
15033 { "CD", 0x4 },
15034 },
15035};
15036
15037static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15038 .num_items = 2,
15039 .items = {
15040 { "Mic", 0x1 },
15041 { "Line", 0x2 },
15042 },
15043};
Kailang Yang291702f2007-10-16 14:28:03 +020015044
15045static struct hda_input_mux alc662_eeepc_capture_source = {
15046 .num_items = 2,
15047 .items = {
15048 { "i-Mic", 0x1 },
15049 { "e-Mic", 0x0 },
15050 },
15051};
15052
Kailang Yang6dda9f42008-05-27 12:05:31 +020015053static struct hda_input_mux alc663_capture_source = {
15054 .num_items = 3,
15055 .items = {
15056 { "Mic", 0x0 },
15057 { "Front Mic", 0x1 },
15058 { "Line", 0x2 },
15059 },
15060};
15061
15062static struct hda_input_mux alc663_m51va_capture_source = {
15063 .num_items = 2,
15064 .items = {
15065 { "Ext-Mic", 0x0 },
15066 { "D-Mic", 0x9 },
15067 },
15068};
15069
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015070/*
15071 * 2ch mode
15072 */
15073static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15074 { 2, NULL }
15075};
15076
15077/*
15078 * 2ch mode
15079 */
15080static struct hda_verb alc662_3ST_ch2_init[] = {
15081 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15082 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15083 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15084 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15085 { } /* end */
15086};
15087
15088/*
15089 * 6ch mode
15090 */
15091static struct hda_verb alc662_3ST_ch6_init[] = {
15092 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15093 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15094 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15095 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15096 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15097 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15098 { } /* end */
15099};
15100
15101static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15102 { 2, alc662_3ST_ch2_init },
15103 { 6, alc662_3ST_ch6_init },
15104};
15105
15106/*
15107 * 2ch mode
15108 */
15109static struct hda_verb alc662_sixstack_ch6_init[] = {
15110 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15111 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15112 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15113 { } /* end */
15114};
15115
15116/*
15117 * 6ch mode
15118 */
15119static struct hda_verb alc662_sixstack_ch8_init[] = {
15120 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15121 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15122 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15123 { } /* end */
15124};
15125
15126static struct hda_channel_mode alc662_5stack_modes[2] = {
15127 { 2, alc662_sixstack_ch6_init },
15128 { 6, alc662_sixstack_ch8_init },
15129};
15130
15131/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15132 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15133 */
15134
15135static struct snd_kcontrol_new alc662_base_mixer[] = {
15136 /* output mixer control */
15137 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015138 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015139 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015140 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015141 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15142 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015143 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15144 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015145 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15146
15147 /*Input mixer control */
15148 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15149 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15150 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15151 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15152 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15153 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15154 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15155 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015156 { } /* end */
15157};
15158
15159static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15160 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015161 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015162 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15163 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15164 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15165 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15166 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15167 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15168 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15169 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15170 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015171 { } /* end */
15172};
15173
15174static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15175 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015176 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015177 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015178 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015179 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15180 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015181 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15182 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015183 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15184 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15185 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15186 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15187 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15188 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15189 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15190 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15191 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015192 { } /* end */
15193};
15194
15195static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15196 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15197 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015198 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15199 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015200 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15201 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15202 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15203 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15204 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015205 { } /* end */
15206};
15207
Kailang Yang291702f2007-10-16 14:28:03 +020015208static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015209 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015210
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015211 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15212 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015213
15214 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15215 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15216 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15217
15218 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15219 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15220 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15221 { } /* end */
15222};
15223
Kailang Yang8c427222008-01-10 13:03:59 +010015224static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015225 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15226 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015227 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15228 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15229 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15230 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15231 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15232 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015233 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015234 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15235 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15236 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15237 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15238 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15239 { } /* end */
15240};
15241
Kailang Yangf1d4e282008-08-26 14:03:29 +020015242static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15243 .ops = &snd_hda_bind_vol,
15244 .values = {
15245 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15246 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15247 0
15248 },
15249};
15250
15251static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15252 .ops = &snd_hda_bind_sw,
15253 .values = {
15254 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15255 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15256 0
15257 },
15258};
15259
Kailang Yang6dda9f42008-05-27 12:05:31 +020015260static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015261 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15262 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15263 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15264 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15265 { } /* end */
15266};
15267
15268static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15269 .ops = &snd_hda_bind_sw,
15270 .values = {
15271 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15272 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15273 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15274 0
15275 },
15276};
15277
15278static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15279 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15280 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15281 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15282 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15283 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15284 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15285
15286 { } /* end */
15287};
15288
15289static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15290 .ops = &snd_hda_bind_sw,
15291 .values = {
15292 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15293 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15294 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15295 0
15296 },
15297};
15298
15299static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15300 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15301 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15302 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15303 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15304 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15305 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15306 { } /* end */
15307};
15308
15309static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015310 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15311 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015312 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15313 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15314 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15315 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15316 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15317 { } /* end */
15318};
15319
15320static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15321 .ops = &snd_hda_bind_vol,
15322 .values = {
15323 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15324 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15325 0
15326 },
15327};
15328
15329static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15330 .ops = &snd_hda_bind_sw,
15331 .values = {
15332 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15333 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15334 0
15335 },
15336};
15337
15338static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15339 HDA_BIND_VOL("Master Playback Volume",
15340 &alc663_asus_two_bind_master_vol),
15341 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15342 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015343 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15344 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15345 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015346 { } /* end */
15347};
15348
15349static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15350 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15351 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15352 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15353 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15354 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15355 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015356 { } /* end */
15357};
15358
15359static struct snd_kcontrol_new alc663_g71v_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_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15363 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15364 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15365
15366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15367 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15368 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15369 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15370 { } /* end */
15371};
15372
15373static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15374 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15375 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15376 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15377
15378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15379 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15380 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15381 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15382 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15383 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15384 { } /* end */
15385};
15386
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015387static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15388 {
15389 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15390 .name = "Channel Mode",
15391 .info = alc_ch_mode_info,
15392 .get = alc_ch_mode_get,
15393 .put = alc_ch_mode_put,
15394 },
15395 { } /* end */
15396};
15397
15398static struct hda_verb alc662_init_verbs[] = {
15399 /* ADC: mute amp left and right */
15400 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15401 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15402 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15403
Takashi Iwaicb53c622007-08-10 17:21:45 +020015404 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15405 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15406 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15407 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15408 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015409
Kailang Yangb60dd392007-09-20 12:50:29 +020015410 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15411 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15412 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15413 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15414 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15415 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015416
15417 /* Front Pin: output 0 (0x0c) */
15418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15419 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15420
15421 /* Rear Pin: output 1 (0x0d) */
15422 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15424
15425 /* CLFE Pin: output 2 (0x0e) */
15426 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15427 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15428
15429 /* Mic (rear) pin: input vref at 80% */
15430 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15431 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15432 /* Front Mic pin: input vref at 80% */
15433 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15434 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15435 /* Line In pin: input */
15436 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15437 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15438 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15439 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15440 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15441 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15442 /* CD pin widget for input */
15443 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15444
15445 /* FIXME: use matrix-type input source selection */
15446 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15447 /* Input mixer */
15448 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15449 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15450 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15451 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015452
15453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15455 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15456 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015457
15458 /* always trun on EAPD */
15459 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15460 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15461
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015462 { }
15463};
15464
15465static struct hda_verb alc662_sue_init_verbs[] = {
15466 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15467 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015468 {}
15469};
15470
15471static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15472 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15473 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15474 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015475};
15476
Kailang Yang8c427222008-01-10 13:03:59 +010015477/* Set Unsolicited Event*/
15478static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15480 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15481 {}
15482};
15483
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015484/*
15485 * generic initialization of ADC, input mixers and output mixers
15486 */
15487static struct hda_verb alc662_auto_init_verbs[] = {
15488 /*
15489 * Unmute ADC and set the default input to mic-in
15490 */
15491 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15492 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15493
15494 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15495 * mixer widget
15496 * Note: PASD motherboards uses the Line In 2 as the input for front
15497 * panel mic (mic 2)
15498 */
15499 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15502 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15503 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015505
15506 /*
15507 * Set up output mixers (0x0c - 0x0f)
15508 */
15509 /* set vol=0 to output mixers */
15510 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15511 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15512 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15513
15514 /* set up input amps for analog loopback */
15515 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15518 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15520 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15521 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015522
15523
15524 /* FIXME: use matrix-type input source selection */
15525 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15526 /* Input mixer */
15527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015528 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015529 { }
15530};
15531
Takashi Iwai24fb9172008-09-02 14:48:20 +020015532/* additional verbs for ALC663 */
15533static struct hda_verb alc663_auto_init_verbs[] = {
15534 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15535 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15536 { }
15537};
15538
Kailang Yang6dda9f42008-05-27 12:05:31 +020015539static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015540 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15541 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015542 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15543 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015544 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15545 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15546 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015547 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15548 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15549 {}
15550};
15551
Kailang Yangf1d4e282008-08-26 14:03:29 +020015552static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15553 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15554 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15555 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15556 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15557 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15558 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15559 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15560 {}
15561};
15562
15563static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15564 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15565 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15566 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15567 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15568 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15569 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15570 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15571 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15572 {}
15573};
15574
15575static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15576 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15577 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15578 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15580 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15581 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15582 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15583 {}
15584};
15585
15586static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15587 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15588 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15589 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15590 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15591 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15592 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15593 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15596 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15597 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15598 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15599 {}
15600};
15601
15602static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15603 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15604 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15605 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15606 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15607 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15608 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15609 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15611 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15612 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15613 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15614 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15615 {}
15616};
15617
Kailang Yang6dda9f42008-05-27 12:05:31 +020015618static struct hda_verb alc663_g71v_init_verbs[] = {
15619 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15620 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15621 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15622
15623 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15624 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15625 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15626
15627 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15628 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15629 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15630 {}
15631};
15632
15633static struct hda_verb alc663_g50v_init_verbs[] = {
15634 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15635 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15636 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15637
15638 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15639 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15640 {}
15641};
15642
Kailang Yangf1d4e282008-08-26 14:03:29 +020015643static struct hda_verb alc662_ecs_init_verbs[] = {
15644 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15645 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15646 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15647 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15648 {}
15649};
15650
Kailang Yangf1d4e282008-08-26 14:03:29 +020015651static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15652 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15653 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15654 { } /* end */
15655};
15656
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015657static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15658{
15659 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015660 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015661
15662 present = snd_hda_codec_read(codec, 0x14, 0,
15663 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015664 bits = present ? HDA_AMP_MUTE : 0;
15665 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15666 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015667}
15668
15669static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15670{
15671 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015672 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015673
15674 present = snd_hda_codec_read(codec, 0x1b, 0,
15675 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015676 bits = present ? HDA_AMP_MUTE : 0;
15677 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15678 HDA_AMP_MUTE, bits);
15679 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15680 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015681}
15682
15683static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15684 unsigned int res)
15685{
15686 if ((res >> 26) == ALC880_HP_EVENT)
15687 alc662_lenovo_101e_all_automute(codec);
15688 if ((res >> 26) == ALC880_FRONT_EVENT)
15689 alc662_lenovo_101e_ispeaker_automute(codec);
15690}
15691
Kailang Yang291702f2007-10-16 14:28:03 +020015692static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15693{
15694 unsigned int present;
15695
15696 present = snd_hda_codec_read(codec, 0x18, 0,
15697 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15698 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15699 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15700 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15701 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15702 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15703 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15704 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15705 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15706}
15707
15708/* unsolicited event for HP jack sensing */
15709static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15710 unsigned int res)
15711{
15712 if ((res >> 26) == ALC880_HP_EVENT)
15713 alc262_hippo1_automute( codec );
15714
15715 if ((res >> 26) == ALC880_MIC_EVENT)
15716 alc662_eeepc_mic_automute(codec);
15717}
15718
15719static void alc662_eeepc_inithook(struct hda_codec *codec)
15720{
15721 alc262_hippo1_automute( codec );
15722 alc662_eeepc_mic_automute(codec);
15723}
15724
Kailang Yang8c427222008-01-10 13:03:59 +010015725static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15726{
15727 unsigned int mute;
15728 unsigned int present;
15729
15730 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15731 present = snd_hda_codec_read(codec, 0x14, 0,
15732 AC_VERB_GET_PIN_SENSE, 0);
15733 present = (present & 0x80000000) != 0;
15734 if (present) {
15735 /* mute internal speaker */
15736 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015737 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015738 } else {
15739 /* unmute internal speaker if necessary */
15740 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15741 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015742 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015743 }
15744}
15745
15746/* unsolicited event for HP jack sensing */
15747static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15748 unsigned int res)
15749{
15750 if ((res >> 26) == ALC880_HP_EVENT)
15751 alc662_eeepc_ep20_automute(codec);
15752}
15753
15754static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15755{
15756 alc662_eeepc_ep20_automute(codec);
15757}
15758
Kailang Yang6dda9f42008-05-27 12:05:31 +020015759static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15760{
15761 unsigned int present;
15762 unsigned char bits;
15763
15764 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015765 AC_VERB_GET_PIN_SENSE, 0)
15766 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015767 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015768 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15769 AMP_IN_MUTE(0), bits);
15770 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15771 AMP_IN_MUTE(0), bits);
15772}
15773
15774static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15775{
15776 unsigned int present;
15777 unsigned char bits;
15778
15779 present = snd_hda_codec_read(codec, 0x21, 0,
15780 AC_VERB_GET_PIN_SENSE, 0)
15781 & AC_PINSENSE_PRESENCE;
15782 bits = present ? HDA_AMP_MUTE : 0;
15783 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15784 AMP_IN_MUTE(0), bits);
15785 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15786 AMP_IN_MUTE(0), bits);
15787 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15788 AMP_IN_MUTE(0), bits);
15789 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15790 AMP_IN_MUTE(0), bits);
15791}
15792
15793static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15794{
15795 unsigned int present;
15796 unsigned char bits;
15797
15798 present = snd_hda_codec_read(codec, 0x15, 0,
15799 AC_VERB_GET_PIN_SENSE, 0)
15800 & AC_PINSENSE_PRESENCE;
15801 bits = present ? HDA_AMP_MUTE : 0;
15802 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15803 AMP_IN_MUTE(0), bits);
15804 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15805 AMP_IN_MUTE(0), bits);
15806 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15807 AMP_IN_MUTE(0), bits);
15808 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15809 AMP_IN_MUTE(0), bits);
15810}
15811
15812static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15813{
15814 unsigned int present;
15815 unsigned char bits;
15816
15817 present = snd_hda_codec_read(codec, 0x1b, 0,
15818 AC_VERB_GET_PIN_SENSE, 0)
15819 & AC_PINSENSE_PRESENCE;
15820 bits = present ? 0 : PIN_OUT;
15821 snd_hda_codec_write(codec, 0x14, 0,
15822 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15823}
15824
15825static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15826{
15827 unsigned int present1, present2;
15828
15829 present1 = snd_hda_codec_read(codec, 0x21, 0,
15830 AC_VERB_GET_PIN_SENSE, 0)
15831 & AC_PINSENSE_PRESENCE;
15832 present2 = snd_hda_codec_read(codec, 0x15, 0,
15833 AC_VERB_GET_PIN_SENSE, 0)
15834 & AC_PINSENSE_PRESENCE;
15835
15836 if (present1 || present2) {
15837 snd_hda_codec_write_cache(codec, 0x14, 0,
15838 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15839 } else {
15840 snd_hda_codec_write_cache(codec, 0x14, 0,
15841 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15842 }
15843}
15844
15845static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15846{
15847 unsigned int present1, present2;
15848
15849 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15850 AC_VERB_GET_PIN_SENSE, 0)
15851 & AC_PINSENSE_PRESENCE;
15852 present2 = snd_hda_codec_read(codec, 0x15, 0,
15853 AC_VERB_GET_PIN_SENSE, 0)
15854 & AC_PINSENSE_PRESENCE;
15855
15856 if (present1 || present2) {
15857 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15858 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15859 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15860 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15861 } else {
15862 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15863 AMP_IN_MUTE(0), 0);
15864 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15865 AMP_IN_MUTE(0), 0);
15866 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015867}
15868
15869static void alc663_m51va_mic_automute(struct hda_codec *codec)
15870{
15871 unsigned int present;
15872
15873 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015874 AC_VERB_GET_PIN_SENSE, 0)
15875 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015876 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015877 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015878 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015879 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015880 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015881 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015882 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015883 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015884}
15885
15886static void alc663_m51va_unsol_event(struct hda_codec *codec,
15887 unsigned int res)
15888{
15889 switch (res >> 26) {
15890 case ALC880_HP_EVENT:
15891 alc663_m51va_speaker_automute(codec);
15892 break;
15893 case ALC880_MIC_EVENT:
15894 alc663_m51va_mic_automute(codec);
15895 break;
15896 }
15897}
15898
15899static void alc663_m51va_inithook(struct hda_codec *codec)
15900{
15901 alc663_m51va_speaker_automute(codec);
15902 alc663_m51va_mic_automute(codec);
15903}
15904
Kailang Yangf1d4e282008-08-26 14:03:29 +020015905/* ***************** Mode1 ******************************/
15906static void alc663_mode1_unsol_event(struct hda_codec *codec,
15907 unsigned int res)
15908{
15909 switch (res >> 26) {
15910 case ALC880_HP_EVENT:
15911 alc663_m51va_speaker_automute(codec);
15912 break;
15913 case ALC880_MIC_EVENT:
15914 alc662_eeepc_mic_automute(codec);
15915 break;
15916 }
15917}
15918
15919static void alc663_mode1_inithook(struct hda_codec *codec)
15920{
15921 alc663_m51va_speaker_automute(codec);
15922 alc662_eeepc_mic_automute(codec);
15923}
15924/* ***************** Mode2 ******************************/
15925static void alc662_mode2_unsol_event(struct hda_codec *codec,
15926 unsigned int res)
15927{
15928 switch (res >> 26) {
15929 case ALC880_HP_EVENT:
15930 alc662_f5z_speaker_automute(codec);
15931 break;
15932 case ALC880_MIC_EVENT:
15933 alc662_eeepc_mic_automute(codec);
15934 break;
15935 }
15936}
15937
15938static void alc662_mode2_inithook(struct hda_codec *codec)
15939{
15940 alc662_f5z_speaker_automute(codec);
15941 alc662_eeepc_mic_automute(codec);
15942}
15943/* ***************** Mode3 ******************************/
15944static void alc663_mode3_unsol_event(struct hda_codec *codec,
15945 unsigned int res)
15946{
15947 switch (res >> 26) {
15948 case ALC880_HP_EVENT:
15949 alc663_two_hp_m1_speaker_automute(codec);
15950 break;
15951 case ALC880_MIC_EVENT:
15952 alc662_eeepc_mic_automute(codec);
15953 break;
15954 }
15955}
15956
15957static void alc663_mode3_inithook(struct hda_codec *codec)
15958{
15959 alc663_two_hp_m1_speaker_automute(codec);
15960 alc662_eeepc_mic_automute(codec);
15961}
15962/* ***************** Mode4 ******************************/
15963static void alc663_mode4_unsol_event(struct hda_codec *codec,
15964 unsigned int res)
15965{
15966 switch (res >> 26) {
15967 case ALC880_HP_EVENT:
15968 alc663_21jd_two_speaker_automute(codec);
15969 break;
15970 case ALC880_MIC_EVENT:
15971 alc662_eeepc_mic_automute(codec);
15972 break;
15973 }
15974}
15975
15976static void alc663_mode4_inithook(struct hda_codec *codec)
15977{
15978 alc663_21jd_two_speaker_automute(codec);
15979 alc662_eeepc_mic_automute(codec);
15980}
15981/* ***************** Mode5 ******************************/
15982static void alc663_mode5_unsol_event(struct hda_codec *codec,
15983 unsigned int res)
15984{
15985 switch (res >> 26) {
15986 case ALC880_HP_EVENT:
15987 alc663_15jd_two_speaker_automute(codec);
15988 break;
15989 case ALC880_MIC_EVENT:
15990 alc662_eeepc_mic_automute(codec);
15991 break;
15992 }
15993}
15994
15995static void alc663_mode5_inithook(struct hda_codec *codec)
15996{
15997 alc663_15jd_two_speaker_automute(codec);
15998 alc662_eeepc_mic_automute(codec);
15999}
16000/* ***************** Mode6 ******************************/
16001static void alc663_mode6_unsol_event(struct hda_codec *codec,
16002 unsigned int res)
16003{
16004 switch (res >> 26) {
16005 case ALC880_HP_EVENT:
16006 alc663_two_hp_m2_speaker_automute(codec);
16007 break;
16008 case ALC880_MIC_EVENT:
16009 alc662_eeepc_mic_automute(codec);
16010 break;
16011 }
16012}
16013
16014static void alc663_mode6_inithook(struct hda_codec *codec)
16015{
16016 alc663_two_hp_m2_speaker_automute(codec);
16017 alc662_eeepc_mic_automute(codec);
16018}
16019
Kailang Yang6dda9f42008-05-27 12:05:31 +020016020static void alc663_g71v_hp_automute(struct hda_codec *codec)
16021{
16022 unsigned int present;
16023 unsigned char bits;
16024
16025 present = snd_hda_codec_read(codec, 0x21, 0,
16026 AC_VERB_GET_PIN_SENSE, 0)
16027 & AC_PINSENSE_PRESENCE;
16028 bits = present ? HDA_AMP_MUTE : 0;
16029 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16030 HDA_AMP_MUTE, bits);
16031 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16032 HDA_AMP_MUTE, bits);
16033}
16034
16035static void alc663_g71v_front_automute(struct hda_codec *codec)
16036{
16037 unsigned int present;
16038 unsigned char bits;
16039
16040 present = snd_hda_codec_read(codec, 0x15, 0,
16041 AC_VERB_GET_PIN_SENSE, 0)
16042 & AC_PINSENSE_PRESENCE;
16043 bits = present ? HDA_AMP_MUTE : 0;
16044 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16045 HDA_AMP_MUTE, bits);
16046}
16047
16048static void alc663_g71v_unsol_event(struct hda_codec *codec,
16049 unsigned int res)
16050{
16051 switch (res >> 26) {
16052 case ALC880_HP_EVENT:
16053 alc663_g71v_hp_automute(codec);
16054 break;
16055 case ALC880_FRONT_EVENT:
16056 alc663_g71v_front_automute(codec);
16057 break;
16058 case ALC880_MIC_EVENT:
16059 alc662_eeepc_mic_automute(codec);
16060 break;
16061 }
16062}
16063
16064static void alc663_g71v_inithook(struct hda_codec *codec)
16065{
16066 alc663_g71v_front_automute(codec);
16067 alc663_g71v_hp_automute(codec);
16068 alc662_eeepc_mic_automute(codec);
16069}
16070
16071static void alc663_g50v_unsol_event(struct hda_codec *codec,
16072 unsigned int res)
16073{
16074 switch (res >> 26) {
16075 case ALC880_HP_EVENT:
16076 alc663_m51va_speaker_automute(codec);
16077 break;
16078 case ALC880_MIC_EVENT:
16079 alc662_eeepc_mic_automute(codec);
16080 break;
16081 }
16082}
16083
16084static void alc663_g50v_inithook(struct hda_codec *codec)
16085{
16086 alc663_m51va_speaker_automute(codec);
16087 alc662_eeepc_mic_automute(codec);
16088}
16089
Kailang Yangf1d4e282008-08-26 14:03:29 +020016090/* bind hp and internal speaker mute (with plug check) */
16091static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16092 struct snd_ctl_elem_value *ucontrol)
16093{
16094 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16095 long *valp = ucontrol->value.integer.value;
16096 int change;
16097
16098 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16099 HDA_AMP_MUTE,
16100 valp[0] ? 0 : HDA_AMP_MUTE);
16101 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16102 HDA_AMP_MUTE,
16103 valp[1] ? 0 : HDA_AMP_MUTE);
16104 if (change)
16105 alc262_hippo1_automute(codec);
16106 return change;
16107}
16108
16109static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16110 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16111 {
16112 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16113 .name = "Master Playback Switch",
16114 .info = snd_hda_mixer_amp_switch_info,
16115 .get = snd_hda_mixer_amp_switch_get,
16116 .put = alc662_ecs_master_sw_put,
16117 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16118 },
16119
16120 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16121 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16122 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16123
16124 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16125 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16126 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16127 { } /* end */
16128};
16129
Takashi Iwaicb53c622007-08-10 17:21:45 +020016130#ifdef CONFIG_SND_HDA_POWER_SAVE
16131#define alc662_loopbacks alc880_loopbacks
16132#endif
16133
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016134
16135/* pcm configuration: identiacal with ALC880 */
16136#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16137#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16138#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16139#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16140
16141/*
16142 * configuration and preset
16143 */
16144static const char *alc662_models[ALC662_MODEL_LAST] = {
16145 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16146 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16147 [ALC662_3ST_6ch] = "3stack-6ch",
16148 [ALC662_5ST_DIG] = "6stack-dig",
16149 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016150 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016151 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016152 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016153 [ALC663_ASUS_M51VA] = "m51va",
16154 [ALC663_ASUS_G71V] = "g71v",
16155 [ALC663_ASUS_H13] = "h13",
16156 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016157 [ALC663_ASUS_MODE1] = "asus-mode1",
16158 [ALC662_ASUS_MODE2] = "asus-mode2",
16159 [ALC663_ASUS_MODE3] = "asus-mode3",
16160 [ALC663_ASUS_MODE4] = "asus-mode4",
16161 [ALC663_ASUS_MODE5] = "asus-mode5",
16162 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016163 [ALC662_AUTO] = "auto",
16164};
16165
16166static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016167 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16168 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16169 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16170 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16171 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16172 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16173 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16174 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16175 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16176 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16177 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16178 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16179 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16180 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16181 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16182 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16183 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16184 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16185 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016186 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016187 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16188 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16189 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16190 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16191 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16192 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16193 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16194 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16195 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016196 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016197 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16198 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16199 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16200 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16201 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016202 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016203 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016204 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016205 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016206 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16207 ALC662_3ST_6ch_DIG),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016208 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16209 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016210 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016211 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016212 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016213 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016214 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16215 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016216 {}
16217};
16218
16219static struct alc_config_preset alc662_presets[] = {
16220 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016221 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016222 .init_verbs = { alc662_init_verbs },
16223 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16224 .dac_nids = alc662_dac_nids,
16225 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016226 .dig_in_nid = ALC662_DIGIN_NID,
16227 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16228 .channel_mode = alc662_3ST_2ch_modes,
16229 .input_mux = &alc662_capture_source,
16230 },
16231 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016232 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016233 .init_verbs = { alc662_init_verbs },
16234 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16235 .dac_nids = alc662_dac_nids,
16236 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016237 .dig_in_nid = ALC662_DIGIN_NID,
16238 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16239 .channel_mode = alc662_3ST_6ch_modes,
16240 .need_dac_fix = 1,
16241 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016242 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016243 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016244 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016245 .init_verbs = { alc662_init_verbs },
16246 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16247 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016248 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16249 .channel_mode = alc662_3ST_6ch_modes,
16250 .need_dac_fix = 1,
16251 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016252 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016253 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016254 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016255 .init_verbs = { alc662_init_verbs },
16256 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16257 .dac_nids = alc662_dac_nids,
16258 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016259 .dig_in_nid = ALC662_DIGIN_NID,
16260 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16261 .channel_mode = alc662_5stack_modes,
16262 .input_mux = &alc662_capture_source,
16263 },
16264 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016265 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016266 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16267 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16268 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016269 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16270 .channel_mode = alc662_3ST_2ch_modes,
16271 .input_mux = &alc662_lenovo_101e_capture_source,
16272 .unsol_event = alc662_lenovo_101e_unsol_event,
16273 .init_hook = alc662_lenovo_101e_all_automute,
16274 },
Kailang Yang291702f2007-10-16 14:28:03 +020016275 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016276 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016277 .init_verbs = { alc662_init_verbs,
16278 alc662_eeepc_sue_init_verbs },
16279 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16280 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016281 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16282 .channel_mode = alc662_3ST_2ch_modes,
16283 .input_mux = &alc662_eeepc_capture_source,
16284 .unsol_event = alc662_eeepc_unsol_event,
16285 .init_hook = alc662_eeepc_inithook,
16286 },
Kailang Yang8c427222008-01-10 13:03:59 +010016287 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016288 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016289 alc662_chmode_mixer },
16290 .init_verbs = { alc662_init_verbs,
16291 alc662_eeepc_ep20_sue_init_verbs },
16292 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16293 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016294 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16295 .channel_mode = alc662_3ST_6ch_modes,
16296 .input_mux = &alc662_lenovo_101e_capture_source,
16297 .unsol_event = alc662_eeepc_ep20_unsol_event,
16298 .init_hook = alc662_eeepc_ep20_inithook,
16299 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016300 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016301 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016302 .init_verbs = { alc662_init_verbs,
16303 alc662_ecs_init_verbs },
16304 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16305 .dac_nids = alc662_dac_nids,
16306 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16307 .channel_mode = alc662_3ST_2ch_modes,
16308 .input_mux = &alc662_eeepc_capture_source,
16309 .unsol_event = alc662_eeepc_unsol_event,
16310 .init_hook = alc662_eeepc_inithook,
16311 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016312 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016313 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016314 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16315 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16316 .dac_nids = alc662_dac_nids,
16317 .dig_out_nid = ALC662_DIGOUT_NID,
16318 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16319 .channel_mode = alc662_3ST_2ch_modes,
16320 .input_mux = &alc663_m51va_capture_source,
16321 .unsol_event = alc663_m51va_unsol_event,
16322 .init_hook = alc663_m51va_inithook,
16323 },
16324 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016325 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016326 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16327 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16328 .dac_nids = alc662_dac_nids,
16329 .dig_out_nid = ALC662_DIGOUT_NID,
16330 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16331 .channel_mode = alc662_3ST_2ch_modes,
16332 .input_mux = &alc662_eeepc_capture_source,
16333 .unsol_event = alc663_g71v_unsol_event,
16334 .init_hook = alc663_g71v_inithook,
16335 },
16336 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016337 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016338 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16339 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16340 .dac_nids = alc662_dac_nids,
16341 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16342 .channel_mode = alc662_3ST_2ch_modes,
16343 .input_mux = &alc663_m51va_capture_source,
16344 .unsol_event = alc663_m51va_unsol_event,
16345 .init_hook = alc663_m51va_inithook,
16346 },
16347 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016348 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016349 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16350 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16351 .dac_nids = alc662_dac_nids,
16352 .dig_out_nid = ALC662_DIGOUT_NID,
16353 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16354 .channel_mode = alc662_3ST_6ch_modes,
16355 .input_mux = &alc663_capture_source,
16356 .unsol_event = alc663_g50v_unsol_event,
16357 .init_hook = alc663_g50v_inithook,
16358 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016359 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016360 .mixers = { alc663_m51va_mixer },
16361 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016362 .init_verbs = { alc662_init_verbs,
16363 alc663_21jd_amic_init_verbs },
16364 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16365 .hp_nid = 0x03,
16366 .dac_nids = alc662_dac_nids,
16367 .dig_out_nid = ALC662_DIGOUT_NID,
16368 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16369 .channel_mode = alc662_3ST_2ch_modes,
16370 .input_mux = &alc662_eeepc_capture_source,
16371 .unsol_event = alc663_mode1_unsol_event,
16372 .init_hook = alc663_mode1_inithook,
16373 },
16374 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016375 .mixers = { alc662_1bjd_mixer },
16376 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016377 .init_verbs = { alc662_init_verbs,
16378 alc662_1bjd_amic_init_verbs },
16379 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16380 .dac_nids = alc662_dac_nids,
16381 .dig_out_nid = ALC662_DIGOUT_NID,
16382 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16383 .channel_mode = alc662_3ST_2ch_modes,
16384 .input_mux = &alc662_eeepc_capture_source,
16385 .unsol_event = alc662_mode2_unsol_event,
16386 .init_hook = alc662_mode2_inithook,
16387 },
16388 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016389 .mixers = { alc663_two_hp_m1_mixer },
16390 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016391 .init_verbs = { alc662_init_verbs,
16392 alc663_two_hp_amic_m1_init_verbs },
16393 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16394 .hp_nid = 0x03,
16395 .dac_nids = alc662_dac_nids,
16396 .dig_out_nid = ALC662_DIGOUT_NID,
16397 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16398 .channel_mode = alc662_3ST_2ch_modes,
16399 .input_mux = &alc662_eeepc_capture_source,
16400 .unsol_event = alc663_mode3_unsol_event,
16401 .init_hook = alc663_mode3_inithook,
16402 },
16403 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016404 .mixers = { alc663_asus_21jd_clfe_mixer },
16405 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016406 .init_verbs = { alc662_init_verbs,
16407 alc663_21jd_amic_init_verbs},
16408 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16409 .hp_nid = 0x03,
16410 .dac_nids = alc662_dac_nids,
16411 .dig_out_nid = ALC662_DIGOUT_NID,
16412 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16413 .channel_mode = alc662_3ST_2ch_modes,
16414 .input_mux = &alc662_eeepc_capture_source,
16415 .unsol_event = alc663_mode4_unsol_event,
16416 .init_hook = alc663_mode4_inithook,
16417 },
16418 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016419 .mixers = { alc663_asus_15jd_clfe_mixer },
16420 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016421 .init_verbs = { alc662_init_verbs,
16422 alc663_15jd_amic_init_verbs },
16423 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16424 .hp_nid = 0x03,
16425 .dac_nids = alc662_dac_nids,
16426 .dig_out_nid = ALC662_DIGOUT_NID,
16427 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16428 .channel_mode = alc662_3ST_2ch_modes,
16429 .input_mux = &alc662_eeepc_capture_source,
16430 .unsol_event = alc663_mode5_unsol_event,
16431 .init_hook = alc663_mode5_inithook,
16432 },
16433 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016434 .mixers = { alc663_two_hp_m2_mixer },
16435 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016436 .init_verbs = { alc662_init_verbs,
16437 alc663_two_hp_amic_m2_init_verbs },
16438 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16439 .hp_nid = 0x03,
16440 .dac_nids = alc662_dac_nids,
16441 .dig_out_nid = ALC662_DIGOUT_NID,
16442 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16443 .channel_mode = alc662_3ST_2ch_modes,
16444 .input_mux = &alc662_eeepc_capture_source,
16445 .unsol_event = alc663_mode6_unsol_event,
16446 .init_hook = alc663_mode6_inithook,
16447 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016448};
16449
16450
16451/*
16452 * BIOS auto configuration
16453 */
16454
16455/* add playback controls from the parsed DAC table */
16456static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16457 const struct auto_pin_cfg *cfg)
16458{
16459 char name[32];
16460 static const char *chname[4] = {
16461 "Front", "Surround", NULL /*CLFE*/, "Side"
16462 };
16463 hda_nid_t nid;
16464 int i, err;
16465
16466 for (i = 0; i < cfg->line_outs; i++) {
16467 if (!spec->multiout.dac_nids[i])
16468 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016469 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016470 if (i == 2) {
16471 /* Center/LFE */
16472 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16473 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016474 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16475 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016476 if (err < 0)
16477 return err;
16478 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16479 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016480 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16481 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016482 if (err < 0)
16483 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016484 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016485 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016486 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016487 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016488 if (err < 0)
16489 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016490 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016491 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016492 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016493 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016494 if (err < 0)
16495 return err;
16496 } else {
16497 sprintf(name, "%s Playback Volume", chname[i]);
16498 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016499 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16500 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016501 if (err < 0)
16502 return err;
16503 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016504 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16505 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16506 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016507 if (err < 0)
16508 return err;
16509 }
16510 }
16511 return 0;
16512}
16513
16514/* add playback controls for speaker and HP outputs */
16515static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16516 const char *pfx)
16517{
16518 hda_nid_t nid;
16519 int err;
16520 char name[32];
16521
16522 if (!pin)
16523 return 0;
16524
Takashi Iwai24fb9172008-09-02 14:48:20 +020016525 if (pin == 0x17) {
16526 /* ALC663 has a mono output pin on 0x17 */
16527 sprintf(name, "%s Playback Switch", pfx);
16528 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16529 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16530 return err;
16531 }
16532
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016533 if (alc880_is_fixed_pin(pin)) {
16534 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016535 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016536 /* specify the DAC as the extra output */
16537 if (!spec->multiout.hp_nid)
16538 spec->multiout.hp_nid = nid;
16539 else
16540 spec->multiout.extra_out_nid[0] = nid;
16541 /* control HP volume/switch on the output mixer amp */
16542 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16543 sprintf(name, "%s Playback Volume", pfx);
16544 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16545 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16546 if (err < 0)
16547 return err;
16548 sprintf(name, "%s Playback Switch", pfx);
16549 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16550 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16551 if (err < 0)
16552 return err;
16553 } else if (alc880_is_multi_pin(pin)) {
16554 /* set manual connection */
16555 /* we have only a switch on HP-out PIN */
16556 sprintf(name, "%s Playback Switch", pfx);
16557 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16558 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16559 if (err < 0)
16560 return err;
16561 }
16562 return 0;
16563}
16564
16565/* create playback/capture controls for input pins */
16566static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16567 const struct auto_pin_cfg *cfg)
16568{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016569 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016570 int i, err, idx;
16571
16572 for (i = 0; i < AUTO_PIN_LAST; i++) {
16573 if (alc880_is_input_pin(cfg->input_pins[i])) {
16574 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16575 err = new_analog_input(spec, cfg->input_pins[i],
16576 auto_pin_cfg_labels[i],
16577 idx, 0x0b);
16578 if (err < 0)
16579 return err;
16580 imux->items[imux->num_items].label =
16581 auto_pin_cfg_labels[i];
16582 imux->items[imux->num_items].index =
16583 alc880_input_pin_idx(cfg->input_pins[i]);
16584 imux->num_items++;
16585 }
16586 }
16587 return 0;
16588}
16589
16590static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16591 hda_nid_t nid, int pin_type,
16592 int dac_idx)
16593{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016594 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016595 /* need the manual connection? */
16596 if (alc880_is_multi_pin(nid)) {
16597 struct alc_spec *spec = codec->spec;
16598 int idx = alc880_multi_pin_idx(nid);
16599 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16600 AC_VERB_SET_CONNECT_SEL,
16601 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16602 }
16603}
16604
16605static void alc662_auto_init_multi_out(struct hda_codec *codec)
16606{
16607 struct alc_spec *spec = codec->spec;
16608 int i;
16609
Kailang Yang8c427222008-01-10 13:03:59 +010016610 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016611 for (i = 0; i <= HDA_SIDE; i++) {
16612 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016613 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016614 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016615 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016616 i);
16617 }
16618}
16619
16620static void alc662_auto_init_hp_out(struct hda_codec *codec)
16621{
16622 struct alc_spec *spec = codec->spec;
16623 hda_nid_t pin;
16624
16625 pin = spec->autocfg.hp_pins[0];
16626 if (pin) /* connect to front */
16627 /* use dac 0 */
16628 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016629 pin = spec->autocfg.speaker_pins[0];
16630 if (pin)
16631 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016632}
16633
16634#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16635#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16636
16637static void alc662_auto_init_analog_input(struct hda_codec *codec)
16638{
16639 struct alc_spec *spec = codec->spec;
16640 int i;
16641
16642 for (i = 0; i < AUTO_PIN_LAST; i++) {
16643 hda_nid_t nid = spec->autocfg.input_pins[i];
16644 if (alc662_is_input_pin(nid)) {
16645 snd_hda_codec_write(codec, nid, 0,
16646 AC_VERB_SET_PIN_WIDGET_CONTROL,
16647 (i <= AUTO_PIN_FRONT_MIC ?
16648 PIN_VREF80 : PIN_IN));
16649 if (nid != ALC662_PIN_CD_NID)
16650 snd_hda_codec_write(codec, nid, 0,
16651 AC_VERB_SET_AMP_GAIN_MUTE,
16652 AMP_OUT_MUTE);
16653 }
16654 }
16655}
16656
Takashi Iwaif511b012008-08-15 16:46:42 +020016657#define alc662_auto_init_input_src alc882_auto_init_input_src
16658
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016659static int alc662_parse_auto_config(struct hda_codec *codec)
16660{
16661 struct alc_spec *spec = codec->spec;
16662 int err;
16663 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16664
16665 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16666 alc662_ignore);
16667 if (err < 0)
16668 return err;
16669 if (!spec->autocfg.line_outs)
16670 return 0; /* can't find valid BIOS pin config */
16671
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016672 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16673 if (err < 0)
16674 return err;
16675 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16676 if (err < 0)
16677 return err;
16678 err = alc662_auto_create_extra_out(spec,
16679 spec->autocfg.speaker_pins[0],
16680 "Speaker");
16681 if (err < 0)
16682 return err;
16683 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16684 "Headphone");
16685 if (err < 0)
16686 return err;
16687 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16688 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016689 return err;
16690
16691 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16692
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016693 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016694 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16695
Takashi Iwai603c4012008-07-30 15:01:44 +020016696 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016697 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016698
16699 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016700 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016701
Takashi Iwaid88897e2008-10-31 15:01:37 +010016702 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016703 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016704 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016705
16706 err = alc_auto_add_mic_boost(codec);
16707 if (err < 0)
16708 return err;
16709
Takashi Iwaie044c392008-10-27 16:56:24 +010016710 store_pin_configs(codec);
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016711 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016712}
16713
16714/* additional initialization for auto-configuration model */
16715static void alc662_auto_init(struct hda_codec *codec)
16716{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016717 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016718 alc662_auto_init_multi_out(codec);
16719 alc662_auto_init_hp_out(codec);
16720 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016721 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016722 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016723 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016724}
16725
16726static int patch_alc662(struct hda_codec *codec)
16727{
16728 struct alc_spec *spec;
16729 int err, board_config;
16730
16731 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16732 if (!spec)
16733 return -ENOMEM;
16734
16735 codec->spec = spec;
16736
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016737 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16738
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016739 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16740 alc662_models,
16741 alc662_cfg_tbl);
16742 if (board_config < 0) {
16743 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16744 "trying auto-probe from BIOS...\n");
16745 board_config = ALC662_AUTO;
16746 }
16747
16748 if (board_config == ALC662_AUTO) {
16749 /* automatic parse from the BIOS config */
16750 err = alc662_parse_auto_config(codec);
16751 if (err < 0) {
16752 alc_free(codec);
16753 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016754 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016755 printk(KERN_INFO
16756 "hda_codec: Cannot set up configuration "
16757 "from BIOS. Using base mode...\n");
16758 board_config = ALC662_3ST_2ch_DIG;
16759 }
16760 }
16761
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016762 err = snd_hda_attach_beep_device(codec, 0x1);
16763 if (err < 0) {
16764 alc_free(codec);
16765 return err;
16766 }
16767
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016768 if (board_config != ALC662_AUTO)
16769 setup_preset(spec, &alc662_presets[board_config]);
16770
Kailang Yang6dda9f42008-05-27 12:05:31 +020016771 if (codec->vendor_id == 0x10ec0663) {
16772 spec->stream_name_analog = "ALC663 Analog";
16773 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016774 } else if (codec->vendor_id == 0x10ec0272) {
16775 spec->stream_name_analog = "ALC272 Analog";
16776 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016777 } else {
16778 spec->stream_name_analog = "ALC662 Analog";
16779 spec->stream_name_digital = "ALC662 Digital";
16780 }
16781
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016782 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16783 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16784
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016785 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16786 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16787
Takashi Iwaie1406342008-02-11 18:32:32 +010016788 spec->adc_nids = alc662_adc_nids;
16789 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16790 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016791 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016792
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016793 if (!spec->cap_mixer)
16794 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016795 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016796
Takashi Iwai2134ea42008-01-10 16:53:55 +010016797 spec->vmaster_nid = 0x02;
16798
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016799 codec->patch_ops = alc_patch_ops;
16800 if (board_config == ALC662_AUTO)
16801 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016802#ifdef CONFIG_SND_HDA_POWER_SAVE
16803 if (!spec->loopback.amplist)
16804 spec->loopback.amplist = alc662_loopbacks;
16805#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016806 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016807
16808 return 0;
16809}
16810
16811/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016812 * patch entries
16813 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016814static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016815 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016816 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016817 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016818 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016819 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016820 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016821 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016822 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016823 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16824 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16825 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016826 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16827 .patch = patch_alc883 },
16828 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16829 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016830 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016831 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016832 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016833 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016834 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16835 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016836 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016837 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016838 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016839 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016840 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16841 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080016842 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016843 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016844 {} /* terminator */
16845};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016846
16847MODULE_ALIAS("snd-hda-codec-id:10ec*");
16848
16849MODULE_LICENSE("GPL");
16850MODULE_DESCRIPTION("Realtek HD-audio codec");
16851
16852static struct hda_codec_preset_list realtek_list = {
16853 .preset = snd_hda_preset_realtek,
16854 .owner = THIS_MODULE,
16855};
16856
16857static int __init patch_realtek_init(void)
16858{
16859 return snd_hda_add_codec_preset(&realtek_list);
16860}
16861
16862static void __exit patch_realtek_exit(void)
16863{
16864 snd_hda_delete_codec_preset(&realtek_list);
16865}
16866
16867module_init(patch_realtek_init)
16868module_exit(patch_realtek_exit)