blob: 7ae8fad0189fc4e8b0522747a451d64d067bae31 [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
4294 if (spec->autocfg.dig_out_pin)
4295 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
5661 if (spec->autocfg.dig_out_pin)
5662 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),
8523 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8524 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008525 /* default Acer */
8526 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008527 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008528 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008529 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8530 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008531 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008532 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008533 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008534 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008535 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008536 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008537 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008538 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008539 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008540 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8541 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008542 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008543 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008544 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008545 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8546 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8547 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008548 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008549 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008550 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008551 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8552 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8553 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8554 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8555 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8556 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8557 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8558 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8559 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008560 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8561 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008562 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008563 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008564 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008565 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008566 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008567 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008568 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008569 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8570 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008571 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008572 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008573 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaif67d8172009-02-04 23:30:19 +01008574 SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550",
8575 ALC883_FUJITSU_PI2515),
Jiang zhefb97dc62008-03-06 11:07:11 +01008576 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008577 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8578 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008579 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008580 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008581 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8582 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008583 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008584 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008585 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008586 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008587 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008588 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8589 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008590 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008591 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008592 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008593 {}
8594};
8595
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008596static hda_nid_t alc1200_slave_dig_outs[] = {
8597 ALC883_DIGOUT_NID, 0,
8598};
8599
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008600static struct alc_config_preset alc883_presets[] = {
8601 [ALC883_3ST_2ch_DIG] = {
8602 .mixers = { alc883_3ST_2ch_mixer },
8603 .init_verbs = { alc883_init_verbs },
8604 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8605 .dac_nids = alc883_dac_nids,
8606 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008607 .dig_in_nid = ALC883_DIGIN_NID,
8608 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8609 .channel_mode = alc883_3ST_2ch_modes,
8610 .input_mux = &alc883_capture_source,
8611 },
8612 [ALC883_3ST_6ch_DIG] = {
8613 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8614 .init_verbs = { alc883_init_verbs },
8615 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8616 .dac_nids = alc883_dac_nids,
8617 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008618 .dig_in_nid = ALC883_DIGIN_NID,
8619 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8620 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008621 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008622 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008623 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008624 [ALC883_3ST_6ch] = {
8625 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8626 .init_verbs = { alc883_init_verbs },
8627 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8628 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008629 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8630 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008631 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008632 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008633 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008634 [ALC883_3ST_6ch_INTEL] = {
8635 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8636 .init_verbs = { alc883_init_verbs },
8637 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8638 .dac_nids = alc883_dac_nids,
8639 .dig_out_nid = ALC883_DIGOUT_NID,
8640 .dig_in_nid = ALC883_DIGIN_NID,
8641 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8642 .channel_mode = alc883_3ST_6ch_intel_modes,
8643 .need_dac_fix = 1,
8644 .input_mux = &alc883_3stack_6ch_intel,
8645 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008646 [ALC883_6ST_DIG] = {
8647 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8648 .init_verbs = { alc883_init_verbs },
8649 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8650 .dac_nids = alc883_dac_nids,
8651 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008652 .dig_in_nid = ALC883_DIGIN_NID,
8653 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8654 .channel_mode = alc883_sixstack_modes,
8655 .input_mux = &alc883_capture_source,
8656 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008657 [ALC883_TARGA_DIG] = {
8658 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8659 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8660 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8661 .dac_nids = alc883_dac_nids,
8662 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008663 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8664 .channel_mode = alc883_3ST_6ch_modes,
8665 .need_dac_fix = 1,
8666 .input_mux = &alc883_capture_source,
8667 .unsol_event = alc883_tagra_unsol_event,
8668 .init_hook = alc883_tagra_automute,
8669 },
8670 [ALC883_TARGA_2ch_DIG] = {
8671 .mixers = { alc883_tagra_2ch_mixer},
8672 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8673 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8674 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008675 .adc_nids = alc883_adc_nids_alt,
8676 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008677 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008678 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8679 .channel_mode = alc883_3ST_2ch_modes,
8680 .input_mux = &alc883_capture_source,
8681 .unsol_event = alc883_tagra_unsol_event,
8682 .init_hook = alc883_tagra_automute,
8683 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008684 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008685 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008686 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8687 * and the headphone jack. Turn this on and rely on the
8688 * standard mute methods whenever the user wants to turn
8689 * these outputs off.
8690 */
8691 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8692 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8693 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008694 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8695 .channel_mode = alc883_3ST_2ch_modes,
8696 .input_mux = &alc883_capture_source,
8697 },
Tobin Davis2880a862007-08-07 11:50:26 +02008698 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008699 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008700 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008701 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8702 .dac_nids = alc883_dac_nids,
8703 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008704 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8705 .channel_mode = alc883_3ST_2ch_modes,
8706 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008707 .unsol_event = alc883_acer_aspire_unsol_event,
8708 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008709 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008710 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008711 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008712 alc883_chmode_mixer },
8713 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8714 alc888_acer_aspire_4930g_verbs },
8715 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8716 .dac_nids = alc883_dac_nids,
8717 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8718 .adc_nids = alc883_adc_nids_rev,
8719 .capsrc_nids = alc883_capsrc_nids_rev,
8720 .dig_out_nid = ALC883_DIGOUT_NID,
8721 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8722 .channel_mode = alc883_3ST_6ch_modes,
8723 .need_dac_fix = 1,
8724 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008725 ARRAY_SIZE(alc888_2_capture_sources),
8726 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008727 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8728 .init_hook = alc888_acer_aspire_4930g_automute,
8729 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008730 [ALC883_MEDION] = {
8731 .mixers = { alc883_fivestack_mixer,
8732 alc883_chmode_mixer },
8733 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008734 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008735 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8736 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008737 .adc_nids = alc883_adc_nids_alt,
8738 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008739 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8740 .channel_mode = alc883_sixstack_modes,
8741 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008742 },
Kailang Yang272a5272007-05-14 11:00:38 +02008743 [ALC883_MEDION_MD2] = {
8744 .mixers = { alc883_medion_md2_mixer},
8745 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8746 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8747 .dac_nids = alc883_dac_nids,
8748 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008749 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8750 .channel_mode = alc883_3ST_2ch_modes,
8751 .input_mux = &alc883_capture_source,
8752 .unsol_event = alc883_medion_md2_unsol_event,
8753 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008754 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008755 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008756 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008757 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8758 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8759 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008760 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8761 .channel_mode = alc883_3ST_2ch_modes,
8762 .input_mux = &alc883_capture_source,
8763 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008764 [ALC883_CLEVO_M720] = {
8765 .mixers = { alc883_clevo_m720_mixer },
8766 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008767 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8768 .dac_nids = alc883_dac_nids,
8769 .dig_out_nid = ALC883_DIGOUT_NID,
8770 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8771 .channel_mode = alc883_3ST_2ch_modes,
8772 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008773 .unsol_event = alc883_clevo_m720_unsol_event,
8774 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008775 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008776 [ALC883_LENOVO_101E_2ch] = {
8777 .mixers = { alc883_lenovo_101e_2ch_mixer},
8778 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8779 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8780 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008781 .adc_nids = alc883_adc_nids_alt,
8782 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008783 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8784 .channel_mode = alc883_3ST_2ch_modes,
8785 .input_mux = &alc883_lenovo_101e_capture_source,
8786 .unsol_event = alc883_lenovo_101e_unsol_event,
8787 .init_hook = alc883_lenovo_101e_all_automute,
8788 },
Kailang Yang272a5272007-05-14 11:00:38 +02008789 [ALC883_LENOVO_NB0763] = {
8790 .mixers = { alc883_lenovo_nb0763_mixer },
8791 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8792 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8793 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008794 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8795 .channel_mode = alc883_3ST_2ch_modes,
8796 .need_dac_fix = 1,
8797 .input_mux = &alc883_lenovo_nb0763_capture_source,
8798 .unsol_event = alc883_medion_md2_unsol_event,
8799 .init_hook = alc883_medion_md2_automute,
8800 },
8801 [ALC888_LENOVO_MS7195_DIG] = {
8802 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8803 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8804 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8805 .dac_nids = alc883_dac_nids,
8806 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008807 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8808 .channel_mode = alc883_3ST_6ch_modes,
8809 .need_dac_fix = 1,
8810 .input_mux = &alc883_capture_source,
8811 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8812 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008813 },
8814 [ALC883_HAIER_W66] = {
8815 .mixers = { alc883_tagra_2ch_mixer},
8816 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8817 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8818 .dac_nids = alc883_dac_nids,
8819 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008820 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8821 .channel_mode = alc883_3ST_2ch_modes,
8822 .input_mux = &alc883_capture_source,
8823 .unsol_event = alc883_haier_w66_unsol_event,
8824 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008825 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008826 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008827 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008828 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008829 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8830 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008831 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8832 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008833 .need_dac_fix = 1,
8834 .input_mux = &alc883_capture_source,
8835 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008836 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008837 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008838 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8839 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8840 .dac_nids = alc883_dac_nids,
8841 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008842 .dig_in_nid = ALC883_DIGIN_NID,
8843 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8844 .channel_mode = alc883_sixstack_modes,
8845 .input_mux = &alc883_capture_source,
8846 .unsol_event = alc888_6st_dell_unsol_event,
8847 .init_hook = alc888_6st_dell_front_automute,
8848 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008849 [ALC883_MITAC] = {
8850 .mixers = { alc883_mitac_mixer },
8851 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8852 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8853 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008854 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8855 .channel_mode = alc883_3ST_2ch_modes,
8856 .input_mux = &alc883_capture_source,
8857 .unsol_event = alc883_mitac_unsol_event,
8858 .init_hook = alc883_mitac_automute,
8859 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008860 [ALC883_FUJITSU_PI2515] = {
8861 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8862 .init_verbs = { alc883_init_verbs,
8863 alc883_2ch_fujitsu_pi2515_verbs},
8864 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8865 .dac_nids = alc883_dac_nids,
8866 .dig_out_nid = ALC883_DIGOUT_NID,
8867 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8868 .channel_mode = alc883_3ST_2ch_modes,
8869 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8870 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8871 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8872 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008873 [ALC888_FUJITSU_XA3530] = {
8874 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8875 .init_verbs = { alc883_init_verbs,
8876 alc888_fujitsu_xa3530_verbs },
8877 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8878 .dac_nids = alc883_dac_nids,
8879 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8880 .adc_nids = alc883_adc_nids_rev,
8881 .capsrc_nids = alc883_capsrc_nids_rev,
8882 .dig_out_nid = ALC883_DIGOUT_NID,
8883 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8884 .channel_mode = alc888_4ST_8ch_intel_modes,
8885 .num_mux_defs =
8886 ARRAY_SIZE(alc888_2_capture_sources),
8887 .input_mux = alc888_2_capture_sources,
8888 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
8889 .init_hook = alc888_fujitsu_xa3530_automute,
8890 },
Kailang Yange2757d52008-08-26 13:17:46 +02008891 [ALC888_LENOVO_SKY] = {
8892 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8893 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8894 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8895 .dac_nids = alc883_dac_nids,
8896 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02008897 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8898 .channel_mode = alc883_sixstack_modes,
8899 .need_dac_fix = 1,
8900 .input_mux = &alc883_lenovo_sky_capture_source,
8901 .unsol_event = alc883_lenovo_sky_unsol_event,
8902 .init_hook = alc888_lenovo_sky_front_automute,
8903 },
8904 [ALC888_ASUS_M90V] = {
8905 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8906 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8907 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8908 .dac_nids = alc883_dac_nids,
8909 .dig_out_nid = ALC883_DIGOUT_NID,
8910 .dig_in_nid = ALC883_DIGIN_NID,
8911 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8912 .channel_mode = alc883_3ST_6ch_modes,
8913 .need_dac_fix = 1,
8914 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8915 .unsol_event = alc883_mode2_unsol_event,
8916 .init_hook = alc883_mode2_inithook,
8917 },
8918 [ALC888_ASUS_EEE1601] = {
8919 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008920 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02008921 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8922 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8923 .dac_nids = alc883_dac_nids,
8924 .dig_out_nid = ALC883_DIGOUT_NID,
8925 .dig_in_nid = ALC883_DIGIN_NID,
8926 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8927 .channel_mode = alc883_3ST_2ch_modes,
8928 .need_dac_fix = 1,
8929 .input_mux = &alc883_asus_eee1601_capture_source,
8930 .unsol_event = alc883_eee1601_unsol_event,
8931 .init_hook = alc883_eee1601_inithook,
8932 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01008933 [ALC1200_ASUS_P5Q] = {
8934 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8935 .init_verbs = { alc883_init_verbs },
8936 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8937 .dac_nids = alc883_dac_nids,
8938 .dig_out_nid = ALC1200_DIGOUT_NID,
8939 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008940 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01008941 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8942 .channel_mode = alc883_sixstack_modes,
8943 .input_mux = &alc883_capture_source,
8944 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008945};
8946
8947
8948/*
8949 * BIOS auto configuration
8950 */
8951static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8952 hda_nid_t nid, int pin_type,
8953 int dac_idx)
8954{
8955 /* set as output */
8956 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008957 int idx;
8958
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008959 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008960 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8961 idx = 4;
8962 else
8963 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008964 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8965
8966}
8967
8968static void alc883_auto_init_multi_out(struct hda_codec *codec)
8969{
8970 struct alc_spec *spec = codec->spec;
8971 int i;
8972
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008973 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008974 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008975 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008976 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008977 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008978 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008979 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008980 }
8981}
8982
8983static void alc883_auto_init_hp_out(struct hda_codec *codec)
8984{
8985 struct alc_spec *spec = codec->spec;
8986 hda_nid_t pin;
8987
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008988 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008989 if (pin) /* connect to front */
8990 /* use dac 0 */
8991 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008992 pin = spec->autocfg.speaker_pins[0];
8993 if (pin)
8994 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008995}
8996
8997#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8998#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8999
9000static void alc883_auto_init_analog_input(struct hda_codec *codec)
9001{
9002 struct alc_spec *spec = codec->spec;
9003 int i;
9004
9005 for (i = 0; i < AUTO_PIN_LAST; i++) {
9006 hda_nid_t nid = spec->autocfg.input_pins[i];
9007 if (alc883_is_input_pin(nid)) {
9008 snd_hda_codec_write(codec, nid, 0,
9009 AC_VERB_SET_PIN_WIDGET_CONTROL,
9010 (i <= AUTO_PIN_FRONT_MIC ?
9011 PIN_VREF80 : PIN_IN));
9012 if (nid != ALC883_PIN_CD_NID)
9013 snd_hda_codec_write(codec, nid, 0,
9014 AC_VERB_SET_AMP_GAIN_MUTE,
9015 AMP_OUT_MUTE);
9016 }
9017 }
9018}
9019
Takashi Iwaif511b012008-08-15 16:46:42 +02009020#define alc883_auto_init_input_src alc882_auto_init_input_src
9021
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009022/* almost identical with ALC880 parser... */
9023static int alc883_parse_auto_config(struct hda_codec *codec)
9024{
9025 struct alc_spec *spec = codec->spec;
9026 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009027 struct auto_pin_cfg *cfg = &spec->autocfg;
9028 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009029
9030 if (err < 0)
9031 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009032 else if (!err)
9033 return 0; /* no config found */
9034
9035 err = alc_auto_add_mic_boost(codec);
9036 if (err < 0)
9037 return err;
9038
9039 /* hack - override the init verbs */
9040 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009041
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009042 /* setup input_mux for ALC889 */
9043 if (codec->vendor_id == 0x10ec0889) {
9044 /* digital-mic input pin is excluded in alc880_auto_create..()
9045 * because it's under 0x18
9046 */
9047 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9048 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9049 struct hda_input_mux *imux = &spec->private_imux[0];
9050 for (i = 1; i < 3; i++)
9051 memcpy(&spec->private_imux[i],
9052 &spec->private_imux[0],
9053 sizeof(spec->private_imux[0]));
9054 imux->items[imux->num_items].label = "Int DMic";
9055 imux->items[imux->num_items].index = 0x0b;
9056 imux->num_items++;
9057 spec->num_mux_defs = 3;
9058 spec->input_mux = spec->private_imux;
9059 }
9060 }
9061
Takashi Iwai776e1842007-08-29 15:07:11 +02009062 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009063}
9064
9065/* additional initialization for auto-configuration model */
9066static void alc883_auto_init(struct hda_codec *codec)
9067{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009068 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009069 alc883_auto_init_multi_out(codec);
9070 alc883_auto_init_hp_out(codec);
9071 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009072 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009073 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009074 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009075}
9076
9077static int patch_alc883(struct hda_codec *codec)
9078{
9079 struct alc_spec *spec;
9080 int err, board_config;
9081
9082 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9083 if (spec == NULL)
9084 return -ENOMEM;
9085
9086 codec->spec = spec;
9087
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009088 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9089
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009090 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9091 alc883_models,
9092 alc883_cfg_tbl);
9093 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009094 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9095 "trying auto-probe from BIOS...\n");
9096 board_config = ALC883_AUTO;
9097 }
9098
9099 if (board_config == ALC883_AUTO) {
9100 /* automatic parse from the BIOS config */
9101 err = alc883_parse_auto_config(codec);
9102 if (err < 0) {
9103 alc_free(codec);
9104 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009105 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009106 printk(KERN_INFO
9107 "hda_codec: Cannot set up configuration "
9108 "from BIOS. Using base mode...\n");
9109 board_config = ALC883_3ST_2ch_DIG;
9110 }
9111 }
9112
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009113 err = snd_hda_attach_beep_device(codec, 0x1);
9114 if (err < 0) {
9115 alc_free(codec);
9116 return err;
9117 }
9118
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009119 if (board_config != ALC883_AUTO)
9120 setup_preset(spec, &alc883_presets[board_config]);
9121
Kailang Yang2f893282008-05-27 12:14:47 +02009122 switch (codec->vendor_id) {
9123 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009124 if (codec->revision_id == 0x100101) {
9125 spec->stream_name_analog = "ALC1200 Analog";
9126 spec->stream_name_digital = "ALC1200 Digital";
9127 } else {
9128 spec->stream_name_analog = "ALC888 Analog";
9129 spec->stream_name_digital = "ALC888 Digital";
9130 }
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009131 if (!spec->num_adc_nids) {
9132 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9133 spec->adc_nids = alc883_adc_nids;
9134 }
9135 if (!spec->capsrc_nids)
9136 spec->capsrc_nids = alc883_capsrc_nids;
9137 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009138 break;
9139 case 0x10ec0889:
9140 spec->stream_name_analog = "ALC889 Analog";
9141 spec->stream_name_digital = "ALC889 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009142 if (!spec->num_adc_nids) {
9143 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9144 spec->adc_nids = alc889_adc_nids;
9145 }
9146 if (!spec->capsrc_nids)
9147 spec->capsrc_nids = alc889_capsrc_nids;
9148 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9149 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009150 break;
9151 default:
9152 spec->stream_name_analog = "ALC883 Analog";
9153 spec->stream_name_digital = "ALC883 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009154 if (!spec->num_adc_nids) {
9155 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9156 spec->adc_nids = alc883_adc_nids;
9157 }
9158 if (!spec->capsrc_nids)
9159 spec->capsrc_nids = alc883_capsrc_nids;
9160 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009161 break;
9162 }
9163
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009164 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9165 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009166 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009167
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009168 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9169 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9170
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009171 if (!spec->cap_mixer)
9172 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009173 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009174
Takashi Iwai2134ea42008-01-10 16:53:55 +01009175 spec->vmaster_nid = 0x0c;
9176
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009177 codec->patch_ops = alc_patch_ops;
9178 if (board_config == ALC883_AUTO)
9179 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009180
Takashi Iwaicb53c622007-08-10 17:21:45 +02009181#ifdef CONFIG_SND_HDA_POWER_SAVE
9182 if (!spec->loopback.amplist)
9183 spec->loopback.amplist = alc883_loopbacks;
9184#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009185 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009186
9187 return 0;
9188}
9189
9190/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009191 * ALC262 support
9192 */
9193
9194#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9195#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9196
9197#define alc262_dac_nids alc260_dac_nids
9198#define alc262_adc_nids alc882_adc_nids
9199#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009200#define alc262_capsrc_nids alc882_capsrc_nids
9201#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009202
9203#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009204#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009205
Kailang Yang4e555fe2008-08-26 13:05:55 +02009206static hda_nid_t alc262_dmic_adc_nids[1] = {
9207 /* ADC0 */
9208 0x09
9209};
9210
9211static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9212
Kailang Yangdf694da2005-12-05 19:42:22 +01009213static struct snd_kcontrol_new alc262_base_mixer[] = {
9214 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9215 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9216 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9217 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9218 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9219 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9220 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9221 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009222 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009223 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9224 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009225 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009226 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9227 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9228 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9229 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009230 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009231};
9232
Kailang Yangccc656c2006-10-17 12:32:26 +02009233static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9234 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9235 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9236 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9237 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9238 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9239 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9240 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9241 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009242 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009243 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9244 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009245 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009246 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9247 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9248 { } /* end */
9249};
9250
Takashi Iwaice875f02008-01-28 18:17:43 +01009251/* update HP, line and mono-out pins according to the master switch */
9252static void alc262_hp_master_update(struct hda_codec *codec)
9253{
9254 struct alc_spec *spec = codec->spec;
9255 int val = spec->master_sw;
9256
9257 /* HP & line-out */
9258 snd_hda_codec_write_cache(codec, 0x1b, 0,
9259 AC_VERB_SET_PIN_WIDGET_CONTROL,
9260 val ? PIN_HP : 0);
9261 snd_hda_codec_write_cache(codec, 0x15, 0,
9262 AC_VERB_SET_PIN_WIDGET_CONTROL,
9263 val ? PIN_HP : 0);
9264 /* mono (speaker) depending on the HP jack sense */
9265 val = val && !spec->jack_present;
9266 snd_hda_codec_write_cache(codec, 0x16, 0,
9267 AC_VERB_SET_PIN_WIDGET_CONTROL,
9268 val ? PIN_OUT : 0);
9269}
9270
9271static void alc262_hp_bpc_automute(struct hda_codec *codec)
9272{
9273 struct alc_spec *spec = codec->spec;
9274 unsigned int presence;
9275 presence = snd_hda_codec_read(codec, 0x1b, 0,
9276 AC_VERB_GET_PIN_SENSE, 0);
9277 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9278 alc262_hp_master_update(codec);
9279}
9280
9281static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9282{
9283 if ((res >> 26) != ALC880_HP_EVENT)
9284 return;
9285 alc262_hp_bpc_automute(codec);
9286}
9287
9288static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9289{
9290 struct alc_spec *spec = codec->spec;
9291 unsigned int presence;
9292 presence = snd_hda_codec_read(codec, 0x15, 0,
9293 AC_VERB_GET_PIN_SENSE, 0);
9294 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9295 alc262_hp_master_update(codec);
9296}
9297
9298static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9299 unsigned int res)
9300{
9301 if ((res >> 26) != ALC880_HP_EVENT)
9302 return;
9303 alc262_hp_wildwest_automute(codec);
9304}
9305
9306static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9307 struct snd_ctl_elem_value *ucontrol)
9308{
9309 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9310 struct alc_spec *spec = codec->spec;
9311 *ucontrol->value.integer.value = spec->master_sw;
9312 return 0;
9313}
9314
9315static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9316 struct snd_ctl_elem_value *ucontrol)
9317{
9318 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9319 struct alc_spec *spec = codec->spec;
9320 int val = !!*ucontrol->value.integer.value;
9321
9322 if (val == spec->master_sw)
9323 return 0;
9324 spec->master_sw = val;
9325 alc262_hp_master_update(codec);
9326 return 1;
9327}
9328
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009329static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009330 {
9331 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9332 .name = "Master Playback Switch",
9333 .info = snd_ctl_boolean_mono_info,
9334 .get = alc262_hp_master_sw_get,
9335 .put = alc262_hp_master_sw_put,
9336 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009337 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9338 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9339 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009340 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9341 HDA_OUTPUT),
9342 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9343 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009344 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9345 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009346 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009347 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9348 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009349 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009350 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9351 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9352 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9353 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009354 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9355 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9356 { } /* end */
9357};
9358
Kailang Yangcd7509a2007-01-26 18:33:17 +01009359static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009360 {
9361 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9362 .name = "Master Playback Switch",
9363 .info = snd_ctl_boolean_mono_info,
9364 .get = alc262_hp_master_sw_get,
9365 .put = alc262_hp_master_sw_put,
9366 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009367 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9368 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9369 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9370 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009371 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9372 HDA_OUTPUT),
9373 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9374 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009375 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9376 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009377 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009378 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9379 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9380 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9381 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009382 { } /* end */
9383};
9384
9385static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9386 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9387 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009388 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009389 { } /* end */
9390};
9391
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009392/* mute/unmute internal speaker according to the hp jack and mute state */
9393static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9394{
9395 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009396
9397 if (force || !spec->sense_updated) {
9398 unsigned int present;
9399 present = snd_hda_codec_read(codec, 0x15, 0,
9400 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009401 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009402 spec->sense_updated = 1;
9403 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009404 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9405 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009406}
9407
9408static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9409 unsigned int res)
9410{
9411 if ((res >> 26) != ALC880_HP_EVENT)
9412 return;
9413 alc262_hp_t5735_automute(codec, 1);
9414}
9415
9416static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9417{
9418 alc262_hp_t5735_automute(codec, 1);
9419}
9420
9421static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009422 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9423 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009424 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9425 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9426 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9427 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9428 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9429 { } /* end */
9430};
9431
9432static struct hda_verb alc262_hp_t5735_verbs[] = {
9433 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9434 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9435
9436 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9437 { }
9438};
9439
Kailang Yang8c427222008-01-10 13:03:59 +01009440static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009441 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9442 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009443 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9444 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009445 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9446 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9447 { } /* end */
9448};
9449
9450static struct hda_verb alc262_hp_rp5700_verbs[] = {
9451 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9452 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9453 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9454 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9455 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9456 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9457 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9458 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9459 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9460 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9461 {}
9462};
9463
9464static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9465 .num_items = 1,
9466 .items = {
9467 { "Line", 0x1 },
9468 },
9469};
9470
Takashi Iwai0724ea22007-08-23 00:31:43 +02009471/* bind hp and internal speaker mute (with plug check) */
9472static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9473 struct snd_ctl_elem_value *ucontrol)
9474{
9475 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9476 long *valp = ucontrol->value.integer.value;
9477 int change;
9478
9479 /* change hp mute */
9480 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9481 HDA_AMP_MUTE,
9482 valp[0] ? 0 : HDA_AMP_MUTE);
9483 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9484 HDA_AMP_MUTE,
9485 valp[1] ? 0 : HDA_AMP_MUTE);
9486 if (change) {
9487 /* change speaker according to HP jack state */
9488 struct alc_spec *spec = codec->spec;
9489 unsigned int mute;
9490 if (spec->jack_present)
9491 mute = HDA_AMP_MUTE;
9492 else
9493 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9494 HDA_OUTPUT, 0);
9495 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9496 HDA_AMP_MUTE, mute);
9497 }
9498 return change;
9499}
Takashi Iwai5b319542007-07-26 11:49:22 +02009500
Kailang Yang272a5272007-05-14 11:00:38 +02009501static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009502 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9503 {
9504 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9505 .name = "Master Playback Switch",
9506 .info = snd_hda_mixer_amp_switch_info,
9507 .get = snd_hda_mixer_amp_switch_get,
9508 .put = alc262_sony_master_sw_put,
9509 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9510 },
Kailang Yang272a5272007-05-14 11:00:38 +02009511 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9512 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9513 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9514 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9515 { } /* end */
9516};
9517
Kailang Yang83c34212007-07-05 11:43:05 +02009518static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9519 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9520 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9521 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9522 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9523 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9524 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9525 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9526 { } /* end */
9527};
Kailang Yang272a5272007-05-14 11:00:38 +02009528
Tony Vroonba340e82009-02-02 19:01:30 +00009529static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9530 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9531 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9532 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9533 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9534 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9535 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9536 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9537 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9538 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9539 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9540 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9541 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9542 { } /* end */
9543};
9544
9545static struct hda_verb alc262_tyan_verbs[] = {
9546 /* Headphone automute */
9547 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9548 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9549 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9550
9551 /* P11 AUX_IN, white 4-pin connector */
9552 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9553 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9554 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9555 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9556
9557 {}
9558};
9559
9560/* unsolicited event for HP jack sensing */
9561static void alc262_tyan_automute(struct hda_codec *codec)
9562{
9563 unsigned int mute;
9564 unsigned int present;
9565
9566 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9567 present = snd_hda_codec_read(codec, 0x1b, 0,
9568 AC_VERB_GET_PIN_SENSE, 0);
9569 present = (present & 0x80000000) != 0;
9570 if (present) {
9571 /* mute line output on ATX panel */
9572 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9573 HDA_AMP_MUTE, HDA_AMP_MUTE);
9574 } else {
9575 /* unmute line output if necessary */
9576 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9577 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9578 HDA_AMP_MUTE, mute);
9579 }
9580}
9581
9582static void alc262_tyan_unsol_event(struct hda_codec *codec,
9583 unsigned int res)
9584{
9585 if ((res >> 26) != ALC880_HP_EVENT)
9586 return;
9587 alc262_tyan_automute(codec);
9588}
9589
Kailang Yangdf694da2005-12-05 19:42:22 +01009590#define alc262_capture_mixer alc882_capture_mixer
9591#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9592
9593/*
9594 * generic initialization of ADC, input mixers and output mixers
9595 */
9596static struct hda_verb alc262_init_verbs[] = {
9597 /*
9598 * Unmute ADC0-2 and set the default input to mic-in
9599 */
9600 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9601 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9602 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9603 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9604 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9605 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9606
Takashi Iwaicb53c622007-08-10 17:21:45 +02009607 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009608 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009609 * Note: PASD motherboards uses the Line In 2 as the input for
9610 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009611 */
9612 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009613 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9614 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9615 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9616 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9617 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009618
9619 /*
9620 * Set up output mixers (0x0c - 0x0e)
9621 */
9622 /* set vol=0 to output mixers */
9623 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9624 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9625 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9626 /* set up input amps for analog loopback */
9627 /* Amp Indices: DAC = 0, mixer = 1 */
9628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9629 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9630 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9631 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9632 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9633 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9634
9635 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9637 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9638 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9639 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9640 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9641
9642 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9643 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9644 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9645 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9646 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009647
Kailang Yangdf694da2005-12-05 19:42:22 +01009648 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9649 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009650
Kailang Yangdf694da2005-12-05 19:42:22 +01009651 /* FIXME: use matrix-type input source selection */
9652 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9653 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9654 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9655 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9656 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9657 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9658 /* Input mixer2 */
9659 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9660 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9661 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9662 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9663 /* Input mixer3 */
9664 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9665 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9666 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009667 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009668
9669 { }
9670};
9671
Kailang Yang4e555fe2008-08-26 13:05:55 +02009672static struct hda_verb alc262_eapd_verbs[] = {
9673 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9674 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9675 { }
9676};
9677
Kailang Yangccc656c2006-10-17 12:32:26 +02009678static struct hda_verb alc262_hippo_unsol_verbs[] = {
9679 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9680 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9681 {}
9682};
9683
9684static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9685 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9686 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9687 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9688
9689 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9690 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9691 {}
9692};
9693
Kailang Yang272a5272007-05-14 11:00:38 +02009694static struct hda_verb alc262_sony_unsol_verbs[] = {
9695 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9696 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9697 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9698
9699 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9700 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009701 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009702};
9703
Kailang Yang4e555fe2008-08-26 13:05:55 +02009704static struct hda_input_mux alc262_dmic_capture_source = {
9705 .num_items = 2,
9706 .items = {
9707 { "Int DMic", 0x9 },
9708 { "Mic", 0x0 },
9709 },
9710};
9711
9712static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9713 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9714 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9715 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9716 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9717 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009718 { } /* end */
9719};
9720
9721static struct hda_verb alc262_toshiba_s06_verbs[] = {
9722 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9723 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9724 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9725 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9726 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9727 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9728 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9729 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9730 {}
9731};
9732
9733static void alc262_dmic_automute(struct hda_codec *codec)
9734{
9735 unsigned int present;
9736
9737 present = snd_hda_codec_read(codec, 0x18, 0,
9738 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9739 snd_hda_codec_write(codec, 0x22, 0,
9740 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9741}
9742
9743/* toggle speaker-output according to the hp-jack state */
9744static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9745{
9746 unsigned int present;
9747 unsigned char bits;
9748
9749 present = snd_hda_codec_read(codec, 0x15, 0,
9750 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9751 bits = present ? 0 : PIN_OUT;
9752 snd_hda_codec_write(codec, 0x14, 0,
9753 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9754}
9755
9756
9757
9758/* unsolicited event for HP jack sensing */
9759static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9760 unsigned int res)
9761{
9762 if ((res >> 26) == ALC880_HP_EVENT)
9763 alc262_toshiba_s06_speaker_automute(codec);
9764 if ((res >> 26) == ALC880_MIC_EVENT)
9765 alc262_dmic_automute(codec);
9766
9767}
9768
9769static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9770{
9771 alc262_toshiba_s06_speaker_automute(codec);
9772 alc262_dmic_automute(codec);
9773}
9774
Kailang Yangccc656c2006-10-17 12:32:26 +02009775/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009776static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009777{
9778 struct alc_spec *spec = codec->spec;
9779 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009780 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009781
Takashi Iwai5b319542007-07-26 11:49:22 +02009782 /* need to execute and sync at first */
9783 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9784 present = snd_hda_codec_read(codec, 0x15, 0,
9785 AC_VERB_GET_PIN_SENSE, 0);
9786 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009787 if (spec->jack_present) {
9788 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009789 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9790 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009791 } else {
9792 /* unmute internal speaker if necessary */
9793 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009794 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9795 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009796 }
9797}
9798
9799/* unsolicited event for HP jack sensing */
9800static void alc262_hippo_unsol_event(struct hda_codec *codec,
9801 unsigned int res)
9802{
9803 if ((res >> 26) != ALC880_HP_EVENT)
9804 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009805 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009806}
9807
Takashi Iwai5b319542007-07-26 11:49:22 +02009808static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009809{
Kailang Yangccc656c2006-10-17 12:32:26 +02009810 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009811 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009812
Takashi Iwai5b319542007-07-26 11:49:22 +02009813 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9814 present = snd_hda_codec_read(codec, 0x1b, 0,
9815 AC_VERB_GET_PIN_SENSE, 0);
9816 present = (present & 0x80000000) != 0;
9817 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009818 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009819 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9820 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009821 } else {
9822 /* unmute internal speaker if necessary */
9823 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009824 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9825 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009826 }
9827}
9828
9829/* unsolicited event for HP jack sensing */
9830static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9831 unsigned int res)
9832{
9833 if ((res >> 26) != ALC880_HP_EVENT)
9834 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009835 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009836}
9837
Takashi Iwai834be882006-03-01 14:16:17 +01009838/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009839 * nec model
9840 * 0x15 = headphone
9841 * 0x16 = internal speaker
9842 * 0x18 = external mic
9843 */
9844
9845static struct snd_kcontrol_new alc262_nec_mixer[] = {
9846 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9847 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9848
9849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9850 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9851 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9852
9853 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9854 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9855 { } /* end */
9856};
9857
9858static struct hda_verb alc262_nec_verbs[] = {
9859 /* Unmute Speaker */
9860 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9861
9862 /* Headphone */
9863 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9865
9866 /* External mic to headphone */
9867 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9868 /* External mic to speaker */
9869 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9870 {}
9871};
9872
9873/*
Takashi Iwai834be882006-03-01 14:16:17 +01009874 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009875 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9876 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009877 */
9878
9879#define ALC_HP_EVENT 0x37
9880
9881static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9882 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9883 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009884 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9885 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009886 {}
9887};
9888
Jiang zhe0e31daf2008-03-20 12:12:39 +01009889static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9890 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9891 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9892 {}
9893};
9894
Takashi Iwai834be882006-03-01 14:16:17 +01009895static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009896 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009897 .items = {
9898 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009899 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009900 { "CD", 0x4 },
9901 },
9902};
9903
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009904static struct hda_input_mux alc262_HP_capture_source = {
9905 .num_items = 5,
9906 .items = {
9907 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009908 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009909 { "Line", 0x2 },
9910 { "CD", 0x4 },
9911 { "AUX IN", 0x6 },
9912 },
9913};
9914
zhejiangaccbe492007-08-31 12:36:05 +02009915static struct hda_input_mux alc262_HP_D7000_capture_source = {
9916 .num_items = 4,
9917 .items = {
9918 { "Mic", 0x0 },
9919 { "Front Mic", 0x2 },
9920 { "Line", 0x1 },
9921 { "CD", 0x4 },
9922 },
9923};
9924
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009925/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009926static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9927{
9928 struct alc_spec *spec = codec->spec;
9929 unsigned int mute;
9930
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009931 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009932 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009933 /* need to execute and sync at first */
9934 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009935 /* check laptop HP jack */
9936 present = snd_hda_codec_read(codec, 0x14, 0,
9937 AC_VERB_GET_PIN_SENSE, 0);
9938 /* need to execute and sync at first */
9939 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9940 /* check docking HP jack */
9941 present |= snd_hda_codec_read(codec, 0x1b, 0,
9942 AC_VERB_GET_PIN_SENSE, 0);
9943 if (present & AC_PINSENSE_PRESENCE)
9944 spec->jack_present = 1;
9945 else
9946 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009947 spec->sense_updated = 1;
9948 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009949 /* unmute internal speaker only if both HPs are unplugged and
9950 * master switch is on
9951 */
9952 if (spec->jack_present)
9953 mute = HDA_AMP_MUTE;
9954 else
Takashi Iwai834be882006-03-01 14:16:17 +01009955 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009956 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9957 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009958}
9959
9960/* unsolicited event for HP jack sensing */
9961static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9962 unsigned int res)
9963{
9964 if ((res >> 26) != ALC_HP_EVENT)
9965 return;
9966 alc262_fujitsu_automute(codec, 1);
9967}
9968
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009969static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9970{
9971 alc262_fujitsu_automute(codec, 1);
9972}
9973
Takashi Iwai834be882006-03-01 14:16:17 +01009974/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009975static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9976 .ops = &snd_hda_bind_vol,
9977 .values = {
9978 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9979 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9980 0
9981 },
9982};
Takashi Iwai834be882006-03-01 14:16:17 +01009983
Jiang zhe0e31daf2008-03-20 12:12:39 +01009984/* mute/unmute internal speaker according to the hp jack and mute state */
9985static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9986{
9987 struct alc_spec *spec = codec->spec;
9988 unsigned int mute;
9989
9990 if (force || !spec->sense_updated) {
9991 unsigned int present_int_hp;
9992 /* need to execute and sync at first */
9993 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9994 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9995 AC_VERB_GET_PIN_SENSE, 0);
9996 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9997 spec->sense_updated = 1;
9998 }
9999 if (spec->jack_present) {
10000 /* mute internal speaker */
10001 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10002 HDA_AMP_MUTE, HDA_AMP_MUTE);
10003 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10004 HDA_AMP_MUTE, HDA_AMP_MUTE);
10005 } else {
10006 /* unmute internal speaker if necessary */
10007 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10008 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10009 HDA_AMP_MUTE, mute);
10010 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10011 HDA_AMP_MUTE, mute);
10012 }
10013}
10014
10015/* unsolicited event for HP jack sensing */
10016static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10017 unsigned int res)
10018{
10019 if ((res >> 26) != ALC_HP_EVENT)
10020 return;
10021 alc262_lenovo_3000_automute(codec, 1);
10022}
10023
Takashi Iwai834be882006-03-01 14:16:17 +010010024/* bind hp and internal speaker mute (with plug check) */
10025static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10026 struct snd_ctl_elem_value *ucontrol)
10027{
10028 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10029 long *valp = ucontrol->value.integer.value;
10030 int change;
10031
Tony Vroon5d9fab22008-03-14 17:09:18 +010010032 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10033 HDA_AMP_MUTE,
10034 valp ? 0 : HDA_AMP_MUTE);
10035 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10036 HDA_AMP_MUTE,
10037 valp ? 0 : HDA_AMP_MUTE);
10038
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010039 if (change)
10040 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010041 return change;
10042}
10043
10044static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010045 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010046 {
10047 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10048 .name = "Master Playback Switch",
10049 .info = snd_hda_mixer_amp_switch_info,
10050 .get = snd_hda_mixer_amp_switch_get,
10051 .put = alc262_fujitsu_master_sw_put,
10052 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10053 },
10054 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10055 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10056 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10057 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10058 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010059 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10060 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10061 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010062 { } /* end */
10063};
10064
Jiang zhe0e31daf2008-03-20 12:12:39 +010010065/* bind hp and internal speaker mute (with plug check) */
10066static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10067 struct snd_ctl_elem_value *ucontrol)
10068{
10069 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10070 long *valp = ucontrol->value.integer.value;
10071 int change;
10072
10073 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10074 HDA_AMP_MUTE,
10075 valp ? 0 : HDA_AMP_MUTE);
10076
10077 if (change)
10078 alc262_lenovo_3000_automute(codec, 0);
10079 return change;
10080}
10081
10082static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10083 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10084 {
10085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10086 .name = "Master Playback Switch",
10087 .info = snd_hda_mixer_amp_switch_info,
10088 .get = snd_hda_mixer_amp_switch_get,
10089 .put = alc262_lenovo_3000_master_sw_put,
10090 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10091 },
10092 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10093 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10094 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10095 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10096 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10097 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10098 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10099 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10100 { } /* end */
10101};
10102
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010103static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10104 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10105 {
10106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10107 .name = "Master Playback Switch",
10108 .info = snd_hda_mixer_amp_switch_info,
10109 .get = snd_hda_mixer_amp_switch_get,
10110 .put = alc262_sony_master_sw_put,
10111 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
10112 },
10113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10115 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10116 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10117 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10118 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10119 { } /* end */
10120};
10121
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010122/* additional init verbs for Benq laptops */
10123static struct hda_verb alc262_EAPD_verbs[] = {
10124 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10125 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10126 {}
10127};
10128
Kailang Yang83c34212007-07-05 11:43:05 +020010129static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10130 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10131 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10132
10133 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10134 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10135 {}
10136};
10137
Tobin Davisf651b502007-10-26 12:40:47 +020010138/* Samsung Q1 Ultra Vista model setup */
10139static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010140 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10141 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010142 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10143 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10144 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010145 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010146 { } /* end */
10147};
10148
10149static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010150 /* output mixer */
10151 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10152 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10153 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10154 /* speaker */
10155 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10156 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10157 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10158 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10159 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010160 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010161 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10162 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10163 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10164 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10165 /* internal mic */
10166 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10167 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10168 /* ADC, choose mic */
10169 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10170 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10171 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10172 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10173 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10174 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10175 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10176 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10177 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10178 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010179 {}
10180};
10181
Tobin Davisf651b502007-10-26 12:40:47 +020010182/* mute/unmute internal speaker according to the hp jack and mute state */
10183static void alc262_ultra_automute(struct hda_codec *codec)
10184{
10185 struct alc_spec *spec = codec->spec;
10186 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010187
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010188 mute = 0;
10189 /* auto-mute only when HP is used as HP */
10190 if (!spec->cur_mux[0]) {
10191 unsigned int present;
10192 /* need to execute and sync at first */
10193 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10194 present = snd_hda_codec_read(codec, 0x15, 0,
10195 AC_VERB_GET_PIN_SENSE, 0);
10196 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10197 if (spec->jack_present)
10198 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010199 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010200 /* mute/unmute internal speaker */
10201 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10202 HDA_AMP_MUTE, mute);
10203 /* mute/unmute HP */
10204 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10205 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010206}
10207
10208/* unsolicited event for HP jack sensing */
10209static void alc262_ultra_unsol_event(struct hda_codec *codec,
10210 unsigned int res)
10211{
10212 if ((res >> 26) != ALC880_HP_EVENT)
10213 return;
10214 alc262_ultra_automute(codec);
10215}
10216
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010217static struct hda_input_mux alc262_ultra_capture_source = {
10218 .num_items = 2,
10219 .items = {
10220 { "Mic", 0x1 },
10221 { "Headphone", 0x7 },
10222 },
10223};
10224
10225static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10226 struct snd_ctl_elem_value *ucontrol)
10227{
10228 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10229 struct alc_spec *spec = codec->spec;
10230 int ret;
10231
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010232 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010233 if (!ret)
10234 return 0;
10235 /* reprogram the HP pin as mic or HP according to the input source */
10236 snd_hda_codec_write_cache(codec, 0x15, 0,
10237 AC_VERB_SET_PIN_WIDGET_CONTROL,
10238 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10239 alc262_ultra_automute(codec); /* mute/unmute HP */
10240 return ret;
10241}
10242
10243static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10244 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10245 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10246 {
10247 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10248 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010249 .info = alc_mux_enum_info,
10250 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010251 .put = alc262_ultra_mux_enum_put,
10252 },
10253 { } /* end */
10254};
10255
Kailang Yangdf694da2005-12-05 19:42:22 +010010256/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010257static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10258 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010259{
10260 hda_nid_t nid;
10261 int err;
10262
10263 spec->multiout.num_dacs = 1; /* only use one dac */
10264 spec->multiout.dac_nids = spec->private_dac_nids;
10265 spec->multiout.dac_nids[0] = 2;
10266
10267 nid = cfg->line_out_pins[0];
10268 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010269 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10270 "Front Playback Volume",
10271 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10272 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010273 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010274 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10275 "Front Playback Switch",
10276 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10277 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010278 return err;
10279 }
10280
Takashi Iwai82bc9552006-03-21 11:24:42 +010010281 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010282 if (nid) {
10283 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010284 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10285 "Speaker Playback Volume",
10286 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10287 HDA_OUTPUT));
10288 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010289 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010290 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10291 "Speaker Playback Switch",
10292 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10293 HDA_OUTPUT));
10294 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010295 return err;
10296 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010297 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10298 "Speaker Playback Switch",
10299 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10300 HDA_OUTPUT));
10301 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010302 return err;
10303 }
10304 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010305 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010306 if (nid) {
10307 /* spec->multiout.hp_nid = 2; */
10308 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010309 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10310 "Headphone Playback Volume",
10311 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10312 HDA_OUTPUT));
10313 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010314 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010315 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10316 "Headphone Playback Switch",
10317 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10318 HDA_OUTPUT));
10319 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010320 return err;
10321 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010322 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10323 "Headphone Playback Switch",
10324 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10325 HDA_OUTPUT));
10326 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010327 return err;
10328 }
10329 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010330 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010331}
10332
10333/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010334#define alc262_auto_create_analog_input_ctls \
10335 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010336
10337/*
10338 * generic initialization of ADC, input mixers and output mixers
10339 */
10340static struct hda_verb alc262_volume_init_verbs[] = {
10341 /*
10342 * Unmute ADC0-2 and set the default input to mic-in
10343 */
10344 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10345 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10346 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10347 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10348 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10349 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10350
Takashi Iwaicb53c622007-08-10 17:21:45 +020010351 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010352 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010353 * Note: PASD motherboards uses the Line In 2 as the input for
10354 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010355 */
10356 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010357 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10358 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10359 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10360 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10361 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010362
10363 /*
10364 * Set up output mixers (0x0c - 0x0f)
10365 */
10366 /* set vol=0 to output mixers */
10367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10368 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10369 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010370
Kailang Yangdf694da2005-12-05 19:42:22 +010010371 /* set up input amps for analog loopback */
10372 /* Amp Indices: DAC = 0, mixer = 1 */
10373 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10374 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10375 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10376 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10377 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10378 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10379
10380 /* FIXME: use matrix-type input source selection */
10381 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10382 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10383 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10384 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10385 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10386 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10387 /* Input mixer2 */
10388 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10389 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10390 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10391 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10392 /* Input mixer3 */
10393 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10394 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10395 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10396 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10397
10398 { }
10399};
10400
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010401static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10402 /*
10403 * Unmute ADC0-2 and set the default input to mic-in
10404 */
10405 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10406 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10407 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10408 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10409 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10410 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10411
Takashi Iwaicb53c622007-08-10 17:21:45 +020010412 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010413 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010414 * Note: PASD motherboards uses the Line In 2 as the input for
10415 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010416 */
10417 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010418 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10419 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10420 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10421 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10422 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10423 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10424 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010425
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010426 /*
10427 * Set up output mixers (0x0c - 0x0e)
10428 */
10429 /* set vol=0 to output mixers */
10430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10431 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10432 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10433
10434 /* set up input amps for analog loopback */
10435 /* Amp Indices: DAC = 0, mixer = 1 */
10436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10437 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10438 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10439 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10440 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10441 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10442
Takashi Iwaice875f02008-01-28 18:17:43 +010010443 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010444 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10445 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10446
10447 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10449
10450 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10451 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10452
10453 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10454 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10455 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10456 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10457 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10458
10459 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10460 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10461 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10463 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10464 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10465
10466
10467 /* FIXME: use matrix-type input source selection */
10468 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10469 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10470 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10471 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10472 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10473 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10474 /* Input mixer2 */
10475 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10476 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10477 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10478 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10479 /* Input mixer3 */
10480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10483 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10484
Takashi Iwaice875f02008-01-28 18:17:43 +010010485 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10486
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010487 { }
10488};
10489
Kailang Yangcd7509a2007-01-26 18:33:17 +010010490static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10491 /*
10492 * Unmute ADC0-2 and set the default input to mic-in
10493 */
10494 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10495 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10496 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10497 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10498 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10499 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10500
Takashi Iwaicb53c622007-08-10 17:21:45 +020010501 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010502 * mixer widget
10503 * Note: PASD motherboards uses the Line In 2 as the input for front
10504 * panel mic (mic 2)
10505 */
10506 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10508 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10509 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10510 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10511 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10512 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10513 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10514 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010515 /*
10516 * Set up output mixers (0x0c - 0x0e)
10517 */
10518 /* set vol=0 to output mixers */
10519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10520 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10521 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10522
10523 /* set up input amps for analog loopback */
10524 /* Amp Indices: DAC = 0, mixer = 1 */
10525 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10526 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10527 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10528 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10529 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10530 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10531
10532
10533 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10534 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10535 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10536 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10537 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10538 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10539 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10540
10541 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10542 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10543
10544 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10545 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10546
10547 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10548 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10549 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10550 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10551 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10552 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10553
10554 /* FIXME: use matrix-type input source selection */
10555 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10556 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10557 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10558 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10559 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10560 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10561 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10562 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10563 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10564 /* Input mixer2 */
10565 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10566 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10567 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10568 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10569 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10570 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10571 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10572 /* Input mixer3 */
10573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10574 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10575 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10578 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10580
Takashi Iwaice875f02008-01-28 18:17:43 +010010581 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10582
Kailang Yangcd7509a2007-01-26 18:33:17 +010010583 { }
10584};
10585
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010586static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10587
10588 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10589 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10590 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10591
10592 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10593 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10594 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10595 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10596
10597 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10598 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10599 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10600 {}
10601};
10602
10603
Takashi Iwaicb53c622007-08-10 17:21:45 +020010604#ifdef CONFIG_SND_HDA_POWER_SAVE
10605#define alc262_loopbacks alc880_loopbacks
10606#endif
10607
Kailang Yangdf694da2005-12-05 19:42:22 +010010608/* pcm configuration: identiacal with ALC880 */
10609#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10610#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10611#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10612#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10613
10614/*
10615 * BIOS auto configuration
10616 */
10617static int alc262_parse_auto_config(struct hda_codec *codec)
10618{
10619 struct alc_spec *spec = codec->spec;
10620 int err;
10621 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10622
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010623 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10624 alc262_ignore);
10625 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010626 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010627 if (!spec->autocfg.line_outs) {
10628 if (spec->autocfg.dig_out_pin || spec->autocfg.dig_in_pin) {
10629 spec->multiout.max_channels = 2;
10630 spec->no_analog = 1;
10631 goto dig_only;
10632 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010633 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010634 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010635 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10636 if (err < 0)
10637 return err;
10638 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10639 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010640 return err;
10641
10642 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10643
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010644 dig_only:
10645 if (spec->autocfg.dig_out_pin) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010646 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010647 spec->dig_out_type = spec->autocfg.dig_out_type;
10648 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010649 if (spec->autocfg.dig_in_pin)
10650 spec->dig_in_nid = ALC262_DIGIN_NID;
10651
Takashi Iwai603c4012008-07-30 15:01:44 +020010652 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010653 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010654
Takashi Iwaid88897e2008-10-31 15:01:37 +010010655 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010656 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010657 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010658
Takashi Iwai776e1842007-08-29 15:07:11 +020010659 err = alc_auto_add_mic_boost(codec);
10660 if (err < 0)
10661 return err;
10662
Takashi Iwaie044c392008-10-27 16:56:24 +010010663 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010664 return 1;
10665}
10666
10667#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10668#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10669#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010670#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010671
10672
10673/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010674static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010675{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010676 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010677 alc262_auto_init_multi_out(codec);
10678 alc262_auto_init_hp_out(codec);
10679 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010680 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010681 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010682 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010683}
10684
10685/*
10686 * configuration and preset
10687 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010688static const char *alc262_models[ALC262_MODEL_LAST] = {
10689 [ALC262_BASIC] = "basic",
10690 [ALC262_HIPPO] = "hippo",
10691 [ALC262_HIPPO_1] = "hippo_1",
10692 [ALC262_FUJITSU] = "fujitsu",
10693 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010694 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010695 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010696 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010697 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010698 [ALC262_BENQ_T31] = "benq-t31",
10699 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010700 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010701 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010702 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010703 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010704 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010705 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010706 [ALC262_AUTO] = "auto",
10707};
10708
10709static struct snd_pci_quirk alc262_cfg_tbl[] = {
10710 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010711 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010712 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10713 ALC262_HP_BPC),
10714 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10715 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010716 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010717 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010718 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010719 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010720 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010721 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010722 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010723 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010724 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10725 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10726 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010727 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10728 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010729 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010730 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010731 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010732 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10733 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10734 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwai57a5ef42008-11-28 14:46:28 +010010735 SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN",
10736 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010737 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010738 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010739 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010740 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010741 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010742 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010743 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10744 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010745 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010746 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010747 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010748 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010749 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010750 {}
10751};
10752
10753static struct alc_config_preset alc262_presets[] = {
10754 [ALC262_BASIC] = {
10755 .mixers = { alc262_base_mixer },
10756 .init_verbs = { alc262_init_verbs },
10757 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10758 .dac_nids = alc262_dac_nids,
10759 .hp_nid = 0x03,
10760 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10761 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010762 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010763 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010764 [ALC262_HIPPO] = {
10765 .mixers = { alc262_base_mixer },
10766 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10767 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10768 .dac_nids = alc262_dac_nids,
10769 .hp_nid = 0x03,
10770 .dig_out_nid = ALC262_DIGOUT_NID,
10771 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10772 .channel_mode = alc262_modes,
10773 .input_mux = &alc262_capture_source,
10774 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010775 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010776 },
10777 [ALC262_HIPPO_1] = {
10778 .mixers = { alc262_hippo1_mixer },
10779 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10780 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10781 .dac_nids = alc262_dac_nids,
10782 .hp_nid = 0x02,
10783 .dig_out_nid = ALC262_DIGOUT_NID,
10784 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10785 .channel_mode = alc262_modes,
10786 .input_mux = &alc262_capture_source,
10787 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010788 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010789 },
Takashi Iwai834be882006-03-01 14:16:17 +010010790 [ALC262_FUJITSU] = {
10791 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010792 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10793 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010794 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10795 .dac_nids = alc262_dac_nids,
10796 .hp_nid = 0x03,
10797 .dig_out_nid = ALC262_DIGOUT_NID,
10798 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10799 .channel_mode = alc262_modes,
10800 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010801 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010802 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010803 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010804 [ALC262_HP_BPC] = {
10805 .mixers = { alc262_HP_BPC_mixer },
10806 .init_verbs = { alc262_HP_BPC_init_verbs },
10807 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10808 .dac_nids = alc262_dac_nids,
10809 .hp_nid = 0x03,
10810 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10811 .channel_mode = alc262_modes,
10812 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010813 .unsol_event = alc262_hp_bpc_unsol_event,
10814 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010815 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010816 [ALC262_HP_BPC_D7000_WF] = {
10817 .mixers = { alc262_HP_BPC_WildWest_mixer },
10818 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10819 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10820 .dac_nids = alc262_dac_nids,
10821 .hp_nid = 0x03,
10822 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10823 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010824 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010825 .unsol_event = alc262_hp_wildwest_unsol_event,
10826 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010827 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010828 [ALC262_HP_BPC_D7000_WL] = {
10829 .mixers = { alc262_HP_BPC_WildWest_mixer,
10830 alc262_HP_BPC_WildWest_option_mixer },
10831 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10832 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10833 .dac_nids = alc262_dac_nids,
10834 .hp_nid = 0x03,
10835 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10836 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010837 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010838 .unsol_event = alc262_hp_wildwest_unsol_event,
10839 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010840 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010841 [ALC262_HP_TC_T5735] = {
10842 .mixers = { alc262_hp_t5735_mixer },
10843 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10844 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10845 .dac_nids = alc262_dac_nids,
10846 .hp_nid = 0x03,
10847 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10848 .channel_mode = alc262_modes,
10849 .input_mux = &alc262_capture_source,
10850 .unsol_event = alc262_hp_t5735_unsol_event,
10851 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010852 },
10853 [ALC262_HP_RP5700] = {
10854 .mixers = { alc262_hp_rp5700_mixer },
10855 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10856 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10857 .dac_nids = alc262_dac_nids,
10858 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10859 .channel_mode = alc262_modes,
10860 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010861 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010862 [ALC262_BENQ_ED8] = {
10863 .mixers = { alc262_base_mixer },
10864 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10865 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10866 .dac_nids = alc262_dac_nids,
10867 .hp_nid = 0x03,
10868 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10869 .channel_mode = alc262_modes,
10870 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010871 },
Kailang Yang272a5272007-05-14 11:00:38 +020010872 [ALC262_SONY_ASSAMD] = {
10873 .mixers = { alc262_sony_mixer },
10874 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10875 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10876 .dac_nids = alc262_dac_nids,
10877 .hp_nid = 0x02,
10878 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10879 .channel_mode = alc262_modes,
10880 .input_mux = &alc262_capture_source,
10881 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010882 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010883 },
10884 [ALC262_BENQ_T31] = {
10885 .mixers = { alc262_benq_t31_mixer },
10886 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10887 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10888 .dac_nids = alc262_dac_nids,
10889 .hp_nid = 0x03,
10890 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10891 .channel_mode = alc262_modes,
10892 .input_mux = &alc262_capture_source,
10893 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010894 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010895 },
Tobin Davisf651b502007-10-26 12:40:47 +020010896 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010897 .mixers = { alc262_ultra_mixer },
10898 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010899 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010900 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10901 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010902 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10903 .channel_mode = alc262_modes,
10904 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010905 .adc_nids = alc262_adc_nids, /* ADC0 */
10906 .capsrc_nids = alc262_capsrc_nids,
10907 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010908 .unsol_event = alc262_ultra_unsol_event,
10909 .init_hook = alc262_ultra_automute,
10910 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010911 [ALC262_LENOVO_3000] = {
10912 .mixers = { alc262_lenovo_3000_mixer },
10913 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10914 alc262_lenovo_3000_unsol_verbs },
10915 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10916 .dac_nids = alc262_dac_nids,
10917 .hp_nid = 0x03,
10918 .dig_out_nid = ALC262_DIGOUT_NID,
10919 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10920 .channel_mode = alc262_modes,
10921 .input_mux = &alc262_fujitsu_capture_source,
10922 .unsol_event = alc262_lenovo_3000_unsol_event,
10923 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010924 [ALC262_NEC] = {
10925 .mixers = { alc262_nec_mixer },
10926 .init_verbs = { alc262_nec_verbs },
10927 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10928 .dac_nids = alc262_dac_nids,
10929 .hp_nid = 0x03,
10930 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10931 .channel_mode = alc262_modes,
10932 .input_mux = &alc262_capture_source,
10933 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010934 [ALC262_TOSHIBA_S06] = {
10935 .mixers = { alc262_toshiba_s06_mixer },
10936 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10937 alc262_eapd_verbs },
10938 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10939 .capsrc_nids = alc262_dmic_capsrc_nids,
10940 .dac_nids = alc262_dac_nids,
10941 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10942 .dig_out_nid = ALC262_DIGOUT_NID,
10943 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10944 .channel_mode = alc262_modes,
10945 .input_mux = &alc262_dmic_capture_source,
10946 .unsol_event = alc262_toshiba_s06_unsol_event,
10947 .init_hook = alc262_toshiba_s06_init_hook,
10948 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010949 [ALC262_TOSHIBA_RX1] = {
10950 .mixers = { alc262_toshiba_rx1_mixer },
10951 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10952 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10953 .dac_nids = alc262_dac_nids,
10954 .hp_nid = 0x03,
10955 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10956 .channel_mode = alc262_modes,
10957 .input_mux = &alc262_capture_source,
10958 .unsol_event = alc262_hippo_unsol_event,
10959 .init_hook = alc262_hippo_automute,
10960 },
Tony Vroonba340e82009-02-02 19:01:30 +000010961 [ALC262_TYAN] = {
10962 .mixers = { alc262_tyan_mixer },
10963 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
10964 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10965 .dac_nids = alc262_dac_nids,
10966 .hp_nid = 0x02,
10967 .dig_out_nid = ALC262_DIGOUT_NID,
10968 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10969 .channel_mode = alc262_modes,
10970 .input_mux = &alc262_capture_source,
10971 .unsol_event = alc262_tyan_unsol_event,
10972 .init_hook = alc262_tyan_automute,
10973 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010974};
10975
10976static int patch_alc262(struct hda_codec *codec)
10977{
10978 struct alc_spec *spec;
10979 int board_config;
10980 int err;
10981
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010982 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010983 if (spec == NULL)
10984 return -ENOMEM;
10985
10986 codec->spec = spec;
10987#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010988 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10989 * under-run
10990 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010991 {
10992 int tmp;
10993 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10994 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10995 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10996 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10997 }
10998#endif
10999
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011000 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11001
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011002 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11003 alc262_models,
11004 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011005
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011006 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011007 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11008 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011009 board_config = ALC262_AUTO;
11010 }
11011
11012 if (board_config == ALC262_AUTO) {
11013 /* automatic parse from the BIOS config */
11014 err = alc262_parse_auto_config(codec);
11015 if (err < 0) {
11016 alc_free(codec);
11017 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011018 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011019 printk(KERN_INFO
11020 "hda_codec: Cannot set up configuration "
11021 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011022 board_config = ALC262_BASIC;
11023 }
11024 }
11025
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011026 err = snd_hda_attach_beep_device(codec, 0x1);
11027 if (err < 0) {
11028 alc_free(codec);
11029 return err;
11030 }
11031
Kailang Yangdf694da2005-12-05 19:42:22 +010011032 if (board_config != ALC262_AUTO)
11033 setup_preset(spec, &alc262_presets[board_config]);
11034
11035 spec->stream_name_analog = "ALC262 Analog";
11036 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11037 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011038
Kailang Yangdf694da2005-12-05 19:42:22 +010011039 spec->stream_name_digital = "ALC262 Digital";
11040 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11041 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11042
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011043 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011044 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011045 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011046 unsigned int wcap = get_wcaps(codec, 0x07);
11047
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011048 /* get type */
11049 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011050 if (wcap != AC_WID_AUD_IN) {
11051 spec->adc_nids = alc262_adc_nids_alt;
11052 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011053 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011054 } else {
11055 spec->adc_nids = alc262_adc_nids;
11056 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011057 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011058 }
11059 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011060 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011061 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010011062 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011063
Takashi Iwai2134ea42008-01-10 16:53:55 +010011064 spec->vmaster_nid = 0x0c;
11065
Kailang Yangdf694da2005-12-05 19:42:22 +010011066 codec->patch_ops = alc_patch_ops;
11067 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011068 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011069#ifdef CONFIG_SND_HDA_POWER_SAVE
11070 if (!spec->loopback.amplist)
11071 spec->loopback.amplist = alc262_loopbacks;
11072#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011073 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011074
Kailang Yangdf694da2005-12-05 19:42:22 +010011075 return 0;
11076}
11077
Kailang Yangdf694da2005-12-05 19:42:22 +010011078/*
Kailang Yanga361d842007-06-05 12:30:55 +020011079 * ALC268 channel source setting (2 channel)
11080 */
11081#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11082#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011083
Kailang Yanga361d842007-06-05 12:30:55 +020011084static hda_nid_t alc268_dac_nids[2] = {
11085 /* front, hp */
11086 0x02, 0x03
11087};
11088
11089static hda_nid_t alc268_adc_nids[2] = {
11090 /* ADC0-1 */
11091 0x08, 0x07
11092};
11093
11094static hda_nid_t alc268_adc_nids_alt[1] = {
11095 /* ADC0 */
11096 0x08
11097};
11098
Takashi Iwaie1406342008-02-11 18:32:32 +010011099static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11100
Kailang Yanga361d842007-06-05 12:30:55 +020011101static struct snd_kcontrol_new alc268_base_mixer[] = {
11102 /* output mixer control */
11103 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11104 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11105 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11106 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011107 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11108 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11109 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011110 { }
11111};
11112
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011113/* bind Beep switches of both NID 0x0f and 0x10 */
11114static struct hda_bind_ctls alc268_bind_beep_sw = {
11115 .ops = &snd_hda_bind_sw,
11116 .values = {
11117 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11118 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11119 0
11120 },
11121};
11122
11123static struct snd_kcontrol_new alc268_beep_mixer[] = {
11124 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11125 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11126 { }
11127};
11128
Kailang Yangd1a991a2007-08-15 16:21:59 +020011129static struct hda_verb alc268_eapd_verbs[] = {
11130 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11131 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11132 { }
11133};
11134
Takashi Iwaid2738092007-08-16 14:59:45 +020011135/* Toshiba specific */
11136#define alc268_toshiba_automute alc262_hippo_automute
11137
11138static struct hda_verb alc268_toshiba_verbs[] = {
11139 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11140 { } /* end */
11141};
11142
Kailang Yang8ef355d2008-08-26 13:10:22 +020011143static struct hda_input_mux alc268_acer_lc_capture_source = {
11144 .num_items = 2,
11145 .items = {
11146 { "i-Mic", 0x6 },
11147 { "E-Mic", 0x0 },
11148 },
11149};
11150
Takashi Iwaid2738092007-08-16 14:59:45 +020011151/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011152/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011153static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11154 .ops = &snd_hda_bind_vol,
11155 .values = {
11156 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11157 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11158 0
11159 },
11160};
11161
Takashi Iwai889c4392007-08-23 18:56:52 +020011162/* mute/unmute internal speaker according to the hp jack and mute state */
11163static void alc268_acer_automute(struct hda_codec *codec, int force)
11164{
11165 struct alc_spec *spec = codec->spec;
11166 unsigned int mute;
11167
11168 if (force || !spec->sense_updated) {
11169 unsigned int present;
11170 present = snd_hda_codec_read(codec, 0x14, 0,
11171 AC_VERB_GET_PIN_SENSE, 0);
11172 spec->jack_present = (present & 0x80000000) != 0;
11173 spec->sense_updated = 1;
11174 }
11175 if (spec->jack_present)
11176 mute = HDA_AMP_MUTE; /* mute internal speaker */
11177 else /* unmute internal speaker if necessary */
11178 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11179 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11180 HDA_AMP_MUTE, mute);
11181}
11182
11183
11184/* bind hp and internal speaker mute (with plug check) */
11185static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11186 struct snd_ctl_elem_value *ucontrol)
11187{
11188 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11189 long *valp = ucontrol->value.integer.value;
11190 int change;
11191
11192 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11193 HDA_AMP_MUTE,
11194 valp[0] ? 0 : HDA_AMP_MUTE);
11195 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11196 HDA_AMP_MUTE,
11197 valp[1] ? 0 : HDA_AMP_MUTE);
11198 if (change)
11199 alc268_acer_automute(codec, 0);
11200 return change;
11201}
Takashi Iwaid2738092007-08-16 14:59:45 +020011202
Kailang Yang8ef355d2008-08-26 13:10:22 +020011203static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11204 /* output mixer control */
11205 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11206 {
11207 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11208 .name = "Master Playback Switch",
11209 .info = snd_hda_mixer_amp_switch_info,
11210 .get = snd_hda_mixer_amp_switch_get,
11211 .put = alc268_acer_master_sw_put,
11212 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11213 },
11214 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11215 { }
11216};
11217
Takashi Iwaid2738092007-08-16 14:59:45 +020011218static struct snd_kcontrol_new alc268_acer_mixer[] = {
11219 /* output mixer control */
11220 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11221 {
11222 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11223 .name = "Master Playback Switch",
11224 .info = snd_hda_mixer_amp_switch_info,
11225 .get = snd_hda_mixer_amp_switch_get,
11226 .put = alc268_acer_master_sw_put,
11227 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11228 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011229 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11230 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11231 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011232 { }
11233};
11234
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011235static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11236 /* output mixer control */
11237 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11238 {
11239 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11240 .name = "Master Playback Switch",
11241 .info = snd_hda_mixer_amp_switch_info,
11242 .get = snd_hda_mixer_amp_switch_get,
11243 .put = alc268_acer_master_sw_put,
11244 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11245 },
11246 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11247 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11248 { }
11249};
11250
Kailang Yang8ef355d2008-08-26 13:10:22 +020011251static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11252 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11253 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11254 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11255 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11256 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11257 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11258 { }
11259};
11260
Takashi Iwaid2738092007-08-16 14:59:45 +020011261static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011262 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11263 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011264 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11265 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011266 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11267 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011268 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11269 { }
11270};
11271
11272/* unsolicited event for HP jack sensing */
11273static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11274 unsigned int res)
11275{
Takashi Iwai889c4392007-08-23 18:56:52 +020011276 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011277 return;
11278 alc268_toshiba_automute(codec);
11279}
11280
11281static void alc268_acer_unsol_event(struct hda_codec *codec,
11282 unsigned int res)
11283{
Takashi Iwai889c4392007-08-23 18:56:52 +020011284 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011285 return;
11286 alc268_acer_automute(codec, 1);
11287}
11288
Takashi Iwai889c4392007-08-23 18:56:52 +020011289static void alc268_acer_init_hook(struct hda_codec *codec)
11290{
11291 alc268_acer_automute(codec, 1);
11292}
11293
Kailang Yang8ef355d2008-08-26 13:10:22 +020011294/* toggle speaker-output according to the hp-jack state */
11295static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11296{
11297 unsigned int present;
11298 unsigned char bits;
11299
11300 present = snd_hda_codec_read(codec, 0x15, 0,
11301 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11302 bits = present ? AMP_IN_MUTE(0) : 0;
11303 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11304 AMP_IN_MUTE(0), bits);
11305 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11306 AMP_IN_MUTE(0), bits);
11307}
11308
11309
11310static void alc268_acer_mic_automute(struct hda_codec *codec)
11311{
11312 unsigned int present;
11313
11314 present = snd_hda_codec_read(codec, 0x18, 0,
11315 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11316 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11317 present ? 0x0 : 0x6);
11318}
11319
11320static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11321 unsigned int res)
11322{
11323 if ((res >> 26) == ALC880_HP_EVENT)
11324 alc268_aspire_one_speaker_automute(codec);
11325 if ((res >> 26) == ALC880_MIC_EVENT)
11326 alc268_acer_mic_automute(codec);
11327}
11328
11329static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11330{
11331 alc268_aspire_one_speaker_automute(codec);
11332 alc268_acer_mic_automute(codec);
11333}
11334
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011335static struct snd_kcontrol_new alc268_dell_mixer[] = {
11336 /* output mixer control */
11337 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11338 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11339 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11340 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11341 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11342 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11343 { }
11344};
11345
11346static struct hda_verb alc268_dell_verbs[] = {
11347 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11348 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11349 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11350 { }
11351};
11352
11353/* mute/unmute internal speaker according to the hp jack and mute state */
11354static void alc268_dell_automute(struct hda_codec *codec)
11355{
11356 unsigned int present;
11357 unsigned int mute;
11358
11359 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11360 if (present & 0x80000000)
11361 mute = HDA_AMP_MUTE;
11362 else
11363 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11364 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11365 HDA_AMP_MUTE, mute);
11366}
11367
11368static void alc268_dell_unsol_event(struct hda_codec *codec,
11369 unsigned int res)
11370{
11371 if ((res >> 26) != ALC880_HP_EVENT)
11372 return;
11373 alc268_dell_automute(codec);
11374}
11375
11376#define alc268_dell_init_hook alc268_dell_automute
11377
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011378static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11379 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11380 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11381 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11382 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11383 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11384 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11385 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11386 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11387 { }
11388};
11389
11390static struct hda_verb alc267_quanta_il1_verbs[] = {
11391 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11392 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11393 { }
11394};
11395
11396static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11397{
11398 unsigned int present;
11399
11400 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11401 & AC_PINSENSE_PRESENCE;
11402 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11403 present ? 0 : PIN_OUT);
11404}
11405
11406static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11407{
11408 unsigned int present;
11409
11410 present = snd_hda_codec_read(codec, 0x18, 0,
11411 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11412 snd_hda_codec_write(codec, 0x23, 0,
11413 AC_VERB_SET_CONNECT_SEL,
11414 present ? 0x00 : 0x01);
11415}
11416
11417static void alc267_quanta_il1_automute(struct hda_codec *codec)
11418{
11419 alc267_quanta_il1_hp_automute(codec);
11420 alc267_quanta_il1_mic_automute(codec);
11421}
11422
11423static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11424 unsigned int res)
11425{
11426 switch (res >> 26) {
11427 case ALC880_HP_EVENT:
11428 alc267_quanta_il1_hp_automute(codec);
11429 break;
11430 case ALC880_MIC_EVENT:
11431 alc267_quanta_il1_mic_automute(codec);
11432 break;
11433 }
11434}
11435
Kailang Yanga361d842007-06-05 12:30:55 +020011436/*
11437 * generic initialization of ADC, input mixers and output mixers
11438 */
11439static struct hda_verb alc268_base_init_verbs[] = {
11440 /* Unmute DAC0-1 and set vol = 0 */
11441 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011442 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011443
11444 /*
11445 * Set up output mixers (0x0c - 0x0e)
11446 */
11447 /* set vol=0 to output mixers */
11448 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011449 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11450
11451 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11452 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11453
11454 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11455 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11456 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11457 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11458 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11459 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11460 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11461 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11462
11463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11464 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11465 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11466 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011467 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011468
11469 /* set PCBEEP vol = 0, mute connections */
11470 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11471 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11472 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011473
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011474 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011475
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011476 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11477 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11478 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11479 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011480
Kailang Yanga361d842007-06-05 12:30:55 +020011481 { }
11482};
11483
11484/*
11485 * generic initialization of ADC, input mixers and output mixers
11486 */
11487static struct hda_verb alc268_volume_init_verbs[] = {
11488 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011489 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11490 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011491
11492 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11493 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11494 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11495 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11496 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11497
Kailang Yanga361d842007-06-05 12:30:55 +020011498 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011499 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11500 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11501
11502 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011503 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011504
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011505 /* set PCBEEP vol = 0, mute connections */
11506 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11507 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11508 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011509
11510 { }
11511};
11512
Kailang Yanga361d842007-06-05 12:30:55 +020011513static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11514 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11515 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11516 {
11517 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11518 /* The multiple "Capture Source" controls confuse alsamixer
11519 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011520 */
11521 /* .name = "Capture Source", */
11522 .name = "Input Source",
11523 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011524 .info = alc_mux_enum_info,
11525 .get = alc_mux_enum_get,
11526 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011527 },
11528 { } /* end */
11529};
11530
11531static struct snd_kcontrol_new alc268_capture_mixer[] = {
11532 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11533 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11534 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11535 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11536 {
11537 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11538 /* The multiple "Capture Source" controls confuse alsamixer
11539 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011540 */
11541 /* .name = "Capture Source", */
11542 .name = "Input Source",
11543 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011544 .info = alc_mux_enum_info,
11545 .get = alc_mux_enum_get,
11546 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011547 },
11548 { } /* end */
11549};
11550
11551static struct hda_input_mux alc268_capture_source = {
11552 .num_items = 4,
11553 .items = {
11554 { "Mic", 0x0 },
11555 { "Front Mic", 0x1 },
11556 { "Line", 0x2 },
11557 { "CD", 0x3 },
11558 },
11559};
11560
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011561static struct hda_input_mux alc268_acer_capture_source = {
11562 .num_items = 3,
11563 .items = {
11564 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011565 { "Internal Mic", 0x1 },
11566 { "Line", 0x2 },
11567 },
11568};
11569
11570static struct hda_input_mux alc268_acer_dmic_capture_source = {
11571 .num_items = 3,
11572 .items = {
11573 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011574 { "Internal Mic", 0x6 },
11575 { "Line", 0x2 },
11576 },
11577};
11578
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011579#ifdef CONFIG_SND_DEBUG
11580static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011581 /* Volume widgets */
11582 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11583 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11584 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11585 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11586 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11587 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11588 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11589 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11590 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11591 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11592 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11593 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11594 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011595 /* The below appears problematic on some hardwares */
11596 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011597 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11598 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11599 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11600 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11601
11602 /* Modes for retasking pin widgets */
11603 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11604 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11605 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11606 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11607
11608 /* Controls for GPIO pins, assuming they are configured as outputs */
11609 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11610 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11611 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11612 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11613
11614 /* Switches to allow the digital SPDIF output pin to be enabled.
11615 * The ALC268 does not have an SPDIF input.
11616 */
11617 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11618
11619 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11620 * this output to turn on an external amplifier.
11621 */
11622 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11623 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11624
11625 { } /* end */
11626};
11627#endif
11628
Kailang Yanga361d842007-06-05 12:30:55 +020011629/* create input playback/capture controls for the given pin */
11630static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11631 const char *ctlname, int idx)
11632{
11633 char name[32];
11634 int err;
11635
11636 sprintf(name, "%s Playback Volume", ctlname);
11637 if (nid == 0x14) {
11638 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11639 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11640 HDA_OUTPUT));
11641 if (err < 0)
11642 return err;
11643 } else if (nid == 0x15) {
11644 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11645 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11646 HDA_OUTPUT));
11647 if (err < 0)
11648 return err;
11649 } else
11650 return -1;
11651 sprintf(name, "%s Playback Switch", ctlname);
11652 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11653 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11654 if (err < 0)
11655 return err;
11656 return 0;
11657}
11658
11659/* add playback controls from the parsed DAC table */
11660static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11661 const struct auto_pin_cfg *cfg)
11662{
11663 hda_nid_t nid;
11664 int err;
11665
11666 spec->multiout.num_dacs = 2; /* only use one dac */
11667 spec->multiout.dac_nids = spec->private_dac_nids;
11668 spec->multiout.dac_nids[0] = 2;
11669 spec->multiout.dac_nids[1] = 3;
11670
11671 nid = cfg->line_out_pins[0];
11672 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011673 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011674
11675 nid = cfg->speaker_pins[0];
11676 if (nid == 0x1d) {
11677 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11678 "Speaker Playback Volume",
11679 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11680 if (err < 0)
11681 return err;
11682 }
11683 nid = cfg->hp_pins[0];
11684 if (nid)
11685 alc268_new_analog_output(spec, nid, "Headphone", 0);
11686
11687 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11688 if (nid == 0x16) {
11689 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11690 "Mono Playback Switch",
11691 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11692 if (err < 0)
11693 return err;
11694 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011695 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011696}
11697
11698/* create playback/capture controls for input pins */
11699static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11700 const struct auto_pin_cfg *cfg)
11701{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011702 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011703 int i, idx1;
11704
11705 for (i = 0; i < AUTO_PIN_LAST; i++) {
11706 switch(cfg->input_pins[i]) {
11707 case 0x18:
11708 idx1 = 0; /* Mic 1 */
11709 break;
11710 case 0x19:
11711 idx1 = 1; /* Mic 2 */
11712 break;
11713 case 0x1a:
11714 idx1 = 2; /* Line In */
11715 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011716 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011717 idx1 = 3; /* CD */
11718 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011719 case 0x12:
11720 case 0x13:
11721 idx1 = 6; /* digital mics */
11722 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011723 default:
11724 continue;
11725 }
11726 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11727 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011728 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011729 }
11730 return 0;
11731}
11732
11733static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11734{
11735 struct alc_spec *spec = codec->spec;
11736 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11737 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11738 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11739 unsigned int dac_vol1, dac_vol2;
11740
11741 if (speaker_nid) {
11742 snd_hda_codec_write(codec, speaker_nid, 0,
11743 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11744 snd_hda_codec_write(codec, 0x0f, 0,
11745 AC_VERB_SET_AMP_GAIN_MUTE,
11746 AMP_IN_UNMUTE(1));
11747 snd_hda_codec_write(codec, 0x10, 0,
11748 AC_VERB_SET_AMP_GAIN_MUTE,
11749 AMP_IN_UNMUTE(1));
11750 } else {
11751 snd_hda_codec_write(codec, 0x0f, 0,
11752 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11753 snd_hda_codec_write(codec, 0x10, 0,
11754 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11755 }
11756
11757 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011758 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011759 dac_vol2 = AMP_OUT_ZERO;
11760 else if (line_nid == 0x15)
11761 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011762 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011763 dac_vol2 = AMP_OUT_ZERO;
11764 else if (hp_nid == 0x15)
11765 dac_vol1 = AMP_OUT_ZERO;
11766 if (line_nid != 0x16 || hp_nid != 0x16 ||
11767 spec->autocfg.line_out_pins[1] != 0x16 ||
11768 spec->autocfg.line_out_pins[2] != 0x16)
11769 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11770
11771 snd_hda_codec_write(codec, 0x02, 0,
11772 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11773 snd_hda_codec_write(codec, 0x03, 0,
11774 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11775}
11776
11777/* pcm configuration: identiacal with ALC880 */
11778#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11779#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011780#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011781#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11782
11783/*
11784 * BIOS auto configuration
11785 */
11786static int alc268_parse_auto_config(struct hda_codec *codec)
11787{
11788 struct alc_spec *spec = codec->spec;
11789 int err;
11790 static hda_nid_t alc268_ignore[] = { 0 };
11791
11792 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11793 alc268_ignore);
11794 if (err < 0)
11795 return err;
11796 if (!spec->autocfg.line_outs)
11797 return 0; /* can't find valid BIOS pin config */
11798
11799 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11800 if (err < 0)
11801 return err;
11802 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11803 if (err < 0)
11804 return err;
11805
11806 spec->multiout.max_channels = 2;
11807
11808 /* digital only support output */
11809 if (spec->autocfg.dig_out_pin)
11810 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11811
Takashi Iwai603c4012008-07-30 15:01:44 +020011812 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011813 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011814
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011815 if (spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011816 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011817
Takashi Iwaid88897e2008-10-31 15:01:37 +010011818 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011819 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011820 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011821
Takashi Iwai776e1842007-08-29 15:07:11 +020011822 err = alc_auto_add_mic_boost(codec);
11823 if (err < 0)
11824 return err;
11825
Takashi Iwaie044c392008-10-27 16:56:24 +010011826 store_pin_configs(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011827 return 1;
11828}
11829
11830#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11831#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11832#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11833
11834/* init callback for auto-configuration model -- overriding the default init */
11835static void alc268_auto_init(struct hda_codec *codec)
11836{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011837 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011838 alc268_auto_init_multi_out(codec);
11839 alc268_auto_init_hp_out(codec);
11840 alc268_auto_init_mono_speaker_out(codec);
11841 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011842 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011843 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011844}
11845
11846/*
11847 * configuration and preset
11848 */
11849static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011850 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011851 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011852 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011853 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011854 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011855 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011856 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011857 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011858#ifdef CONFIG_SND_DEBUG
11859 [ALC268_TEST] = "test",
11860#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011861 [ALC268_AUTO] = "auto",
11862};
11863
11864static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011865 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011866 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011867 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011868 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011869 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011870 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11871 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011872 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010011873 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011874 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011875 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011876 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011877 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011878 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011879 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011880 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011881 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011882 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011883 {}
11884};
11885
11886static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011887 [ALC267_QUANTA_IL1] = {
11888 .mixers = { alc267_quanta_il1_mixer },
11889 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11890 alc267_quanta_il1_verbs },
11891 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11892 .dac_nids = alc268_dac_nids,
11893 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11894 .adc_nids = alc268_adc_nids_alt,
11895 .hp_nid = 0x03,
11896 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11897 .channel_mode = alc268_modes,
11898 .input_mux = &alc268_capture_source,
11899 .unsol_event = alc267_quanta_il1_unsol_event,
11900 .init_hook = alc267_quanta_il1_automute,
11901 },
Kailang Yanga361d842007-06-05 12:30:55 +020011902 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011903 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11904 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011905 .init_verbs = { alc268_base_init_verbs },
11906 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11907 .dac_nids = alc268_dac_nids,
11908 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11909 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011910 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011911 .hp_nid = 0x03,
11912 .dig_out_nid = ALC268_DIGOUT_NID,
11913 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11914 .channel_mode = alc268_modes,
11915 .input_mux = &alc268_capture_source,
11916 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011917 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011918 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11919 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011920 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11921 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011922 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11923 .dac_nids = alc268_dac_nids,
11924 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11925 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011926 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011927 .hp_nid = 0x03,
11928 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11929 .channel_mode = alc268_modes,
11930 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011931 .unsol_event = alc268_toshiba_unsol_event,
11932 .init_hook = alc268_toshiba_automute,
11933 },
11934 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011935 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11936 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011937 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11938 alc268_acer_verbs },
11939 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11940 .dac_nids = alc268_dac_nids,
11941 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11942 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011943 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011944 .hp_nid = 0x02,
11945 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11946 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011947 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011948 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011949 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011950 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011951 [ALC268_ACER_DMIC] = {
11952 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
11953 alc268_beep_mixer },
11954 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11955 alc268_acer_verbs },
11956 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11957 .dac_nids = alc268_dac_nids,
11958 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11959 .adc_nids = alc268_adc_nids_alt,
11960 .capsrc_nids = alc268_capsrc_nids,
11961 .hp_nid = 0x02,
11962 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11963 .channel_mode = alc268_modes,
11964 .input_mux = &alc268_acer_dmic_capture_source,
11965 .unsol_event = alc268_acer_unsol_event,
11966 .init_hook = alc268_acer_init_hook,
11967 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011968 [ALC268_ACER_ASPIRE_ONE] = {
11969 .mixers = { alc268_acer_aspire_one_mixer,
11970 alc268_capture_alt_mixer },
11971 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11972 alc268_acer_aspire_one_verbs },
11973 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11974 .dac_nids = alc268_dac_nids,
11975 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11976 .adc_nids = alc268_adc_nids_alt,
11977 .capsrc_nids = alc268_capsrc_nids,
11978 .hp_nid = 0x03,
11979 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11980 .channel_mode = alc268_modes,
11981 .input_mux = &alc268_acer_lc_capture_source,
11982 .unsol_event = alc268_acer_lc_unsol_event,
11983 .init_hook = alc268_acer_lc_init_hook,
11984 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011985 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011986 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011987 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11988 alc268_dell_verbs },
11989 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11990 .dac_nids = alc268_dac_nids,
11991 .hp_nid = 0x02,
11992 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11993 .channel_mode = alc268_modes,
11994 .unsol_event = alc268_dell_unsol_event,
11995 .init_hook = alc268_dell_init_hook,
11996 .input_mux = &alc268_capture_source,
11997 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011998 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011999 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12000 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012001 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12002 alc268_toshiba_verbs },
12003 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12004 .dac_nids = alc268_dac_nids,
12005 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12006 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012007 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012008 .hp_nid = 0x03,
12009 .dig_out_nid = ALC268_DIGOUT_NID,
12010 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12011 .channel_mode = alc268_modes,
12012 .input_mux = &alc268_capture_source,
12013 .unsol_event = alc268_toshiba_unsol_event,
12014 .init_hook = alc268_toshiba_automute
12015 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012016#ifdef CONFIG_SND_DEBUG
12017 [ALC268_TEST] = {
12018 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12019 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12020 alc268_volume_init_verbs },
12021 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12022 .dac_nids = alc268_dac_nids,
12023 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12024 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012025 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012026 .hp_nid = 0x03,
12027 .dig_out_nid = ALC268_DIGOUT_NID,
12028 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12029 .channel_mode = alc268_modes,
12030 .input_mux = &alc268_capture_source,
12031 },
12032#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012033};
12034
12035static int patch_alc268(struct hda_codec *codec)
12036{
12037 struct alc_spec *spec;
12038 int board_config;
12039 int err;
12040
12041 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12042 if (spec == NULL)
12043 return -ENOMEM;
12044
12045 codec->spec = spec;
12046
12047 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12048 alc268_models,
12049 alc268_cfg_tbl);
12050
12051 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12052 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12053 "trying auto-probe from BIOS...\n");
12054 board_config = ALC268_AUTO;
12055 }
12056
12057 if (board_config == ALC268_AUTO) {
12058 /* automatic parse from the BIOS config */
12059 err = alc268_parse_auto_config(codec);
12060 if (err < 0) {
12061 alc_free(codec);
12062 return err;
12063 } else if (!err) {
12064 printk(KERN_INFO
12065 "hda_codec: Cannot set up configuration "
12066 "from BIOS. Using base mode...\n");
12067 board_config = ALC268_3ST;
12068 }
12069 }
12070
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012071 err = snd_hda_attach_beep_device(codec, 0x1);
12072 if (err < 0) {
12073 alc_free(codec);
12074 return err;
12075 }
12076
Kailang Yanga361d842007-06-05 12:30:55 +020012077 if (board_config != ALC268_AUTO)
12078 setup_preset(spec, &alc268_presets[board_config]);
12079
Kailang Yang2f893282008-05-27 12:14:47 +020012080 if (codec->vendor_id == 0x10ec0267) {
12081 spec->stream_name_analog = "ALC267 Analog";
12082 spec->stream_name_digital = "ALC267 Digital";
12083 } else {
12084 spec->stream_name_analog = "ALC268 Analog";
12085 spec->stream_name_digital = "ALC268 Digital";
12086 }
12087
Kailang Yanga361d842007-06-05 12:30:55 +020012088 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12089 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012090 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012091
Kailang Yanga361d842007-06-05 12:30:55 +020012092 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12093
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012094 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12095 /* override the amp caps for beep generator */
12096 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
12097 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12098 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12099 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12100 (0 << AC_AMPCAP_MUTE_SHIFT));
12101
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012102 if (!spec->adc_nids && spec->input_mux) {
12103 /* check whether NID 0x07 is valid */
12104 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012105 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012106
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012107 /* get type */
12108 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012109 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012110 spec->adc_nids = alc268_adc_nids_alt;
12111 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012112 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012113 } else {
12114 spec->adc_nids = alc268_adc_nids;
12115 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012116 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012117 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012118 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012119 /* set default input source */
12120 for (i = 0; i < spec->num_adc_nids; i++)
12121 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12122 0, AC_VERB_SET_CONNECT_SEL,
12123 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012124 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012125
12126 spec->vmaster_nid = 0x02;
12127
Kailang Yanga361d842007-06-05 12:30:55 +020012128 codec->patch_ops = alc_patch_ops;
12129 if (board_config == ALC268_AUTO)
12130 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012131
Takashi Iwaidaead532008-11-28 12:55:36 +010012132 codec->proc_widget_hook = print_realtek_coef;
12133
Kailang Yanga361d842007-06-05 12:30:55 +020012134 return 0;
12135}
12136
12137/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012138 * ALC269 channel source setting (2 channel)
12139 */
12140#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12141
12142#define alc269_dac_nids alc260_dac_nids
12143
12144static hda_nid_t alc269_adc_nids[1] = {
12145 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012146 0x08,
12147};
12148
Takashi Iwaie01bf502008-08-21 16:25:07 +020012149static hda_nid_t alc269_capsrc_nids[1] = {
12150 0x23,
12151};
12152
12153/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12154 * not a mux!
12155 */
12156
Kailang Yangf53281e2008-07-18 12:36:43 +020012157static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12158 .num_items = 2,
12159 .items = {
12160 { "i-Mic", 0x5 },
12161 { "e-Mic", 0x0 },
12162 },
12163};
12164
12165static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12166 .num_items = 2,
12167 .items = {
12168 { "i-Mic", 0x1 },
12169 { "e-Mic", 0x0 },
12170 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012171};
12172
12173#define alc269_modes alc260_modes
12174#define alc269_capture_source alc880_lg_lw_capture_source
12175
12176static struct snd_kcontrol_new alc269_base_mixer[] = {
12177 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12178 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12179 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12180 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12181 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12182 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12183 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12184 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12185 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12186 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12188 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12189 { } /* end */
12190};
12191
Kailang Yang60db6b52008-08-26 13:13:00 +020012192static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12193 /* output mixer control */
12194 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12195 {
12196 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12197 .name = "Master Playback Switch",
12198 .info = snd_hda_mixer_amp_switch_info,
12199 .get = snd_hda_mixer_amp_switch_get,
12200 .put = alc268_acer_master_sw_put,
12201 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12202 },
12203 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12204 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12205 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12206 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12207 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12208 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012209 { }
12210};
12211
Tony Vroon64154832008-11-06 15:08:49 +000012212static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12213 /* output mixer control */
12214 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12215 {
12216 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12217 .name = "Master Playback Switch",
12218 .info = snd_hda_mixer_amp_switch_info,
12219 .get = snd_hda_mixer_amp_switch_get,
12220 .put = alc268_acer_master_sw_put,
12221 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12222 },
12223 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12224 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12225 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12226 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12227 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12228 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12229 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12230 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12231 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012232 { }
12233};
12234
Kailang Yangf53281e2008-07-18 12:36:43 +020012235/* bind volumes of both NID 0x0c and 0x0d */
12236static struct hda_bind_ctls alc269_epc_bind_vol = {
12237 .ops = &snd_hda_bind_vol,
12238 .values = {
12239 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12240 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12241 0
12242 },
12243};
12244
12245static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12246 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12247 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12248 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12249 { } /* end */
12250};
12251
Kailang Yangf6a92242007-12-13 16:52:54 +010012252/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012253static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12254 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12255 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012256 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12257 { } /* end */
12258};
12259
12260/* FSC amilo */
12261static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12262 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12263 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12264 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012265 { } /* end */
12266};
12267
Kailang Yang60db6b52008-08-26 13:13:00 +020012268static struct hda_verb alc269_quanta_fl1_verbs[] = {
12269 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12270 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12271 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12272 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12273 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12274 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12275 { }
12276};
12277
Tony Vroon64154832008-11-06 15:08:49 +000012278static struct hda_verb alc269_lifebook_verbs[] = {
12279 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12280 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12281 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12283 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12284 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12285 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12286 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12287 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12288 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12289 { }
12290};
12291
Kailang Yang60db6b52008-08-26 13:13:00 +020012292/* toggle speaker-output according to the hp-jack state */
12293static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12294{
12295 unsigned int present;
12296 unsigned char bits;
12297
12298 present = snd_hda_codec_read(codec, 0x15, 0,
12299 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12300 bits = present ? AMP_IN_MUTE(0) : 0;
12301 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12302 AMP_IN_MUTE(0), bits);
12303 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12304 AMP_IN_MUTE(0), bits);
12305
12306 snd_hda_codec_write(codec, 0x20, 0,
12307 AC_VERB_SET_COEF_INDEX, 0x0c);
12308 snd_hda_codec_write(codec, 0x20, 0,
12309 AC_VERB_SET_PROC_COEF, 0x680);
12310
12311 snd_hda_codec_write(codec, 0x20, 0,
12312 AC_VERB_SET_COEF_INDEX, 0x0c);
12313 snd_hda_codec_write(codec, 0x20, 0,
12314 AC_VERB_SET_PROC_COEF, 0x480);
12315}
12316
Tony Vroon64154832008-11-06 15:08:49 +000012317/* toggle speaker-output according to the hp-jacks state */
12318static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12319{
12320 unsigned int present;
12321 unsigned char bits;
12322
12323 /* Check laptop headphone socket */
12324 present = snd_hda_codec_read(codec, 0x15, 0,
12325 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12326
12327 /* Check port replicator headphone socket */
12328 present |= snd_hda_codec_read(codec, 0x1a, 0,
12329 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12330
12331 bits = present ? AMP_IN_MUTE(0) : 0;
12332 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12333 AMP_IN_MUTE(0), bits);
12334 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12335 AMP_IN_MUTE(0), bits);
12336
12337 snd_hda_codec_write(codec, 0x20, 0,
12338 AC_VERB_SET_COEF_INDEX, 0x0c);
12339 snd_hda_codec_write(codec, 0x20, 0,
12340 AC_VERB_SET_PROC_COEF, 0x680);
12341
12342 snd_hda_codec_write(codec, 0x20, 0,
12343 AC_VERB_SET_COEF_INDEX, 0x0c);
12344 snd_hda_codec_write(codec, 0x20, 0,
12345 AC_VERB_SET_PROC_COEF, 0x480);
12346}
12347
Kailang Yang60db6b52008-08-26 13:13:00 +020012348static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12349{
12350 unsigned int present;
12351
12352 present = snd_hda_codec_read(codec, 0x18, 0,
12353 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12354 snd_hda_codec_write(codec, 0x23, 0,
12355 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12356}
12357
Tony Vroon64154832008-11-06 15:08:49 +000012358static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12359{
12360 unsigned int present_laptop;
12361 unsigned int present_dock;
12362
12363 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12364 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12365
12366 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12367 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12368
12369 /* Laptop mic port overrides dock mic port, design decision */
12370 if (present_dock)
12371 snd_hda_codec_write(codec, 0x23, 0,
12372 AC_VERB_SET_CONNECT_SEL, 0x3);
12373 if (present_laptop)
12374 snd_hda_codec_write(codec, 0x23, 0,
12375 AC_VERB_SET_CONNECT_SEL, 0x0);
12376 if (!present_dock && !present_laptop)
12377 snd_hda_codec_write(codec, 0x23, 0,
12378 AC_VERB_SET_CONNECT_SEL, 0x1);
12379}
12380
Kailang Yang60db6b52008-08-26 13:13:00 +020012381static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12382 unsigned int res)
12383{
12384 if ((res >> 26) == ALC880_HP_EVENT)
12385 alc269_quanta_fl1_speaker_automute(codec);
12386 if ((res >> 26) == ALC880_MIC_EVENT)
12387 alc269_quanta_fl1_mic_automute(codec);
12388}
12389
Tony Vroon64154832008-11-06 15:08:49 +000012390static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12391 unsigned int res)
12392{
12393 if ((res >> 26) == ALC880_HP_EVENT)
12394 alc269_lifebook_speaker_automute(codec);
12395 if ((res >> 26) == ALC880_MIC_EVENT)
12396 alc269_lifebook_mic_autoswitch(codec);
12397}
12398
Kailang Yang60db6b52008-08-26 13:13:00 +020012399static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12400{
12401 alc269_quanta_fl1_speaker_automute(codec);
12402 alc269_quanta_fl1_mic_automute(codec);
12403}
12404
Tony Vroon64154832008-11-06 15:08:49 +000012405static void alc269_lifebook_init_hook(struct hda_codec *codec)
12406{
12407 alc269_lifebook_speaker_automute(codec);
12408 alc269_lifebook_mic_autoswitch(codec);
12409}
12410
Kailang Yang60db6b52008-08-26 13:13:00 +020012411static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12412 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12413 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12414 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12415 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12416 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12417 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12418 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12419 {}
12420};
12421
12422static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12423 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12424 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12425 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12426 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12427 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12428 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12429 {}
12430};
12431
12432/* toggle speaker-output according to the hp-jack state */
12433static void alc269_speaker_automute(struct hda_codec *codec)
12434{
12435 unsigned int present;
12436 unsigned char bits;
12437
12438 present = snd_hda_codec_read(codec, 0x15, 0,
12439 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12440 bits = present ? AMP_IN_MUTE(0) : 0;
12441 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12442 AMP_IN_MUTE(0), bits);
12443 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12444 AMP_IN_MUTE(0), bits);
12445}
12446
12447static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12448{
12449 unsigned int present;
12450
12451 present = snd_hda_codec_read(codec, 0x18, 0,
12452 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12453 snd_hda_codec_write(codec, 0x23, 0,
12454 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12455}
12456
12457static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12458{
12459 unsigned int present;
12460
12461 present = snd_hda_codec_read(codec, 0x18, 0,
12462 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12463 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12464 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12465 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12466 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12467}
12468
12469/* unsolicited event for HP jack sensing */
12470static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12471 unsigned int res)
12472{
12473 if ((res >> 26) == ALC880_HP_EVENT)
12474 alc269_speaker_automute(codec);
12475
12476 if ((res >> 26) == ALC880_MIC_EVENT)
12477 alc269_eeepc_dmic_automute(codec);
12478}
12479
12480static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12481{
12482 alc269_speaker_automute(codec);
12483 alc269_eeepc_dmic_automute(codec);
12484}
12485
12486/* unsolicited event for HP jack sensing */
12487static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12488 unsigned int res)
12489{
12490 if ((res >> 26) == ALC880_HP_EVENT)
12491 alc269_speaker_automute(codec);
12492
12493 if ((res >> 26) == ALC880_MIC_EVENT)
12494 alc269_eeepc_amic_automute(codec);
12495}
12496
12497static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12498{
12499 alc269_speaker_automute(codec);
12500 alc269_eeepc_amic_automute(codec);
12501}
12502
Kailang Yangf6a92242007-12-13 16:52:54 +010012503/*
12504 * generic initialization of ADC, input mixers and output mixers
12505 */
12506static struct hda_verb alc269_init_verbs[] = {
12507 /*
12508 * Unmute ADC0 and set the default input to mic-in
12509 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012510 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012511
12512 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12513 * analog-loopback mixer widget
12514 * Note: PASD motherboards uses the Line In 2 as the input for
12515 * front panel mic (mic 2)
12516 */
12517 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12523
12524 /*
12525 * Set up output mixers (0x0c - 0x0e)
12526 */
12527 /* set vol=0 to output mixers */
12528 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12529 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12530
12531 /* set up input amps for analog loopback */
12532 /* Amp Indices: DAC = 0, mixer = 1 */
12533 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12534 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12535 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12536 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12537 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12538 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12539
12540 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12541 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12542 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12544 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12545 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12546 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12547
12548 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12549 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12550 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12551 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12552 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12553 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12554 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12555
12556 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12557 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12558
12559 /* FIXME: use matrix-type input source selection */
12560 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12561 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012562 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12563 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012564 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12565 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12566
12567 /* set EAPD */
12568 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12569 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12570 { }
12571};
12572
12573/* add playback controls from the parsed DAC table */
12574static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12575 const struct auto_pin_cfg *cfg)
12576{
12577 hda_nid_t nid;
12578 int err;
12579
12580 spec->multiout.num_dacs = 1; /* only use one dac */
12581 spec->multiout.dac_nids = spec->private_dac_nids;
12582 spec->multiout.dac_nids[0] = 2;
12583
12584 nid = cfg->line_out_pins[0];
12585 if (nid) {
12586 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12587 "Front Playback Volume",
12588 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12589 if (err < 0)
12590 return err;
12591 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12592 "Front Playback Switch",
12593 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12594 if (err < 0)
12595 return err;
12596 }
12597
12598 nid = cfg->speaker_pins[0];
12599 if (nid) {
12600 if (!cfg->line_out_pins[0]) {
12601 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12602 "Speaker Playback Volume",
12603 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12604 HDA_OUTPUT));
12605 if (err < 0)
12606 return err;
12607 }
12608 if (nid == 0x16) {
12609 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12610 "Speaker Playback Switch",
12611 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12612 HDA_OUTPUT));
12613 if (err < 0)
12614 return err;
12615 } else {
12616 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12617 "Speaker Playback Switch",
12618 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12619 HDA_OUTPUT));
12620 if (err < 0)
12621 return err;
12622 }
12623 }
12624 nid = cfg->hp_pins[0];
12625 if (nid) {
12626 /* spec->multiout.hp_nid = 2; */
12627 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12628 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12629 "Headphone Playback Volume",
12630 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12631 HDA_OUTPUT));
12632 if (err < 0)
12633 return err;
12634 }
12635 if (nid == 0x16) {
12636 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12637 "Headphone Playback Switch",
12638 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12639 HDA_OUTPUT));
12640 if (err < 0)
12641 return err;
12642 } else {
12643 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12644 "Headphone Playback Switch",
12645 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12646 HDA_OUTPUT));
12647 if (err < 0)
12648 return err;
12649 }
12650 }
12651 return 0;
12652}
12653
Takashi Iwaiee956e02008-10-31 17:16:31 +010012654static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12655 const struct auto_pin_cfg *cfg)
12656{
12657 int err;
12658
12659 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12660 if (err < 0)
12661 return err;
12662 /* digital-mic input pin is excluded in alc880_auto_create..()
12663 * because it's under 0x18
12664 */
12665 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12666 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012667 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012668 imux->items[imux->num_items].label = "Int Mic";
12669 imux->items[imux->num_items].index = 0x05;
12670 imux->num_items++;
12671 }
12672 return 0;
12673}
Kailang Yangf6a92242007-12-13 16:52:54 +010012674
12675#ifdef CONFIG_SND_HDA_POWER_SAVE
12676#define alc269_loopbacks alc880_loopbacks
12677#endif
12678
12679/* pcm configuration: identiacal with ALC880 */
12680#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12681#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12682#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12683#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12684
12685/*
12686 * BIOS auto configuration
12687 */
12688static int alc269_parse_auto_config(struct hda_codec *codec)
12689{
12690 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012691 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012692 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12693
12694 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12695 alc269_ignore);
12696 if (err < 0)
12697 return err;
12698
12699 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12700 if (err < 0)
12701 return err;
12702 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12703 if (err < 0)
12704 return err;
12705
12706 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12707
12708 if (spec->autocfg.dig_out_pin)
12709 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12710
Takashi Iwai603c4012008-07-30 15:01:44 +020012711 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012712 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012713
Takashi Iwaid88897e2008-10-31 15:01:37 +010012714 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012715 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012716 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012717 /* set default input source */
12718 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12719 0, AC_VERB_SET_CONNECT_SEL,
12720 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012721
12722 err = alc_auto_add_mic_boost(codec);
12723 if (err < 0)
12724 return err;
12725
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012726 if (!spec->cap_mixer)
12727 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012728
Takashi Iwaie044c392008-10-27 16:56:24 +010012729 store_pin_configs(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012730 return 1;
12731}
12732
12733#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12734#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12735#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12736
12737
12738/* init callback for auto-configuration model -- overriding the default init */
12739static void alc269_auto_init(struct hda_codec *codec)
12740{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012741 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012742 alc269_auto_init_multi_out(codec);
12743 alc269_auto_init_hp_out(codec);
12744 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012745 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012746 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012747}
12748
12749/*
12750 * configuration and preset
12751 */
12752static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012753 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012754 [ALC269_QUANTA_FL1] = "quanta",
12755 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012756 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012757 [ALC269_FUJITSU] = "fujitsu",
12758 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012759};
12760
12761static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012762 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012763 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12764 ALC269_ASUS_EEEPC_P703),
12765 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12766 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012767 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12768 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012769 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012770 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012771 {}
12772};
12773
12774static struct alc_config_preset alc269_presets[] = {
12775 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012776 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012777 .init_verbs = { alc269_init_verbs },
12778 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12779 .dac_nids = alc269_dac_nids,
12780 .hp_nid = 0x03,
12781 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12782 .channel_mode = alc269_modes,
12783 .input_mux = &alc269_capture_source,
12784 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012785 [ALC269_QUANTA_FL1] = {
12786 .mixers = { alc269_quanta_fl1_mixer },
12787 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12788 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12789 .dac_nids = alc269_dac_nids,
12790 .hp_nid = 0x03,
12791 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12792 .channel_mode = alc269_modes,
12793 .input_mux = &alc269_capture_source,
12794 .unsol_event = alc269_quanta_fl1_unsol_event,
12795 .init_hook = alc269_quanta_fl1_init_hook,
12796 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012797 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012798 .mixers = { alc269_eeepc_mixer },
12799 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012800 .init_verbs = { alc269_init_verbs,
12801 alc269_eeepc_amic_init_verbs },
12802 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12803 .dac_nids = alc269_dac_nids,
12804 .hp_nid = 0x03,
12805 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12806 .channel_mode = alc269_modes,
12807 .input_mux = &alc269_eeepc_amic_capture_source,
12808 .unsol_event = alc269_eeepc_amic_unsol_event,
12809 .init_hook = alc269_eeepc_amic_inithook,
12810 },
12811 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012812 .mixers = { alc269_eeepc_mixer },
12813 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012814 .init_verbs = { alc269_init_verbs,
12815 alc269_eeepc_dmic_init_verbs },
12816 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12817 .dac_nids = alc269_dac_nids,
12818 .hp_nid = 0x03,
12819 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12820 .channel_mode = alc269_modes,
12821 .input_mux = &alc269_eeepc_dmic_capture_source,
12822 .unsol_event = alc269_eeepc_dmic_unsol_event,
12823 .init_hook = alc269_eeepc_dmic_inithook,
12824 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012825 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012826 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012827 .cap_mixer = alc269_epc_capture_mixer,
12828 .init_verbs = { alc269_init_verbs,
12829 alc269_eeepc_dmic_init_verbs },
12830 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12831 .dac_nids = alc269_dac_nids,
12832 .hp_nid = 0x03,
12833 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12834 .channel_mode = alc269_modes,
12835 .input_mux = &alc269_eeepc_dmic_capture_source,
12836 .unsol_event = alc269_eeepc_dmic_unsol_event,
12837 .init_hook = alc269_eeepc_dmic_inithook,
12838 },
Tony Vroon64154832008-11-06 15:08:49 +000012839 [ALC269_LIFEBOOK] = {
12840 .mixers = { alc269_lifebook_mixer },
12841 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12842 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12843 .dac_nids = alc269_dac_nids,
12844 .hp_nid = 0x03,
12845 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12846 .channel_mode = alc269_modes,
12847 .input_mux = &alc269_capture_source,
12848 .unsol_event = alc269_lifebook_unsol_event,
12849 .init_hook = alc269_lifebook_init_hook,
12850 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012851};
12852
12853static int patch_alc269(struct hda_codec *codec)
12854{
12855 struct alc_spec *spec;
12856 int board_config;
12857 int err;
12858
12859 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12860 if (spec == NULL)
12861 return -ENOMEM;
12862
12863 codec->spec = spec;
12864
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012865 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12866
Kailang Yangf6a92242007-12-13 16:52:54 +010012867 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12868 alc269_models,
12869 alc269_cfg_tbl);
12870
12871 if (board_config < 0) {
12872 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12873 "trying auto-probe from BIOS...\n");
12874 board_config = ALC269_AUTO;
12875 }
12876
12877 if (board_config == ALC269_AUTO) {
12878 /* automatic parse from the BIOS config */
12879 err = alc269_parse_auto_config(codec);
12880 if (err < 0) {
12881 alc_free(codec);
12882 return err;
12883 } else if (!err) {
12884 printk(KERN_INFO
12885 "hda_codec: Cannot set up configuration "
12886 "from BIOS. Using base mode...\n");
12887 board_config = ALC269_BASIC;
12888 }
12889 }
12890
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012891 err = snd_hda_attach_beep_device(codec, 0x1);
12892 if (err < 0) {
12893 alc_free(codec);
12894 return err;
12895 }
12896
Kailang Yangf6a92242007-12-13 16:52:54 +010012897 if (board_config != ALC269_AUTO)
12898 setup_preset(spec, &alc269_presets[board_config]);
12899
12900 spec->stream_name_analog = "ALC269 Analog";
12901 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12902 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12903
12904 spec->stream_name_digital = "ALC269 Digital";
12905 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12906 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12907
12908 spec->adc_nids = alc269_adc_nids;
12909 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012910 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012911 if (!spec->cap_mixer)
12912 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012913 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010012914
12915 codec->patch_ops = alc_patch_ops;
12916 if (board_config == ALC269_AUTO)
12917 spec->init_hook = alc269_auto_init;
12918#ifdef CONFIG_SND_HDA_POWER_SAVE
12919 if (!spec->loopback.amplist)
12920 spec->loopback.amplist = alc269_loopbacks;
12921#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010012922 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010012923
12924 return 0;
12925}
12926
12927/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012928 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12929 */
12930
12931/*
12932 * set the path ways for 2 channel output
12933 * need to set the codec line out and mic 1 pin widgets to inputs
12934 */
12935static struct hda_verb alc861_threestack_ch2_init[] = {
12936 /* set pin widget 1Ah (line in) for input */
12937 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012938 /* set pin widget 18h (mic1/2) for input, for mic also enable
12939 * the vref
12940 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012941 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12942
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012943 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12944#if 0
12945 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12946 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12947#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012948 { } /* end */
12949};
12950/*
12951 * 6ch mode
12952 * need to set the codec line out and mic 1 pin widgets to outputs
12953 */
12954static struct hda_verb alc861_threestack_ch6_init[] = {
12955 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12956 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12957 /* set pin widget 18h (mic1) for output (CLFE)*/
12958 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12959
12960 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012961 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012962
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012963 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12964#if 0
12965 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12966 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12967#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012968 { } /* end */
12969};
12970
12971static struct hda_channel_mode alc861_threestack_modes[2] = {
12972 { 2, alc861_threestack_ch2_init },
12973 { 6, alc861_threestack_ch6_init },
12974};
Takashi Iwai22309c32006-08-09 16:57:28 +020012975/* Set mic1 as input and unmute the mixer */
12976static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12977 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12978 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12979 { } /* end */
12980};
12981/* Set mic1 as output and mute mixer */
12982static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
12983 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12984 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12985 { } /* end */
12986};
12987
12988static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
12989 { 2, alc861_uniwill_m31_ch2_init },
12990 { 4, alc861_uniwill_m31_ch4_init },
12991};
Kailang Yangdf694da2005-12-05 19:42:22 +010012992
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012993/* Set mic1 and line-in as input and unmute the mixer */
12994static struct hda_verb alc861_asus_ch2_init[] = {
12995 /* set pin widget 1Ah (line in) for input */
12996 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012997 /* set pin widget 18h (mic1/2) for input, for mic also enable
12998 * the vref
12999 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013000 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13001
13002 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13003#if 0
13004 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13005 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13006#endif
13007 { } /* end */
13008};
13009/* Set mic1 nad line-in as output and mute mixer */
13010static struct hda_verb alc861_asus_ch6_init[] = {
13011 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13012 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13013 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13014 /* set pin widget 18h (mic1) for output (CLFE)*/
13015 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13016 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13017 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13018 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13019
13020 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13021#if 0
13022 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13023 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13024#endif
13025 { } /* end */
13026};
13027
13028static struct hda_channel_mode alc861_asus_modes[2] = {
13029 { 2, alc861_asus_ch2_init },
13030 { 6, alc861_asus_ch6_init },
13031};
13032
Kailang Yangdf694da2005-12-05 19:42:22 +010013033/* patch-ALC861 */
13034
13035static struct snd_kcontrol_new alc861_base_mixer[] = {
13036 /* output mixer control */
13037 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13038 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13039 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13040 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13041 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13042
13043 /*Input mixer control */
13044 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13045 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13046 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13047 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13048 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13049 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13051 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13052 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13053 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013054
Kailang Yangdf694da2005-12-05 19:42:22 +010013055 { } /* end */
13056};
13057
13058static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13059 /* output mixer control */
13060 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13061 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13062 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13063 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13064 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13065
13066 /* Input mixer control */
13067 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13068 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13069 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13070 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13071 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13072 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13073 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13074 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13075 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13076 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013077
Kailang Yangdf694da2005-12-05 19:42:22 +010013078 {
13079 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13080 .name = "Channel Mode",
13081 .info = alc_ch_mode_info,
13082 .get = alc_ch_mode_get,
13083 .put = alc_ch_mode_put,
13084 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13085 },
13086 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013087};
13088
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013089static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013090 /* output mixer control */
13091 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13092 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13093 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013094
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013095 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013096};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013097
Takashi Iwai22309c32006-08-09 16:57:28 +020013098static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13099 /* output mixer control */
13100 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13101 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13102 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13103 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13104 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13105
13106 /* Input mixer control */
13107 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13108 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13109 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13110 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13111 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13112 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13114 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13115 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13116 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013117
Takashi Iwai22309c32006-08-09 16:57:28 +020013118 {
13119 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13120 .name = "Channel Mode",
13121 .info = alc_ch_mode_info,
13122 .get = alc_ch_mode_get,
13123 .put = alc_ch_mode_put,
13124 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13125 },
13126 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013127};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013128
13129static struct snd_kcontrol_new alc861_asus_mixer[] = {
13130 /* output mixer control */
13131 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13132 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13133 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13134 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13135 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13136
13137 /* Input mixer control */
13138 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13139 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13140 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13141 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13142 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13143 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13145 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13146 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013147 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13148
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013149 {
13150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13151 .name = "Channel Mode",
13152 .info = alc_ch_mode_info,
13153 .get = alc_ch_mode_get,
13154 .put = alc_ch_mode_put,
13155 .private_value = ARRAY_SIZE(alc861_asus_modes),
13156 },
13157 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013158};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013159
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013160/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013161static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013162 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13163 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013164 { }
13165};
13166
Kailang Yangdf694da2005-12-05 19:42:22 +010013167/*
13168 * generic initialization of ADC, input mixers and output mixers
13169 */
13170static struct hda_verb alc861_base_init_verbs[] = {
13171 /*
13172 * Unmute ADC0 and set the default input to mic-in
13173 */
13174 /* port-A for surround (rear panel) */
13175 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13176 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13177 /* port-B for mic-in (rear panel) with vref */
13178 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13179 /* port-C for line-in (rear panel) */
13180 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13181 /* port-D for Front */
13182 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13183 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13184 /* port-E for HP out (front panel) */
13185 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13186 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013187 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013188 /* port-F for mic-in (front panel) with vref */
13189 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13190 /* port-G for CLFE (rear panel) */
13191 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13192 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13193 /* port-H for side (rear panel) */
13194 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13195 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13196 /* CD-in */
13197 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13198 /* route front mic to ADC1*/
13199 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13200 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013201
Kailang Yangdf694da2005-12-05 19:42:22 +010013202 /* Unmute DAC0~3 & spdif out*/
13203 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13204 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13205 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13206 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13207 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013208
Kailang Yangdf694da2005-12-05 19:42:22 +010013209 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13210 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13211 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13212 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13213 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013214
Kailang Yangdf694da2005-12-05 19:42:22 +010013215 /* Unmute Stereo Mixer 15 */
13216 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13217 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13218 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013219 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013220
13221 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13222 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13223 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13224 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13225 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13226 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13227 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13228 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013229 /* hp used DAC 3 (Front) */
13230 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013231 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13232
13233 { }
13234};
13235
13236static struct hda_verb alc861_threestack_init_verbs[] = {
13237 /*
13238 * Unmute ADC0 and set the default input to mic-in
13239 */
13240 /* port-A for surround (rear panel) */
13241 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13242 /* port-B for mic-in (rear panel) with vref */
13243 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13244 /* port-C for line-in (rear panel) */
13245 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13246 /* port-D for Front */
13247 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13248 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13249 /* port-E for HP out (front panel) */
13250 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13251 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013252 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013253 /* port-F for mic-in (front panel) with vref */
13254 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13255 /* port-G for CLFE (rear panel) */
13256 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13257 /* port-H for side (rear panel) */
13258 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13259 /* CD-in */
13260 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13261 /* route front mic to ADC1*/
13262 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13263 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13264 /* Unmute DAC0~3 & spdif out*/
13265 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13266 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13267 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13268 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13269 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013270
Kailang Yangdf694da2005-12-05 19:42:22 +010013271 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13272 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13273 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13274 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13275 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013276
Kailang Yangdf694da2005-12-05 19:42:22 +010013277 /* Unmute Stereo Mixer 15 */
13278 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13279 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13280 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013281 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013282
13283 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13284 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13285 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13286 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13287 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13288 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13289 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13290 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013291 /* hp used DAC 3 (Front) */
13292 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013293 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13294 { }
13295};
Takashi Iwai22309c32006-08-09 16:57:28 +020013296
13297static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13298 /*
13299 * Unmute ADC0 and set the default input to mic-in
13300 */
13301 /* port-A for surround (rear panel) */
13302 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13303 /* port-B for mic-in (rear panel) with vref */
13304 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13305 /* port-C for line-in (rear panel) */
13306 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13307 /* port-D for Front */
13308 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13309 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13310 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013311 /* this has to be set to VREF80 */
13312 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013313 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013314 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013315 /* port-F for mic-in (front panel) with vref */
13316 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13317 /* port-G for CLFE (rear panel) */
13318 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13319 /* port-H for side (rear panel) */
13320 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13321 /* CD-in */
13322 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13323 /* route front mic to ADC1*/
13324 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13325 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13326 /* Unmute DAC0~3 & spdif out*/
13327 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13328 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13329 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13330 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013332
Takashi Iwai22309c32006-08-09 16:57:28 +020013333 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13334 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13335 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13336 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13337 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013338
Takashi Iwai22309c32006-08-09 16:57:28 +020013339 /* Unmute Stereo Mixer 15 */
13340 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13341 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13342 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013343 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013344
13345 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13346 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13347 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13348 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13349 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13350 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13352 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013353 /* hp used DAC 3 (Front) */
13354 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013355 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13356 { }
13357};
13358
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013359static struct hda_verb alc861_asus_init_verbs[] = {
13360 /*
13361 * Unmute ADC0 and set the default input to mic-in
13362 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013363 /* port-A for surround (rear panel)
13364 * according to codec#0 this is the HP jack
13365 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013366 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13367 /* route front PCM to HP */
13368 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13369 /* port-B for mic-in (rear panel) with vref */
13370 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13371 /* port-C for line-in (rear panel) */
13372 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13373 /* port-D for Front */
13374 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13375 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13376 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013377 /* this has to be set to VREF80 */
13378 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013379 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013380 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013381 /* port-F for mic-in (front panel) with vref */
13382 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13383 /* port-G for CLFE (rear panel) */
13384 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13385 /* port-H for side (rear panel) */
13386 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13387 /* CD-in */
13388 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13389 /* route front mic to ADC1*/
13390 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13391 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13392 /* Unmute DAC0~3 & spdif out*/
13393 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13394 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13395 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13396 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13398 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13399 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13400 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13401 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13402 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013403
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013404 /* Unmute Stereo Mixer 15 */
13405 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13406 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13407 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013408 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013409
13410 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13411 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13412 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13413 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13414 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13415 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13416 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13417 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013418 /* hp used DAC 3 (Front) */
13419 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013420 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13421 { }
13422};
13423
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013424/* additional init verbs for ASUS laptops */
13425static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13426 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13427 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13428 { }
13429};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013430
Kailang Yangdf694da2005-12-05 19:42:22 +010013431/*
13432 * generic initialization of ADC, input mixers and output mixers
13433 */
13434static struct hda_verb alc861_auto_init_verbs[] = {
13435 /*
13436 * Unmute ADC0 and set the default input to mic-in
13437 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013438 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013440
Kailang Yangdf694da2005-12-05 19:42:22 +010013441 /* Unmute DAC0~3 & spdif out*/
13442 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13443 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13444 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13445 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13446 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013447
Kailang Yangdf694da2005-12-05 19:42:22 +010013448 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13449 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13450 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13451 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13452 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013453
Kailang Yangdf694da2005-12-05 19:42:22 +010013454 /* Unmute Stereo Mixer 15 */
13455 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13456 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13457 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13458 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13459
13460 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13461 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13462 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13463 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13464 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13465 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13466 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13467 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13468
13469 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13470 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013471 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13472 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013473 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13474 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013475 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13476 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013477
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013478 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013479
13480 { }
13481};
13482
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013483static struct hda_verb alc861_toshiba_init_verbs[] = {
13484 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013485
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013486 { }
13487};
13488
13489/* toggle speaker-output according to the hp-jack state */
13490static void alc861_toshiba_automute(struct hda_codec *codec)
13491{
13492 unsigned int present;
13493
13494 present = snd_hda_codec_read(codec, 0x0f, 0,
13495 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013496 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13497 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13498 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13499 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013500}
13501
13502static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13503 unsigned int res)
13504{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013505 if ((res >> 26) == ALC880_HP_EVENT)
13506 alc861_toshiba_automute(codec);
13507}
13508
Kailang Yangdf694da2005-12-05 19:42:22 +010013509/* pcm configuration: identiacal with ALC880 */
13510#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13511#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13512#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13513#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13514
13515
13516#define ALC861_DIGOUT_NID 0x07
13517
13518static struct hda_channel_mode alc861_8ch_modes[1] = {
13519 { 8, NULL }
13520};
13521
13522static hda_nid_t alc861_dac_nids[4] = {
13523 /* front, surround, clfe, side */
13524 0x03, 0x06, 0x05, 0x04
13525};
13526
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013527static hda_nid_t alc660_dac_nids[3] = {
13528 /* front, clfe, surround */
13529 0x03, 0x05, 0x06
13530};
13531
Kailang Yangdf694da2005-12-05 19:42:22 +010013532static hda_nid_t alc861_adc_nids[1] = {
13533 /* ADC0-2 */
13534 0x08,
13535};
13536
13537static struct hda_input_mux alc861_capture_source = {
13538 .num_items = 5,
13539 .items = {
13540 { "Mic", 0x0 },
13541 { "Front Mic", 0x3 },
13542 { "Line", 0x1 },
13543 { "CD", 0x4 },
13544 { "Mixer", 0x5 },
13545 },
13546};
13547
13548/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013549static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13550 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013551{
13552 int i;
13553 hda_nid_t nid;
13554
13555 spec->multiout.dac_nids = spec->private_dac_nids;
13556 for (i = 0; i < cfg->line_outs; i++) {
13557 nid = cfg->line_out_pins[i];
13558 if (nid) {
13559 if (i >= ARRAY_SIZE(alc861_dac_nids))
13560 continue;
13561 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13562 }
13563 }
13564 spec->multiout.num_dacs = cfg->line_outs;
13565 return 0;
13566}
13567
13568/* add playback controls from the parsed DAC table */
13569static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13570 const struct auto_pin_cfg *cfg)
13571{
13572 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013573 static const char *chname[4] = {
13574 "Front", "Surround", NULL /*CLFE*/, "Side"
13575 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013576 hda_nid_t nid;
13577 int i, idx, err;
13578
13579 for (i = 0; i < cfg->line_outs; i++) {
13580 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013581 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013582 continue;
13583 if (nid == 0x05) {
13584 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013585 err = add_control(spec, ALC_CTL_BIND_MUTE,
13586 "Center Playback Switch",
13587 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13588 HDA_OUTPUT));
13589 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013590 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013591 err = add_control(spec, ALC_CTL_BIND_MUTE,
13592 "LFE Playback Switch",
13593 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13594 HDA_OUTPUT));
13595 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013596 return err;
13597 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013598 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13599 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013600 if (nid == alc861_dac_nids[idx])
13601 break;
13602 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013603 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13604 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13605 HDA_OUTPUT));
13606 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013607 return err;
13608 }
13609 }
13610 return 0;
13611}
13612
13613static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13614{
13615 int err;
13616 hda_nid_t nid;
13617
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013618 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013619 return 0;
13620
13621 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13622 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013623 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13624 "Headphone Playback Switch",
13625 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13626 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013627 return err;
13628 spec->multiout.hp_nid = nid;
13629 }
13630 return 0;
13631}
13632
13633/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013634static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13635 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013636{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013637 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013638 int i, err, idx, idx1;
13639
13640 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013641 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013642 case 0x0c:
13643 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013644 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013645 break;
13646 case 0x0f:
13647 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013648 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013649 break;
13650 case 0x0d:
13651 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013652 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013653 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013654 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013655 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013656 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013657 break;
13658 case 0x11:
13659 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013660 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013661 break;
13662 default:
13663 continue;
13664 }
13665
Takashi Iwai4a471b72005-12-07 13:56:29 +010013666 err = new_analog_input(spec, cfg->input_pins[i],
13667 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013668 if (err < 0)
13669 return err;
13670
Takashi Iwai4a471b72005-12-07 13:56:29 +010013671 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013672 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013673 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013674 }
13675 return 0;
13676}
13677
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013678static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13679 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013680 int pin_type, int dac_idx)
13681{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013682 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13683 pin_type);
13684 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13685 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013686}
13687
13688static void alc861_auto_init_multi_out(struct hda_codec *codec)
13689{
13690 struct alc_spec *spec = codec->spec;
13691 int i;
13692
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013693 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013694 for (i = 0; i < spec->autocfg.line_outs; i++) {
13695 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013696 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013697 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013698 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013699 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013700 }
13701}
13702
13703static void alc861_auto_init_hp_out(struct hda_codec *codec)
13704{
13705 struct alc_spec *spec = codec->spec;
13706 hda_nid_t pin;
13707
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013708 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013709 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013710 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13711 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013712 pin = spec->autocfg.speaker_pins[0];
13713 if (pin)
13714 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013715}
13716
13717static void alc861_auto_init_analog_input(struct hda_codec *codec)
13718{
13719 struct alc_spec *spec = codec->spec;
13720 int i;
13721
13722 for (i = 0; i < AUTO_PIN_LAST; i++) {
13723 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013724 if (nid >= 0x0c && nid <= 0x11) {
13725 snd_hda_codec_write(codec, nid, 0,
13726 AC_VERB_SET_PIN_WIDGET_CONTROL,
13727 i <= AUTO_PIN_FRONT_MIC ?
13728 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013729 }
13730 }
13731}
13732
13733/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013734/* return 1 if successful, 0 if the proper config is not found,
13735 * or a negative error code
13736 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013737static int alc861_parse_auto_config(struct hda_codec *codec)
13738{
13739 struct alc_spec *spec = codec->spec;
13740 int err;
13741 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13742
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013743 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13744 alc861_ignore);
13745 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013746 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013747 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013748 return 0; /* can't find valid BIOS pin config */
13749
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013750 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13751 if (err < 0)
13752 return err;
13753 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13754 if (err < 0)
13755 return err;
13756 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13757 if (err < 0)
13758 return err;
13759 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13760 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013761 return err;
13762
13763 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13764
13765 if (spec->autocfg.dig_out_pin)
13766 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13767
Takashi Iwai603c4012008-07-30 15:01:44 +020013768 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013769 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013770
Takashi Iwaid88897e2008-10-31 15:01:37 +010013771 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013772
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013773 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013774 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013775
13776 spec->adc_nids = alc861_adc_nids;
13777 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013778 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013779
Takashi Iwaie044c392008-10-27 16:56:24 +010013780 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013781 return 1;
13782}
13783
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013784/* additional initialization for auto-configuration model */
13785static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013786{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013787 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013788 alc861_auto_init_multi_out(codec);
13789 alc861_auto_init_hp_out(codec);
13790 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013791 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013792 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013793}
13794
Takashi Iwaicb53c622007-08-10 17:21:45 +020013795#ifdef CONFIG_SND_HDA_POWER_SAVE
13796static struct hda_amp_list alc861_loopbacks[] = {
13797 { 0x15, HDA_INPUT, 0 },
13798 { 0x15, HDA_INPUT, 1 },
13799 { 0x15, HDA_INPUT, 2 },
13800 { 0x15, HDA_INPUT, 3 },
13801 { } /* end */
13802};
13803#endif
13804
Kailang Yangdf694da2005-12-05 19:42:22 +010013805
13806/*
13807 * configuration and preset
13808 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013809static const char *alc861_models[ALC861_MODEL_LAST] = {
13810 [ALC861_3ST] = "3stack",
13811 [ALC660_3ST] = "3stack-660",
13812 [ALC861_3ST_DIG] = "3stack-dig",
13813 [ALC861_6ST_DIG] = "6stack-dig",
13814 [ALC861_UNIWILL_M31] = "uniwill-m31",
13815 [ALC861_TOSHIBA] = "toshiba",
13816 [ALC861_ASUS] = "asus",
13817 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13818 [ALC861_AUTO] = "auto",
13819};
13820
13821static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013822 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013823 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13824 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13825 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013826 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013827 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013828 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013829 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13830 * Any other models that need this preset?
13831 */
13832 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013833 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13834 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013835 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13836 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13837 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13838 /* FIXME: the below seems conflict */
13839 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13840 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13841 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013842 {}
13843};
13844
13845static struct alc_config_preset alc861_presets[] = {
13846 [ALC861_3ST] = {
13847 .mixers = { alc861_3ST_mixer },
13848 .init_verbs = { alc861_threestack_init_verbs },
13849 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13850 .dac_nids = alc861_dac_nids,
13851 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13852 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013853 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013854 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13855 .adc_nids = alc861_adc_nids,
13856 .input_mux = &alc861_capture_source,
13857 },
13858 [ALC861_3ST_DIG] = {
13859 .mixers = { alc861_base_mixer },
13860 .init_verbs = { alc861_threestack_init_verbs },
13861 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13862 .dac_nids = alc861_dac_nids,
13863 .dig_out_nid = ALC861_DIGOUT_NID,
13864 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13865 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013866 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013867 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13868 .adc_nids = alc861_adc_nids,
13869 .input_mux = &alc861_capture_source,
13870 },
13871 [ALC861_6ST_DIG] = {
13872 .mixers = { alc861_base_mixer },
13873 .init_verbs = { alc861_base_init_verbs },
13874 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13875 .dac_nids = alc861_dac_nids,
13876 .dig_out_nid = ALC861_DIGOUT_NID,
13877 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13878 .channel_mode = alc861_8ch_modes,
13879 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13880 .adc_nids = alc861_adc_nids,
13881 .input_mux = &alc861_capture_source,
13882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013883 [ALC660_3ST] = {
13884 .mixers = { alc861_3ST_mixer },
13885 .init_verbs = { alc861_threestack_init_verbs },
13886 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13887 .dac_nids = alc660_dac_nids,
13888 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13889 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013890 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013891 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13892 .adc_nids = alc861_adc_nids,
13893 .input_mux = &alc861_capture_source,
13894 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013895 [ALC861_UNIWILL_M31] = {
13896 .mixers = { alc861_uniwill_m31_mixer },
13897 .init_verbs = { alc861_uniwill_m31_init_verbs },
13898 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13899 .dac_nids = alc861_dac_nids,
13900 .dig_out_nid = ALC861_DIGOUT_NID,
13901 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13902 .channel_mode = alc861_uniwill_m31_modes,
13903 .need_dac_fix = 1,
13904 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13905 .adc_nids = alc861_adc_nids,
13906 .input_mux = &alc861_capture_source,
13907 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013908 [ALC861_TOSHIBA] = {
13909 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013910 .init_verbs = { alc861_base_init_verbs,
13911 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013912 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13913 .dac_nids = alc861_dac_nids,
13914 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13915 .channel_mode = alc883_3ST_2ch_modes,
13916 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13917 .adc_nids = alc861_adc_nids,
13918 .input_mux = &alc861_capture_source,
13919 .unsol_event = alc861_toshiba_unsol_event,
13920 .init_hook = alc861_toshiba_automute,
13921 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013922 [ALC861_ASUS] = {
13923 .mixers = { alc861_asus_mixer },
13924 .init_verbs = { alc861_asus_init_verbs },
13925 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13926 .dac_nids = alc861_dac_nids,
13927 .dig_out_nid = ALC861_DIGOUT_NID,
13928 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13929 .channel_mode = alc861_asus_modes,
13930 .need_dac_fix = 1,
13931 .hp_nid = 0x06,
13932 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13933 .adc_nids = alc861_adc_nids,
13934 .input_mux = &alc861_capture_source,
13935 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013936 [ALC861_ASUS_LAPTOP] = {
13937 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13938 .init_verbs = { alc861_asus_init_verbs,
13939 alc861_asus_laptop_init_verbs },
13940 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13941 .dac_nids = alc861_dac_nids,
13942 .dig_out_nid = ALC861_DIGOUT_NID,
13943 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13944 .channel_mode = alc883_3ST_2ch_modes,
13945 .need_dac_fix = 1,
13946 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13947 .adc_nids = alc861_adc_nids,
13948 .input_mux = &alc861_capture_source,
13949 },
13950};
Kailang Yangdf694da2005-12-05 19:42:22 +010013951
13952
13953static int patch_alc861(struct hda_codec *codec)
13954{
13955 struct alc_spec *spec;
13956 int board_config;
13957 int err;
13958
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013959 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013960 if (spec == NULL)
13961 return -ENOMEM;
13962
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013963 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013964
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013965 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13966 alc861_models,
13967 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013968
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013969 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013970 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13971 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013972 board_config = ALC861_AUTO;
13973 }
13974
13975 if (board_config == ALC861_AUTO) {
13976 /* automatic parse from the BIOS config */
13977 err = alc861_parse_auto_config(codec);
13978 if (err < 0) {
13979 alc_free(codec);
13980 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013981 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013982 printk(KERN_INFO
13983 "hda_codec: Cannot set up configuration "
13984 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013985 board_config = ALC861_3ST_DIG;
13986 }
13987 }
13988
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013989 err = snd_hda_attach_beep_device(codec, 0x23);
13990 if (err < 0) {
13991 alc_free(codec);
13992 return err;
13993 }
13994
Kailang Yangdf694da2005-12-05 19:42:22 +010013995 if (board_config != ALC861_AUTO)
13996 setup_preset(spec, &alc861_presets[board_config]);
13997
13998 spec->stream_name_analog = "ALC861 Analog";
13999 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14000 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14001
14002 spec->stream_name_digital = "ALC861 Digital";
14003 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14004 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14005
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014006 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14007
Takashi Iwai2134ea42008-01-10 16:53:55 +010014008 spec->vmaster_nid = 0x03;
14009
Kailang Yangdf694da2005-12-05 19:42:22 +010014010 codec->patch_ops = alc_patch_ops;
14011 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014012 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014013#ifdef CONFIG_SND_HDA_POWER_SAVE
14014 if (!spec->loopback.amplist)
14015 spec->loopback.amplist = alc861_loopbacks;
14016#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014017 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014018
Kailang Yangdf694da2005-12-05 19:42:22 +010014019 return 0;
14020}
14021
14022/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014023 * ALC861-VD support
14024 *
14025 * Based on ALC882
14026 *
14027 * In addition, an independent DAC
14028 */
14029#define ALC861VD_DIGOUT_NID 0x06
14030
14031static hda_nid_t alc861vd_dac_nids[4] = {
14032 /* front, surr, clfe, side surr */
14033 0x02, 0x03, 0x04, 0x05
14034};
14035
14036/* dac_nids for ALC660vd are in a different order - according to
14037 * Realtek's driver.
14038 * This should probably tesult in a different mixer for 6stack models
14039 * of ALC660vd codecs, but for now there is only 3stack mixer
14040 * - and it is the same as in 861vd.
14041 * adc_nids in ALC660vd are (is) the same as in 861vd
14042 */
14043static hda_nid_t alc660vd_dac_nids[3] = {
14044 /* front, rear, clfe, rear_surr */
14045 0x02, 0x04, 0x03
14046};
14047
14048static hda_nid_t alc861vd_adc_nids[1] = {
14049 /* ADC0 */
14050 0x09,
14051};
14052
Takashi Iwaie1406342008-02-11 18:32:32 +010014053static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14054
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014055/* input MUX */
14056/* FIXME: should be a matrix-type input source selection */
14057static struct hda_input_mux alc861vd_capture_source = {
14058 .num_items = 4,
14059 .items = {
14060 { "Mic", 0x0 },
14061 { "Front Mic", 0x1 },
14062 { "Line", 0x2 },
14063 { "CD", 0x4 },
14064 },
14065};
14066
Kailang Yang272a5272007-05-14 11:00:38 +020014067static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014068 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014069 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014070 { "Ext Mic", 0x0 },
14071 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014072 },
14073};
14074
Kailang Yangd1a991a2007-08-15 16:21:59 +020014075static struct hda_input_mux alc861vd_hp_capture_source = {
14076 .num_items = 2,
14077 .items = {
14078 { "Front Mic", 0x0 },
14079 { "ATAPI Mic", 0x1 },
14080 },
14081};
14082
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014083/*
14084 * 2ch mode
14085 */
14086static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14087 { 2, NULL }
14088};
14089
14090/*
14091 * 6ch mode
14092 */
14093static struct hda_verb alc861vd_6stack_ch6_init[] = {
14094 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14095 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14096 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14097 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14098 { } /* end */
14099};
14100
14101/*
14102 * 8ch mode
14103 */
14104static struct hda_verb alc861vd_6stack_ch8_init[] = {
14105 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14106 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14107 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14108 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14109 { } /* end */
14110};
14111
14112static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14113 { 6, alc861vd_6stack_ch6_init },
14114 { 8, alc861vd_6stack_ch8_init },
14115};
14116
14117static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14118 {
14119 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14120 .name = "Channel Mode",
14121 .info = alc_ch_mode_info,
14122 .get = alc_ch_mode_get,
14123 .put = alc_ch_mode_put,
14124 },
14125 { } /* end */
14126};
14127
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014128/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14129 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14130 */
14131static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14132 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14133 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14134
14135 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14136 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14137
14138 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14139 HDA_OUTPUT),
14140 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14141 HDA_OUTPUT),
14142 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14143 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14144
14145 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14146 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14147
14148 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14149
14150 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14151 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14152 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14153
14154 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14155 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14156 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14157
14158 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14159 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14160
14161 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14162 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14163
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014164 { } /* end */
14165};
14166
14167static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14168 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14169 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14170
14171 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14172
14173 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14174 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14175 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14176
14177 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14178 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14179 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14180
14181 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14182 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14183
14184 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14185 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14186
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014187 { } /* end */
14188};
14189
Kailang Yangbdd148a2007-05-08 15:19:08 +020014190static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14191 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14192 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14193 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14194
14195 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14196
14197 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14200
14201 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14202 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14203 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14204
14205 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14206 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14207
14208 { } /* end */
14209};
14210
Tobin Davisb419f342008-03-07 11:57:51 +010014211/* Pin assignment: Speaker=0x14, HP = 0x15,
14212 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014213 */
14214static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014215 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14216 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014217 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14218 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014219 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14220 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14221 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14222 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14223 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14224 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014225 { } /* end */
14226};
14227
Kailang Yangd1a991a2007-08-15 16:21:59 +020014228/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14229 * Front Mic=0x18, ATAPI Mic = 0x19,
14230 */
14231static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14232 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14233 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14234 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14235 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14236 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14237 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14238 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14239 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014240
Kailang Yangd1a991a2007-08-15 16:21:59 +020014241 { } /* end */
14242};
14243
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014244/*
14245 * generic initialization of ADC, input mixers and output mixers
14246 */
14247static struct hda_verb alc861vd_volume_init_verbs[] = {
14248 /*
14249 * Unmute ADC0 and set the default input to mic-in
14250 */
14251 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14252 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14253
14254 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14255 * the analog-loopback mixer widget
14256 */
14257 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014258 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14260 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14261 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014263
14264 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14266 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014269
14270 /*
14271 * Set up output mixers (0x02 - 0x05)
14272 */
14273 /* set vol=0 to output mixers */
14274 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14275 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14276 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14277 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14278
14279 /* set up input amps for analog loopback */
14280 /* Amp Indices: DAC = 0, mixer = 1 */
14281 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14282 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14283 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14284 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14285 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14286 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14287 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14288 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14289
14290 { }
14291};
14292
14293/*
14294 * 3-stack pin configuration:
14295 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14296 */
14297static struct hda_verb alc861vd_3stack_init_verbs[] = {
14298 /*
14299 * Set pin mode and muting
14300 */
14301 /* set front pin widgets 0x14 for output */
14302 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14304 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14305
14306 /* Mic (rear) pin: input vref at 80% */
14307 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14308 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14309 /* Front Mic pin: input vref at 80% */
14310 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14311 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14312 /* Line In pin: input */
14313 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14315 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14316 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14317 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14318 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14319 /* CD pin widget for input */
14320 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14321
14322 { }
14323};
14324
14325/*
14326 * 6-stack pin configuration:
14327 */
14328static struct hda_verb alc861vd_6stack_init_verbs[] = {
14329 /*
14330 * Set pin mode and muting
14331 */
14332 /* set front pin widgets 0x14 for output */
14333 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14334 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14335 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14336
14337 /* Rear Pin: output 1 (0x0d) */
14338 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14339 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14340 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14341 /* CLFE Pin: output 2 (0x0e) */
14342 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14343 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14344 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14345 /* Side Pin: output 3 (0x0f) */
14346 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14347 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14348 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14349
14350 /* Mic (rear) pin: input vref at 80% */
14351 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14352 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14353 /* Front Mic pin: input vref at 80% */
14354 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14355 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14356 /* Line In pin: input */
14357 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14358 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14359 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14360 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14361 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14362 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14363 /* CD pin widget for input */
14364 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14365
14366 { }
14367};
14368
Kailang Yangbdd148a2007-05-08 15:19:08 +020014369static struct hda_verb alc861vd_eapd_verbs[] = {
14370 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14371 { }
14372};
14373
Kailang Yangf9423e72008-05-27 12:32:25 +020014374static struct hda_verb alc660vd_eapd_verbs[] = {
14375 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14376 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14377 { }
14378};
14379
Kailang Yangbdd148a2007-05-08 15:19:08 +020014380static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14383 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14384 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014385 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014386 {}
14387};
14388
14389/* toggle speaker-output according to the hp-jack state */
14390static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14391{
14392 unsigned int present;
14393 unsigned char bits;
14394
14395 present = snd_hda_codec_read(codec, 0x1b, 0,
14396 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014397 bits = present ? HDA_AMP_MUTE : 0;
14398 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14399 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014400}
14401
14402static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14403{
14404 unsigned int present;
14405 unsigned char bits;
14406
14407 present = snd_hda_codec_read(codec, 0x18, 0,
14408 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014409 bits = present ? HDA_AMP_MUTE : 0;
14410 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14411 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014412}
14413
14414static void alc861vd_lenovo_automute(struct hda_codec *codec)
14415{
14416 alc861vd_lenovo_hp_automute(codec);
14417 alc861vd_lenovo_mic_automute(codec);
14418}
14419
14420static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14421 unsigned int res)
14422{
14423 switch (res >> 26) {
14424 case ALC880_HP_EVENT:
14425 alc861vd_lenovo_hp_automute(codec);
14426 break;
14427 case ALC880_MIC_EVENT:
14428 alc861vd_lenovo_mic_automute(codec);
14429 break;
14430 }
14431}
14432
Kailang Yang272a5272007-05-14 11:00:38 +020014433static struct hda_verb alc861vd_dallas_verbs[] = {
14434 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14435 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14436 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14437 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14438
14439 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14440 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14441 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14442 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14443 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14444 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14445 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14446 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014447
Kailang Yang272a5272007-05-14 11:00:38 +020014448 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14449 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14450 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14451 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14452 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14453 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14454 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14455 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14456
14457 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14458 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14459 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14460 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14461 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14462 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14463 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14464 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14465
14466 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14467 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14468 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14470
14471 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014472 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014473 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14474
14475 { } /* end */
14476};
14477
14478/* toggle speaker-output according to the hp-jack state */
14479static void alc861vd_dallas_automute(struct hda_codec *codec)
14480{
14481 unsigned int present;
14482
14483 present = snd_hda_codec_read(codec, 0x15, 0,
14484 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014485 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14486 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014487}
14488
14489static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14490{
14491 if ((res >> 26) == ALC880_HP_EVENT)
14492 alc861vd_dallas_automute(codec);
14493}
14494
Takashi Iwaicb53c622007-08-10 17:21:45 +020014495#ifdef CONFIG_SND_HDA_POWER_SAVE
14496#define alc861vd_loopbacks alc880_loopbacks
14497#endif
14498
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014499/* pcm configuration: identiacal with ALC880 */
14500#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14501#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14502#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14503#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14504
14505/*
14506 * configuration and preset
14507 */
14508static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14509 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014510 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014511 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014512 [ALC861VD_3ST] = "3stack",
14513 [ALC861VD_3ST_DIG] = "3stack-digout",
14514 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014515 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014516 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014517 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014518 [ALC861VD_AUTO] = "auto",
14519};
14520
14521static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014522 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14523 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014524 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014525 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014526 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014527 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014528 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014529 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014530 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014531 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014532 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014533 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014534 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014535 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014536 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014537 {}
14538};
14539
14540static struct alc_config_preset alc861vd_presets[] = {
14541 [ALC660VD_3ST] = {
14542 .mixers = { alc861vd_3st_mixer },
14543 .init_verbs = { alc861vd_volume_init_verbs,
14544 alc861vd_3stack_init_verbs },
14545 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14546 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014547 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14548 .channel_mode = alc861vd_3stack_2ch_modes,
14549 .input_mux = &alc861vd_capture_source,
14550 },
Mike Crash6963f842007-06-25 12:12:51 +020014551 [ALC660VD_3ST_DIG] = {
14552 .mixers = { alc861vd_3st_mixer },
14553 .init_verbs = { alc861vd_volume_init_verbs,
14554 alc861vd_3stack_init_verbs },
14555 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14556 .dac_nids = alc660vd_dac_nids,
14557 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014558 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14559 .channel_mode = alc861vd_3stack_2ch_modes,
14560 .input_mux = &alc861vd_capture_source,
14561 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014562 [ALC861VD_3ST] = {
14563 .mixers = { alc861vd_3st_mixer },
14564 .init_verbs = { alc861vd_volume_init_verbs,
14565 alc861vd_3stack_init_verbs },
14566 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14567 .dac_nids = alc861vd_dac_nids,
14568 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14569 .channel_mode = alc861vd_3stack_2ch_modes,
14570 .input_mux = &alc861vd_capture_source,
14571 },
14572 [ALC861VD_3ST_DIG] = {
14573 .mixers = { alc861vd_3st_mixer },
14574 .init_verbs = { alc861vd_volume_init_verbs,
14575 alc861vd_3stack_init_verbs },
14576 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14577 .dac_nids = alc861vd_dac_nids,
14578 .dig_out_nid = ALC861VD_DIGOUT_NID,
14579 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14580 .channel_mode = alc861vd_3stack_2ch_modes,
14581 .input_mux = &alc861vd_capture_source,
14582 },
14583 [ALC861VD_6ST_DIG] = {
14584 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14585 .init_verbs = { alc861vd_volume_init_verbs,
14586 alc861vd_6stack_init_verbs },
14587 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14588 .dac_nids = alc861vd_dac_nids,
14589 .dig_out_nid = ALC861VD_DIGOUT_NID,
14590 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14591 .channel_mode = alc861vd_6stack_modes,
14592 .input_mux = &alc861vd_capture_source,
14593 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014594 [ALC861VD_LENOVO] = {
14595 .mixers = { alc861vd_lenovo_mixer },
14596 .init_verbs = { alc861vd_volume_init_verbs,
14597 alc861vd_3stack_init_verbs,
14598 alc861vd_eapd_verbs,
14599 alc861vd_lenovo_unsol_verbs },
14600 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14601 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014602 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14603 .channel_mode = alc861vd_3stack_2ch_modes,
14604 .input_mux = &alc861vd_capture_source,
14605 .unsol_event = alc861vd_lenovo_unsol_event,
14606 .init_hook = alc861vd_lenovo_automute,
14607 },
Kailang Yang272a5272007-05-14 11:00:38 +020014608 [ALC861VD_DALLAS] = {
14609 .mixers = { alc861vd_dallas_mixer },
14610 .init_verbs = { alc861vd_dallas_verbs },
14611 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14612 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014613 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14614 .channel_mode = alc861vd_3stack_2ch_modes,
14615 .input_mux = &alc861vd_dallas_capture_source,
14616 .unsol_event = alc861vd_dallas_unsol_event,
14617 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014618 },
14619 [ALC861VD_HP] = {
14620 .mixers = { alc861vd_hp_mixer },
14621 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14622 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14623 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014624 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014625 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14626 .channel_mode = alc861vd_3stack_2ch_modes,
14627 .input_mux = &alc861vd_hp_capture_source,
14628 .unsol_event = alc861vd_dallas_unsol_event,
14629 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014630 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014631 [ALC660VD_ASUS_V1S] = {
14632 .mixers = { alc861vd_lenovo_mixer },
14633 .init_verbs = { alc861vd_volume_init_verbs,
14634 alc861vd_3stack_init_verbs,
14635 alc861vd_eapd_verbs,
14636 alc861vd_lenovo_unsol_verbs },
14637 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14638 .dac_nids = alc660vd_dac_nids,
14639 .dig_out_nid = ALC861VD_DIGOUT_NID,
14640 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14641 .channel_mode = alc861vd_3stack_2ch_modes,
14642 .input_mux = &alc861vd_capture_source,
14643 .unsol_event = alc861vd_lenovo_unsol_event,
14644 .init_hook = alc861vd_lenovo_automute,
14645 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014646};
14647
14648/*
14649 * BIOS auto configuration
14650 */
14651static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14652 hda_nid_t nid, int pin_type, int dac_idx)
14653{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014654 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014655}
14656
14657static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14658{
14659 struct alc_spec *spec = codec->spec;
14660 int i;
14661
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014662 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014663 for (i = 0; i <= HDA_SIDE; i++) {
14664 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014665 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014666 if (nid)
14667 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014668 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014669 }
14670}
14671
14672
14673static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14674{
14675 struct alc_spec *spec = codec->spec;
14676 hda_nid_t pin;
14677
14678 pin = spec->autocfg.hp_pins[0];
14679 if (pin) /* connect to front and use dac 0 */
14680 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014681 pin = spec->autocfg.speaker_pins[0];
14682 if (pin)
14683 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014684}
14685
14686#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14687#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14688
14689static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14690{
14691 struct alc_spec *spec = codec->spec;
14692 int i;
14693
14694 for (i = 0; i < AUTO_PIN_LAST; i++) {
14695 hda_nid_t nid = spec->autocfg.input_pins[i];
14696 if (alc861vd_is_input_pin(nid)) {
14697 snd_hda_codec_write(codec, nid, 0,
14698 AC_VERB_SET_PIN_WIDGET_CONTROL,
14699 i <= AUTO_PIN_FRONT_MIC ?
14700 PIN_VREF80 : PIN_IN);
14701 if (nid != ALC861VD_PIN_CD_NID)
14702 snd_hda_codec_write(codec, nid, 0,
14703 AC_VERB_SET_AMP_GAIN_MUTE,
14704 AMP_OUT_MUTE);
14705 }
14706 }
14707}
14708
Takashi Iwaif511b012008-08-15 16:46:42 +020014709#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14710
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014711#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14712#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14713
14714/* add playback controls from the parsed DAC table */
14715/* Based on ALC880 version. But ALC861VD has separate,
14716 * different NIDs for mute/unmute switch and volume control */
14717static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14718 const struct auto_pin_cfg *cfg)
14719{
14720 char name[32];
14721 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14722 hda_nid_t nid_v, nid_s;
14723 int i, err;
14724
14725 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014726 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014727 continue;
14728 nid_v = alc861vd_idx_to_mixer_vol(
14729 alc880_dac_to_idx(
14730 spec->multiout.dac_nids[i]));
14731 nid_s = alc861vd_idx_to_mixer_switch(
14732 alc880_dac_to_idx(
14733 spec->multiout.dac_nids[i]));
14734
14735 if (i == 2) {
14736 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014737 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14738 "Center Playback Volume",
14739 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14740 HDA_OUTPUT));
14741 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014742 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014743 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14744 "LFE Playback Volume",
14745 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14746 HDA_OUTPUT));
14747 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014748 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014749 err = add_control(spec, ALC_CTL_BIND_MUTE,
14750 "Center Playback Switch",
14751 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14752 HDA_INPUT));
14753 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014754 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014755 err = add_control(spec, ALC_CTL_BIND_MUTE,
14756 "LFE Playback Switch",
14757 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14758 HDA_INPUT));
14759 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014760 return err;
14761 } else {
14762 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014763 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14764 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14765 HDA_OUTPUT));
14766 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014767 return err;
14768 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014769 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014770 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014771 HDA_INPUT));
14772 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014773 return err;
14774 }
14775 }
14776 return 0;
14777}
14778
14779/* add playback controls for speaker and HP outputs */
14780/* Based on ALC880 version. But ALC861VD has separate,
14781 * different NIDs for mute/unmute switch and volume control */
14782static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14783 hda_nid_t pin, const char *pfx)
14784{
14785 hda_nid_t nid_v, nid_s;
14786 int err;
14787 char name[32];
14788
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014789 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014790 return 0;
14791
14792 if (alc880_is_fixed_pin(pin)) {
14793 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14794 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014795 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014796 spec->multiout.hp_nid = nid_v;
14797 else
14798 spec->multiout.extra_out_nid[0] = nid_v;
14799 /* control HP volume/switch on the output mixer amp */
14800 nid_v = alc861vd_idx_to_mixer_vol(
14801 alc880_fixed_pin_idx(pin));
14802 nid_s = alc861vd_idx_to_mixer_switch(
14803 alc880_fixed_pin_idx(pin));
14804
14805 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014806 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14807 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14808 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014809 return err;
14810 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014811 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14812 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14813 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014814 return err;
14815 } else if (alc880_is_multi_pin(pin)) {
14816 /* set manual connection */
14817 /* we have only a switch on HP-out PIN */
14818 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014819 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14820 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14821 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014822 return err;
14823 }
14824 return 0;
14825}
14826
14827/* parse the BIOS configuration and set up the alc_spec
14828 * return 1 if successful, 0 if the proper config is not found,
14829 * or a negative error code
14830 * Based on ALC880 version - had to change it to override
14831 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14832static int alc861vd_parse_auto_config(struct hda_codec *codec)
14833{
14834 struct alc_spec *spec = codec->spec;
14835 int err;
14836 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14837
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014838 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14839 alc861vd_ignore);
14840 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014841 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014842 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014843 return 0; /* can't find valid BIOS pin config */
14844
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014845 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14846 if (err < 0)
14847 return err;
14848 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14849 if (err < 0)
14850 return err;
14851 err = alc861vd_auto_create_extra_out(spec,
14852 spec->autocfg.speaker_pins[0],
14853 "Speaker");
14854 if (err < 0)
14855 return err;
14856 err = alc861vd_auto_create_extra_out(spec,
14857 spec->autocfg.hp_pins[0],
14858 "Headphone");
14859 if (err < 0)
14860 return err;
14861 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14862 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014863 return err;
14864
14865 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14866
14867 if (spec->autocfg.dig_out_pin)
14868 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14869
Takashi Iwai603c4012008-07-30 15:01:44 +020014870 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014871 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014872
Takashi Iwaid88897e2008-10-31 15:01:37 +010014873 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014874
14875 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014876 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014877
Takashi Iwai776e1842007-08-29 15:07:11 +020014878 err = alc_auto_add_mic_boost(codec);
14879 if (err < 0)
14880 return err;
14881
Takashi Iwaie044c392008-10-27 16:56:24 +010014882 store_pin_configs(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014883 return 1;
14884}
14885
14886/* additional initialization for auto-configuration model */
14887static void alc861vd_auto_init(struct hda_codec *codec)
14888{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014889 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014890 alc861vd_auto_init_multi_out(codec);
14891 alc861vd_auto_init_hp_out(codec);
14892 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014893 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014894 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014895 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014896}
14897
14898static int patch_alc861vd(struct hda_codec *codec)
14899{
14900 struct alc_spec *spec;
14901 int err, board_config;
14902
14903 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14904 if (spec == NULL)
14905 return -ENOMEM;
14906
14907 codec->spec = spec;
14908
14909 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14910 alc861vd_models,
14911 alc861vd_cfg_tbl);
14912
14913 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14914 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14915 "ALC861VD, trying auto-probe from BIOS...\n");
14916 board_config = ALC861VD_AUTO;
14917 }
14918
14919 if (board_config == ALC861VD_AUTO) {
14920 /* automatic parse from the BIOS config */
14921 err = alc861vd_parse_auto_config(codec);
14922 if (err < 0) {
14923 alc_free(codec);
14924 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014925 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014926 printk(KERN_INFO
14927 "hda_codec: Cannot set up configuration "
14928 "from BIOS. Using base mode...\n");
14929 board_config = ALC861VD_3ST;
14930 }
14931 }
14932
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014933 err = snd_hda_attach_beep_device(codec, 0x23);
14934 if (err < 0) {
14935 alc_free(codec);
14936 return err;
14937 }
14938
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014939 if (board_config != ALC861VD_AUTO)
14940 setup_preset(spec, &alc861vd_presets[board_config]);
14941
Kailang Yang2f893282008-05-27 12:14:47 +020014942 if (codec->vendor_id == 0x10ec0660) {
14943 spec->stream_name_analog = "ALC660-VD Analog";
14944 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014945 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010014946 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020014947 } else {
14948 spec->stream_name_analog = "ALC861VD Analog";
14949 spec->stream_name_digital = "ALC861VD Digital";
14950 }
14951
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014952 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14953 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14954
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014955 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14956 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14957
14958 spec->adc_nids = alc861vd_adc_nids;
14959 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014960 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014961 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014962
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014963 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014964 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014965
Takashi Iwai2134ea42008-01-10 16:53:55 +010014966 spec->vmaster_nid = 0x02;
14967
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014968 codec->patch_ops = alc_patch_ops;
14969
14970 if (board_config == ALC861VD_AUTO)
14971 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014972#ifdef CONFIG_SND_HDA_POWER_SAVE
14973 if (!spec->loopback.amplist)
14974 spec->loopback.amplist = alc861vd_loopbacks;
14975#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014976 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014977
14978 return 0;
14979}
14980
14981/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014982 * ALC662 support
14983 *
14984 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14985 * configuration. Each pin widget can choose any input DACs and a mixer.
14986 * Each ADC is connected from a mixer of all inputs. This makes possible
14987 * 6-channel independent captures.
14988 *
14989 * In addition, an independent DAC for the multi-playback (not used in this
14990 * driver yet).
14991 */
14992#define ALC662_DIGOUT_NID 0x06
14993#define ALC662_DIGIN_NID 0x0a
14994
14995static hda_nid_t alc662_dac_nids[4] = {
14996 /* front, rear, clfe, rear_surr */
14997 0x02, 0x03, 0x04
14998};
14999
15000static hda_nid_t alc662_adc_nids[1] = {
15001 /* ADC1-2 */
15002 0x09,
15003};
Takashi Iwaie1406342008-02-11 18:32:32 +010015004
Kailang Yang77a261b2008-02-19 11:38:05 +010015005static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010015006
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015007/* input MUX */
15008/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015009static struct hda_input_mux alc662_capture_source = {
15010 .num_items = 4,
15011 .items = {
15012 { "Mic", 0x0 },
15013 { "Front Mic", 0x1 },
15014 { "Line", 0x2 },
15015 { "CD", 0x4 },
15016 },
15017};
15018
15019static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15020 .num_items = 2,
15021 .items = {
15022 { "Mic", 0x1 },
15023 { "Line", 0x2 },
15024 },
15025};
Kailang Yang291702f2007-10-16 14:28:03 +020015026
15027static struct hda_input_mux alc662_eeepc_capture_source = {
15028 .num_items = 2,
15029 .items = {
15030 { "i-Mic", 0x1 },
15031 { "e-Mic", 0x0 },
15032 },
15033};
15034
Kailang Yang6dda9f42008-05-27 12:05:31 +020015035static struct hda_input_mux alc663_capture_source = {
15036 .num_items = 3,
15037 .items = {
15038 { "Mic", 0x0 },
15039 { "Front Mic", 0x1 },
15040 { "Line", 0x2 },
15041 },
15042};
15043
15044static struct hda_input_mux alc663_m51va_capture_source = {
15045 .num_items = 2,
15046 .items = {
15047 { "Ext-Mic", 0x0 },
15048 { "D-Mic", 0x9 },
15049 },
15050};
15051
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015052/*
15053 * 2ch mode
15054 */
15055static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15056 { 2, NULL }
15057};
15058
15059/*
15060 * 2ch mode
15061 */
15062static struct hda_verb alc662_3ST_ch2_init[] = {
15063 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15064 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15065 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15066 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15067 { } /* end */
15068};
15069
15070/*
15071 * 6ch mode
15072 */
15073static struct hda_verb alc662_3ST_ch6_init[] = {
15074 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15075 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15076 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15077 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15078 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15079 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15080 { } /* end */
15081};
15082
15083static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15084 { 2, alc662_3ST_ch2_init },
15085 { 6, alc662_3ST_ch6_init },
15086};
15087
15088/*
15089 * 2ch mode
15090 */
15091static struct hda_verb alc662_sixstack_ch6_init[] = {
15092 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15093 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15094 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15095 { } /* end */
15096};
15097
15098/*
15099 * 6ch mode
15100 */
15101static struct hda_verb alc662_sixstack_ch8_init[] = {
15102 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15103 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15104 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15105 { } /* end */
15106};
15107
15108static struct hda_channel_mode alc662_5stack_modes[2] = {
15109 { 2, alc662_sixstack_ch6_init },
15110 { 6, alc662_sixstack_ch8_init },
15111};
15112
15113/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15114 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15115 */
15116
15117static struct snd_kcontrol_new alc662_base_mixer[] = {
15118 /* output mixer control */
15119 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015120 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015121 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015122 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015123 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15124 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015125 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15126 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015127 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15128
15129 /*Input mixer control */
15130 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15131 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15132 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15133 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15134 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15135 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15136 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15137 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015138 { } /* end */
15139};
15140
15141static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15142 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015143 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015144 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15145 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15146 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15147 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15148 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15149 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15150 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15151 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15152 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015153 { } /* end */
15154};
15155
15156static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15157 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015158 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015159 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015160 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015161 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15162 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015163 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15164 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015165 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15166 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15167 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15168 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15169 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15170 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15171 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15172 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15173 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015174 { } /* end */
15175};
15176
15177static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15178 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15179 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015180 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15181 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015182 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15183 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15184 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15185 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15186 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015187 { } /* end */
15188};
15189
Kailang Yang291702f2007-10-16 14:28:03 +020015190static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015191 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015192
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015193 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15194 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015195
15196 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15197 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15198 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15199
15200 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15201 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15202 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15203 { } /* end */
15204};
15205
Kailang Yang8c427222008-01-10 13:03:59 +010015206static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015207 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15208 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015209 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15210 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15211 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15212 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15213 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15214 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015215 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015216 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15217 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15218 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15219 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15220 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15221 { } /* end */
15222};
15223
Kailang Yangf1d4e282008-08-26 14:03:29 +020015224static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15225 .ops = &snd_hda_bind_vol,
15226 .values = {
15227 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15228 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15229 0
15230 },
15231};
15232
15233static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15234 .ops = &snd_hda_bind_sw,
15235 .values = {
15236 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15237 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15238 0
15239 },
15240};
15241
Kailang Yang6dda9f42008-05-27 12:05:31 +020015242static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015243 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15244 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15245 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15246 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15247 { } /* end */
15248};
15249
15250static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15251 .ops = &snd_hda_bind_sw,
15252 .values = {
15253 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15254 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15255 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15256 0
15257 },
15258};
15259
15260static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15261 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15262 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_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 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15266 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15267
15268 { } /* end */
15269};
15270
15271static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15272 .ops = &snd_hda_bind_sw,
15273 .values = {
15274 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15275 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15276 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15277 0
15278 },
15279};
15280
15281static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15282 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15283 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15284 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15285 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15286 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15287 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15288 { } /* end */
15289};
15290
15291static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015292 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15293 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015294 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15296 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15297 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15298 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15299 { } /* end */
15300};
15301
15302static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15303 .ops = &snd_hda_bind_vol,
15304 .values = {
15305 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15306 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15307 0
15308 },
15309};
15310
15311static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15312 .ops = &snd_hda_bind_sw,
15313 .values = {
15314 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15315 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15316 0
15317 },
15318};
15319
15320static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15321 HDA_BIND_VOL("Master Playback Volume",
15322 &alc663_asus_two_bind_master_vol),
15323 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15324 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015325 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15326 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15327 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015328 { } /* end */
15329};
15330
15331static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15332 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15333 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15334 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15335 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15336 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15337 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015338 { } /* end */
15339};
15340
15341static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15342 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15343 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15344 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15345 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15346 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15347
15348 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15349 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15350 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15351 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15352 { } /* end */
15353};
15354
15355static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15356 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15357 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15358 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15359
15360 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15361 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15362 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15363 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15364 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15365 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15366 { } /* end */
15367};
15368
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015369static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15370 {
15371 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15372 .name = "Channel Mode",
15373 .info = alc_ch_mode_info,
15374 .get = alc_ch_mode_get,
15375 .put = alc_ch_mode_put,
15376 },
15377 { } /* end */
15378};
15379
15380static struct hda_verb alc662_init_verbs[] = {
15381 /* ADC: mute amp left and right */
15382 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15383 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15384 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15385
Takashi Iwaicb53c622007-08-10 17:21:45 +020015386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15387 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15388 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15389 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15390 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015391
Kailang Yangb60dd392007-09-20 12:50:29 +020015392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15393 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15394 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15395 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15397 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015398
15399 /* Front Pin: output 0 (0x0c) */
15400 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15401 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15402
15403 /* Rear Pin: output 1 (0x0d) */
15404 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15405 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15406
15407 /* CLFE Pin: output 2 (0x0e) */
15408 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15409 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15410
15411 /* Mic (rear) pin: input vref at 80% */
15412 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15413 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15414 /* Front Mic pin: input vref at 80% */
15415 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15416 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15417 /* Line In pin: input */
15418 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15419 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15420 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15421 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15422 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15423 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15424 /* CD pin widget for input */
15425 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15426
15427 /* FIXME: use matrix-type input source selection */
15428 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15429 /* Input mixer */
15430 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15431 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15432 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15433 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015434
15435 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15436 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15437 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15438 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015439
15440 /* always trun on EAPD */
15441 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15442 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15443
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015444 { }
15445};
15446
15447static struct hda_verb alc662_sue_init_verbs[] = {
15448 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15449 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015450 {}
15451};
15452
15453static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15454 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15455 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15456 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015457};
15458
Kailang Yang8c427222008-01-10 13:03:59 +010015459/* Set Unsolicited Event*/
15460static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15461 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15462 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15463 {}
15464};
15465
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015466/*
15467 * generic initialization of ADC, input mixers and output mixers
15468 */
15469static struct hda_verb alc662_auto_init_verbs[] = {
15470 /*
15471 * Unmute ADC and set the default input to mic-in
15472 */
15473 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15474 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15475
15476 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15477 * mixer widget
15478 * Note: PASD motherboards uses the Line In 2 as the input for front
15479 * panel mic (mic 2)
15480 */
15481 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015482 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15483 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15484 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15485 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15486 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015487
15488 /*
15489 * Set up output mixers (0x0c - 0x0f)
15490 */
15491 /* set vol=0 to output mixers */
15492 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15493 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15494 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15495
15496 /* set up input amps for analog loopback */
15497 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015498 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15499 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15500 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15501 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15502 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15503 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015504
15505
15506 /* FIXME: use matrix-type input source selection */
15507 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15508 /* Input mixer */
15509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015510 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015511 { }
15512};
15513
Takashi Iwai24fb9172008-09-02 14:48:20 +020015514/* additional verbs for ALC663 */
15515static struct hda_verb alc663_auto_init_verbs[] = {
15516 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15517 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15518 { }
15519};
15520
Kailang Yang6dda9f42008-05-27 12:05:31 +020015521static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015522 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15523 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015524 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15525 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015526 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015529 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15530 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15531 {}
15532};
15533
Kailang Yangf1d4e282008-08-26 14:03:29 +020015534static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15535 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15536 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15537 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15539 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15540 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15541 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15542 {}
15543};
15544
15545static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15546 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15547 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15548 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15549 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15550 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15551 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15552 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15553 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15554 {}
15555};
15556
15557static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15558 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15559 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15560 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15561 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15562 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15563 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15564 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15565 {}
15566};
15567
15568static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15569 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15570 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15571 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15572 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15573 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15574 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15575 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15577 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15578 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15579 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15580 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15581 {}
15582};
15583
15584static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15585 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15586 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15587 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15588 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15589 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15591 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15592 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15593 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15594 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15595 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15596 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15597 {}
15598};
15599
Kailang Yang6dda9f42008-05-27 12:05:31 +020015600static struct hda_verb alc663_g71v_init_verbs[] = {
15601 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15602 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15603 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15604
15605 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15606 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15607 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15608
15609 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15610 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15611 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15612 {}
15613};
15614
15615static struct hda_verb alc663_g50v_init_verbs[] = {
15616 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15617 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15618 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15619
15620 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15621 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15622 {}
15623};
15624
Kailang Yangf1d4e282008-08-26 14:03:29 +020015625static struct hda_verb alc662_ecs_init_verbs[] = {
15626 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15627 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15628 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15629 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15630 {}
15631};
15632
Kailang Yangf1d4e282008-08-26 14:03:29 +020015633static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15634 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15635 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15636 { } /* end */
15637};
15638
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015639static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15640{
15641 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015642 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015643
15644 present = snd_hda_codec_read(codec, 0x14, 0,
15645 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015646 bits = present ? HDA_AMP_MUTE : 0;
15647 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15648 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015649}
15650
15651static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15652{
15653 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015654 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015655
15656 present = snd_hda_codec_read(codec, 0x1b, 0,
15657 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015658 bits = present ? HDA_AMP_MUTE : 0;
15659 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15660 HDA_AMP_MUTE, bits);
15661 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15662 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015663}
15664
15665static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15666 unsigned int res)
15667{
15668 if ((res >> 26) == ALC880_HP_EVENT)
15669 alc662_lenovo_101e_all_automute(codec);
15670 if ((res >> 26) == ALC880_FRONT_EVENT)
15671 alc662_lenovo_101e_ispeaker_automute(codec);
15672}
15673
Kailang Yang291702f2007-10-16 14:28:03 +020015674static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15675{
15676 unsigned int present;
15677
15678 present = snd_hda_codec_read(codec, 0x18, 0,
15679 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15680 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15681 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15682 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15683 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15684 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15685 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15686 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15687 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15688}
15689
15690/* unsolicited event for HP jack sensing */
15691static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15692 unsigned int res)
15693{
15694 if ((res >> 26) == ALC880_HP_EVENT)
15695 alc262_hippo1_automute( codec );
15696
15697 if ((res >> 26) == ALC880_MIC_EVENT)
15698 alc662_eeepc_mic_automute(codec);
15699}
15700
15701static void alc662_eeepc_inithook(struct hda_codec *codec)
15702{
15703 alc262_hippo1_automute( codec );
15704 alc662_eeepc_mic_automute(codec);
15705}
15706
Kailang Yang8c427222008-01-10 13:03:59 +010015707static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15708{
15709 unsigned int mute;
15710 unsigned int present;
15711
15712 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15713 present = snd_hda_codec_read(codec, 0x14, 0,
15714 AC_VERB_GET_PIN_SENSE, 0);
15715 present = (present & 0x80000000) != 0;
15716 if (present) {
15717 /* mute internal speaker */
15718 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015719 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015720 } else {
15721 /* unmute internal speaker if necessary */
15722 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15723 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015724 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015725 }
15726}
15727
15728/* unsolicited event for HP jack sensing */
15729static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15730 unsigned int res)
15731{
15732 if ((res >> 26) == ALC880_HP_EVENT)
15733 alc662_eeepc_ep20_automute(codec);
15734}
15735
15736static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15737{
15738 alc662_eeepc_ep20_automute(codec);
15739}
15740
Kailang Yang6dda9f42008-05-27 12:05:31 +020015741static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15742{
15743 unsigned int present;
15744 unsigned char bits;
15745
15746 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015747 AC_VERB_GET_PIN_SENSE, 0)
15748 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015749 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015750 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15751 AMP_IN_MUTE(0), bits);
15752 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15753 AMP_IN_MUTE(0), bits);
15754}
15755
15756static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15757{
15758 unsigned int present;
15759 unsigned char bits;
15760
15761 present = snd_hda_codec_read(codec, 0x21, 0,
15762 AC_VERB_GET_PIN_SENSE, 0)
15763 & AC_PINSENSE_PRESENCE;
15764 bits = present ? HDA_AMP_MUTE : 0;
15765 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15766 AMP_IN_MUTE(0), bits);
15767 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15768 AMP_IN_MUTE(0), bits);
15769 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15770 AMP_IN_MUTE(0), bits);
15771 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15772 AMP_IN_MUTE(0), bits);
15773}
15774
15775static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15776{
15777 unsigned int present;
15778 unsigned char bits;
15779
15780 present = snd_hda_codec_read(codec, 0x15, 0,
15781 AC_VERB_GET_PIN_SENSE, 0)
15782 & AC_PINSENSE_PRESENCE;
15783 bits = present ? HDA_AMP_MUTE : 0;
15784 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15785 AMP_IN_MUTE(0), bits);
15786 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15787 AMP_IN_MUTE(0), bits);
15788 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15789 AMP_IN_MUTE(0), bits);
15790 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15791 AMP_IN_MUTE(0), bits);
15792}
15793
15794static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15795{
15796 unsigned int present;
15797 unsigned char bits;
15798
15799 present = snd_hda_codec_read(codec, 0x1b, 0,
15800 AC_VERB_GET_PIN_SENSE, 0)
15801 & AC_PINSENSE_PRESENCE;
15802 bits = present ? 0 : PIN_OUT;
15803 snd_hda_codec_write(codec, 0x14, 0,
15804 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15805}
15806
15807static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15808{
15809 unsigned int present1, present2;
15810
15811 present1 = snd_hda_codec_read(codec, 0x21, 0,
15812 AC_VERB_GET_PIN_SENSE, 0)
15813 & AC_PINSENSE_PRESENCE;
15814 present2 = snd_hda_codec_read(codec, 0x15, 0,
15815 AC_VERB_GET_PIN_SENSE, 0)
15816 & AC_PINSENSE_PRESENCE;
15817
15818 if (present1 || present2) {
15819 snd_hda_codec_write_cache(codec, 0x14, 0,
15820 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15821 } else {
15822 snd_hda_codec_write_cache(codec, 0x14, 0,
15823 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15824 }
15825}
15826
15827static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15828{
15829 unsigned int present1, present2;
15830
15831 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15832 AC_VERB_GET_PIN_SENSE, 0)
15833 & AC_PINSENSE_PRESENCE;
15834 present2 = snd_hda_codec_read(codec, 0x15, 0,
15835 AC_VERB_GET_PIN_SENSE, 0)
15836 & AC_PINSENSE_PRESENCE;
15837
15838 if (present1 || present2) {
15839 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15840 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15841 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15842 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15843 } else {
15844 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15845 AMP_IN_MUTE(0), 0);
15846 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15847 AMP_IN_MUTE(0), 0);
15848 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015849}
15850
15851static void alc663_m51va_mic_automute(struct hda_codec *codec)
15852{
15853 unsigned int present;
15854
15855 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015856 AC_VERB_GET_PIN_SENSE, 0)
15857 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015858 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015859 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015860 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015861 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015862 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015863 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015864 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015865 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015866}
15867
15868static void alc663_m51va_unsol_event(struct hda_codec *codec,
15869 unsigned int res)
15870{
15871 switch (res >> 26) {
15872 case ALC880_HP_EVENT:
15873 alc663_m51va_speaker_automute(codec);
15874 break;
15875 case ALC880_MIC_EVENT:
15876 alc663_m51va_mic_automute(codec);
15877 break;
15878 }
15879}
15880
15881static void alc663_m51va_inithook(struct hda_codec *codec)
15882{
15883 alc663_m51va_speaker_automute(codec);
15884 alc663_m51va_mic_automute(codec);
15885}
15886
Kailang Yangf1d4e282008-08-26 14:03:29 +020015887/* ***************** Mode1 ******************************/
15888static void alc663_mode1_unsol_event(struct hda_codec *codec,
15889 unsigned int res)
15890{
15891 switch (res >> 26) {
15892 case ALC880_HP_EVENT:
15893 alc663_m51va_speaker_automute(codec);
15894 break;
15895 case ALC880_MIC_EVENT:
15896 alc662_eeepc_mic_automute(codec);
15897 break;
15898 }
15899}
15900
15901static void alc663_mode1_inithook(struct hda_codec *codec)
15902{
15903 alc663_m51va_speaker_automute(codec);
15904 alc662_eeepc_mic_automute(codec);
15905}
15906/* ***************** Mode2 ******************************/
15907static void alc662_mode2_unsol_event(struct hda_codec *codec,
15908 unsigned int res)
15909{
15910 switch (res >> 26) {
15911 case ALC880_HP_EVENT:
15912 alc662_f5z_speaker_automute(codec);
15913 break;
15914 case ALC880_MIC_EVENT:
15915 alc662_eeepc_mic_automute(codec);
15916 break;
15917 }
15918}
15919
15920static void alc662_mode2_inithook(struct hda_codec *codec)
15921{
15922 alc662_f5z_speaker_automute(codec);
15923 alc662_eeepc_mic_automute(codec);
15924}
15925/* ***************** Mode3 ******************************/
15926static void alc663_mode3_unsol_event(struct hda_codec *codec,
15927 unsigned int res)
15928{
15929 switch (res >> 26) {
15930 case ALC880_HP_EVENT:
15931 alc663_two_hp_m1_speaker_automute(codec);
15932 break;
15933 case ALC880_MIC_EVENT:
15934 alc662_eeepc_mic_automute(codec);
15935 break;
15936 }
15937}
15938
15939static void alc663_mode3_inithook(struct hda_codec *codec)
15940{
15941 alc663_two_hp_m1_speaker_automute(codec);
15942 alc662_eeepc_mic_automute(codec);
15943}
15944/* ***************** Mode4 ******************************/
15945static void alc663_mode4_unsol_event(struct hda_codec *codec,
15946 unsigned int res)
15947{
15948 switch (res >> 26) {
15949 case ALC880_HP_EVENT:
15950 alc663_21jd_two_speaker_automute(codec);
15951 break;
15952 case ALC880_MIC_EVENT:
15953 alc662_eeepc_mic_automute(codec);
15954 break;
15955 }
15956}
15957
15958static void alc663_mode4_inithook(struct hda_codec *codec)
15959{
15960 alc663_21jd_two_speaker_automute(codec);
15961 alc662_eeepc_mic_automute(codec);
15962}
15963/* ***************** Mode5 ******************************/
15964static void alc663_mode5_unsol_event(struct hda_codec *codec,
15965 unsigned int res)
15966{
15967 switch (res >> 26) {
15968 case ALC880_HP_EVENT:
15969 alc663_15jd_two_speaker_automute(codec);
15970 break;
15971 case ALC880_MIC_EVENT:
15972 alc662_eeepc_mic_automute(codec);
15973 break;
15974 }
15975}
15976
15977static void alc663_mode5_inithook(struct hda_codec *codec)
15978{
15979 alc663_15jd_two_speaker_automute(codec);
15980 alc662_eeepc_mic_automute(codec);
15981}
15982/* ***************** Mode6 ******************************/
15983static void alc663_mode6_unsol_event(struct hda_codec *codec,
15984 unsigned int res)
15985{
15986 switch (res >> 26) {
15987 case ALC880_HP_EVENT:
15988 alc663_two_hp_m2_speaker_automute(codec);
15989 break;
15990 case ALC880_MIC_EVENT:
15991 alc662_eeepc_mic_automute(codec);
15992 break;
15993 }
15994}
15995
15996static void alc663_mode6_inithook(struct hda_codec *codec)
15997{
15998 alc663_two_hp_m2_speaker_automute(codec);
15999 alc662_eeepc_mic_automute(codec);
16000}
16001
Kailang Yang6dda9f42008-05-27 12:05:31 +020016002static void alc663_g71v_hp_automute(struct hda_codec *codec)
16003{
16004 unsigned int present;
16005 unsigned char bits;
16006
16007 present = snd_hda_codec_read(codec, 0x21, 0,
16008 AC_VERB_GET_PIN_SENSE, 0)
16009 & AC_PINSENSE_PRESENCE;
16010 bits = present ? HDA_AMP_MUTE : 0;
16011 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16012 HDA_AMP_MUTE, bits);
16013 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16014 HDA_AMP_MUTE, bits);
16015}
16016
16017static void alc663_g71v_front_automute(struct hda_codec *codec)
16018{
16019 unsigned int present;
16020 unsigned char bits;
16021
16022 present = snd_hda_codec_read(codec, 0x15, 0,
16023 AC_VERB_GET_PIN_SENSE, 0)
16024 & AC_PINSENSE_PRESENCE;
16025 bits = present ? HDA_AMP_MUTE : 0;
16026 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16027 HDA_AMP_MUTE, bits);
16028}
16029
16030static void alc663_g71v_unsol_event(struct hda_codec *codec,
16031 unsigned int res)
16032{
16033 switch (res >> 26) {
16034 case ALC880_HP_EVENT:
16035 alc663_g71v_hp_automute(codec);
16036 break;
16037 case ALC880_FRONT_EVENT:
16038 alc663_g71v_front_automute(codec);
16039 break;
16040 case ALC880_MIC_EVENT:
16041 alc662_eeepc_mic_automute(codec);
16042 break;
16043 }
16044}
16045
16046static void alc663_g71v_inithook(struct hda_codec *codec)
16047{
16048 alc663_g71v_front_automute(codec);
16049 alc663_g71v_hp_automute(codec);
16050 alc662_eeepc_mic_automute(codec);
16051}
16052
16053static void alc663_g50v_unsol_event(struct hda_codec *codec,
16054 unsigned int res)
16055{
16056 switch (res >> 26) {
16057 case ALC880_HP_EVENT:
16058 alc663_m51va_speaker_automute(codec);
16059 break;
16060 case ALC880_MIC_EVENT:
16061 alc662_eeepc_mic_automute(codec);
16062 break;
16063 }
16064}
16065
16066static void alc663_g50v_inithook(struct hda_codec *codec)
16067{
16068 alc663_m51va_speaker_automute(codec);
16069 alc662_eeepc_mic_automute(codec);
16070}
16071
Kailang Yangf1d4e282008-08-26 14:03:29 +020016072/* bind hp and internal speaker mute (with plug check) */
16073static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16074 struct snd_ctl_elem_value *ucontrol)
16075{
16076 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16077 long *valp = ucontrol->value.integer.value;
16078 int change;
16079
16080 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16081 HDA_AMP_MUTE,
16082 valp[0] ? 0 : HDA_AMP_MUTE);
16083 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16084 HDA_AMP_MUTE,
16085 valp[1] ? 0 : HDA_AMP_MUTE);
16086 if (change)
16087 alc262_hippo1_automute(codec);
16088 return change;
16089}
16090
16091static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16092 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16093 {
16094 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16095 .name = "Master Playback Switch",
16096 .info = snd_hda_mixer_amp_switch_info,
16097 .get = snd_hda_mixer_amp_switch_get,
16098 .put = alc662_ecs_master_sw_put,
16099 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16100 },
16101
16102 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16103 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16104 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16105
16106 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16107 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16108 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16109 { } /* end */
16110};
16111
Takashi Iwaicb53c622007-08-10 17:21:45 +020016112#ifdef CONFIG_SND_HDA_POWER_SAVE
16113#define alc662_loopbacks alc880_loopbacks
16114#endif
16115
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016116
16117/* pcm configuration: identiacal with ALC880 */
16118#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16119#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16120#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16121#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16122
16123/*
16124 * configuration and preset
16125 */
16126static const char *alc662_models[ALC662_MODEL_LAST] = {
16127 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16128 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16129 [ALC662_3ST_6ch] = "3stack-6ch",
16130 [ALC662_5ST_DIG] = "6stack-dig",
16131 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016132 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016133 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016134 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016135 [ALC663_ASUS_M51VA] = "m51va",
16136 [ALC663_ASUS_G71V] = "g71v",
16137 [ALC663_ASUS_H13] = "h13",
16138 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016139 [ALC663_ASUS_MODE1] = "asus-mode1",
16140 [ALC662_ASUS_MODE2] = "asus-mode2",
16141 [ALC663_ASUS_MODE3] = "asus-mode3",
16142 [ALC663_ASUS_MODE4] = "asus-mode4",
16143 [ALC663_ASUS_MODE5] = "asus-mode5",
16144 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016145 [ALC662_AUTO] = "auto",
16146};
16147
16148static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016149 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16150 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16151 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16152 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16153 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16154 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16155 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16156 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16157 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16158 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16159 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16160 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16161 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16162 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16163 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16164 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16165 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16166 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16167 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016168 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016169 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16170 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16171 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16172 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16173 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16174 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16175 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16176 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16177 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016178 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016179 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16180 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16181 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16182 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16183 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016184 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016185 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016186 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016187 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016188 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16189 ALC662_3ST_6ch_DIG),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016190 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16191 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016192 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016193 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016194 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016195 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016196 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16197 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016198 {}
16199};
16200
16201static struct alc_config_preset alc662_presets[] = {
16202 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016203 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016204 .init_verbs = { alc662_init_verbs },
16205 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16206 .dac_nids = alc662_dac_nids,
16207 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016208 .dig_in_nid = ALC662_DIGIN_NID,
16209 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16210 .channel_mode = alc662_3ST_2ch_modes,
16211 .input_mux = &alc662_capture_source,
16212 },
16213 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016214 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016215 .init_verbs = { alc662_init_verbs },
16216 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16217 .dac_nids = alc662_dac_nids,
16218 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016219 .dig_in_nid = ALC662_DIGIN_NID,
16220 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16221 .channel_mode = alc662_3ST_6ch_modes,
16222 .need_dac_fix = 1,
16223 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016224 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016225 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016226 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016227 .init_verbs = { alc662_init_verbs },
16228 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16229 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016230 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16231 .channel_mode = alc662_3ST_6ch_modes,
16232 .need_dac_fix = 1,
16233 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016234 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016235 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016236 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016237 .init_verbs = { alc662_init_verbs },
16238 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16239 .dac_nids = alc662_dac_nids,
16240 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016241 .dig_in_nid = ALC662_DIGIN_NID,
16242 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16243 .channel_mode = alc662_5stack_modes,
16244 .input_mux = &alc662_capture_source,
16245 },
16246 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016247 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016248 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16249 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16250 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016251 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16252 .channel_mode = alc662_3ST_2ch_modes,
16253 .input_mux = &alc662_lenovo_101e_capture_source,
16254 .unsol_event = alc662_lenovo_101e_unsol_event,
16255 .init_hook = alc662_lenovo_101e_all_automute,
16256 },
Kailang Yang291702f2007-10-16 14:28:03 +020016257 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016258 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016259 .init_verbs = { alc662_init_verbs,
16260 alc662_eeepc_sue_init_verbs },
16261 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16262 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016263 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16264 .channel_mode = alc662_3ST_2ch_modes,
16265 .input_mux = &alc662_eeepc_capture_source,
16266 .unsol_event = alc662_eeepc_unsol_event,
16267 .init_hook = alc662_eeepc_inithook,
16268 },
Kailang Yang8c427222008-01-10 13:03:59 +010016269 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016270 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016271 alc662_chmode_mixer },
16272 .init_verbs = { alc662_init_verbs,
16273 alc662_eeepc_ep20_sue_init_verbs },
16274 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16275 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016276 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16277 .channel_mode = alc662_3ST_6ch_modes,
16278 .input_mux = &alc662_lenovo_101e_capture_source,
16279 .unsol_event = alc662_eeepc_ep20_unsol_event,
16280 .init_hook = alc662_eeepc_ep20_inithook,
16281 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016282 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016283 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016284 .init_verbs = { alc662_init_verbs,
16285 alc662_ecs_init_verbs },
16286 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16287 .dac_nids = alc662_dac_nids,
16288 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16289 .channel_mode = alc662_3ST_2ch_modes,
16290 .input_mux = &alc662_eeepc_capture_source,
16291 .unsol_event = alc662_eeepc_unsol_event,
16292 .init_hook = alc662_eeepc_inithook,
16293 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016294 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016295 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016296 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16297 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16298 .dac_nids = alc662_dac_nids,
16299 .dig_out_nid = ALC662_DIGOUT_NID,
16300 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16301 .channel_mode = alc662_3ST_2ch_modes,
16302 .input_mux = &alc663_m51va_capture_source,
16303 .unsol_event = alc663_m51va_unsol_event,
16304 .init_hook = alc663_m51va_inithook,
16305 },
16306 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016307 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016308 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16309 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16310 .dac_nids = alc662_dac_nids,
16311 .dig_out_nid = ALC662_DIGOUT_NID,
16312 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16313 .channel_mode = alc662_3ST_2ch_modes,
16314 .input_mux = &alc662_eeepc_capture_source,
16315 .unsol_event = alc663_g71v_unsol_event,
16316 .init_hook = alc663_g71v_inithook,
16317 },
16318 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016319 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016320 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16321 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16322 .dac_nids = alc662_dac_nids,
16323 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16324 .channel_mode = alc662_3ST_2ch_modes,
16325 .input_mux = &alc663_m51va_capture_source,
16326 .unsol_event = alc663_m51va_unsol_event,
16327 .init_hook = alc663_m51va_inithook,
16328 },
16329 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016330 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016331 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16332 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16333 .dac_nids = alc662_dac_nids,
16334 .dig_out_nid = ALC662_DIGOUT_NID,
16335 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16336 .channel_mode = alc662_3ST_6ch_modes,
16337 .input_mux = &alc663_capture_source,
16338 .unsol_event = alc663_g50v_unsol_event,
16339 .init_hook = alc663_g50v_inithook,
16340 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016341 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016342 .mixers = { alc663_m51va_mixer },
16343 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016344 .init_verbs = { alc662_init_verbs,
16345 alc663_21jd_amic_init_verbs },
16346 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16347 .hp_nid = 0x03,
16348 .dac_nids = alc662_dac_nids,
16349 .dig_out_nid = ALC662_DIGOUT_NID,
16350 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16351 .channel_mode = alc662_3ST_2ch_modes,
16352 .input_mux = &alc662_eeepc_capture_source,
16353 .unsol_event = alc663_mode1_unsol_event,
16354 .init_hook = alc663_mode1_inithook,
16355 },
16356 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016357 .mixers = { alc662_1bjd_mixer },
16358 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016359 .init_verbs = { alc662_init_verbs,
16360 alc662_1bjd_amic_init_verbs },
16361 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16362 .dac_nids = alc662_dac_nids,
16363 .dig_out_nid = ALC662_DIGOUT_NID,
16364 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16365 .channel_mode = alc662_3ST_2ch_modes,
16366 .input_mux = &alc662_eeepc_capture_source,
16367 .unsol_event = alc662_mode2_unsol_event,
16368 .init_hook = alc662_mode2_inithook,
16369 },
16370 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016371 .mixers = { alc663_two_hp_m1_mixer },
16372 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016373 .init_verbs = { alc662_init_verbs,
16374 alc663_two_hp_amic_m1_init_verbs },
16375 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16376 .hp_nid = 0x03,
16377 .dac_nids = alc662_dac_nids,
16378 .dig_out_nid = ALC662_DIGOUT_NID,
16379 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16380 .channel_mode = alc662_3ST_2ch_modes,
16381 .input_mux = &alc662_eeepc_capture_source,
16382 .unsol_event = alc663_mode3_unsol_event,
16383 .init_hook = alc663_mode3_inithook,
16384 },
16385 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016386 .mixers = { alc663_asus_21jd_clfe_mixer },
16387 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016388 .init_verbs = { alc662_init_verbs,
16389 alc663_21jd_amic_init_verbs},
16390 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16391 .hp_nid = 0x03,
16392 .dac_nids = alc662_dac_nids,
16393 .dig_out_nid = ALC662_DIGOUT_NID,
16394 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16395 .channel_mode = alc662_3ST_2ch_modes,
16396 .input_mux = &alc662_eeepc_capture_source,
16397 .unsol_event = alc663_mode4_unsol_event,
16398 .init_hook = alc663_mode4_inithook,
16399 },
16400 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016401 .mixers = { alc663_asus_15jd_clfe_mixer },
16402 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016403 .init_verbs = { alc662_init_verbs,
16404 alc663_15jd_amic_init_verbs },
16405 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16406 .hp_nid = 0x03,
16407 .dac_nids = alc662_dac_nids,
16408 .dig_out_nid = ALC662_DIGOUT_NID,
16409 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16410 .channel_mode = alc662_3ST_2ch_modes,
16411 .input_mux = &alc662_eeepc_capture_source,
16412 .unsol_event = alc663_mode5_unsol_event,
16413 .init_hook = alc663_mode5_inithook,
16414 },
16415 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016416 .mixers = { alc663_two_hp_m2_mixer },
16417 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016418 .init_verbs = { alc662_init_verbs,
16419 alc663_two_hp_amic_m2_init_verbs },
16420 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16421 .hp_nid = 0x03,
16422 .dac_nids = alc662_dac_nids,
16423 .dig_out_nid = ALC662_DIGOUT_NID,
16424 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16425 .channel_mode = alc662_3ST_2ch_modes,
16426 .input_mux = &alc662_eeepc_capture_source,
16427 .unsol_event = alc663_mode6_unsol_event,
16428 .init_hook = alc663_mode6_inithook,
16429 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016430};
16431
16432
16433/*
16434 * BIOS auto configuration
16435 */
16436
16437/* add playback controls from the parsed DAC table */
16438static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16439 const struct auto_pin_cfg *cfg)
16440{
16441 char name[32];
16442 static const char *chname[4] = {
16443 "Front", "Surround", NULL /*CLFE*/, "Side"
16444 };
16445 hda_nid_t nid;
16446 int i, err;
16447
16448 for (i = 0; i < cfg->line_outs; i++) {
16449 if (!spec->multiout.dac_nids[i])
16450 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016451 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016452 if (i == 2) {
16453 /* Center/LFE */
16454 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16455 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016456 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16457 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016458 if (err < 0)
16459 return err;
16460 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16461 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016462 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16463 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016464 if (err < 0)
16465 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016466 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016467 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016468 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016469 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016470 if (err < 0)
16471 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016472 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016473 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016474 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016475 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016476 if (err < 0)
16477 return err;
16478 } else {
16479 sprintf(name, "%s Playback Volume", chname[i]);
16480 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016481 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16482 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016483 if (err < 0)
16484 return err;
16485 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016486 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16487 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16488 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016489 if (err < 0)
16490 return err;
16491 }
16492 }
16493 return 0;
16494}
16495
16496/* add playback controls for speaker and HP outputs */
16497static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16498 const char *pfx)
16499{
16500 hda_nid_t nid;
16501 int err;
16502 char name[32];
16503
16504 if (!pin)
16505 return 0;
16506
Takashi Iwai24fb9172008-09-02 14:48:20 +020016507 if (pin == 0x17) {
16508 /* ALC663 has a mono output pin on 0x17 */
16509 sprintf(name, "%s Playback Switch", pfx);
16510 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16511 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16512 return err;
16513 }
16514
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016515 if (alc880_is_fixed_pin(pin)) {
16516 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016517 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016518 /* specify the DAC as the extra output */
16519 if (!spec->multiout.hp_nid)
16520 spec->multiout.hp_nid = nid;
16521 else
16522 spec->multiout.extra_out_nid[0] = nid;
16523 /* control HP volume/switch on the output mixer amp */
16524 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16525 sprintf(name, "%s Playback Volume", pfx);
16526 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16527 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16528 if (err < 0)
16529 return err;
16530 sprintf(name, "%s Playback Switch", pfx);
16531 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16532 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16533 if (err < 0)
16534 return err;
16535 } else if (alc880_is_multi_pin(pin)) {
16536 /* set manual connection */
16537 /* we have only a switch on HP-out PIN */
16538 sprintf(name, "%s Playback Switch", pfx);
16539 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16540 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16541 if (err < 0)
16542 return err;
16543 }
16544 return 0;
16545}
16546
16547/* create playback/capture controls for input pins */
16548static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16549 const struct auto_pin_cfg *cfg)
16550{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016551 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016552 int i, err, idx;
16553
16554 for (i = 0; i < AUTO_PIN_LAST; i++) {
16555 if (alc880_is_input_pin(cfg->input_pins[i])) {
16556 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16557 err = new_analog_input(spec, cfg->input_pins[i],
16558 auto_pin_cfg_labels[i],
16559 idx, 0x0b);
16560 if (err < 0)
16561 return err;
16562 imux->items[imux->num_items].label =
16563 auto_pin_cfg_labels[i];
16564 imux->items[imux->num_items].index =
16565 alc880_input_pin_idx(cfg->input_pins[i]);
16566 imux->num_items++;
16567 }
16568 }
16569 return 0;
16570}
16571
16572static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16573 hda_nid_t nid, int pin_type,
16574 int dac_idx)
16575{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016576 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016577 /* need the manual connection? */
16578 if (alc880_is_multi_pin(nid)) {
16579 struct alc_spec *spec = codec->spec;
16580 int idx = alc880_multi_pin_idx(nid);
16581 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16582 AC_VERB_SET_CONNECT_SEL,
16583 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16584 }
16585}
16586
16587static void alc662_auto_init_multi_out(struct hda_codec *codec)
16588{
16589 struct alc_spec *spec = codec->spec;
16590 int i;
16591
Kailang Yang8c427222008-01-10 13:03:59 +010016592 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016593 for (i = 0; i <= HDA_SIDE; i++) {
16594 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016595 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016596 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016597 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016598 i);
16599 }
16600}
16601
16602static void alc662_auto_init_hp_out(struct hda_codec *codec)
16603{
16604 struct alc_spec *spec = codec->spec;
16605 hda_nid_t pin;
16606
16607 pin = spec->autocfg.hp_pins[0];
16608 if (pin) /* connect to front */
16609 /* use dac 0 */
16610 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016611 pin = spec->autocfg.speaker_pins[0];
16612 if (pin)
16613 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016614}
16615
16616#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16617#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16618
16619static void alc662_auto_init_analog_input(struct hda_codec *codec)
16620{
16621 struct alc_spec *spec = codec->spec;
16622 int i;
16623
16624 for (i = 0; i < AUTO_PIN_LAST; i++) {
16625 hda_nid_t nid = spec->autocfg.input_pins[i];
16626 if (alc662_is_input_pin(nid)) {
16627 snd_hda_codec_write(codec, nid, 0,
16628 AC_VERB_SET_PIN_WIDGET_CONTROL,
16629 (i <= AUTO_PIN_FRONT_MIC ?
16630 PIN_VREF80 : PIN_IN));
16631 if (nid != ALC662_PIN_CD_NID)
16632 snd_hda_codec_write(codec, nid, 0,
16633 AC_VERB_SET_AMP_GAIN_MUTE,
16634 AMP_OUT_MUTE);
16635 }
16636 }
16637}
16638
Takashi Iwaif511b012008-08-15 16:46:42 +020016639#define alc662_auto_init_input_src alc882_auto_init_input_src
16640
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016641static int alc662_parse_auto_config(struct hda_codec *codec)
16642{
16643 struct alc_spec *spec = codec->spec;
16644 int err;
16645 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16646
16647 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16648 alc662_ignore);
16649 if (err < 0)
16650 return err;
16651 if (!spec->autocfg.line_outs)
16652 return 0; /* can't find valid BIOS pin config */
16653
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016654 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16655 if (err < 0)
16656 return err;
16657 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16658 if (err < 0)
16659 return err;
16660 err = alc662_auto_create_extra_out(spec,
16661 spec->autocfg.speaker_pins[0],
16662 "Speaker");
16663 if (err < 0)
16664 return err;
16665 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16666 "Headphone");
16667 if (err < 0)
16668 return err;
16669 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16670 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016671 return err;
16672
16673 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16674
16675 if (spec->autocfg.dig_out_pin)
16676 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16677
Takashi Iwai603c4012008-07-30 15:01:44 +020016678 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016679 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016680
16681 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016682 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016683
Takashi Iwaid88897e2008-10-31 15:01:37 +010016684 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016685 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016686 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016687
16688 err = alc_auto_add_mic_boost(codec);
16689 if (err < 0)
16690 return err;
16691
Takashi Iwaie044c392008-10-27 16:56:24 +010016692 store_pin_configs(codec);
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016693 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016694}
16695
16696/* additional initialization for auto-configuration model */
16697static void alc662_auto_init(struct hda_codec *codec)
16698{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016699 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016700 alc662_auto_init_multi_out(codec);
16701 alc662_auto_init_hp_out(codec);
16702 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016703 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016704 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016705 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016706}
16707
16708static int patch_alc662(struct hda_codec *codec)
16709{
16710 struct alc_spec *spec;
16711 int err, board_config;
16712
16713 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16714 if (!spec)
16715 return -ENOMEM;
16716
16717 codec->spec = spec;
16718
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016719 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16720
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016721 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16722 alc662_models,
16723 alc662_cfg_tbl);
16724 if (board_config < 0) {
16725 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16726 "trying auto-probe from BIOS...\n");
16727 board_config = ALC662_AUTO;
16728 }
16729
16730 if (board_config == ALC662_AUTO) {
16731 /* automatic parse from the BIOS config */
16732 err = alc662_parse_auto_config(codec);
16733 if (err < 0) {
16734 alc_free(codec);
16735 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016736 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016737 printk(KERN_INFO
16738 "hda_codec: Cannot set up configuration "
16739 "from BIOS. Using base mode...\n");
16740 board_config = ALC662_3ST_2ch_DIG;
16741 }
16742 }
16743
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016744 err = snd_hda_attach_beep_device(codec, 0x1);
16745 if (err < 0) {
16746 alc_free(codec);
16747 return err;
16748 }
16749
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016750 if (board_config != ALC662_AUTO)
16751 setup_preset(spec, &alc662_presets[board_config]);
16752
Kailang Yang6dda9f42008-05-27 12:05:31 +020016753 if (codec->vendor_id == 0x10ec0663) {
16754 spec->stream_name_analog = "ALC663 Analog";
16755 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016756 } else if (codec->vendor_id == 0x10ec0272) {
16757 spec->stream_name_analog = "ALC272 Analog";
16758 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016759 } else {
16760 spec->stream_name_analog = "ALC662 Analog";
16761 spec->stream_name_digital = "ALC662 Digital";
16762 }
16763
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016764 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16765 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16766
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016767 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16768 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16769
Takashi Iwaie1406342008-02-11 18:32:32 +010016770 spec->adc_nids = alc662_adc_nids;
16771 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16772 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016773 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016774
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016775 if (!spec->cap_mixer)
16776 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016777 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016778
Takashi Iwai2134ea42008-01-10 16:53:55 +010016779 spec->vmaster_nid = 0x02;
16780
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016781 codec->patch_ops = alc_patch_ops;
16782 if (board_config == ALC662_AUTO)
16783 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016784#ifdef CONFIG_SND_HDA_POWER_SAVE
16785 if (!spec->loopback.amplist)
16786 spec->loopback.amplist = alc662_loopbacks;
16787#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016788 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016789
16790 return 0;
16791}
16792
16793/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016794 * patch entries
16795 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016796static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016797 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016798 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016799 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016800 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016801 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016802 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016803 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016804 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016805 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16806 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16807 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016808 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16809 .patch = patch_alc883 },
16810 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16811 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016812 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016813 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016814 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016815 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016816 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16817 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016818 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016819 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016820 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016821 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016822 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16823 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080016824 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016825 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016826 {} /* terminator */
16827};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016828
16829MODULE_ALIAS("snd-hda-codec-id:10ec*");
16830
16831MODULE_LICENSE("GPL");
16832MODULE_DESCRIPTION("Realtek HD-audio codec");
16833
16834static struct hda_codec_preset_list realtek_list = {
16835 .preset = snd_hda_preset_realtek,
16836 .owner = THIS_MODULE,
16837};
16838
16839static int __init patch_realtek_init(void)
16840{
16841 return snd_hda_add_codec_preset(&realtek_list);
16842}
16843
16844static void __exit patch_realtek_exit(void)
16845{
16846 snd_hda_delete_codec_preset(&realtek_list);
16847}
16848
16849module_init(patch_realtek_init)
16850module_exit(patch_realtek_exit)