blob: 244de597c5be67020496b839fd2ed74a72175708 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e42006-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 Avdoninbab282b2006-08-22 13:31:58 +0200218 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200219 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800220 ALC888_ACER_ASPIRE_4930G,
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 Iwai6a05ac42009-02-13 11:19:09 +0100282 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100283 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
285 /* capture */
286 unsigned int num_adc_nids;
287 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100288 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200289 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200290 int capture_style; /* capture style (CAPT_*) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291
292 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200293 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 const struct hda_input_mux *input_mux;
295 unsigned int cur_mux[3];
296
297 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100298 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200300 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301
302 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100303 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200304
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200305 /* dynamic controls, init_verbs and input_mux */
306 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200307 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200308 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200309 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100310
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100311 /* hooks */
312 void (*init_hook)(struct hda_codec *codec);
313 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
314
Takashi Iwai834be882006-03-01 14:16:17 +0100315 /* for pin sensing */
316 unsigned int sense_updated: 1;
317 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100318 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200319
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100320 /* other flags */
321 unsigned int no_analog :1; /* digital I/O only */
322
Takashi Iwai2134ea42008-01-10 16:53:55 +0100323 /* for virtual master */
324 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200325#ifdef CONFIG_SND_HDA_POWER_SAVE
326 struct hda_loopback_check loopback;
327#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200328
329 /* for PLL fix */
330 hda_nid_t pll_nid;
331 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaie044c392008-10-27 16:56:24 +0100332
333#ifdef SND_HDA_NEEDS_RESUME
334#define ALC_MAX_PINS 16
335 unsigned int num_pins;
336 hda_nid_t pin_nids[ALC_MAX_PINS];
337 unsigned int pin_cfgs[ALC_MAX_PINS];
338#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100339};
340
341/*
342 * configuration template - to be copied to the spec instance
343 */
344struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200345 struct snd_kcontrol_new *mixers[5]; /* should be identical size
346 * with spec
347 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100348 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100349 const struct hda_verb *init_verbs[5];
350 unsigned int num_dacs;
351 hda_nid_t *dac_nids;
352 hda_nid_t dig_out_nid; /* optional */
353 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800354 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100355 unsigned int num_adc_nids;
356 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100357 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100358 hda_nid_t dig_in_nid;
359 unsigned int num_channel_mode;
360 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200361 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200362 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100363 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100364 void (*unsol_event)(struct hda_codec *, unsigned int);
365 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200366#ifdef CONFIG_SND_HDA_POWER_SAVE
367 struct hda_amp_list *loopbacks;
368#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369};
370
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371
372/*
373 * input MUX handling
374 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200375static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
376 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377{
378 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
379 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200380 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
381 if (mux_idx >= spec->num_mux_defs)
382 mux_idx = 0;
383 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384}
385
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200386static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
387 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388{
389 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
390 struct alc_spec *spec = codec->spec;
391 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
392
393 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
394 return 0;
395}
396
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200397static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
398 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399{
400 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
401 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100402 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100404 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100405 hda_nid_t nid = spec->capsrc_nids ?
406 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407
Takashi Iwaicd896c32008-11-18 12:36:33 +0100408 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
409 imux = &spec->input_mux[mux_idx];
410
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200411 if (spec->capture_style &&
412 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100413 /* Matrix-mixer style (e.g. ALC882) */
414 unsigned int *cur_val = &spec->cur_mux[adc_idx];
415 unsigned int i, idx;
416
417 idx = ucontrol->value.enumerated.item[0];
418 if (idx >= imux->num_items)
419 idx = imux->num_items - 1;
420 if (*cur_val == idx)
421 return 0;
422 for (i = 0; i < imux->num_items; i++) {
423 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
424 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
425 imux->items[i].index,
426 HDA_AMP_MUTE, v);
427 }
428 *cur_val = idx;
429 return 1;
430 } else {
431 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100432 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100433 &spec->cur_mux[adc_idx]);
434 }
435}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200436
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437/*
438 * channel mode setting
439 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200440static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
441 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442{
443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
444 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100445 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
446 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447}
448
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200449static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
450 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451{
452 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
453 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100454 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200455 spec->num_channel_mode,
456 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457}
458
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200459static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461{
462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
463 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200464 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
465 spec->num_channel_mode,
466 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200467 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200468 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
469 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470}
471
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100473 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200474 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100475 * being part of a format specifier. Maximum allowed length of a value is
476 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100477 *
478 * Note: some retasking pin complexes seem to ignore requests for input
479 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
480 * are requested. Therefore order this list so that this behaviour will not
481 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200482 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
483 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200484 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100485static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100486 "Mic 50pc bias", "Mic 80pc bias",
487 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100488};
489static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e42006-02-09 12:01:26 +0100490 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100491};
492/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200493 * in the pin being assumed to be exclusively an input or an output pin. In
494 * addition, "input" pins may or may not process the mic bias option
495 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
496 * accept requests for bias as of chip versions up to March 2006) and/or
497 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100498 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200499#define ALC_PIN_DIR_IN 0x00
500#define ALC_PIN_DIR_OUT 0x01
501#define ALC_PIN_DIR_INOUT 0x02
502#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
503#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100504
Kailang Yangea1fb292008-08-26 12:58:38 +0200505/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100506 * For each direction the minimum and maximum values are given.
507 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200508static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100509 { 0, 2 }, /* ALC_PIN_DIR_IN */
510 { 3, 4 }, /* ALC_PIN_DIR_OUT */
511 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200512 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
513 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100514};
515#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
516#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
517#define alc_pin_mode_n_items(_dir) \
518 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
519
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200520static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
521 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200522{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100523 unsigned int item_num = uinfo->value.enumerated.item;
524 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
525
526 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200527 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100528 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
529
530 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
531 item_num = alc_pin_mode_min(dir);
532 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200533 return 0;
534}
535
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200536static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
537 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200538{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100539 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200540 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
541 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100542 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200543 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200544 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
545 AC_VERB_GET_PIN_WIDGET_CONTROL,
546 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200547
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100548 /* Find enumerated value for current pinctl setting */
549 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200550 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100551 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200552 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100553 return 0;
554}
555
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200556static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
557 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100558{
559 signed int change;
560 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
561 hda_nid_t nid = kcontrol->private_value & 0xffff;
562 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
563 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200564 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
565 AC_VERB_GET_PIN_WIDGET_CONTROL,
566 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100567
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200568 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100569 val = alc_pin_mode_min(dir);
570
571 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100572 if (change) {
573 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200574 snd_hda_codec_write_cache(codec, nid, 0,
575 AC_VERB_SET_PIN_WIDGET_CONTROL,
576 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100577
Kailang Yangea1fb292008-08-26 12:58:38 +0200578 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100579 * for the requested pin mode. Enum values of 2 or less are
580 * input modes.
581 *
582 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200583 * reduces noise slightly (particularly on input) so we'll
584 * do it. However, having both input and output buffers
585 * enabled simultaneously doesn't seem to be problematic if
586 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100587 */
588 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200589 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
590 HDA_AMP_MUTE, HDA_AMP_MUTE);
591 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
592 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100593 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200594 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
595 HDA_AMP_MUTE, HDA_AMP_MUTE);
596 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
597 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100598 }
599 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200600 return change;
601}
602
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100603#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200604 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100605 .info = alc_pin_mode_info, \
606 .get = alc_pin_mode_get, \
607 .put = alc_pin_mode_put, \
608 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100609
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100610/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
611 * together using a mask with more than one bit set. This control is
612 * currently used only by the ALC260 test model. At this stage they are not
613 * needed for any "production" models.
614 */
615#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200616#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200617
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200618static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
619 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100620{
621 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
622 hda_nid_t nid = kcontrol->private_value & 0xffff;
623 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
624 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200625 unsigned int val = snd_hda_codec_read(codec, nid, 0,
626 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100627
628 *valp = (val & mask) != 0;
629 return 0;
630}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200631static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
632 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100633{
634 signed int change;
635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
636 hda_nid_t nid = kcontrol->private_value & 0xffff;
637 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
638 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200639 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
640 AC_VERB_GET_GPIO_DATA,
641 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100642
643 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200644 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
645 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100646 gpio_data &= ~mask;
647 else
648 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200649 snd_hda_codec_write_cache(codec, nid, 0,
650 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100651
652 return change;
653}
654#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
655 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
656 .info = alc_gpio_data_info, \
657 .get = alc_gpio_data_get, \
658 .put = alc_gpio_data_put, \
659 .private_value = nid | (mask<<16) }
660#endif /* CONFIG_SND_DEBUG */
661
Jonathan Woithe92621f12006-02-28 11:47:47 +0100662/* A switch control to allow the enabling of the digital IO pins on the
663 * ALC260. This is incredibly simplistic; the intention of this control is
664 * to provide something in the test model allowing digital outputs to be
665 * identified if present. If models are found which can utilise these
666 * outputs a more complete mixer control can be devised for those models if
667 * necessary.
668 */
669#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200670#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200671
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200672static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
673 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100674{
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
676 hda_nid_t nid = kcontrol->private_value & 0xffff;
677 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
678 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200679 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100680 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100681
682 *valp = (val & mask) != 0;
683 return 0;
684}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200685static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
686 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100687{
688 signed int change;
689 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
690 hda_nid_t nid = kcontrol->private_value & 0xffff;
691 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
692 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200693 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100694 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200695 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100696
697 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200698 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100699 if (val==0)
700 ctrl_data &= ~mask;
701 else
702 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200703 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
704 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100705
706 return change;
707}
708#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
709 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
710 .info = alc_spdif_ctrl_info, \
711 .get = alc_spdif_ctrl_get, \
712 .put = alc_spdif_ctrl_put, \
713 .private_value = nid | (mask<<16) }
714#endif /* CONFIG_SND_DEBUG */
715
Jonathan Woithef8225f62008-01-08 12:16:54 +0100716/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
717 * Again, this is only used in the ALC26x test models to help identify when
718 * the EAPD line must be asserted for features to work.
719 */
720#ifdef CONFIG_SND_DEBUG
721#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
722
723static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
724 struct snd_ctl_elem_value *ucontrol)
725{
726 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
727 hda_nid_t nid = kcontrol->private_value & 0xffff;
728 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
729 long *valp = ucontrol->value.integer.value;
730 unsigned int val = snd_hda_codec_read(codec, nid, 0,
731 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
732
733 *valp = (val & mask) != 0;
734 return 0;
735}
736
737static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
738 struct snd_ctl_elem_value *ucontrol)
739{
740 int change;
741 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
742 hda_nid_t nid = kcontrol->private_value & 0xffff;
743 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
744 long val = *ucontrol->value.integer.value;
745 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
746 AC_VERB_GET_EAPD_BTLENABLE,
747 0x00);
748
749 /* Set/unset the masked control bit(s) as needed */
750 change = (!val ? 0 : mask) != (ctrl_data & mask);
751 if (!val)
752 ctrl_data &= ~mask;
753 else
754 ctrl_data |= mask;
755 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
756 ctrl_data);
757
758 return change;
759}
760
761#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
762 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
763 .info = alc_eapd_ctrl_info, \
764 .get = alc_eapd_ctrl_get, \
765 .put = alc_eapd_ctrl_put, \
766 .private_value = nid | (mask<<16) }
767#endif /* CONFIG_SND_DEBUG */
768
Kailang Yangdf694da2005-12-05 19:42:22 +0100769/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100770 */
771static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
772{
773 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
774 return;
775 spec->mixers[spec->num_mixers++] = mix;
776}
777
778static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
779{
780 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
781 return;
782 spec->init_verbs[spec->num_init_verbs++] = verb;
783}
784
Takashi Iwaidaead532008-11-28 12:55:36 +0100785#ifdef CONFIG_PROC_FS
786/*
787 * hook for proc
788 */
789static void print_realtek_coef(struct snd_info_buffer *buffer,
790 struct hda_codec *codec, hda_nid_t nid)
791{
792 int coeff;
793
794 if (nid != 0x20)
795 return;
796 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
797 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
798 coeff = snd_hda_codec_read(codec, nid, 0,
799 AC_VERB_GET_COEF_INDEX, 0);
800 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
801}
802#else
803#define print_realtek_coef NULL
804#endif
805
Takashi Iwaid88897e2008-10-31 15:01:37 +0100806/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100807 * set up from the preset table
808 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200809static void setup_preset(struct alc_spec *spec,
810 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100811{
812 int i;
813
814 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100815 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100816 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200817 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
818 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100819 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200820
Kailang Yangdf694da2005-12-05 19:42:22 +0100821 spec->channel_mode = preset->channel_mode;
822 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200823 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100824
825 spec->multiout.max_channels = spec->channel_mode[0].channels;
826
827 spec->multiout.num_dacs = preset->num_dacs;
828 spec->multiout.dac_nids = preset->dac_nids;
829 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800830 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100831 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200832
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200833 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200834 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200835 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100836 spec->input_mux = preset->input_mux;
837
838 spec->num_adc_nids = preset->num_adc_nids;
839 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100840 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100841 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100842
843 spec->unsol_event = preset->unsol_event;
844 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200845#ifdef CONFIG_SND_HDA_POWER_SAVE
846 spec->loopback.amplist = preset->loopbacks;
847#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100848}
849
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200850/* Enable GPIO mask and set output */
851static struct hda_verb alc_gpio1_init_verbs[] = {
852 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
853 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
854 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
855 { }
856};
857
858static struct hda_verb alc_gpio2_init_verbs[] = {
859 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
860 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
861 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
862 { }
863};
864
Kailang Yangbdd148a2007-05-08 15:19:08 +0200865static struct hda_verb alc_gpio3_init_verbs[] = {
866 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
867 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
868 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
869 { }
870};
871
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200872/*
873 * Fix hardware PLL issue
874 * On some codecs, the analog PLL gating control must be off while
875 * the default value is 1.
876 */
877static void alc_fix_pll(struct hda_codec *codec)
878{
879 struct alc_spec *spec = codec->spec;
880 unsigned int val;
881
882 if (!spec->pll_nid)
883 return;
884 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
885 spec->pll_coef_idx);
886 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
887 AC_VERB_GET_PROC_COEF, 0);
888 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
889 spec->pll_coef_idx);
890 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
891 val & ~(1 << spec->pll_coef_bit));
892}
893
894static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
895 unsigned int coef_idx, unsigned int coef_bit)
896{
897 struct alc_spec *spec = codec->spec;
898 spec->pll_nid = nid;
899 spec->pll_coef_idx = coef_idx;
900 spec->pll_coef_bit = coef_bit;
901 alc_fix_pll(codec);
902}
903
Kailang Yangc9b58002007-10-16 14:30:01 +0200904static void alc_sku_automute(struct hda_codec *codec)
905{
906 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200907 unsigned int present;
908 unsigned int hp_nid = spec->autocfg.hp_pins[0];
909 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
910
911 /* need to execute and sync at first */
912 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
913 present = snd_hda_codec_read(codec, hp_nid, 0,
914 AC_VERB_GET_PIN_SENSE, 0);
915 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100916 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
917 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200918}
919
Takashi Iwai4605b712008-10-31 14:18:24 +0100920#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200921static void alc_mic_automute(struct hda_codec *codec)
922{
923 struct alc_spec *spec = codec->spec;
924 unsigned int present;
925 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
926 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
927 unsigned int mix_nid = spec->capsrc_nids[0];
928 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
929
930 capsrc_idx_mic = mic_nid - 0x18;
931 capsrc_idx_fmic = fmic_nid - 0x18;
932 present = snd_hda_codec_read(codec, mic_nid, 0,
933 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
934 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
935 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
936 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
937 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
938 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
939 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
940}
Takashi Iwai4605b712008-10-31 14:18:24 +0100941#else
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100942#define alc_mic_automute(codec) do {} while(0) /* NOP */
Takashi Iwai4605b712008-10-31 14:18:24 +0100943#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200944
Kailang Yangc9b58002007-10-16 14:30:01 +0200945/* unsolicited event for HP jack sensing */
946static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
947{
948 if (codec->vendor_id == 0x10ec0880)
949 res >>= 28;
950 else
951 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200952 if (res == ALC880_HP_EVENT)
953 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200954
Kailang Yang7fb0d782008-10-15 11:12:35 +0200955 if (res == ALC880_MIC_EVENT)
956 alc_mic_automute(codec);
957}
958
959static void alc_inithook(struct hda_codec *codec)
960{
Kailang Yangc9b58002007-10-16 14:30:01 +0200961 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200962 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200963}
964
Kailang Yangf9423e72008-05-27 12:32:25 +0200965/* additional initialization for ALC888 variants */
966static void alc888_coef_init(struct hda_codec *codec)
967{
968 unsigned int tmp;
969
970 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
971 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
972 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
973 if ((tmp & 0xf0) == 2)
974 /* alc888S-VC */
975 snd_hda_codec_read(codec, 0x20, 0,
976 AC_VERB_SET_PROC_COEF, 0x830);
977 else
978 /* alc888-VB */
979 snd_hda_codec_read(codec, 0x20, 0,
980 AC_VERB_SET_PROC_COEF, 0x3030);
981}
982
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200983/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
984 * 31 ~ 16 : Manufacture ID
985 * 15 ~ 8 : SKU ID
986 * 7 ~ 0 : Assembly ID
987 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
988 */
989static void alc_subsystem_id(struct hda_codec *codec,
990 unsigned int porta, unsigned int porte,
991 unsigned int portd)
992{
Kailang Yangc9b58002007-10-16 14:30:01 +0200993 unsigned int ass, tmp, i;
994 unsigned nid;
995 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200996
Kailang Yangc9b58002007-10-16 14:30:01 +0200997 ass = codec->subsystem_id & 0xffff;
998 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
999 goto do_sku;
1000
Kailang Yangea1fb292008-08-26 12:58:38 +02001001 /*
Kailang Yangc9b58002007-10-16 14:30:01 +02001002 * 31~30 : port conetcivity
1003 * 29~21 : reserve
1004 * 20 : PCBEEP input
1005 * 19~16 : Check sum (15:1)
1006 * 15~1 : Custom
1007 * 0 : override
1008 */
1009 nid = 0x1d;
1010 if (codec->vendor_id == 0x10ec0260)
1011 nid = 0x17;
1012 ass = snd_hda_codec_read(codec, nid, 0,
1013 AC_VERB_GET_CONFIG_DEFAULT, 0);
1014 if (!(ass & 1) && !(ass & 0x100000))
1015 return;
1016 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001017 return;
1018
Kailang Yangc9b58002007-10-16 14:30:01 +02001019 /* check sum */
1020 tmp = 0;
1021 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +01001022 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +02001023 tmp++;
1024 }
1025 if (((ass >> 16) & 0xf) != tmp)
1026 return;
1027do_sku:
1028 /*
1029 * 0 : override
1030 * 1 : Swap Jack
1031 * 2 : 0 --> Desktop, 1 --> Laptop
1032 * 3~5 : External Amplifier control
1033 * 7~6 : Reserved
1034 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001035 tmp = (ass & 0x38) >> 3; /* external Amp control */
1036 switch (tmp) {
1037 case 1:
1038 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1039 break;
1040 case 3:
1041 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1042 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001043 case 7:
1044 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1045 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001046 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +02001047 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001048 case 0x10ec0260:
1049 snd_hda_codec_write(codec, 0x0f, 0,
1050 AC_VERB_SET_EAPD_BTLENABLE, 2);
1051 snd_hda_codec_write(codec, 0x10, 0,
1052 AC_VERB_SET_EAPD_BTLENABLE, 2);
1053 break;
1054 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001055 case 0x10ec0267:
1056 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001057 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001058 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001059 case 0x10ec0660:
1060 case 0x10ec0662:
1061 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001062 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001063 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001064 snd_hda_codec_write(codec, 0x14, 0,
1065 AC_VERB_SET_EAPD_BTLENABLE, 2);
1066 snd_hda_codec_write(codec, 0x15, 0,
1067 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001068 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001069 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001070 switch (codec->vendor_id) {
1071 case 0x10ec0260:
1072 snd_hda_codec_write(codec, 0x1a, 0,
1073 AC_VERB_SET_COEF_INDEX, 7);
1074 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1075 AC_VERB_GET_PROC_COEF, 0);
1076 snd_hda_codec_write(codec, 0x1a, 0,
1077 AC_VERB_SET_COEF_INDEX, 7);
1078 snd_hda_codec_write(codec, 0x1a, 0,
1079 AC_VERB_SET_PROC_COEF,
1080 tmp | 0x2010);
1081 break;
1082 case 0x10ec0262:
1083 case 0x10ec0880:
1084 case 0x10ec0882:
1085 case 0x10ec0883:
1086 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001087 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001088 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001089 snd_hda_codec_write(codec, 0x20, 0,
1090 AC_VERB_SET_COEF_INDEX, 7);
1091 tmp = snd_hda_codec_read(codec, 0x20, 0,
1092 AC_VERB_GET_PROC_COEF, 0);
1093 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001094 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001095 snd_hda_codec_write(codec, 0x20, 0,
1096 AC_VERB_SET_PROC_COEF,
1097 tmp | 0x2010);
1098 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001099 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +02001100 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +02001101 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001102 case 0x10ec0267:
1103 case 0x10ec0268:
1104 snd_hda_codec_write(codec, 0x20, 0,
1105 AC_VERB_SET_COEF_INDEX, 7);
1106 tmp = snd_hda_codec_read(codec, 0x20, 0,
1107 AC_VERB_GET_PROC_COEF, 0);
1108 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001109 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001110 snd_hda_codec_write(codec, 0x20, 0,
1111 AC_VERB_SET_PROC_COEF,
1112 tmp | 0x3000);
1113 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001114 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001115 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001116 break;
1117 }
Kailang Yangea1fb292008-08-26 12:58:38 +02001118
Kailang Yang8c427222008-01-10 13:03:59 +01001119 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +02001120 * when the external headphone out jack is plugged"
1121 */
Kailang Yang8c427222008-01-10 13:03:59 +01001122 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +02001123 return;
1124 /*
1125 * 10~8 : Jack location
1126 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1127 * 14~13: Resvered
1128 * 15 : 1 --> enable the function "Mute internal speaker
1129 * when the external headphone out jack is plugged"
1130 */
1131 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001132 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001133 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001134 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001135 else
1136 return;
1137 }
1138
1139 if (!spec->autocfg.hp_pins[0]) {
1140 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1141 if (tmp == 0)
1142 spec->autocfg.hp_pins[0] = porta;
1143 else if (tmp == 1)
1144 spec->autocfg.hp_pins[0] = porte;
1145 else if (tmp == 2)
1146 spec->autocfg.hp_pins[0] = portd;
1147 else
1148 return;
1149 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001150 if (spec->autocfg.hp_pins[0])
1151 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1152 AC_VERB_SET_UNSOLICITED_ENABLE,
1153 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangc9b58002007-10-16 14:30:01 +02001154
Takashi Iwai4605b712008-10-31 14:18:24 +01001155#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001156 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1157 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1158 snd_hda_codec_write(codec,
1159 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1160 AC_VERB_SET_UNSOLICITED_ENABLE,
1161 AC_USRSP_EN | ALC880_MIC_EVENT);
Takashi Iwai4605b712008-10-31 14:18:24 +01001162#endif /* disabled */
Kailang Yangea1fb292008-08-26 12:58:38 +02001163
Kailang Yangc9b58002007-10-16 14:30:01 +02001164 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001165}
1166
Takashi Iwai41e41f12005-06-08 14:48:49 +02001167/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001168 * Fix-up pin default configurations
1169 */
1170
1171struct alc_pincfg {
1172 hda_nid_t nid;
1173 u32 val;
1174};
1175
1176static void alc_fix_pincfg(struct hda_codec *codec,
1177 const struct snd_pci_quirk *quirk,
1178 const struct alc_pincfg **pinfix)
1179{
1180 const struct alc_pincfg *cfg;
1181
1182 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1183 if (!quirk)
1184 return;
1185
1186 cfg = pinfix[quirk->value];
1187 for (; cfg->nid; cfg++) {
1188 int i;
1189 u32 val = cfg->val;
1190 for (i = 0; i < 4; i++) {
1191 snd_hda_codec_write(codec, cfg->nid, 0,
1192 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1193 val & 0xff);
1194 val >>= 8;
1195 }
1196 }
1197}
1198
1199/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001200 * ALC888
1201 */
1202
1203/*
1204 * 2ch mode
1205 */
1206static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1207/* Mic-in jack as mic in */
1208 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1209 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1210/* Line-in jack as Line in */
1211 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1212 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1213/* Line-Out as Front */
1214 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1215 { } /* end */
1216};
1217
1218/*
1219 * 4ch mode
1220 */
1221static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1222/* Mic-in jack as mic in */
1223 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1224 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1225/* Line-in jack as Surround */
1226 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1227 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1228/* Line-Out as Front */
1229 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1230 { } /* end */
1231};
1232
1233/*
1234 * 6ch mode
1235 */
1236static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1237/* Mic-in jack as CLFE */
1238 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1239 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1240/* Line-in jack as Surround */
1241 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1242 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1243/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1244 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1245 { } /* end */
1246};
1247
1248/*
1249 * 8ch mode
1250 */
1251static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1252/* Mic-in jack as CLFE */
1253 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1254 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1255/* Line-in jack as Surround */
1256 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1257 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1258/* Line-Out as Side */
1259 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1260 { } /* end */
1261};
1262
1263static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1264 { 2, alc888_4ST_ch2_intel_init },
1265 { 4, alc888_4ST_ch4_intel_init },
1266 { 6, alc888_4ST_ch6_intel_init },
1267 { 8, alc888_4ST_ch8_intel_init },
1268};
1269
1270/*
1271 * ALC888 Fujitsu Siemens Amillo xa3530
1272 */
1273
1274static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1275/* Front Mic: set to PIN_IN (empty by default) */
1276 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1277/* Connect Internal HP to Front */
1278 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1279 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1280 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1281/* Connect Bass HP to Front */
1282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1284 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1285/* Connect Line-Out side jack (SPDIF) to Side */
1286 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1287 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1288 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1289/* Connect Mic jack to CLFE */
1290 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1291 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1292 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1293/* Connect Line-in jack to Surround */
1294 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1295 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1296 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1297/* Connect HP out jack to Front */
1298 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1299 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1300 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1301/* Enable unsolicited event for HP jack and Line-out jack */
1302 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1303 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1304 {}
1305};
1306
1307static void alc888_fujitsu_xa3530_automute(struct hda_codec *codec)
1308{
1309 unsigned int present;
1310 unsigned int bits;
1311 /* Line out presence */
1312 present = snd_hda_codec_read(codec, 0x17, 0,
1313 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1314 /* HP out presence */
1315 present = present || snd_hda_codec_read(codec, 0x1b, 0,
1316 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1317 bits = present ? HDA_AMP_MUTE : 0;
1318 /* Toggle internal speakers muting */
1319 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1320 HDA_AMP_MUTE, bits);
1321 /* Toggle internal bass muting */
1322 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1323 HDA_AMP_MUTE, bits);
1324}
1325
1326static void alc888_fujitsu_xa3530_unsol_event(struct hda_codec *codec,
1327 unsigned int res)
1328{
1329 if (res >> 26 == ALC880_HP_EVENT)
1330 alc888_fujitsu_xa3530_automute(codec);
1331}
1332
1333
1334/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001335 * ALC888 Acer Aspire 4930G model
1336 */
1337
1338static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1339/* Front Mic: set to PIN_IN (empty by default) */
1340 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1341/* Unselect Front Mic by default in input mixer 3 */
1342 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001343/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001344 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1345/* Connect Internal HP to front */
1346 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1347 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1348 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1349/* Connect HP out to front */
1350 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1351 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1352 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1353 { }
1354};
1355
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001356static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001357 /* Front mic only available on one ADC */
1358 {
1359 .num_items = 4,
1360 .items = {
1361 { "Mic", 0x0 },
1362 { "Line", 0x2 },
1363 { "CD", 0x4 },
1364 { "Front Mic", 0xb },
1365 },
1366 },
1367 {
1368 .num_items = 3,
1369 .items = {
1370 { "Mic", 0x0 },
1371 { "Line", 0x2 },
1372 { "CD", 0x4 },
1373 },
1374 }
1375};
1376
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001377static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001378 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1379 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1380 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1381 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1382 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1383 HDA_OUTPUT),
1384 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1385 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1386 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1387 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1388 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1389 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1390 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1391 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1392 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1394 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1395 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001396 { } /* end */
1397};
1398
1399static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1400{
1401 unsigned int present;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001402 unsigned int bits;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001403 present = snd_hda_codec_read(codec, 0x15, 0,
1404 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001405 bits = present ? HDA_AMP_MUTE : 0;
1406 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1407 HDA_AMP_MUTE, bits);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001408}
1409
1410static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1411 unsigned int res)
1412{
1413 if (res >> 26 == ALC880_HP_EVENT)
1414 alc888_acer_aspire_4930g_automute(codec);
1415}
1416
1417/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001418 * ALC880 3-stack model
1419 *
1420 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001421 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1422 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001423 */
1424
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001425static hda_nid_t alc880_dac_nids[4] = {
1426 /* front, rear, clfe, rear_surr */
1427 0x02, 0x05, 0x04, 0x03
1428};
1429
1430static hda_nid_t alc880_adc_nids[3] = {
1431 /* ADC0-2 */
1432 0x07, 0x08, 0x09,
1433};
1434
1435/* The datasheet says the node 0x07 is connected from inputs,
1436 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001437 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001438 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001439static hda_nid_t alc880_adc_nids_alt[2] = {
1440 /* ADC1-2 */
1441 0x08, 0x09,
1442};
1443
1444#define ALC880_DIGOUT_NID 0x06
1445#define ALC880_DIGIN_NID 0x0a
1446
1447static struct hda_input_mux alc880_capture_source = {
1448 .num_items = 4,
1449 .items = {
1450 { "Mic", 0x0 },
1451 { "Front Mic", 0x3 },
1452 { "Line", 0x2 },
1453 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001454 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001455};
1456
1457/* channel source setting (2/6 channel selection for 3-stack) */
1458/* 2ch mode */
1459static struct hda_verb alc880_threestack_ch2_init[] = {
1460 /* set line-in to input, mute it */
1461 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1462 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1463 /* set mic-in to input vref 80%, mute it */
1464 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1465 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001466 { } /* end */
1467};
1468
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001469/* 6ch mode */
1470static struct hda_verb alc880_threestack_ch6_init[] = {
1471 /* set line-in to output, unmute it */
1472 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1473 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1474 /* set mic-in to output, unmute it */
1475 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1476 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1477 { } /* end */
1478};
1479
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001480static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001481 { 2, alc880_threestack_ch2_init },
1482 { 6, alc880_threestack_ch6_init },
1483};
1484
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001485static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001486 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001487 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001488 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001489 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001490 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1491 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001492 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1493 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1495 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1496 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1497 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1498 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1499 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1500 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1501 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001502 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001503 {
1504 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1505 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001506 .info = alc_ch_mode_info,
1507 .get = alc_ch_mode_get,
1508 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001509 },
1510 { } /* end */
1511};
1512
1513/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001514static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1515 struct snd_ctl_elem_info *uinfo)
1516{
1517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1518 struct alc_spec *spec = codec->spec;
1519 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001520
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001521 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001522 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1523 HDA_INPUT);
1524 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001525 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001526 return err;
1527}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001528
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001529static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1530 unsigned int size, unsigned int __user *tlv)
1531{
1532 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1533 struct alc_spec *spec = codec->spec;
1534 int err;
1535
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001536 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001537 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1538 HDA_INPUT);
1539 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001540 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001541 return err;
1542}
1543
1544typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1545 struct snd_ctl_elem_value *ucontrol);
1546
1547static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1548 struct snd_ctl_elem_value *ucontrol,
1549 getput_call_t func)
1550{
1551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1552 struct alc_spec *spec = codec->spec;
1553 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1554 int err;
1555
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001556 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001557 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1558 3, 0, HDA_INPUT);
1559 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001560 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001561 return err;
1562}
1563
1564static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1565 struct snd_ctl_elem_value *ucontrol)
1566{
1567 return alc_cap_getput_caller(kcontrol, ucontrol,
1568 snd_hda_mixer_amp_volume_get);
1569}
1570
1571static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1572 struct snd_ctl_elem_value *ucontrol)
1573{
1574 return alc_cap_getput_caller(kcontrol, ucontrol,
1575 snd_hda_mixer_amp_volume_put);
1576}
1577
1578/* capture mixer elements */
1579#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1580
1581static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1582 struct snd_ctl_elem_value *ucontrol)
1583{
1584 return alc_cap_getput_caller(kcontrol, ucontrol,
1585 snd_hda_mixer_amp_switch_get);
1586}
1587
1588static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1589 struct snd_ctl_elem_value *ucontrol)
1590{
1591 return alc_cap_getput_caller(kcontrol, ucontrol,
1592 snd_hda_mixer_amp_switch_put);
1593}
1594
1595#define DEFINE_CAPMIX(num) \
1596static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1597 { \
1598 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1599 .name = "Capture Switch", \
1600 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1601 .count = num, \
1602 .info = alc_cap_sw_info, \
1603 .get = alc_cap_sw_get, \
1604 .put = alc_cap_sw_put, \
1605 }, \
1606 { \
1607 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1608 .name = "Capture Volume", \
1609 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1610 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1611 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1612 .count = num, \
1613 .info = alc_cap_vol_info, \
1614 .get = alc_cap_vol_get, \
1615 .put = alc_cap_vol_put, \
1616 .tlv = { .c = alc_cap_vol_tlv }, \
1617 }, \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001618 { \
1619 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1620 /* .name = "Capture Source", */ \
1621 .name = "Input Source", \
1622 .count = num, \
1623 .info = alc_mux_enum_info, \
1624 .get = alc_mux_enum_get, \
1625 .put = alc_mux_enum_put, \
1626 }, \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001627 { } /* end */ \
1628}
1629
1630/* up to three ADCs */
1631DEFINE_CAPMIX(1);
1632DEFINE_CAPMIX(2);
1633DEFINE_CAPMIX(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001634
1635
1636/*
1637 * ALC880 5-stack model
1638 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001639 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1640 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001641 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1642 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1643 */
1644
1645/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001646static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001647 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001648 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001649 { } /* end */
1650};
1651
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001652/* channel source setting (6/8 channel selection for 5-stack) */
1653/* 6ch mode */
1654static struct hda_verb alc880_fivestack_ch6_init[] = {
1655 /* set line-in to input, mute it */
1656 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1657 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001658 { } /* end */
1659};
1660
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001661/* 8ch mode */
1662static struct hda_verb alc880_fivestack_ch8_init[] = {
1663 /* set line-in to output, unmute it */
1664 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1665 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1666 { } /* end */
1667};
1668
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001669static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001670 { 6, alc880_fivestack_ch6_init },
1671 { 8, alc880_fivestack_ch8_init },
1672};
1673
1674
1675/*
1676 * ALC880 6-stack model
1677 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001678 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1679 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001680 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1681 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1682 */
1683
1684static hda_nid_t alc880_6st_dac_nids[4] = {
1685 /* front, rear, clfe, rear_surr */
1686 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001687};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001688
1689static struct hda_input_mux alc880_6stack_capture_source = {
1690 .num_items = 4,
1691 .items = {
1692 { "Mic", 0x0 },
1693 { "Front Mic", 0x1 },
1694 { "Line", 0x2 },
1695 { "CD", 0x4 },
1696 },
1697};
1698
1699/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001700static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001701 { 8, NULL },
1702};
1703
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001704static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001705 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001706 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001707 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001708 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001709 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1710 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001711 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1712 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001713 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001714 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001715 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1716 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1717 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1718 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1719 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1720 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1721 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1722 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001723 {
1724 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1725 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001726 .info = alc_ch_mode_info,
1727 .get = alc_ch_mode_get,
1728 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001729 },
1730 { } /* end */
1731};
1732
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001733
1734/*
1735 * ALC880 W810 model
1736 *
1737 * W810 has rear IO for:
1738 * Front (DAC 02)
1739 * Surround (DAC 03)
1740 * Center/LFE (DAC 04)
1741 * Digital out (06)
1742 *
1743 * The system also has a pair of internal speakers, and a headphone jack.
1744 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001745 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001746 * There is a variable resistor to control the speaker or headphone
1747 * volume. This is a hardware-only device without a software API.
1748 *
1749 * Plugging headphones in will disable the internal speakers. This is
1750 * implemented in hardware, not via the driver using jack sense. In
1751 * a similar fashion, plugging into the rear socket marked "front" will
1752 * disable both the speakers and headphones.
1753 *
1754 * For input, there's a microphone jack, and an "audio in" jack.
1755 * These may not do anything useful with this driver yet, because I
1756 * haven't setup any initialization verbs for these yet...
1757 */
1758
1759static hda_nid_t alc880_w810_dac_nids[3] = {
1760 /* front, rear/surround, clfe */
1761 0x02, 0x03, 0x04
1762};
1763
1764/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001765static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001766 { 6, NULL }
1767};
1768
1769/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001770static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001771 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001772 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001773 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001774 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001775 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1776 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001777 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1778 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001779 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1780 { } /* end */
1781};
1782
1783
1784/*
1785 * Z710V model
1786 *
1787 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001788 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1789 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001790 */
1791
1792static hda_nid_t alc880_z71v_dac_nids[1] = {
1793 0x02
1794};
1795#define ALC880_Z71V_HP_DAC 0x03
1796
1797/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001798static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001799 { 2, NULL }
1800};
1801
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001802static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001803 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001804 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001805 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001806 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001807 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1808 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1811 { } /* end */
1812};
1813
1814
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001815/*
1816 * ALC880 F1734 model
1817 *
1818 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1819 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1820 */
1821
1822static hda_nid_t alc880_f1734_dac_nids[1] = {
1823 0x03
1824};
1825#define ALC880_F1734_HP_DAC 0x02
1826
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001827static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001828 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001829 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001830 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1831 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001832 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1833 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001834 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1835 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001836 { } /* end */
1837};
1838
Takashi Iwai937b4162008-02-11 14:52:36 +01001839static struct hda_input_mux alc880_f1734_capture_source = {
1840 .num_items = 2,
1841 .items = {
1842 { "Mic", 0x1 },
1843 { "CD", 0x4 },
1844 },
1845};
1846
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001847
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001848/*
1849 * ALC880 ASUS model
1850 *
1851 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1852 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1853 * Mic = 0x18, Line = 0x1a
1854 */
1855
1856#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1857#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1858
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001859static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001860 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001861 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001862 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001863 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001864 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1865 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001866 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1867 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001868 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1869 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1870 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1871 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1872 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1873 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001874 {
1875 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1876 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001877 .info = alc_ch_mode_info,
1878 .get = alc_ch_mode_get,
1879 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001880 },
1881 { } /* end */
1882};
1883
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001884/*
1885 * ALC880 ASUS W1V model
1886 *
1887 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1888 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1889 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1890 */
1891
1892/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01001893static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001894 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1895 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001896 { } /* end */
1897};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001898
Kailang Yangdf694da2005-12-05 19:42:22 +01001899/* TCL S700 */
1900static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1901 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1902 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1903 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1904 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1905 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1906 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1907 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1908 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1909 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001910 { } /* end */
1911};
1912
Kailang Yangccc656c2006-10-17 12:32:26 +02001913/* Uniwill */
1914static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001915 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1916 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1917 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1918 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001919 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1920 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1921 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1922 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1923 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1924 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1925 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1926 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1927 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1928 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1929 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1930 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001931 {
1932 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1933 .name = "Channel Mode",
1934 .info = alc_ch_mode_info,
1935 .get = alc_ch_mode_get,
1936 .put = alc_ch_mode_put,
1937 },
1938 { } /* end */
1939};
1940
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001941static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1942 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1943 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1944 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1945 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1946 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1947 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1948 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1949 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1950 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1951 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1952 { } /* end */
1953};
1954
Kailang Yangccc656c2006-10-17 12:32:26 +02001955static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001956 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1957 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1958 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1959 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001960 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1961 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1962 { } /* end */
1963};
1964
Linus Torvalds1da177e2005-04-16 15:20:36 -07001965/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001966 * virtual master controls
1967 */
1968
1969/*
1970 * slave controls for virtual master
1971 */
1972static const char *alc_slave_vols[] = {
1973 "Front Playback Volume",
1974 "Surround Playback Volume",
1975 "Center Playback Volume",
1976 "LFE Playback Volume",
1977 "Side Playback Volume",
1978 "Headphone Playback Volume",
1979 "Speaker Playback Volume",
1980 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001981 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01001982 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001983 NULL,
1984};
1985
1986static const char *alc_slave_sws[] = {
1987 "Front Playback Switch",
1988 "Surround Playback Switch",
1989 "Center Playback Switch",
1990 "LFE Playback Switch",
1991 "Side Playback Switch",
1992 "Headphone Playback Switch",
1993 "Speaker Playback Switch",
1994 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001995 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001996 NULL,
1997};
1998
1999/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002000 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002001 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002002
2003static void alc_free_kctls(struct hda_codec *codec);
2004
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002005/* additional beep mixers; the actual parameters are overwritten at build */
2006static struct snd_kcontrol_new alc_beep_mixer[] = {
2007 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2008 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2009 { } /* end */
2010};
2011
Linus Torvalds1da177e2005-04-16 15:20:36 -07002012static int alc_build_controls(struct hda_codec *codec)
2013{
2014 struct alc_spec *spec = codec->spec;
2015 int err;
2016 int i;
2017
2018 for (i = 0; i < spec->num_mixers; i++) {
2019 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2020 if (err < 0)
2021 return err;
2022 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002023 if (spec->cap_mixer) {
2024 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2025 if (err < 0)
2026 return err;
2027 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002028 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002029 err = snd_hda_create_spdif_out_ctls(codec,
2030 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002031 if (err < 0)
2032 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002033 if (!spec->no_analog) {
2034 err = snd_hda_create_spdif_share_sw(codec,
2035 &spec->multiout);
2036 if (err < 0)
2037 return err;
2038 spec->multiout.share_spdif = 1;
2039 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002040 }
2041 if (spec->dig_in_nid) {
2042 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2043 if (err < 0)
2044 return err;
2045 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002046
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002047 /* create beep controls if needed */
2048 if (spec->beep_amp) {
2049 struct snd_kcontrol_new *knew;
2050 for (knew = alc_beep_mixer; knew->name; knew++) {
2051 struct snd_kcontrol *kctl;
2052 kctl = snd_ctl_new1(knew, codec);
2053 if (!kctl)
2054 return -ENOMEM;
2055 kctl->private_value = spec->beep_amp;
2056 err = snd_hda_ctl_add(codec, kctl);
2057 if (err < 0)
2058 return err;
2059 }
2060 }
2061
Takashi Iwai2134ea42008-01-10 16:53:55 +01002062 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002063 if (!spec->no_analog &&
2064 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002065 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002066 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002067 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002068 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002069 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002070 if (err < 0)
2071 return err;
2072 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002073 if (!spec->no_analog &&
2074 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002075 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2076 NULL, alc_slave_sws);
2077 if (err < 0)
2078 return err;
2079 }
2080
Takashi Iwai603c4012008-07-30 15:01:44 +02002081 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002082 return 0;
2083}
2084
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002085
Linus Torvalds1da177e2005-04-16 15:20:36 -07002086/*
2087 * initialize the codec volumes, etc
2088 */
2089
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002090/*
2091 * generic initialization of ADC, input mixers and output mixers
2092 */
2093static struct hda_verb alc880_volume_init_verbs[] = {
2094 /*
2095 * Unmute ADC0-2 and set the default input to mic-in
2096 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002097 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002098 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002099 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002100 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002101 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002102 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002103
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002104 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2105 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002106 * Note: PASD motherboards uses the Line In 2 as the input for front
2107 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002108 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002109 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002110 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2111 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002117
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002118 /*
2119 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002120 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002121 /* set vol=0 to output mixers */
2122 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2123 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2124 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2125 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2126 /* set up input amps for analog loopback */
2127 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002128 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002130 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2131 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002132 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2133 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002134 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2135 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002136
2137 { }
2138};
2139
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002140/*
2141 * 3-stack pin configuration:
2142 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2143 */
2144static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2145 /*
2146 * preset connection lists of input pins
2147 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2148 */
2149 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2150 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2151 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2152
2153 /*
2154 * Set pin mode and muting
2155 */
2156 /* set front pin widgets 0x14 for output */
2157 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2158 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2159 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2160 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2161 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2162 /* Mic2 (as headphone out) for HP output */
2163 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2164 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2165 /* Line In pin widget for input */
2166 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2167 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2168 /* Line2 (as front mic) pin widget for input and vref at 80% */
2169 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2170 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2171 /* CD pin widget for input */
2172 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2173
2174 { }
2175};
2176
2177/*
2178 * 5-stack pin configuration:
2179 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2180 * line-in/side = 0x1a, f-mic = 0x1b
2181 */
2182static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2183 /*
2184 * preset connection lists of input pins
2185 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2186 */
2187 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2188 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2189
2190 /*
2191 * Set pin mode and muting
2192 */
2193 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002194 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2195 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2196 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2197 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002198 /* unmute pins for output (no gain on this amp) */
2199 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2200 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2201 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2202 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2203
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002205 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002206 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2207 /* Mic2 (as headphone out) for HP output */
2208 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002209 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002210 /* Line In pin widget for input */
2211 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2212 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2213 /* Line2 (as front mic) pin widget for input and vref at 80% */
2214 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2215 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2216 /* CD pin widget for input */
2217 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002218
2219 { }
2220};
2221
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002222/*
2223 * W810 pin configuration:
2224 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2225 */
2226static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002227 /* hphone/speaker input selector: front DAC */
2228 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2229
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002230 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2231 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2232 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2233 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2234 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2235 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2236
2237 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002238 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239
Linus Torvalds1da177e2005-04-16 15:20:36 -07002240 { }
2241};
2242
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002243/*
2244 * Z71V pin configuration:
2245 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2246 */
2247static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002248 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002249 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002250 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002251 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002252
Takashi Iwai16ded522005-06-10 19:58:24 +02002253 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002254 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002255 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002256 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002257
2258 { }
2259};
2260
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002261/*
2262 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002263 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2264 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002265 */
2266static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2267 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2268
Takashi Iwai16ded522005-06-10 19:58:24 +02002269 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002270 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002271 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002272 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002273 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002274 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002275 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002276 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2277
Takashi Iwai16ded522005-06-10 19:58:24 +02002278 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002279 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002280 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002281 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002282 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002283 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002284 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002285 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002286 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002287
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002288 { }
2289};
Takashi Iwai16ded522005-06-10 19:58:24 +02002290
Kailang Yangccc656c2006-10-17 12:32:26 +02002291/*
2292 * Uniwill pin configuration:
2293 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2294 * line = 0x1a
2295 */
2296static struct hda_verb alc880_uniwill_init_verbs[] = {
2297 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2298
2299 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2300 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2301 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2302 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2303 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2304 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2305 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2306 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2309 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2310 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2311 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2312 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2313
2314 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2315 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2316 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2317 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2318 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2319 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2320 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2321 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2322 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2323
2324 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2325 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2326
2327 { }
2328};
2329
2330/*
2331* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002332* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002333 */
2334static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2335 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2336
2337 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2338 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2339 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2340 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2341 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2342 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2343 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2345 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2349
2350 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2351 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2352 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2353 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2354 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2355 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2356
2357 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2358 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2359
2360 { }
2361};
2362
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002363static struct hda_verb alc880_beep_init_verbs[] = {
2364 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2365 { }
2366};
2367
Kailang Yangccc656c2006-10-17 12:32:26 +02002368/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002369static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002370{
2371 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002372 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002373
2374 present = snd_hda_codec_read(codec, 0x14, 0,
2375 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002376 bits = present ? HDA_AMP_MUTE : 0;
2377 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2378 HDA_AMP_MUTE, bits);
2379 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2380 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002381}
2382
2383/* auto-toggle front mic */
2384static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2385{
2386 unsigned int present;
2387 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002388
2389 present = snd_hda_codec_read(codec, 0x18, 0,
2390 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002391 bits = present ? HDA_AMP_MUTE : 0;
2392 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002393}
2394
2395static void alc880_uniwill_automute(struct hda_codec *codec)
2396{
2397 alc880_uniwill_hp_automute(codec);
2398 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002399}
2400
2401static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2402 unsigned int res)
2403{
2404 /* Looks like the unsol event is incompatible with the standard
2405 * definition. 4bit tag is placed at 28 bit!
2406 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002407 switch (res >> 28) {
2408 case ALC880_HP_EVENT:
2409 alc880_uniwill_hp_automute(codec);
2410 break;
2411 case ALC880_MIC_EVENT:
2412 alc880_uniwill_mic_automute(codec);
2413 break;
2414 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002415}
2416
2417static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2418{
2419 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002420 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002421
2422 present = snd_hda_codec_read(codec, 0x14, 0,
2423 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002424 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002425 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002426}
2427
2428static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2429{
2430 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002431
Kailang Yangccc656c2006-10-17 12:32:26 +02002432 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002433 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2434 present &= HDA_AMP_VOLMASK;
2435 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2436 HDA_AMP_VOLMASK, present);
2437 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2438 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002439}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002440
Kailang Yangccc656c2006-10-17 12:32:26 +02002441static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2442 unsigned int res)
2443{
2444 /* Looks like the unsol event is incompatible with the standard
2445 * definition. 4bit tag is placed at 28 bit!
2446 */
2447 if ((res >> 28) == ALC880_HP_EVENT)
2448 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002449 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002450 alc880_uniwill_p53_dcvol_automute(codec);
2451}
2452
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002453/*
2454 * F1734 pin configuration:
2455 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2456 */
2457static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002458 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002459 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2460 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2461 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2462 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2463
2464 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2465 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2468
2469 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2470 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002471 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002472 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2473 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2474 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2475 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2476 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2477 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002478
Takashi Iwai937b4162008-02-11 14:52:36 +01002479 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2480 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2481
Takashi Iwai16ded522005-06-10 19:58:24 +02002482 { }
2483};
2484
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002485/*
2486 * ASUS pin configuration:
2487 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2488 */
2489static struct hda_verb alc880_pin_asus_init_verbs[] = {
2490 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2491 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2492 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2493 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2494
2495 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2496 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2498 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2499 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2500 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2501 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2502 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2503
2504 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2506 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2507 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2508 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2509 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2510 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2511 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2512 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002513
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002514 { }
2515};
2516
2517/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002518#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2519#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002520
Kailang Yangdf694da2005-12-05 19:42:22 +01002521/* Clevo m520g init */
2522static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2523 /* headphone output */
2524 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2525 /* line-out */
2526 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2527 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2528 /* Line-in */
2529 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2530 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2531 /* CD */
2532 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2533 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2534 /* Mic1 (rear panel) */
2535 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2536 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2537 /* Mic2 (front panel) */
2538 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2539 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2540 /* headphone */
2541 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2542 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2543 /* change to EAPD mode */
2544 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2545 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2546
2547 { }
2548};
2549
2550static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002551 /* change to EAPD mode */
2552 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2553 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2554
Kailang Yangdf694da2005-12-05 19:42:22 +01002555 /* Headphone output */
2556 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2557 /* Front output*/
2558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2559 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2560
2561 /* Line In pin widget for input */
2562 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2563 /* CD pin widget for input */
2564 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2565 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2566 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2567
2568 /* change to EAPD mode */
2569 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2570 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2571
2572 { }
2573};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002574
2575/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002576 * LG m1 express dual
2577 *
2578 * Pin assignment:
2579 * Rear Line-In/Out (blue): 0x14
2580 * Build-in Mic-In: 0x15
2581 * Speaker-out: 0x17
2582 * HP-Out (green): 0x1b
2583 * Mic-In/Out (red): 0x19
2584 * SPDIF-Out: 0x1e
2585 */
2586
2587/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2588static hda_nid_t alc880_lg_dac_nids[3] = {
2589 0x05, 0x02, 0x03
2590};
2591
2592/* seems analog CD is not working */
2593static struct hda_input_mux alc880_lg_capture_source = {
2594 .num_items = 3,
2595 .items = {
2596 { "Mic", 0x1 },
2597 { "Line", 0x5 },
2598 { "Internal Mic", 0x6 },
2599 },
2600};
2601
2602/* 2,4,6 channel modes */
2603static struct hda_verb alc880_lg_ch2_init[] = {
2604 /* set line-in and mic-in to input */
2605 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2606 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2607 { }
2608};
2609
2610static struct hda_verb alc880_lg_ch4_init[] = {
2611 /* set line-in to out and mic-in to input */
2612 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2613 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2614 { }
2615};
2616
2617static struct hda_verb alc880_lg_ch6_init[] = {
2618 /* set line-in and mic-in to output */
2619 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2620 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2621 { }
2622};
2623
2624static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2625 { 2, alc880_lg_ch2_init },
2626 { 4, alc880_lg_ch4_init },
2627 { 6, alc880_lg_ch6_init },
2628};
2629
2630static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002631 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2632 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002633 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2634 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2635 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2636 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2637 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2638 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2639 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2640 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2641 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2642 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2643 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2644 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2645 {
2646 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2647 .name = "Channel Mode",
2648 .info = alc_ch_mode_info,
2649 .get = alc_ch_mode_get,
2650 .put = alc_ch_mode_put,
2651 },
2652 { } /* end */
2653};
2654
2655static struct hda_verb alc880_lg_init_verbs[] = {
2656 /* set capture source to mic-in */
2657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2658 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2659 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2660 /* mute all amp mixer inputs */
2661 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2663 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002664 /* line-in to input */
2665 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2666 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2667 /* built-in mic */
2668 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2669 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2670 /* speaker-out */
2671 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2672 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2673 /* mic-in to input */
2674 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2675 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2676 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2677 /* HP-out */
2678 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2679 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2680 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2681 /* jack sense */
2682 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2683 { }
2684};
2685
2686/* toggle speaker-output according to the hp-jack state */
2687static void alc880_lg_automute(struct hda_codec *codec)
2688{
2689 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002690 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002691
2692 present = snd_hda_codec_read(codec, 0x1b, 0,
2693 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002694 bits = present ? HDA_AMP_MUTE : 0;
2695 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2696 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002697}
2698
2699static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2700{
2701 /* Looks like the unsol event is incompatible with the standard
2702 * definition. 4bit tag is placed at 28 bit!
2703 */
2704 if ((res >> 28) == 0x01)
2705 alc880_lg_automute(codec);
2706}
2707
2708/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002709 * LG LW20
2710 *
2711 * Pin assignment:
2712 * Speaker-out: 0x14
2713 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002714 * Built-in Mic-In: 0x19
2715 * Line-In: 0x1b
2716 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002717 * SPDIF-Out: 0x1e
2718 */
2719
Takashi Iwaid6815182006-03-23 16:06:23 +01002720static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002721 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002722 .items = {
2723 { "Mic", 0x0 },
2724 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002725 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002726 },
2727};
2728
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002729#define alc880_lg_lw_modes alc880_threestack_modes
2730
Takashi Iwaid6815182006-03-23 16:06:23 +01002731static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002732 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2733 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2734 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2735 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2736 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2737 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2738 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2739 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2740 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2741 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2744 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2745 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002746 {
2747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2748 .name = "Channel Mode",
2749 .info = alc_ch_mode_info,
2750 .get = alc_ch_mode_get,
2751 .put = alc_ch_mode_put,
2752 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002753 { } /* end */
2754};
2755
2756static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002757 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2758 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2759 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2760
Takashi Iwaid6815182006-03-23 16:06:23 +01002761 /* set capture source to mic-in */
2762 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2763 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2764 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002765 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002766 /* speaker-out */
2767 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2768 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2769 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002770 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2771 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2772 /* mic-in to input */
2773 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2774 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2775 /* built-in mic */
2776 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2778 /* jack sense */
2779 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2780 { }
2781};
2782
2783/* toggle speaker-output according to the hp-jack state */
2784static void alc880_lg_lw_automute(struct hda_codec *codec)
2785{
2786 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002787 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002788
2789 present = snd_hda_codec_read(codec, 0x1b, 0,
2790 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002791 bits = present ? HDA_AMP_MUTE : 0;
2792 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2793 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002794}
2795
2796static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2797{
2798 /* Looks like the unsol event is incompatible with the standard
2799 * definition. 4bit tag is placed at 28 bit!
2800 */
2801 if ((res >> 28) == 0x01)
2802 alc880_lg_lw_automute(codec);
2803}
2804
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002805static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2806 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2807 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2810 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2811 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2812 { } /* end */
2813};
2814
2815static struct hda_input_mux alc880_medion_rim_capture_source = {
2816 .num_items = 2,
2817 .items = {
2818 { "Mic", 0x0 },
2819 { "Internal Mic", 0x1 },
2820 },
2821};
2822
2823static struct hda_verb alc880_medion_rim_init_verbs[] = {
2824 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2825
2826 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2827 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2828
2829 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2830 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2831 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2832 /* Mic2 (as headphone out) for HP output */
2833 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2834 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2835 /* Internal Speaker */
2836 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2837 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2838
2839 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2840 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2841
2842 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2843 { }
2844};
2845
2846/* toggle speaker-output according to the hp-jack state */
2847static void alc880_medion_rim_automute(struct hda_codec *codec)
2848{
2849 unsigned int present;
2850 unsigned char bits;
2851
2852 present = snd_hda_codec_read(codec, 0x14, 0,
2853 AC_VERB_GET_PIN_SENSE, 0)
2854 & AC_PINSENSE_PRESENCE;
2855 bits = present ? HDA_AMP_MUTE : 0;
2856 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2857 HDA_AMP_MUTE, bits);
2858 if (present)
2859 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2860 else
2861 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2862}
2863
2864static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2865 unsigned int res)
2866{
2867 /* Looks like the unsol event is incompatible with the standard
2868 * definition. 4bit tag is placed at 28 bit!
2869 */
2870 if ((res >> 28) == ALC880_HP_EVENT)
2871 alc880_medion_rim_automute(codec);
2872}
2873
Takashi Iwaicb53c622007-08-10 17:21:45 +02002874#ifdef CONFIG_SND_HDA_POWER_SAVE
2875static struct hda_amp_list alc880_loopbacks[] = {
2876 { 0x0b, HDA_INPUT, 0 },
2877 { 0x0b, HDA_INPUT, 1 },
2878 { 0x0b, HDA_INPUT, 2 },
2879 { 0x0b, HDA_INPUT, 3 },
2880 { 0x0b, HDA_INPUT, 4 },
2881 { } /* end */
2882};
2883
2884static struct hda_amp_list alc880_lg_loopbacks[] = {
2885 { 0x0b, HDA_INPUT, 1 },
2886 { 0x0b, HDA_INPUT, 6 },
2887 { 0x0b, HDA_INPUT, 7 },
2888 { } /* end */
2889};
2890#endif
2891
Takashi Iwaid6815182006-03-23 16:06:23 +01002892/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002893 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002894 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002895
Linus Torvalds1da177e2005-04-16 15:20:36 -07002896static int alc_init(struct hda_codec *codec)
2897{
2898 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002899 unsigned int i;
2900
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002901 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002902 if (codec->vendor_id == 0x10ec0888)
2903 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002904
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002905 for (i = 0; i < spec->num_init_verbs; i++)
2906 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002907
2908 if (spec->init_hook)
2909 spec->init_hook(codec);
2910
Linus Torvalds1da177e2005-04-16 15:20:36 -07002911 return 0;
2912}
2913
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002914static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2915{
2916 struct alc_spec *spec = codec->spec;
2917
2918 if (spec->unsol_event)
2919 spec->unsol_event(codec, res);
2920}
2921
Takashi Iwaicb53c622007-08-10 17:21:45 +02002922#ifdef CONFIG_SND_HDA_POWER_SAVE
2923static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2924{
2925 struct alc_spec *spec = codec->spec;
2926 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2927}
2928#endif
2929
Linus Torvalds1da177e2005-04-16 15:20:36 -07002930/*
2931 * Analog playback callbacks
2932 */
2933static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2934 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002935 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002936{
2937 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002938 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2939 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002940}
2941
2942static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2943 struct hda_codec *codec,
2944 unsigned int stream_tag,
2945 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002946 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002947{
2948 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002949 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2950 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002951}
2952
2953static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2954 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002955 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002956{
2957 struct alc_spec *spec = codec->spec;
2958 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2959}
2960
2961/*
2962 * Digital out
2963 */
2964static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2965 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002966 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002967{
2968 struct alc_spec *spec = codec->spec;
2969 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2970}
2971
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002972static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2973 struct hda_codec *codec,
2974 unsigned int stream_tag,
2975 unsigned int format,
2976 struct snd_pcm_substream *substream)
2977{
2978 struct alc_spec *spec = codec->spec;
2979 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2980 stream_tag, format, substream);
2981}
2982
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01002983static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2984 struct hda_codec *codec,
2985 struct snd_pcm_substream *substream)
2986{
2987 struct alc_spec *spec = codec->spec;
2988 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2989}
2990
Linus Torvalds1da177e2005-04-16 15:20:36 -07002991static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2992 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01002993 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002994{
2995 struct alc_spec *spec = codec->spec;
2996 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2997}
2998
2999/*
3000 * Analog capture
3001 */
Takashi Iwai63300792008-01-24 15:31:36 +01003002static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003003 struct hda_codec *codec,
3004 unsigned int stream_tag,
3005 unsigned int format,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003006 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003007{
3008 struct alc_spec *spec = codec->spec;
3009
Takashi Iwai63300792008-01-24 15:31:36 +01003010 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003011 stream_tag, 0, format);
3012 return 0;
3013}
3014
Takashi Iwai63300792008-01-24 15:31:36 +01003015static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003016 struct hda_codec *codec,
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003017 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003018{
3019 struct alc_spec *spec = codec->spec;
3020
Takashi Iwai888afa12008-03-18 09:57:50 +01003021 snd_hda_codec_cleanup_stream(codec,
3022 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003023 return 0;
3024}
3025
3026
3027/*
3028 */
3029static struct hda_pcm_stream alc880_pcm_analog_playback = {
3030 .substreams = 1,
3031 .channels_min = 2,
3032 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003033 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003034 .ops = {
3035 .open = alc880_playback_pcm_open,
3036 .prepare = alc880_playback_pcm_prepare,
3037 .cleanup = alc880_playback_pcm_cleanup
3038 },
3039};
3040
3041static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003042 .substreams = 1,
3043 .channels_min = 2,
3044 .channels_max = 2,
3045 /* NID is set in alc_build_pcms */
3046};
3047
3048static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3049 .substreams = 1,
3050 .channels_min = 2,
3051 .channels_max = 2,
3052 /* NID is set in alc_build_pcms */
3053};
3054
3055static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3056 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003057 .channels_min = 2,
3058 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003059 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003060 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003061 .prepare = alc880_alt_capture_pcm_prepare,
3062 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003063 },
3064};
3065
3066static struct hda_pcm_stream alc880_pcm_digital_playback = {
3067 .substreams = 1,
3068 .channels_min = 2,
3069 .channels_max = 2,
3070 /* NID is set in alc_build_pcms */
3071 .ops = {
3072 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003073 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003074 .prepare = alc880_dig_playback_pcm_prepare,
3075 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003076 },
3077};
3078
3079static struct hda_pcm_stream alc880_pcm_digital_capture = {
3080 .substreams = 1,
3081 .channels_min = 2,
3082 .channels_max = 2,
3083 /* NID is set in alc_build_pcms */
3084};
3085
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003086/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003087static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003088 .substreams = 0,
3089 .channels_min = 0,
3090 .channels_max = 0,
3091};
3092
Linus Torvalds1da177e2005-04-16 15:20:36 -07003093static int alc_build_pcms(struct hda_codec *codec)
3094{
3095 struct alc_spec *spec = codec->spec;
3096 struct hda_pcm *info = spec->pcm_rec;
3097 int i;
3098
3099 codec->num_pcms = 1;
3100 codec->pcm_info = info;
3101
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003102 if (spec->no_analog)
3103 goto skip_analog;
3104
Linus Torvalds1da177e2005-04-16 15:20:36 -07003105 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003106 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003107 if (snd_BUG_ON(!spec->multiout.dac_nids))
3108 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003109 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3110 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3111 }
3112 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003113 if (snd_BUG_ON(!spec->adc_nids))
3114 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003115 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3116 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3117 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003118
Takashi Iwai4a471b72005-12-07 13:56:29 +01003119 if (spec->channel_mode) {
3120 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3121 for (i = 0; i < spec->num_channel_mode; i++) {
3122 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3123 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3124 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003125 }
3126 }
3127
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003128 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003129 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003130 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003131 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003132 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003133 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003134 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003135 if (spec->dig_out_type)
3136 info->pcm_type = spec->dig_out_type;
3137 else
3138 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003139 if (spec->multiout.dig_out_nid &&
3140 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003141 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3142 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3143 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003144 if (spec->dig_in_nid &&
3145 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003146 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3147 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3148 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003149 /* FIXME: do we need this for all Realtek codec models? */
3150 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003151 }
3152
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003153 if (spec->no_analog)
3154 return 0;
3155
Takashi Iwaie08a0072006-09-07 17:52:14 +02003156 /* If the use of more than one ADC is requested for the current
3157 * model, configure a second analog capture-only PCM.
3158 */
3159 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003160 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3161 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003162 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003163 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003164 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003165 if (spec->alt_dac_nid) {
3166 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3167 *spec->stream_analog_alt_playback;
3168 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3169 spec->alt_dac_nid;
3170 } else {
3171 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3172 alc_pcm_null_stream;
3173 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3174 }
3175 if (spec->num_adc_nids > 1) {
3176 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3177 *spec->stream_analog_alt_capture;
3178 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3179 spec->adc_nids[1];
3180 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3181 spec->num_adc_nids - 1;
3182 } else {
3183 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3184 alc_pcm_null_stream;
3185 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003186 }
3187 }
3188
Linus Torvalds1da177e2005-04-16 15:20:36 -07003189 return 0;
3190}
3191
Takashi Iwai603c4012008-07-30 15:01:44 +02003192static void alc_free_kctls(struct hda_codec *codec)
3193{
3194 struct alc_spec *spec = codec->spec;
3195
3196 if (spec->kctls.list) {
3197 struct snd_kcontrol_new *kctl = spec->kctls.list;
3198 int i;
3199 for (i = 0; i < spec->kctls.used; i++)
3200 kfree(kctl[i].name);
3201 }
3202 snd_array_free(&spec->kctls);
3203}
3204
Linus Torvalds1da177e2005-04-16 15:20:36 -07003205static void alc_free(struct hda_codec *codec)
3206{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003207 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003208
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003209 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003210 return;
3211
Takashi Iwai603c4012008-07-30 15:01:44 +02003212 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003213 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003214 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003215}
3216
Takashi Iwaie044c392008-10-27 16:56:24 +01003217#ifdef SND_HDA_NEEDS_RESUME
3218static void store_pin_configs(struct hda_codec *codec)
3219{
3220 struct alc_spec *spec = codec->spec;
3221 hda_nid_t nid, end_nid;
3222
3223 end_nid = codec->start_nid + codec->num_nodes;
3224 for (nid = codec->start_nid; nid < end_nid; nid++) {
3225 unsigned int wid_caps = get_wcaps(codec, nid);
3226 unsigned int wid_type =
3227 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3228 if (wid_type != AC_WID_PIN)
3229 continue;
3230 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
3231 break;
3232 spec->pin_nids[spec->num_pins] = nid;
3233 spec->pin_cfgs[spec->num_pins] =
3234 snd_hda_codec_read(codec, nid, 0,
3235 AC_VERB_GET_CONFIG_DEFAULT, 0);
3236 spec->num_pins++;
3237 }
3238}
3239
3240static void resume_pin_configs(struct hda_codec *codec)
3241{
3242 struct alc_spec *spec = codec->spec;
3243 int i;
3244
3245 for (i = 0; i < spec->num_pins; i++) {
3246 hda_nid_t pin_nid = spec->pin_nids[i];
3247 unsigned int pin_config = spec->pin_cfgs[i];
3248 snd_hda_codec_write(codec, pin_nid, 0,
3249 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
3250 pin_config & 0x000000ff);
3251 snd_hda_codec_write(codec, pin_nid, 0,
3252 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
3253 (pin_config & 0x0000ff00) >> 8);
3254 snd_hda_codec_write(codec, pin_nid, 0,
3255 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
3256 (pin_config & 0x00ff0000) >> 16);
3257 snd_hda_codec_write(codec, pin_nid, 0,
3258 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
3259 pin_config >> 24);
3260 }
3261}
3262
3263static int alc_resume(struct hda_codec *codec)
3264{
3265 resume_pin_configs(codec);
3266 codec->patch_ops.init(codec);
3267 snd_hda_codec_resume_amp(codec);
3268 snd_hda_codec_resume_cache(codec);
3269 return 0;
3270}
3271#else
3272#define store_pin_configs(codec)
3273#endif
3274
Linus Torvalds1da177e2005-04-16 15:20:36 -07003275/*
3276 */
3277static struct hda_codec_ops alc_patch_ops = {
3278 .build_controls = alc_build_controls,
3279 .build_pcms = alc_build_pcms,
3280 .init = alc_init,
3281 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003282 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003283#ifdef SND_HDA_NEEDS_RESUME
3284 .resume = alc_resume,
3285#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003286#ifdef CONFIG_SND_HDA_POWER_SAVE
3287 .check_power_status = alc_check_power_status,
3288#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003289};
3290
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003291
3292/*
3293 * Test configuration for debugging
3294 *
3295 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3296 * enum controls.
3297 */
3298#ifdef CONFIG_SND_DEBUG
3299static hda_nid_t alc880_test_dac_nids[4] = {
3300 0x02, 0x03, 0x04, 0x05
3301};
3302
3303static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003304 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003305 .items = {
3306 { "In-1", 0x0 },
3307 { "In-2", 0x1 },
3308 { "In-3", 0x2 },
3309 { "In-4", 0x3 },
3310 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003311 { "Front", 0x5 },
3312 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003313 },
3314};
3315
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003316static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003317 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003318 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003319 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003320 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003321};
3322
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003323static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3324 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003325{
3326 static char *texts[] = {
3327 "N/A", "Line Out", "HP Out",
3328 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3329 };
3330 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3331 uinfo->count = 1;
3332 uinfo->value.enumerated.items = 8;
3333 if (uinfo->value.enumerated.item >= 8)
3334 uinfo->value.enumerated.item = 7;
3335 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3336 return 0;
3337}
3338
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003339static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3340 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003341{
3342 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3343 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3344 unsigned int pin_ctl, item = 0;
3345
3346 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3347 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3348 if (pin_ctl & AC_PINCTL_OUT_EN) {
3349 if (pin_ctl & AC_PINCTL_HP_EN)
3350 item = 2;
3351 else
3352 item = 1;
3353 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3354 switch (pin_ctl & AC_PINCTL_VREFEN) {
3355 case AC_PINCTL_VREF_HIZ: item = 3; break;
3356 case AC_PINCTL_VREF_50: item = 4; break;
3357 case AC_PINCTL_VREF_GRD: item = 5; break;
3358 case AC_PINCTL_VREF_80: item = 6; break;
3359 case AC_PINCTL_VREF_100: item = 7; break;
3360 }
3361 }
3362 ucontrol->value.enumerated.item[0] = item;
3363 return 0;
3364}
3365
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003366static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3367 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003368{
3369 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3370 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3371 static unsigned int ctls[] = {
3372 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3373 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3374 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3375 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3376 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3377 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3378 };
3379 unsigned int old_ctl, new_ctl;
3380
3381 old_ctl = snd_hda_codec_read(codec, nid, 0,
3382 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3383 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3384 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003385 int val;
3386 snd_hda_codec_write_cache(codec, nid, 0,
3387 AC_VERB_SET_PIN_WIDGET_CONTROL,
3388 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003389 val = ucontrol->value.enumerated.item[0] >= 3 ?
3390 HDA_AMP_MUTE : 0;
3391 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3392 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003393 return 1;
3394 }
3395 return 0;
3396}
3397
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003398static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3399 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003400{
3401 static char *texts[] = {
3402 "Front", "Surround", "CLFE", "Side"
3403 };
3404 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3405 uinfo->count = 1;
3406 uinfo->value.enumerated.items = 4;
3407 if (uinfo->value.enumerated.item >= 4)
3408 uinfo->value.enumerated.item = 3;
3409 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3410 return 0;
3411}
3412
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003413static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3414 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003415{
3416 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3417 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3418 unsigned int sel;
3419
3420 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3421 ucontrol->value.enumerated.item[0] = sel & 3;
3422 return 0;
3423}
3424
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003425static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3426 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003427{
3428 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3429 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3430 unsigned int sel;
3431
3432 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3433 if (ucontrol->value.enumerated.item[0] != sel) {
3434 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003435 snd_hda_codec_write_cache(codec, nid, 0,
3436 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003437 return 1;
3438 }
3439 return 0;
3440}
3441
3442#define PIN_CTL_TEST(xname,nid) { \
3443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3444 .name = xname, \
3445 .info = alc_test_pin_ctl_info, \
3446 .get = alc_test_pin_ctl_get, \
3447 .put = alc_test_pin_ctl_put, \
3448 .private_value = nid \
3449 }
3450
3451#define PIN_SRC_TEST(xname,nid) { \
3452 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3453 .name = xname, \
3454 .info = alc_test_pin_src_info, \
3455 .get = alc_test_pin_src_get, \
3456 .put = alc_test_pin_src_put, \
3457 .private_value = nid \
3458 }
3459
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003460static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003461 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3462 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3463 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3464 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003465 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3466 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3467 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3468 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003469 PIN_CTL_TEST("Front Pin Mode", 0x14),
3470 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3471 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3472 PIN_CTL_TEST("Side Pin Mode", 0x17),
3473 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3474 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3475 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3476 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3477 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3478 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3479 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3480 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3481 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3482 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3483 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3484 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3485 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3486 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3487 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3488 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3489 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3490 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003491 {
3492 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3493 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003494 .info = alc_ch_mode_info,
3495 .get = alc_ch_mode_get,
3496 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003497 },
3498 { } /* end */
3499};
3500
3501static struct hda_verb alc880_test_init_verbs[] = {
3502 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3509 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3510 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003511 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3514 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3515 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003516 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003517 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3518 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3519 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3520 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003521 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003522 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3523 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3524 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3525 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003526 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003527 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3528 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003529 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3530 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3531 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003532 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003533 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3534 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3535 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3536 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003537 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003538 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003539 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003540 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003541 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003542 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003543 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003544 /* Analog input/passthru */
3545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003550 { }
3551};
3552#endif
3553
Linus Torvalds1da177e2005-04-16 15:20:36 -07003554/*
3555 */
3556
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003557static const char *alc880_models[ALC880_MODEL_LAST] = {
3558 [ALC880_3ST] = "3stack",
3559 [ALC880_TCL_S700] = "tcl",
3560 [ALC880_3ST_DIG] = "3stack-digout",
3561 [ALC880_CLEVO] = "clevo",
3562 [ALC880_5ST] = "5stack",
3563 [ALC880_5ST_DIG] = "5stack-digout",
3564 [ALC880_W810] = "w810",
3565 [ALC880_Z71V] = "z71v",
3566 [ALC880_6ST] = "6stack",
3567 [ALC880_6ST_DIG] = "6stack-digout",
3568 [ALC880_ASUS] = "asus",
3569 [ALC880_ASUS_W1V] = "asus-w1v",
3570 [ALC880_ASUS_DIG] = "asus-dig",
3571 [ALC880_ASUS_DIG2] = "asus-dig2",
3572 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003573 [ALC880_UNIWILL_P53] = "uniwill-p53",
3574 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003575 [ALC880_F1734] = "F1734",
3576 [ALC880_LG] = "lg",
3577 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003578 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003579#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003580 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003581#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003582 [ALC880_AUTO] = "auto",
3583};
3584
3585static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003586 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003587 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3588 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3589 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3590 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3591 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3592 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3593 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3594 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003595 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3596 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003597 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3598 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3599 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3600 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3601 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3602 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3603 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3604 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3605 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3606 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003607 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003608 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3609 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3610 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003611 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003612 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003613 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3614 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003615 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3616 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003617 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3618 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3619 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3620 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003621 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3622 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003623 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003624 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003625 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003626 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003627 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3628 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003629 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003630 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003631 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003632 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003633 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003634 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003635 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003636 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003637 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003638 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3639 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003640 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003641 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3642 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3643 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3644 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003645 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3646 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003647 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003648 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003649 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3650 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003651 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3652 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3653 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003654 /* default Intel */
3655 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003656 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3657 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003658 {}
3659};
3660
Takashi Iwai16ded522005-06-10 19:58:24 +02003661/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003662 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003663 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003664static struct alc_config_preset alc880_presets[] = {
3665 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003666 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003667 .init_verbs = { alc880_volume_init_verbs,
3668 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003669 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003670 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003671 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3672 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003673 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003674 .input_mux = &alc880_capture_source,
3675 },
3676 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003677 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003678 .init_verbs = { alc880_volume_init_verbs,
3679 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003680 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003681 .dac_nids = alc880_dac_nids,
3682 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003683 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3684 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003685 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003686 .input_mux = &alc880_capture_source,
3687 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003688 [ALC880_TCL_S700] = {
3689 .mixers = { alc880_tcl_s700_mixer },
3690 .init_verbs = { alc880_volume_init_verbs,
3691 alc880_pin_tcl_S700_init_verbs,
3692 alc880_gpio2_init_verbs },
3693 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3694 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003695 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3696 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003697 .hp_nid = 0x03,
3698 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3699 .channel_mode = alc880_2_jack_modes,
3700 .input_mux = &alc880_capture_source,
3701 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003702 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003703 .mixers = { alc880_three_stack_mixer,
3704 alc880_five_stack_mixer},
3705 .init_verbs = { alc880_volume_init_verbs,
3706 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003707 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3708 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003709 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3710 .channel_mode = alc880_fivestack_modes,
3711 .input_mux = &alc880_capture_source,
3712 },
3713 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003714 .mixers = { alc880_three_stack_mixer,
3715 alc880_five_stack_mixer },
3716 .init_verbs = { alc880_volume_init_verbs,
3717 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003718 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3719 .dac_nids = alc880_dac_nids,
3720 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003721 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3722 .channel_mode = alc880_fivestack_modes,
3723 .input_mux = &alc880_capture_source,
3724 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003725 [ALC880_6ST] = {
3726 .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 Iwaib6482d42005-06-27 15:32:43 +02003729 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3730 .dac_nids = alc880_6st_dac_nids,
3731 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3732 .channel_mode = alc880_sixstack_modes,
3733 .input_mux = &alc880_6stack_capture_source,
3734 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003735 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003736 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003737 .init_verbs = { alc880_volume_init_verbs,
3738 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003739 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3740 .dac_nids = alc880_6st_dac_nids,
3741 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003742 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3743 .channel_mode = alc880_sixstack_modes,
3744 .input_mux = &alc880_6stack_capture_source,
3745 },
3746 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003747 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003748 .init_verbs = { alc880_volume_init_verbs,
3749 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003750 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003751 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3752 .dac_nids = alc880_w810_dac_nids,
3753 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003754 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3755 .channel_mode = alc880_w810_modes,
3756 .input_mux = &alc880_capture_source,
3757 },
3758 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003759 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003760 .init_verbs = { alc880_volume_init_verbs,
3761 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003762 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3763 .dac_nids = alc880_z71v_dac_nids,
3764 .dig_out_nid = ALC880_DIGOUT_NID,
3765 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003766 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3767 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003768 .input_mux = &alc880_capture_source,
3769 },
3770 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003771 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003772 .init_verbs = { alc880_volume_init_verbs,
3773 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003774 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3775 .dac_nids = alc880_f1734_dac_nids,
3776 .hp_nid = 0x02,
3777 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3778 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003779 .input_mux = &alc880_f1734_capture_source,
3780 .unsol_event = alc880_uniwill_p53_unsol_event,
3781 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003782 },
3783 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003784 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003785 .init_verbs = { alc880_volume_init_verbs,
3786 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003787 alc880_gpio1_init_verbs },
3788 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3789 .dac_nids = alc880_asus_dac_nids,
3790 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3791 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003792 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003793 .input_mux = &alc880_capture_source,
3794 },
3795 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003796 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003797 .init_verbs = { alc880_volume_init_verbs,
3798 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003799 alc880_gpio1_init_verbs },
3800 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3801 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003802 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003803 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3804 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003805 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003806 .input_mux = &alc880_capture_source,
3807 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003808 [ALC880_ASUS_DIG2] = {
3809 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003810 .init_verbs = { alc880_volume_init_verbs,
3811 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003812 alc880_gpio2_init_verbs }, /* use GPIO2 */
3813 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3814 .dac_nids = alc880_asus_dac_nids,
3815 .dig_out_nid = ALC880_DIGOUT_NID,
3816 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3817 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003818 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003819 .input_mux = &alc880_capture_source,
3820 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003821 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003822 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003823 .init_verbs = { alc880_volume_init_verbs,
3824 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003825 alc880_gpio1_init_verbs },
3826 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3827 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003828 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003829 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3830 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003831 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003832 .input_mux = &alc880_capture_source,
3833 },
3834 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003835 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003836 .init_verbs = { alc880_volume_init_verbs,
3837 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003838 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3839 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003840 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003841 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3842 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003843 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003844 .input_mux = &alc880_capture_source,
3845 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003846 [ALC880_UNIWILL] = {
3847 .mixers = { alc880_uniwill_mixer },
3848 .init_verbs = { alc880_volume_init_verbs,
3849 alc880_uniwill_init_verbs },
3850 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3851 .dac_nids = alc880_asus_dac_nids,
3852 .dig_out_nid = ALC880_DIGOUT_NID,
3853 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3854 .channel_mode = alc880_threestack_modes,
3855 .need_dac_fix = 1,
3856 .input_mux = &alc880_capture_source,
3857 .unsol_event = alc880_uniwill_unsol_event,
3858 .init_hook = alc880_uniwill_automute,
3859 },
3860 [ALC880_UNIWILL_P53] = {
3861 .mixers = { alc880_uniwill_p53_mixer },
3862 .init_verbs = { alc880_volume_init_verbs,
3863 alc880_uniwill_p53_init_verbs },
3864 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3865 .dac_nids = alc880_asus_dac_nids,
3866 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003867 .channel_mode = alc880_threestack_modes,
3868 .input_mux = &alc880_capture_source,
3869 .unsol_event = alc880_uniwill_p53_unsol_event,
3870 .init_hook = alc880_uniwill_p53_hp_automute,
3871 },
3872 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01003873 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003874 .init_verbs = { alc880_volume_init_verbs,
3875 alc880_uniwill_p53_init_verbs,
3876 alc880_beep_init_verbs },
3877 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3878 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003879 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003880 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3881 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003882 .input_mux = &alc880_capture_source,
3883 .unsol_event = alc880_uniwill_p53_unsol_event,
3884 .init_hook = alc880_uniwill_p53_hp_automute,
3885 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003886 [ALC880_CLEVO] = {
3887 .mixers = { alc880_three_stack_mixer },
3888 .init_verbs = { alc880_volume_init_verbs,
3889 alc880_pin_clevo_init_verbs },
3890 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3891 .dac_nids = alc880_dac_nids,
3892 .hp_nid = 0x03,
3893 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3894 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003895 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003896 .input_mux = &alc880_capture_source,
3897 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003898 [ALC880_LG] = {
3899 .mixers = { alc880_lg_mixer },
3900 .init_verbs = { alc880_volume_init_verbs,
3901 alc880_lg_init_verbs },
3902 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3903 .dac_nids = alc880_lg_dac_nids,
3904 .dig_out_nid = ALC880_DIGOUT_NID,
3905 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3906 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003907 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003908 .input_mux = &alc880_lg_capture_source,
3909 .unsol_event = alc880_lg_unsol_event,
3910 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003911#ifdef CONFIG_SND_HDA_POWER_SAVE
3912 .loopbacks = alc880_lg_loopbacks,
3913#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003914 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003915 [ALC880_LG_LW] = {
3916 .mixers = { alc880_lg_lw_mixer },
3917 .init_verbs = { alc880_volume_init_verbs,
3918 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003919 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003920 .dac_nids = alc880_dac_nids,
3921 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003922 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3923 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003924 .input_mux = &alc880_lg_lw_capture_source,
3925 .unsol_event = alc880_lg_lw_unsol_event,
3926 .init_hook = alc880_lg_lw_automute,
3927 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003928 [ALC880_MEDION_RIM] = {
3929 .mixers = { alc880_medion_rim_mixer },
3930 .init_verbs = { alc880_volume_init_verbs,
3931 alc880_medion_rim_init_verbs,
3932 alc_gpio2_init_verbs },
3933 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3934 .dac_nids = alc880_dac_nids,
3935 .dig_out_nid = ALC880_DIGOUT_NID,
3936 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3937 .channel_mode = alc880_2_jack_modes,
3938 .input_mux = &alc880_medion_rim_capture_source,
3939 .unsol_event = alc880_medion_rim_unsol_event,
3940 .init_hook = alc880_medion_rim_automute,
3941 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003942#ifdef CONFIG_SND_DEBUG
3943 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003944 .mixers = { alc880_test_mixer },
3945 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003946 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3947 .dac_nids = alc880_test_dac_nids,
3948 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003949 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3950 .channel_mode = alc880_test_modes,
3951 .input_mux = &alc880_test_capture_source,
3952 },
3953#endif
3954};
3955
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003956/*
3957 * Automatic parse of I/O pins from the BIOS configuration
3958 */
3959
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003960enum {
3961 ALC_CTL_WIDGET_VOL,
3962 ALC_CTL_WIDGET_MUTE,
3963 ALC_CTL_BIND_MUTE,
3964};
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003965static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003966 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3967 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003968 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003969};
3970
3971/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003972static int add_control(struct alc_spec *spec, int type, const char *name,
3973 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003974{
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01003975 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003976
Takashi Iwai603c4012008-07-30 15:01:44 +02003977 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3978 knew = snd_array_new(&spec->kctls);
3979 if (!knew)
3980 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003981 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003982 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003983 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003984 return -ENOMEM;
3985 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003986 return 0;
3987}
3988
3989#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3990#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3991#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3992#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3993#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3994#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3995#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3996#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3997#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3998#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3999#define ALC880_PIN_CD_NID 0x1c
4000
4001/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004002static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4003 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004004{
4005 hda_nid_t nid;
4006 int assigned[4];
4007 int i, j;
4008
4009 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004010 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004011
4012 /* check the pins hardwired to audio widget */
4013 for (i = 0; i < cfg->line_outs; i++) {
4014 nid = cfg->line_out_pins[i];
4015 if (alc880_is_fixed_pin(nid)) {
4016 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004017 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004018 assigned[idx] = 1;
4019 }
4020 }
4021 /* left pins can be connect to any audio widget */
4022 for (i = 0; i < cfg->line_outs; i++) {
4023 nid = cfg->line_out_pins[i];
4024 if (alc880_is_fixed_pin(nid))
4025 continue;
4026 /* search for an empty channel */
4027 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004028 if (!assigned[j]) {
4029 spec->multiout.dac_nids[i] =
4030 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004031 assigned[j] = 1;
4032 break;
4033 }
4034 }
4035 }
4036 spec->multiout.num_dacs = cfg->line_outs;
4037 return 0;
4038}
4039
4040/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004041static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4042 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004043{
4044 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004045 static const char *chname[4] = {
4046 "Front", "Surround", NULL /*CLFE*/, "Side"
4047 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004048 hda_nid_t nid;
4049 int i, err;
4050
4051 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004052 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004053 continue;
4054 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4055 if (i == 2) {
4056 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004057 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4058 "Center Playback Volume",
4059 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4060 HDA_OUTPUT));
4061 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004062 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004063 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4064 "LFE Playback Volume",
4065 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4066 HDA_OUTPUT));
4067 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004068 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004069 err = add_control(spec, ALC_CTL_BIND_MUTE,
4070 "Center Playback Switch",
4071 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4072 HDA_INPUT));
4073 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004074 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004075 err = add_control(spec, ALC_CTL_BIND_MUTE,
4076 "LFE Playback Switch",
4077 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4078 HDA_INPUT));
4079 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004080 return err;
4081 } else {
4082 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004083 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4084 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4085 HDA_OUTPUT));
4086 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004087 return err;
4088 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004089 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4090 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4091 HDA_INPUT));
4092 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004093 return err;
4094 }
4095 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004096 return 0;
4097}
4098
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004099/* add playback controls for speaker and HP outputs */
4100static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4101 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004102{
4103 hda_nid_t nid;
4104 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004105 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004106
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004107 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004108 return 0;
4109
4110 if (alc880_is_fixed_pin(pin)) {
4111 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004112 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004113 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004114 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004115 else
4116 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004117 /* control HP volume/switch on the output mixer amp */
4118 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004119 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004120 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4121 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4122 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004123 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004124 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004125 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4126 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4127 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004128 return err;
4129 } else if (alc880_is_multi_pin(pin)) {
4130 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004131 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004132 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004133 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4134 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4135 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004136 return err;
4137 }
4138 return 0;
4139}
4140
4141/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004142static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4143 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004144 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004145{
4146 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004147 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004148
4149 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004150 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4151 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4152 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004153 return err;
4154 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004155 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4156 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4157 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004158 return err;
4159 return 0;
4160}
4161
4162/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004163static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4164 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004165{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004166 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004167 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004168
4169 for (i = 0; i < AUTO_PIN_LAST; i++) {
4170 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004171 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004172 err = new_analog_input(spec, cfg->input_pins[i],
4173 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004174 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004175 if (err < 0)
4176 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004177 imux->items[imux->num_items].label =
4178 auto_pin_cfg_labels[i];
4179 imux->items[imux->num_items].index =
4180 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004181 imux->num_items++;
4182 }
4183 }
4184 return 0;
4185}
4186
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004187static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4188 unsigned int pin_type)
4189{
4190 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4191 pin_type);
4192 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004193 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4194 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004195}
4196
Kailang Yangdf694da2005-12-05 19:42:22 +01004197static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4198 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004199 int dac_idx)
4200{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004201 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004202 /* need the manual connection? */
4203 if (alc880_is_multi_pin(nid)) {
4204 struct alc_spec *spec = codec->spec;
4205 int idx = alc880_multi_pin_idx(nid);
4206 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4207 AC_VERB_SET_CONNECT_SEL,
4208 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4209 }
4210}
4211
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004212static int get_pin_type(int line_out_type)
4213{
4214 if (line_out_type == AUTO_PIN_HP_OUT)
4215 return PIN_HP;
4216 else
4217 return PIN_OUT;
4218}
4219
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004220static void alc880_auto_init_multi_out(struct hda_codec *codec)
4221{
4222 struct alc_spec *spec = codec->spec;
4223 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004224
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004225 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004226 for (i = 0; i < spec->autocfg.line_outs; i++) {
4227 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004228 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4229 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004230 }
4231}
4232
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004233static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004234{
4235 struct alc_spec *spec = codec->spec;
4236 hda_nid_t pin;
4237
Takashi Iwai82bc9552006-03-21 11:24:42 +01004238 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004239 if (pin) /* connect to front */
4240 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004241 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004242 if (pin) /* connect to front */
4243 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4244}
4245
4246static void alc880_auto_init_analog_input(struct hda_codec *codec)
4247{
4248 struct alc_spec *spec = codec->spec;
4249 int i;
4250
4251 for (i = 0; i < AUTO_PIN_LAST; i++) {
4252 hda_nid_t nid = spec->autocfg.input_pins[i];
4253 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004254 snd_hda_codec_write(codec, nid, 0,
4255 AC_VERB_SET_PIN_WIDGET_CONTROL,
4256 i <= AUTO_PIN_FRONT_MIC ?
4257 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004258 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004259 snd_hda_codec_write(codec, nid, 0,
4260 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004261 AMP_OUT_MUTE);
4262 }
4263 }
4264}
4265
4266/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004267/* return 1 if successful, 0 if the proper config is not found,
4268 * or a negative error code
4269 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004270static int alc880_parse_auto_config(struct hda_codec *codec)
4271{
4272 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004273 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004274 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004275
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004276 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4277 alc880_ignore);
4278 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004279 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004280 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004281 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004282
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004283 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4284 if (err < 0)
4285 return err;
4286 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4287 if (err < 0)
4288 return err;
4289 err = alc880_auto_create_extra_out(spec,
4290 spec->autocfg.speaker_pins[0],
4291 "Speaker");
4292 if (err < 0)
4293 return err;
4294 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4295 "Headphone");
4296 if (err < 0)
4297 return err;
4298 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4299 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004300 return err;
4301
4302 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4303
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004304 /* check multiple SPDIF-out (for recent codecs) */
4305 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4306 hda_nid_t dig_nid;
4307 err = snd_hda_get_connections(codec,
4308 spec->autocfg.dig_out_pins[i],
4309 &dig_nid, 1);
4310 if (err < 0)
4311 continue;
4312 if (!i)
4313 spec->multiout.dig_out_nid = dig_nid;
4314 else {
4315 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4316 spec->slave_dig_outs[i - 1] = dig_nid;
4317 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4318 break;
4319 }
4320 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004321 if (spec->autocfg.dig_in_pin)
4322 spec->dig_in_nid = ALC880_DIGIN_NID;
4323
Takashi Iwai603c4012008-07-30 15:01:44 +02004324 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004325 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004326
Takashi Iwaid88897e2008-10-31 15:01:37 +01004327 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004328
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004329 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004330 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004331
Takashi Iwaie044c392008-10-27 16:56:24 +01004332 store_pin_configs(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004333 return 1;
4334}
4335
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004336/* additional initialization for auto-configuration model */
4337static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004338{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004339 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004340 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004341 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004342 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004343 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004344 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004345}
4346
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004347static void set_capture_mixer(struct alc_spec *spec)
4348{
4349 static struct snd_kcontrol_new *caps[3] = {
4350 alc_capture_mixer1,
4351 alc_capture_mixer2,
4352 alc_capture_mixer3,
4353 };
Takashi Iwai30d72e92008-11-27 15:25:34 +01004354 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004355 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4356}
4357
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004358#define set_beep_amp(spec, nid, idx, dir) \
4359 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4360
4361/*
4362 * OK, here we have finally the patch for ALC880
4363 */
4364
Linus Torvalds1da177e2005-04-16 15:20:36 -07004365static int patch_alc880(struct hda_codec *codec)
4366{
4367 struct alc_spec *spec;
4368 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004369 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004370
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004371 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004372 if (spec == NULL)
4373 return -ENOMEM;
4374
4375 codec->spec = spec;
4376
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004377 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4378 alc880_models,
4379 alc880_cfg_tbl);
4380 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004381 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4382 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004383 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004384 }
4385
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004386 if (board_config == ALC880_AUTO) {
4387 /* automatic parse from the BIOS config */
4388 err = alc880_parse_auto_config(codec);
4389 if (err < 0) {
4390 alc_free(codec);
4391 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004392 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004393 printk(KERN_INFO
4394 "hda_codec: Cannot set up configuration "
4395 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004396 board_config = ALC880_3ST;
4397 }
4398 }
4399
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004400 err = snd_hda_attach_beep_device(codec, 0x1);
4401 if (err < 0) {
4402 alc_free(codec);
4403 return err;
4404 }
4405
Kailang Yangdf694da2005-12-05 19:42:22 +01004406 if (board_config != ALC880_AUTO)
4407 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004408
4409 spec->stream_name_analog = "ALC880 Analog";
4410 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4411 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004412 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004413
4414 spec->stream_name_digital = "ALC880 Digital";
4415 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4416 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4417
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004418 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004419 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004420 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004421 /* get type */
4422 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004423 if (wcap != AC_WID_AUD_IN) {
4424 spec->adc_nids = alc880_adc_nids_alt;
4425 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004426 } else {
4427 spec->adc_nids = alc880_adc_nids;
4428 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004429 }
4430 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004431 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004432 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004433
Takashi Iwai2134ea42008-01-10 16:53:55 +01004434 spec->vmaster_nid = 0x0c;
4435
Linus Torvalds1da177e2005-04-16 15:20:36 -07004436 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004437 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004438 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004439#ifdef CONFIG_SND_HDA_POWER_SAVE
4440 if (!spec->loopback.amplist)
4441 spec->loopback.amplist = alc880_loopbacks;
4442#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004443 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004444
4445 return 0;
4446}
4447
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004448
Linus Torvalds1da177e2005-04-16 15:20:36 -07004449/*
4450 * ALC260 support
4451 */
4452
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004453static hda_nid_t alc260_dac_nids[1] = {
4454 /* front */
4455 0x02,
4456};
4457
4458static hda_nid_t alc260_adc_nids[1] = {
4459 /* ADC0 */
4460 0x04,
4461};
4462
Kailang Yangdf694da2005-12-05 19:42:22 +01004463static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004464 /* ADC1 */
4465 0x05,
4466};
4467
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004468/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4469 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4470 */
4471static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004472 /* ADC0, ADC1 */
4473 0x04, 0x05
4474};
4475
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004476#define ALC260_DIGOUT_NID 0x03
4477#define ALC260_DIGIN_NID 0x06
4478
4479static struct hda_input_mux alc260_capture_source = {
4480 .num_items = 4,
4481 .items = {
4482 { "Mic", 0x0 },
4483 { "Front Mic", 0x1 },
4484 { "Line", 0x2 },
4485 { "CD", 0x4 },
4486 },
4487};
4488
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004489/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004490 * headphone jack and the internal CD lines since these are the only pins at
4491 * which audio can appear. For flexibility, also allow the option of
4492 * recording the mixer output on the second ADC (ADC0 doesn't have a
4493 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004494 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004495static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4496 {
4497 .num_items = 3,
4498 .items = {
4499 { "Mic/Line", 0x0 },
4500 { "CD", 0x4 },
4501 { "Headphone", 0x2 },
4502 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004503 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004504 {
4505 .num_items = 4,
4506 .items = {
4507 { "Mic/Line", 0x0 },
4508 { "CD", 0x4 },
4509 { "Headphone", 0x2 },
4510 { "Mixer", 0x5 },
4511 },
4512 },
4513
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004514};
4515
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004516/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4517 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004518 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004519static struct hda_input_mux alc260_acer_capture_sources[2] = {
4520 {
4521 .num_items = 4,
4522 .items = {
4523 { "Mic", 0x0 },
4524 { "Line", 0x2 },
4525 { "CD", 0x4 },
4526 { "Headphone", 0x5 },
4527 },
4528 },
4529 {
4530 .num_items = 5,
4531 .items = {
4532 { "Mic", 0x0 },
4533 { "Line", 0x2 },
4534 { "CD", 0x4 },
4535 { "Headphone", 0x6 },
4536 { "Mixer", 0x5 },
4537 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004538 },
4539};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004540/*
4541 * This is just place-holder, so there's something for alc_build_pcms to look
4542 * at when it calculates the maximum number of channels. ALC260 has no mixer
4543 * element which allows changing the channel mode, so the verb list is
4544 * never used.
4545 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004546static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004547 { 2, NULL },
4548};
4549
Kailang Yangdf694da2005-12-05 19:42:22 +01004550
4551/* Mixer combinations
4552 *
4553 * basic: base_output + input + pc_beep + capture
4554 * HP: base_output + input + capture_alt
4555 * HP_3013: hp_3013 + input + capture
4556 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004557 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004558 */
4559
4560static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004561 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004562 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004563 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4564 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4565 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4566 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4567 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004568};
Kailang Yangdf694da2005-12-05 19:42:22 +01004569
4570static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004571 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4572 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4573 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4574 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4575 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4576 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4577 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4578 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004579 { } /* end */
4580};
4581
Takashi Iwaibec15c32008-01-28 18:16:30 +01004582/* update HP, line and mono out pins according to the master switch */
4583static void alc260_hp_master_update(struct hda_codec *codec,
4584 hda_nid_t hp, hda_nid_t line,
4585 hda_nid_t mono)
4586{
4587 struct alc_spec *spec = codec->spec;
4588 unsigned int val = spec->master_sw ? PIN_HP : 0;
4589 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004590 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004591 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004592 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004593 val);
4594 /* mono (speaker) depending on the HP jack sense */
4595 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004596 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004597 val);
4598}
4599
4600static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4601 struct snd_ctl_elem_value *ucontrol)
4602{
4603 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4604 struct alc_spec *spec = codec->spec;
4605 *ucontrol->value.integer.value = spec->master_sw;
4606 return 0;
4607}
4608
4609static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4610 struct snd_ctl_elem_value *ucontrol)
4611{
4612 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4613 struct alc_spec *spec = codec->spec;
4614 int val = !!*ucontrol->value.integer.value;
4615 hda_nid_t hp, line, mono;
4616
4617 if (val == spec->master_sw)
4618 return 0;
4619 spec->master_sw = val;
4620 hp = (kcontrol->private_value >> 16) & 0xff;
4621 line = (kcontrol->private_value >> 8) & 0xff;
4622 mono = kcontrol->private_value & 0xff;
4623 alc260_hp_master_update(codec, hp, line, mono);
4624 return 1;
4625}
4626
4627static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4628 {
4629 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4630 .name = "Master Playback Switch",
4631 .info = snd_ctl_boolean_mono_info,
4632 .get = alc260_hp_master_sw_get,
4633 .put = alc260_hp_master_sw_put,
4634 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4635 },
4636 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4637 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4638 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4639 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4640 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4641 HDA_OUTPUT),
4642 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4643 { } /* end */
4644};
4645
4646static struct hda_verb alc260_hp_unsol_verbs[] = {
4647 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4648 {},
4649};
4650
4651static void alc260_hp_automute(struct hda_codec *codec)
4652{
4653 struct alc_spec *spec = codec->spec;
4654 unsigned int present;
4655
4656 present = snd_hda_codec_read(codec, 0x10, 0,
4657 AC_VERB_GET_PIN_SENSE, 0);
4658 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4659 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4660}
4661
4662static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4663{
4664 if ((res >> 26) == ALC880_HP_EVENT)
4665 alc260_hp_automute(codec);
4666}
4667
Kailang Yangdf694da2005-12-05 19:42:22 +01004668static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004669 {
4670 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4671 .name = "Master Playback Switch",
4672 .info = snd_ctl_boolean_mono_info,
4673 .get = alc260_hp_master_sw_get,
4674 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004675 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004676 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004677 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4678 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4679 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4680 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4681 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4682 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004683 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4684 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004685 { } /* end */
4686};
4687
Kailang Yang3f878302008-08-26 13:02:23 +02004688static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4689 .ops = &snd_hda_bind_vol,
4690 .values = {
4691 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4692 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4693 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4694 0
4695 },
4696};
4697
4698static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4699 .ops = &snd_hda_bind_sw,
4700 .values = {
4701 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4702 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4703 0
4704 },
4705};
4706
4707static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4708 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4709 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4710 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4711 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4712 { } /* end */
4713};
4714
Takashi Iwaibec15c32008-01-28 18:16:30 +01004715static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4716 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4717 {},
4718};
4719
4720static void alc260_hp_3013_automute(struct hda_codec *codec)
4721{
4722 struct alc_spec *spec = codec->spec;
4723 unsigned int present;
4724
4725 present = snd_hda_codec_read(codec, 0x15, 0,
4726 AC_VERB_GET_PIN_SENSE, 0);
4727 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004728 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004729}
4730
4731static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4732 unsigned int res)
4733{
4734 if ((res >> 26) == ALC880_HP_EVENT)
4735 alc260_hp_3013_automute(codec);
4736}
4737
Kailang Yang3f878302008-08-26 13:02:23 +02004738static void alc260_hp_3012_automute(struct hda_codec *codec)
4739{
4740 unsigned int present, bits;
4741
4742 present = snd_hda_codec_read(codec, 0x10, 0,
4743 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4744
4745 bits = present ? 0 : PIN_OUT;
4746 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4747 bits);
4748 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4749 bits);
4750 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4751 bits);
4752}
4753
4754static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4755 unsigned int res)
4756{
4757 if ((res >> 26) == ALC880_HP_EVENT)
4758 alc260_hp_3012_automute(codec);
4759}
4760
4761/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004762 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4763 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01004764static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004765 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004766 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004767 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004768 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4769 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4770 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4771 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004772 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004773 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4774 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004775 { } /* end */
4776};
4777
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004778/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4779 * versions of the ALC260 don't act on requests to enable mic bias from NID
4780 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4781 * datasheet doesn't mention this restriction. At this stage it's not clear
4782 * whether this behaviour is intentional or is a hardware bug in chip
4783 * revisions available in early 2006. Therefore for now allow the
4784 * "Headphone Jack Mode" control to span all choices, but if it turns out
4785 * that the lack of mic bias for this NID is intentional we could change the
4786 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4787 *
4788 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4789 * don't appear to make the mic bias available from the "line" jack, even
4790 * though the NID used for this jack (0x14) can supply it. The theory is
4791 * that perhaps Acer have included blocking capacitors between the ALC260
4792 * and the output jack. If this turns out to be the case for all such
4793 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4794 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004795 *
4796 * The C20x Tablet series have a mono internal speaker which is controlled
4797 * via the chip's Mono sum widget and pin complex, so include the necessary
4798 * controls for such models. On models without a "mono speaker" the control
4799 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004800 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004801static struct snd_kcontrol_new alc260_acer_mixer[] = {
4802 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4803 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004804 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004805 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004806 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004807 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004808 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004809 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4810 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4812 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4813 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4814 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4815 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4816 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004817 { } /* end */
4818};
4819
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004820/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4821 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4822 */
4823static struct snd_kcontrol_new alc260_will_mixer[] = {
4824 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4825 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4826 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4827 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4828 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4829 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4830 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4831 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4832 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4833 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004834 { } /* end */
4835};
4836
4837/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4838 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4839 */
4840static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4841 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4842 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4843 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4844 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4845 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4846 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4847 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4848 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4849 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4850 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4851 { } /* end */
4852};
4853
Kailang Yangdf694da2005-12-05 19:42:22 +01004854/*
4855 * initialization verbs
4856 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004857static struct hda_verb alc260_init_verbs[] = {
4858 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004859 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004860 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004861 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004862 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004863 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004864 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004865 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004866 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004867 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004868 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004869 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004870 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004871 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004872 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004873 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004874 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004875 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4876 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004877 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004878 /* set connection select to line in (default select for this ADC) */
4879 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004880 /* mute capture amp left and right */
4881 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4882 /* set connection select to line in (default select for this ADC) */
4883 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004884 /* set vol=0 Line-Out mixer amp left and right */
4885 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4886 /* unmute pin widget amp left and right (no gain on this amp) */
4887 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4888 /* set vol=0 HP mixer amp left and right */
4889 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4890 /* unmute pin widget amp left and right (no gain on this amp) */
4891 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4892 /* set vol=0 Mono mixer amp left and right */
4893 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4894 /* unmute pin widget amp left and right (no gain on this amp) */
4895 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4896 /* unmute LINE-2 out pin */
4897 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004898 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4899 * Line In 2 = 0x03
4900 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004901 /* mute analog inputs */
4902 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4903 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4904 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4905 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4906 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004907 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004908 /* mute Front out path */
4909 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4910 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4911 /* mute Headphone out path */
4912 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4913 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4914 /* mute Mono out path */
4915 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4916 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004917 { }
4918};
4919
Takashi Iwai474167d2006-05-17 17:17:43 +02004920#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004921static struct hda_verb alc260_hp_init_verbs[] = {
4922 /* Headphone and output */
4923 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4924 /* mono output */
4925 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4926 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4927 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4928 /* Mic2 (front panel) pin widget for input and vref at 80% */
4929 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4930 /* Line In pin widget for input */
4931 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4932 /* Line-2 pin widget for output */
4933 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4934 /* CD pin widget for input */
4935 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4936 /* unmute amp left and right */
4937 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4938 /* set connection select to line in (default select for this ADC) */
4939 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4940 /* unmute Line-Out mixer amp left and right (volume = 0) */
4941 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4942 /* mute pin widget amp left and right (no gain on this amp) */
4943 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4944 /* unmute HP mixer amp left and right (volume = 0) */
4945 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4946 /* mute pin widget amp left and right (no gain on this amp) */
4947 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004948 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4949 * Line In 2 = 0x03
4950 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004951 /* mute analog inputs */
4952 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4953 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4954 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4955 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4956 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004957 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4958 /* Unmute Front out path */
4959 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4960 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4961 /* Unmute Headphone out path */
4962 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4963 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4964 /* Unmute Mono out path */
4965 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4966 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4967 { }
4968};
Takashi Iwai474167d2006-05-17 17:17:43 +02004969#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004970
4971static struct hda_verb alc260_hp_3013_init_verbs[] = {
4972 /* Line out and output */
4973 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4974 /* mono output */
4975 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4976 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4977 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4978 /* Mic2 (front panel) pin widget for input and vref at 80% */
4979 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4980 /* Line In pin widget for input */
4981 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4982 /* Headphone pin widget for output */
4983 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4984 /* CD pin widget for input */
4985 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4986 /* unmute amp left and right */
4987 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4988 /* set connection select to line in (default select for this ADC) */
4989 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4990 /* unmute Line-Out mixer amp left and right (volume = 0) */
4991 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4992 /* mute pin widget amp left and right (no gain on this amp) */
4993 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4994 /* unmute HP mixer amp left and right (volume = 0) */
4995 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4996 /* mute pin widget amp left and right (no gain on this amp) */
4997 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004998 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4999 * Line In 2 = 0x03
5000 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005001 /* mute analog inputs */
5002 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5003 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5004 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5005 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5006 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005007 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5008 /* Unmute Front out path */
5009 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5010 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5011 /* Unmute Headphone out path */
5012 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5013 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5014 /* Unmute Mono out path */
5015 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5016 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5017 { }
5018};
5019
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005020/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005021 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5022 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005023 */
5024static struct hda_verb alc260_fujitsu_init_verbs[] = {
5025 /* Disable all GPIOs */
5026 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5027 /* Internal speaker is connected to headphone pin */
5028 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5029 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5030 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005031 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5032 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5033 /* Ensure all other unused pins are disabled and muted. */
5034 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5035 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005036 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005037 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005038 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005039 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5040 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5041 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005042
Jonathan Woithef7ace402006-02-28 11:46:14 +01005043 /* Disable digital (SPDIF) pins */
5044 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5045 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005046
Kailang Yangea1fb292008-08-26 12:58:38 +02005047 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005048 * when acting as an output.
5049 */
5050 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5051
5052 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005053 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5054 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5055 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5056 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5057 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5058 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5059 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5060 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5061 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005062
Jonathan Woithef7ace402006-02-28 11:46:14 +01005063 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5064 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5065 /* Unmute Line1 pin widget output buffer since it starts as an output.
5066 * If the pin mode is changed by the user the pin mode control will
5067 * take care of enabling the pin's input/output buffers as needed.
5068 * Therefore there's no need to enable the input buffer at this
5069 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005070 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005071 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005072 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005073 * mixer ctrl)
5074 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005075 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005076
Jonathan Woithef7ace402006-02-28 11:46:14 +01005077 /* Mute capture amp left and right */
5078 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005079 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005080 * in (on mic1 pin)
5081 */
5082 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005083
Jonathan Woithef7ace402006-02-28 11:46:14 +01005084 /* Do the same for the second ADC: mute capture input amp and
5085 * set ADC connection to line in (on mic1 pin)
5086 */
5087 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5088 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005089
Jonathan Woithef7ace402006-02-28 11:46:14 +01005090 /* Mute all inputs to mixer widget (even unconnected ones) */
5091 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5092 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5093 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5094 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5095 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5096 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5097 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5098 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005099
5100 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005101};
5102
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005103/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5104 * similar laptops (adapted from Fujitsu init verbs).
5105 */
5106static struct hda_verb alc260_acer_init_verbs[] = {
5107 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5108 * the headphone jack. Turn this on and rely on the standard mute
5109 * methods whenever the user wants to turn these outputs off.
5110 */
5111 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5112 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5113 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5114 /* Internal speaker/Headphone jack is connected to Line-out pin */
5115 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5116 /* Internal microphone/Mic jack is connected to Mic1 pin */
5117 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5118 /* Line In jack is connected to Line1 pin */
5119 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005120 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5121 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005122 /* Ensure all other unused pins are disabled and muted. */
5123 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5124 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005125 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5126 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5127 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5129 /* Disable digital (SPDIF) pins */
5130 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5131 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5132
Kailang Yangea1fb292008-08-26 12:58:38 +02005133 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005134 * bus when acting as outputs.
5135 */
5136 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5137 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5138
5139 /* Start with output sum widgets muted and their output gains at min */
5140 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5141 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5142 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5143 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5144 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5145 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5146 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5147 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5148 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5149
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005150 /* Unmute Line-out pin widget amp left and right
5151 * (no equiv mixer ctrl)
5152 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005153 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005154 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5155 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005156 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5157 * inputs. If the pin mode is changed by the user the pin mode control
5158 * will take care of enabling the pin's input/output buffers as needed.
5159 * Therefore there's no need to enable the input buffer at this
5160 * stage.
5161 */
5162 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5163 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5164
5165 /* Mute capture amp left and right */
5166 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5167 /* Set ADC connection select to match default mixer setting - mic
5168 * (on mic1 pin)
5169 */
5170 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5171
5172 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005173 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005174 */
5175 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005176 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005177
5178 /* Mute all inputs to mixer widget (even unconnected ones) */
5179 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5180 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5181 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5182 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5183 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5184 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5185 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5187
5188 { }
5189};
5190
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005191static struct hda_verb alc260_will_verbs[] = {
5192 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5193 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5194 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5195 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5196 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5197 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5198 {}
5199};
5200
5201static struct hda_verb alc260_replacer_672v_verbs[] = {
5202 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5203 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5204 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5205
5206 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5207 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5208 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5209
5210 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5211 {}
5212};
5213
5214/* toggle speaker-output according to the hp-jack state */
5215static void alc260_replacer_672v_automute(struct hda_codec *codec)
5216{
5217 unsigned int present;
5218
5219 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5220 present = snd_hda_codec_read(codec, 0x0f, 0,
5221 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5222 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005223 snd_hda_codec_write_cache(codec, 0x01, 0,
5224 AC_VERB_SET_GPIO_DATA, 1);
5225 snd_hda_codec_write_cache(codec, 0x0f, 0,
5226 AC_VERB_SET_PIN_WIDGET_CONTROL,
5227 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005228 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005229 snd_hda_codec_write_cache(codec, 0x01, 0,
5230 AC_VERB_SET_GPIO_DATA, 0);
5231 snd_hda_codec_write_cache(codec, 0x0f, 0,
5232 AC_VERB_SET_PIN_WIDGET_CONTROL,
5233 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005234 }
5235}
5236
5237static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5238 unsigned int res)
5239{
5240 if ((res >> 26) == ALC880_HP_EVENT)
5241 alc260_replacer_672v_automute(codec);
5242}
5243
Kailang Yang3f878302008-08-26 13:02:23 +02005244static struct hda_verb alc260_hp_dc7600_verbs[] = {
5245 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5246 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5247 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5248 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5249 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5250 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5251 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5252 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5253 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5254 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5255 {}
5256};
5257
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005258/* Test configuration for debugging, modelled after the ALC880 test
5259 * configuration.
5260 */
5261#ifdef CONFIG_SND_DEBUG
5262static hda_nid_t alc260_test_dac_nids[1] = {
5263 0x02,
5264};
5265static hda_nid_t alc260_test_adc_nids[2] = {
5266 0x04, 0x05,
5267};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005268/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005269 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005270 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005271 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005272static struct hda_input_mux alc260_test_capture_sources[2] = {
5273 {
5274 .num_items = 7,
5275 .items = {
5276 { "MIC1 pin", 0x0 },
5277 { "MIC2 pin", 0x1 },
5278 { "LINE1 pin", 0x2 },
5279 { "LINE2 pin", 0x3 },
5280 { "CD pin", 0x4 },
5281 { "LINE-OUT pin", 0x5 },
5282 { "HP-OUT pin", 0x6 },
5283 },
5284 },
5285 {
5286 .num_items = 8,
5287 .items = {
5288 { "MIC1 pin", 0x0 },
5289 { "MIC2 pin", 0x1 },
5290 { "LINE1 pin", 0x2 },
5291 { "LINE2 pin", 0x3 },
5292 { "CD pin", 0x4 },
5293 { "Mixer", 0x5 },
5294 { "LINE-OUT pin", 0x6 },
5295 { "HP-OUT pin", 0x7 },
5296 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005297 },
5298};
5299static struct snd_kcontrol_new alc260_test_mixer[] = {
5300 /* Output driver widgets */
5301 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5302 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5303 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5304 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5305 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5306 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5307
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005308 /* Modes for retasking pin widgets
5309 * Note: the ALC260 doesn't seem to act on requests to enable mic
5310 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5311 * mention this restriction. At this stage it's not clear whether
5312 * this behaviour is intentional or is a hardware bug in chip
5313 * revisions available at least up until early 2006. Therefore for
5314 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5315 * choices, but if it turns out that the lack of mic bias for these
5316 * NIDs is intentional we could change their modes from
5317 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5318 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005319 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5320 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5321 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5322 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5323 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5324 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5325
5326 /* Loopback mixer controls */
5327 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5328 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5329 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5330 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5331 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5332 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5333 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5334 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5335 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5336 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005337 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5338 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5339 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5340 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005341
5342 /* Controls for GPIO pins, assuming they are configured as outputs */
5343 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5344 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5345 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5346 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5347
Jonathan Woithe92621f12006-02-28 11:47:47 +01005348 /* Switches to allow the digital IO pins to be enabled. The datasheet
5349 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005350 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005351 */
5352 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5353 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5354
Jonathan Woithef8225f62008-01-08 12:16:54 +01005355 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5356 * this output to turn on an external amplifier.
5357 */
5358 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5359 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5360
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005361 { } /* end */
5362};
5363static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005364 /* Enable all GPIOs as outputs with an initial value of 0 */
5365 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5366 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5367 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5368
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005369 /* Enable retasking pins as output, initially without power amp */
5370 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5371 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5372 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5373 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5374 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5375 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5376
Jonathan Woithe92621f12006-02-28 11:47:47 +01005377 /* Disable digital (SPDIF) pins initially, but users can enable
5378 * them via a mixer switch. In the case of SPDIF-out, this initverb
5379 * payload also sets the generation to 0, output to be in "consumer"
5380 * PCM format, copyright asserted, no pre-emphasis and no validity
5381 * control.
5382 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005383 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5384 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5385
Kailang Yangea1fb292008-08-26 12:58:38 +02005386 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005387 * OUT1 sum bus when acting as an output.
5388 */
5389 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5390 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5391 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5392 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5393
5394 /* Start with output sum widgets muted and their output gains at min */
5395 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5396 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5397 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5398 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5399 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5400 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5401 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5402 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5403 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5404
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005405 /* Unmute retasking pin widget output buffers since the default
5406 * state appears to be output. As the pin mode is changed by the
5407 * user the pin mode control will take care of enabling the pin's
5408 * input/output buffers as needed.
5409 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005410 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5411 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5412 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5413 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5414 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5415 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5416 /* Also unmute the mono-out pin widget */
5417 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5418
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005419 /* Mute capture amp left and right */
5420 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005421 /* Set ADC connection select to match default mixer setting (mic1
5422 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005423 */
5424 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5425
5426 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005427 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005428 */
5429 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5430 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5431
5432 /* Mute all inputs to mixer widget (even unconnected ones) */
5433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5434 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5435 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5437 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5438 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5439 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5441
5442 { }
5443};
5444#endif
5445
Takashi Iwai63300792008-01-24 15:31:36 +01005446#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5447#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005448
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005449#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5450#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5451
Kailang Yangdf694da2005-12-05 19:42:22 +01005452/*
5453 * for BIOS auto-configuration
5454 */
5455
5456static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005457 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005458{
5459 hda_nid_t nid_vol;
5460 unsigned long vol_val, sw_val;
5461 char name[32];
5462 int err;
5463
5464 if (nid >= 0x0f && nid < 0x11) {
5465 nid_vol = nid - 0x7;
5466 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5467 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5468 } else if (nid == 0x11) {
5469 nid_vol = nid - 0x7;
5470 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5471 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5472 } else if (nid >= 0x12 && nid <= 0x15) {
5473 nid_vol = 0x08;
5474 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5475 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5476 } else
5477 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005478
Takashi Iwai863b4512008-10-21 17:01:47 +02005479 if (!(*vol_bits & (1 << nid_vol))) {
5480 /* first control for the volume widget */
5481 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5482 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5483 if (err < 0)
5484 return err;
5485 *vol_bits |= (1 << nid_vol);
5486 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005487 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005488 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5489 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005490 return err;
5491 return 1;
5492}
5493
5494/* add playback controls from the parsed DAC table */
5495static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5496 const struct auto_pin_cfg *cfg)
5497{
5498 hda_nid_t nid;
5499 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005500 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005501
5502 spec->multiout.num_dacs = 1;
5503 spec->multiout.dac_nids = spec->private_dac_nids;
5504 spec->multiout.dac_nids[0] = 0x02;
5505
5506 nid = cfg->line_out_pins[0];
5507 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005508 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005509 if (err < 0)
5510 return err;
5511 }
5512
Takashi Iwai82bc9552006-03-21 11:24:42 +01005513 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005514 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005515 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005516 if (err < 0)
5517 return err;
5518 }
5519
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005520 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005521 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005522 err = alc260_add_playback_controls(spec, nid, "Headphone",
5523 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005524 if (err < 0)
5525 return err;
5526 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005527 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005528}
5529
5530/* create playback/capture controls for input pins */
5531static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5532 const struct auto_pin_cfg *cfg)
5533{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005534 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005535 int i, err, idx;
5536
5537 for (i = 0; i < AUTO_PIN_LAST; i++) {
5538 if (cfg->input_pins[i] >= 0x12) {
5539 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005540 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005541 auto_pin_cfg_labels[i], idx,
5542 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005543 if (err < 0)
5544 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005545 imux->items[imux->num_items].label =
5546 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005547 imux->items[imux->num_items].index = idx;
5548 imux->num_items++;
5549 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005550 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005551 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005552 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005553 auto_pin_cfg_labels[i], idx,
5554 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005555 if (err < 0)
5556 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005557 imux->items[imux->num_items].label =
5558 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005559 imux->items[imux->num_items].index = idx;
5560 imux->num_items++;
5561 }
5562 }
5563 return 0;
5564}
5565
5566static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5567 hda_nid_t nid, int pin_type,
5568 int sel_idx)
5569{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005570 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005571 /* need the manual connection? */
5572 if (nid >= 0x12) {
5573 int idx = nid - 0x12;
5574 snd_hda_codec_write(codec, idx + 0x0b, 0,
5575 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005576 }
5577}
5578
5579static void alc260_auto_init_multi_out(struct hda_codec *codec)
5580{
5581 struct alc_spec *spec = codec->spec;
5582 hda_nid_t nid;
5583
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005584 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005585 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005586 if (nid) {
5587 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5588 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5589 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005590
Takashi Iwai82bc9552006-03-21 11:24:42 +01005591 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005592 if (nid)
5593 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5594
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005595 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005596 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005597 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005598}
Kailang Yangdf694da2005-12-05 19:42:22 +01005599
5600#define ALC260_PIN_CD_NID 0x16
5601static void alc260_auto_init_analog_input(struct hda_codec *codec)
5602{
5603 struct alc_spec *spec = codec->spec;
5604 int i;
5605
5606 for (i = 0; i < AUTO_PIN_LAST; i++) {
5607 hda_nid_t nid = spec->autocfg.input_pins[i];
5608 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005609 snd_hda_codec_write(codec, nid, 0,
5610 AC_VERB_SET_PIN_WIDGET_CONTROL,
5611 i <= AUTO_PIN_FRONT_MIC ?
5612 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005613 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005614 snd_hda_codec_write(codec, nid, 0,
5615 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005616 AMP_OUT_MUTE);
5617 }
5618 }
5619}
5620
5621/*
5622 * generic initialization of ADC, input mixers and output mixers
5623 */
5624static struct hda_verb alc260_volume_init_verbs[] = {
5625 /*
5626 * Unmute ADC0-1 and set the default input to mic-in
5627 */
5628 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5629 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5630 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5631 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005632
Kailang Yangdf694da2005-12-05 19:42:22 +01005633 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5634 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005635 * Note: PASD motherboards uses the Line In 2 as the input for
5636 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005637 */
5638 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005639 /* mute analog inputs */
5640 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5641 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5642 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5643 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005645
5646 /*
5647 * Set up output mixers (0x08 - 0x0a)
5648 */
5649 /* set vol=0 to output mixers */
5650 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5651 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5652 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5653 /* set up input amps for analog loopback */
5654 /* Amp Indices: DAC = 0, mixer = 1 */
5655 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5656 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5657 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5658 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5659 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5660 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005661
Kailang Yangdf694da2005-12-05 19:42:22 +01005662 { }
5663};
5664
5665static int alc260_parse_auto_config(struct hda_codec *codec)
5666{
5667 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005668 int err;
5669 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5670
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005671 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5672 alc260_ignore);
5673 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005674 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005675 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5676 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005677 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005678 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005679 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005680 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5681 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005682 return err;
5683
5684 spec->multiout.max_channels = 2;
5685
Takashi Iwai0852d7a2009-02-11 11:35:15 +01005686 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01005687 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005688 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005689 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005690
Takashi Iwaid88897e2008-10-31 15:01:37 +01005691 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005692
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005693 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005694 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005695
Takashi Iwaie044c392008-10-27 16:56:24 +01005696 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005697 return 1;
5698}
5699
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005700/* additional initialization for auto-configuration model */
5701static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005702{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005703 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005704 alc260_auto_init_multi_out(codec);
5705 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005706 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005707 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005708}
5709
Takashi Iwaicb53c622007-08-10 17:21:45 +02005710#ifdef CONFIG_SND_HDA_POWER_SAVE
5711static struct hda_amp_list alc260_loopbacks[] = {
5712 { 0x07, HDA_INPUT, 0 },
5713 { 0x07, HDA_INPUT, 1 },
5714 { 0x07, HDA_INPUT, 2 },
5715 { 0x07, HDA_INPUT, 3 },
5716 { 0x07, HDA_INPUT, 4 },
5717 { } /* end */
5718};
5719#endif
5720
Kailang Yangdf694da2005-12-05 19:42:22 +01005721/*
5722 * ALC260 configurations
5723 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005724static const char *alc260_models[ALC260_MODEL_LAST] = {
5725 [ALC260_BASIC] = "basic",
5726 [ALC260_HP] = "hp",
5727 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005728 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005729 [ALC260_FUJITSU_S702X] = "fujitsu",
5730 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005731 [ALC260_WILL] = "will",
5732 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005733#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005734 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005735#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005736 [ALC260_AUTO] = "auto",
5737};
5738
5739static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005740 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005741 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005742 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005743 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005744 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005745 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005746 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005747 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5748 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5749 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5750 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5751 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5752 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5753 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5754 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5755 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005756 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005757 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005758 {}
5759};
5760
Kailang Yangdf694da2005-12-05 19:42:22 +01005761static struct alc_config_preset alc260_presets[] = {
5762 [ALC260_BASIC] = {
5763 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005764 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005765 .init_verbs = { alc260_init_verbs },
5766 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5767 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005768 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005769 .adc_nids = alc260_adc_nids,
5770 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5771 .channel_mode = alc260_modes,
5772 .input_mux = &alc260_capture_source,
5773 },
5774 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005775 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005776 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005777 .init_verbs = { alc260_init_verbs,
5778 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005779 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5780 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005781 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5782 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005783 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5784 .channel_mode = alc260_modes,
5785 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005786 .unsol_event = alc260_hp_unsol_event,
5787 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005788 },
Kailang Yang3f878302008-08-26 13:02:23 +02005789 [ALC260_HP_DC7600] = {
5790 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005791 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005792 .init_verbs = { alc260_init_verbs,
5793 alc260_hp_dc7600_verbs },
5794 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5795 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005796 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5797 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005798 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5799 .channel_mode = alc260_modes,
5800 .input_mux = &alc260_capture_source,
5801 .unsol_event = alc260_hp_3012_unsol_event,
5802 .init_hook = alc260_hp_3012_automute,
5803 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005804 [ALC260_HP_3013] = {
5805 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005806 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005807 .init_verbs = { alc260_hp_3013_init_verbs,
5808 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005809 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5810 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005811 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5812 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005813 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5814 .channel_mode = alc260_modes,
5815 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005816 .unsol_event = alc260_hp_3013_unsol_event,
5817 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005818 },
5819 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005820 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005821 .init_verbs = { alc260_fujitsu_init_verbs },
5822 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5823 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005824 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5825 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005826 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5827 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005828 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5829 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005830 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005831 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005832 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005833 .init_verbs = { alc260_acer_init_verbs },
5834 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5835 .dac_nids = alc260_dac_nids,
5836 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5837 .adc_nids = alc260_dual_adc_nids,
5838 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5839 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005840 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5841 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005842 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005843 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005844 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005845 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5846 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5847 .dac_nids = alc260_dac_nids,
5848 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5849 .adc_nids = alc260_adc_nids,
5850 .dig_out_nid = ALC260_DIGOUT_NID,
5851 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5852 .channel_mode = alc260_modes,
5853 .input_mux = &alc260_capture_source,
5854 },
5855 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005856 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005857 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5858 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5859 .dac_nids = alc260_dac_nids,
5860 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5861 .adc_nids = alc260_adc_nids,
5862 .dig_out_nid = ALC260_DIGOUT_NID,
5863 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5864 .channel_mode = alc260_modes,
5865 .input_mux = &alc260_capture_source,
5866 .unsol_event = alc260_replacer_672v_unsol_event,
5867 .init_hook = alc260_replacer_672v_automute,
5868 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005869#ifdef CONFIG_SND_DEBUG
5870 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005871 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005872 .init_verbs = { alc260_test_init_verbs },
5873 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5874 .dac_nids = alc260_test_dac_nids,
5875 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5876 .adc_nids = alc260_test_adc_nids,
5877 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5878 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005879 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5880 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005881 },
5882#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005883};
5884
Linus Torvalds1da177e2005-04-16 15:20:36 -07005885static int patch_alc260(struct hda_codec *codec)
5886{
5887 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005888 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005889
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005890 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005891 if (spec == NULL)
5892 return -ENOMEM;
5893
5894 codec->spec = spec;
5895
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005896 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5897 alc260_models,
5898 alc260_cfg_tbl);
5899 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005900 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5901 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005902 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005903 }
5904
Kailang Yangdf694da2005-12-05 19:42:22 +01005905 if (board_config == ALC260_AUTO) {
5906 /* automatic parse from the BIOS config */
5907 err = alc260_parse_auto_config(codec);
5908 if (err < 0) {
5909 alc_free(codec);
5910 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005911 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005912 printk(KERN_INFO
5913 "hda_codec: Cannot set up configuration "
5914 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005915 board_config = ALC260_BASIC;
5916 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005917 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005918
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005919 err = snd_hda_attach_beep_device(codec, 0x1);
5920 if (err < 0) {
5921 alc_free(codec);
5922 return err;
5923 }
5924
Kailang Yangdf694da2005-12-05 19:42:22 +01005925 if (board_config != ALC260_AUTO)
5926 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005927
5928 spec->stream_name_analog = "ALC260 Analog";
5929 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5930 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5931
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005932 spec->stream_name_digital = "ALC260 Digital";
5933 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5934 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5935
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01005936 if (!spec->adc_nids && spec->input_mux) {
5937 /* check whether NID 0x04 is valid */
5938 unsigned int wcap = get_wcaps(codec, 0x04);
5939 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5940 /* get type */
5941 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5942 spec->adc_nids = alc260_adc_nids_alt;
5943 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5944 } else {
5945 spec->adc_nids = alc260_adc_nids;
5946 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5947 }
5948 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005949 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005950 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005951
Takashi Iwai2134ea42008-01-10 16:53:55 +01005952 spec->vmaster_nid = 0x08;
5953
Linus Torvalds1da177e2005-04-16 15:20:36 -07005954 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005955 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005956 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005957#ifdef CONFIG_SND_HDA_POWER_SAVE
5958 if (!spec->loopback.amplist)
5959 spec->loopback.amplist = alc260_loopbacks;
5960#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01005961 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005962
5963 return 0;
5964}
5965
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005966
Linus Torvalds1da177e2005-04-16 15:20:36 -07005967/*
5968 * ALC882 support
5969 *
5970 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5971 * configuration. Each pin widget can choose any input DACs and a mixer.
5972 * Each ADC is connected from a mixer of all inputs. This makes possible
5973 * 6-channel independent captures.
5974 *
5975 * In addition, an independent DAC for the multi-playback (not used in this
5976 * driver yet).
5977 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005978#define ALC882_DIGOUT_NID 0x06
5979#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005980
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005981static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005982 { 8, NULL }
5983};
5984
5985static hda_nid_t alc882_dac_nids[4] = {
5986 /* front, rear, clfe, rear_surr */
5987 0x02, 0x03, 0x04, 0x05
5988};
5989
Kailang Yangdf694da2005-12-05 19:42:22 +01005990/* identical with ALC880 */
5991#define alc882_adc_nids alc880_adc_nids
5992#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005993
Takashi Iwaie1406342008-02-11 18:32:32 +01005994static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5995static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5996
Linus Torvalds1da177e2005-04-16 15:20:36 -07005997/* input MUX */
5998/* FIXME: should be a matrix-type input source selection */
5999
6000static struct hda_input_mux alc882_capture_source = {
6001 .num_items = 4,
6002 .items = {
6003 { "Mic", 0x0 },
6004 { "Front Mic", 0x1 },
6005 { "Line", 0x2 },
6006 { "CD", 0x4 },
6007 },
6008};
Kailang Yangdf694da2005-12-05 19:42:22 +01006009/*
Kailang Yang272a5272007-05-14 11:00:38 +02006010 * 2ch mode
6011 */
6012static struct hda_verb alc882_3ST_ch2_init[] = {
6013 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6014 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6015 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6016 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6017 { } /* end */
6018};
6019
6020/*
6021 * 6ch mode
6022 */
6023static struct hda_verb alc882_3ST_ch6_init[] = {
6024 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6025 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6026 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6027 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6028 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6029 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6030 { } /* end */
6031};
6032
6033static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
6034 { 2, alc882_3ST_ch2_init },
6035 { 6, alc882_3ST_ch6_init },
6036};
6037
6038/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006039 * 6ch mode
6040 */
6041static struct hda_verb alc882_sixstack_ch6_init[] = {
6042 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6043 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6044 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6045 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6046 { } /* end */
6047};
6048
6049/*
6050 * 8ch mode
6051 */
6052static struct hda_verb alc882_sixstack_ch8_init[] = {
6053 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6054 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6055 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6056 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6057 { } /* end */
6058};
6059
6060static struct hda_channel_mode alc882_sixstack_modes[2] = {
6061 { 6, alc882_sixstack_ch6_init },
6062 { 8, alc882_sixstack_ch8_init },
6063};
6064
Takashi Iwai87350ad2007-08-16 18:19:38 +02006065/*
6066 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
6067 */
6068
6069/*
6070 * 2ch mode
6071 */
6072static struct hda_verb alc885_mbp_ch2_init[] = {
6073 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6074 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6075 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6076 { } /* end */
6077};
6078
6079/*
6080 * 6ch mode
6081 */
6082static struct hda_verb alc885_mbp_ch6_init[] = {
6083 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6084 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6085 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6086 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6087 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6088 { } /* end */
6089};
6090
6091static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6092 { 2, alc885_mbp_ch2_init },
6093 { 6, alc885_mbp_ch6_init },
6094};
6095
6096
Linus Torvalds1da177e2005-04-16 15:20:36 -07006097/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6098 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6099 */
Takashi Iwaic8b6bf9b2005-11-17 14:57:47 +01006100static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006101 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006102 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006103 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006104 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006105 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6106 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006107 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6108 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006109 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006110 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006111 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6112 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6113 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6114 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6115 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006117 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006118 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6119 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006120 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006121 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006122 { } /* end */
6123};
6124
Takashi Iwai87350ad2007-08-16 18:19:38 +02006125static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006126 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6127 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6128 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6129 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6130 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6131 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006132 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6133 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006134 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006135 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6136 { } /* end */
6137};
Kailang Yangbdd148a2007-05-08 15:19:08 +02006138static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6139 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6140 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6141 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6142 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6143 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6144 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6145 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6146 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6147 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006148 { } /* end */
6149};
6150
Kailang Yang272a5272007-05-14 11:00:38 +02006151static struct snd_kcontrol_new alc882_targa_mixer[] = {
6152 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6153 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6154 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6155 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6156 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6157 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6158 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6159 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6160 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02006161 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006162 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6163 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02006164 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006165 { } /* end */
6166};
6167
6168/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6169 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6170 */
6171static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6172 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6173 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6174 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6175 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6176 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6177 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6178 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6179 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6180 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6181 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6182 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6183 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc2007-09-07 10:57:44 +02006184 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006185 { } /* end */
6186};
6187
Takashi Iwai914759b2007-09-06 14:52:04 +02006188static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6189 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6190 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6191 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6192 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6193 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6194 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6195 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6196 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6197 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6198 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02006199 { } /* end */
6200};
6201
Kailang Yangdf694da2005-12-05 19:42:22 +01006202static struct snd_kcontrol_new alc882_chmode_mixer[] = {
6203 {
6204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6205 .name = "Channel Mode",
6206 .info = alc_ch_mode_info,
6207 .get = alc_ch_mode_get,
6208 .put = alc_ch_mode_put,
6209 },
6210 { } /* end */
6211};
6212
Linus Torvalds1da177e2005-04-16 15:20:36 -07006213static struct hda_verb alc882_init_verbs[] = {
6214 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6216 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6217 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006218 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006219 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6220 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6221 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006222 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006223 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6224 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6225 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006226 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006227 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6228 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6229 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006230
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006231 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006232 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006233 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006234 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006235 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006239 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006240 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006241 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006242 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006243 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006244 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006245 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006246 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006247 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006248 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006249 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6250 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006251 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006252 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6253 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006254 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006255 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6256 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6257 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6258 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6259 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006260 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006261 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006262
6263 /* FIXME: use matrix-type input source selection */
6264 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6265 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006266 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6267 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6268 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6269 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006270 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006271 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6272 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6273 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6274 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006275 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006276 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6277 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6278 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6279 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6280 /* ADC1: mute amp left and right */
6281 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006282 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006283 /* ADC2: mute amp left and right */
6284 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006285 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006286 /* ADC3: mute amp left and right */
6287 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006288 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006289
6290 { }
6291};
6292
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006293static struct hda_verb alc882_eapd_verbs[] = {
6294 /* change to EAPD mode */
6295 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006296 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006297 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006298};
6299
Tobin Davis9102cd12006-12-15 10:02:12 +01006300/* Mac Pro test */
6301static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6302 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6303 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6304 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6305 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6306 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006307 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01006308 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6309 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006310 */
Tobin Davis9102cd12006-12-15 10:02:12 +01006311 { } /* end */
6312};
6313
6314static struct hda_verb alc882_macpro_init_verbs[] = {
6315 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6317 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6319 /* Front Pin: output 0 (0x0c) */
6320 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6321 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6322 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6323 /* Front Mic pin: input vref at 80% */
6324 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6325 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6326 /* Speaker: output */
6327 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6328 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6329 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6330 /* Headphone output (output 0 - 0x0c) */
6331 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6332 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6333 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6334
6335 /* FIXME: use matrix-type input source selection */
6336 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6337 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6338 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6339 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6340 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6341 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6342 /* Input mixer2 */
6343 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6344 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6345 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6346 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6347 /* Input mixer3 */
6348 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6349 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6350 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6351 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6352 /* ADC1: mute amp left and right */
6353 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6354 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6355 /* ADC2: mute amp left and right */
6356 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6357 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6358 /* ADC3: mute amp left and right */
6359 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6360 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6361
6362 { }
6363};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006364
Takashi Iwai87350ad2007-08-16 18:19:38 +02006365/* Macbook Pro rev3 */
6366static struct hda_verb alc885_mbp3_init_verbs[] = {
6367 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6368 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6369 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6370 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6371 /* Rear mixer */
6372 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6374 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6375 /* Front Pin: output 0 (0x0c) */
6376 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6377 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6378 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6379 /* HP Pin: output 0 (0x0d) */
6380 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6381 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6382 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6383 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6384 /* Mic (rear) pin: input vref at 80% */
6385 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6386 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6387 /* Front Mic pin: input vref at 80% */
6388 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6389 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6390 /* Line In pin: use output 1 when in LineOut mode */
6391 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6392 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6393 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6394
6395 /* FIXME: use matrix-type input source selection */
6396 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6397 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6398 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6399 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6400 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6401 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6402 /* Input mixer2 */
6403 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6404 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6405 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6406 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6407 /* Input mixer3 */
6408 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6409 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6410 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6411 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6412 /* ADC1: mute amp left and right */
6413 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6414 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6415 /* ADC2: mute amp left and right */
6416 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6417 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6418 /* ADC3: mute amp left and right */
6419 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6420 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6421
6422 { }
6423};
6424
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006425/* iMac 24 mixer. */
6426static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6427 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6428 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6429 { } /* end */
6430};
6431
6432/* iMac 24 init verbs. */
6433static struct hda_verb alc885_imac24_init_verbs[] = {
6434 /* Internal speakers: output 0 (0x0c) */
6435 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6436 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6437 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6438 /* Internal speakers: output 0 (0x0c) */
6439 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6440 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6441 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6442 /* Headphone: output 0 (0x0c) */
6443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6445 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6446 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6447 /* Front Mic: input vref at 80% */
6448 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6449 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6450 { }
6451};
6452
6453/* Toggle speaker-output according to the hp-jack state */
6454static void alc885_imac24_automute(struct hda_codec *codec)
6455{
6456 unsigned int present;
6457
6458 present = snd_hda_codec_read(codec, 0x14, 0,
6459 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006460 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6461 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6462 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6463 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006464}
6465
6466/* Processes unsolicited events. */
6467static void alc885_imac24_unsol_event(struct hda_codec *codec,
6468 unsigned int res)
6469{
6470 /* Headphone insertion or removal. */
6471 if ((res >> 26) == ALC880_HP_EVENT)
6472 alc885_imac24_automute(codec);
6473}
6474
Takashi Iwai87350ad2007-08-16 18:19:38 +02006475static void alc885_mbp3_automute(struct hda_codec *codec)
6476{
6477 unsigned int present;
6478
6479 present = snd_hda_codec_read(codec, 0x15, 0,
6480 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6481 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6482 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6483 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6484 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6485
6486}
6487static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6488 unsigned int res)
6489{
6490 /* Headphone insertion or removal. */
6491 if ((res >> 26) == ALC880_HP_EVENT)
6492 alc885_mbp3_automute(codec);
6493}
6494
6495
Kailang Yang272a5272007-05-14 11:00:38 +02006496static struct hda_verb alc882_targa_verbs[] = {
6497 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6498 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6499
6500 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6501 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006502
Kailang Yang272a5272007-05-14 11:00:38 +02006503 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6504 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6505 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6506
6507 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6508 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6509 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6510 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6511 { } /* end */
6512};
6513
6514/* toggle speaker-output according to the hp-jack state */
6515static void alc882_targa_automute(struct hda_codec *codec)
6516{
6517 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006518
Kailang Yang272a5272007-05-14 11:00:38 +02006519 present = snd_hda_codec_read(codec, 0x14, 0,
6520 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006521 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6522 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006523 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6524 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006525}
6526
6527static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6528{
6529 /* Looks like the unsol event is incompatible with the standard
6530 * definition. 4bit tag is placed at 26 bit!
6531 */
6532 if (((res >> 26) == ALC880_HP_EVENT)) {
6533 alc882_targa_automute(codec);
6534 }
6535}
6536
6537static struct hda_verb alc882_asus_a7j_verbs[] = {
6538 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6539 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6540
6541 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6542 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6543 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006544
Kailang Yang272a5272007-05-14 11:00:38 +02006545 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6546 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6547 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6548
6549 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6550 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6551 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6552 { } /* end */
6553};
6554
Takashi Iwai914759b2007-09-06 14:52:04 +02006555static struct hda_verb alc882_asus_a7m_verbs[] = {
6556 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6557 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6558
6559 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6560 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6561 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006562
Takashi Iwai914759b2007-09-06 14:52:04 +02006563 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6564 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6565 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6566
6567 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6568 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6569 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6570 { } /* end */
6571};
6572
Tobin Davis9102cd12006-12-15 10:02:12 +01006573static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6574{
6575 unsigned int gpiostate, gpiomask, gpiodir;
6576
6577 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6578 AC_VERB_GET_GPIO_DATA, 0);
6579
6580 if (!muted)
6581 gpiostate |= (1 << pin);
6582 else
6583 gpiostate &= ~(1 << pin);
6584
6585 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6586 AC_VERB_GET_GPIO_MASK, 0);
6587 gpiomask |= (1 << pin);
6588
6589 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6590 AC_VERB_GET_GPIO_DIRECTION, 0);
6591 gpiodir |= (1 << pin);
6592
6593
6594 snd_hda_codec_write(codec, codec->afg, 0,
6595 AC_VERB_SET_GPIO_MASK, gpiomask);
6596 snd_hda_codec_write(codec, codec->afg, 0,
6597 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6598
6599 msleep(1);
6600
6601 snd_hda_codec_write(codec, codec->afg, 0,
6602 AC_VERB_SET_GPIO_DATA, gpiostate);
6603}
6604
Takashi Iwai7debbe52007-08-16 15:01:03 +02006605/* set up GPIO at initialization */
6606static void alc885_macpro_init_hook(struct hda_codec *codec)
6607{
6608 alc882_gpio_mute(codec, 0, 0);
6609 alc882_gpio_mute(codec, 1, 0);
6610}
6611
6612/* set up GPIO and update auto-muting at initialization */
6613static void alc885_imac24_init_hook(struct hda_codec *codec)
6614{
6615 alc885_macpro_init_hook(codec);
6616 alc885_imac24_automute(codec);
6617}
6618
Kailang Yangdf694da2005-12-05 19:42:22 +01006619/*
6620 * generic initialization of ADC, input mixers and output mixers
6621 */
6622static struct hda_verb alc882_auto_init_verbs[] = {
6623 /*
6624 * Unmute ADC0-2 and set the default input to mic-in
6625 */
6626 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6627 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6628 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6630 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6631 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6632
Takashi Iwaicb53c622007-08-10 17:21:45 +02006633 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006634 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006635 * Note: PASD motherboards uses the Line In 2 as the input for
6636 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006637 */
6638 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006644
6645 /*
6646 * Set up output mixers (0x0c - 0x0f)
6647 */
6648 /* set vol=0 to output mixers */
6649 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6650 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6651 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6652 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6653 /* set up input amps for analog loopback */
6654 /* Amp Indices: DAC = 0, mixer = 1 */
6655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6657 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6658 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6659 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6660 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6661 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6662 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6663 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6664 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6665
6666 /* FIXME: use matrix-type input source selection */
6667 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6668 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6669 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6670 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6671 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6672 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6673 /* Input mixer2 */
6674 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6675 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6676 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6677 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6678 /* Input mixer3 */
6679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6680 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6681 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6682 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6683
6684 { }
6685};
6686
Takashi Iwaicb53c622007-08-10 17:21:45 +02006687#ifdef CONFIG_SND_HDA_POWER_SAVE
6688#define alc882_loopbacks alc880_loopbacks
6689#endif
6690
Kailang Yangdf694da2005-12-05 19:42:22 +01006691/* pcm configuration: identiacal with ALC880 */
6692#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6693#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6694#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6695#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6696
6697/*
6698 * configuration and preset
6699 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006700static const char *alc882_models[ALC882_MODEL_LAST] = {
6701 [ALC882_3ST_DIG] = "3stack-dig",
6702 [ALC882_6ST_DIG] = "6stack-dig",
6703 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006704 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006705 [ALC882_TARGA] = "targa",
6706 [ALC882_ASUS_A7J] = "asus-a7j",
6707 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006708 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006709 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006710 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006711 [ALC882_AUTO] = "auto",
6712};
6713
6714static struct snd_pci_quirk alc882_cfg_tbl[] = {
6715 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006716 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006717 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006718 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006719 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006720 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006721 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006722 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006723 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006724 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6725 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6726 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006727 {}
6728};
6729
6730static struct alc_config_preset alc882_presets[] = {
6731 [ALC882_3ST_DIG] = {
6732 .mixers = { alc882_base_mixer },
6733 .init_verbs = { alc882_init_verbs },
6734 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6735 .dac_nids = alc882_dac_nids,
6736 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006737 .dig_in_nid = ALC882_DIGIN_NID,
6738 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6739 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006740 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006741 .input_mux = &alc882_capture_source,
6742 },
6743 [ALC882_6ST_DIG] = {
6744 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6745 .init_verbs = { alc882_init_verbs },
6746 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6747 .dac_nids = alc882_dac_nids,
6748 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006749 .dig_in_nid = ALC882_DIGIN_NID,
6750 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6751 .channel_mode = alc882_sixstack_modes,
6752 .input_mux = &alc882_capture_source,
6753 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006754 [ALC882_ARIMA] = {
6755 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6756 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6757 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6758 .dac_nids = alc882_dac_nids,
6759 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6760 .channel_mode = alc882_sixstack_modes,
6761 .input_mux = &alc882_capture_source,
6762 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006763 [ALC882_W2JC] = {
6764 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6765 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6766 alc880_gpio1_init_verbs },
6767 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6768 .dac_nids = alc882_dac_nids,
6769 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6770 .channel_mode = alc880_threestack_modes,
6771 .need_dac_fix = 1,
6772 .input_mux = &alc882_capture_source,
6773 .dig_out_nid = ALC882_DIGOUT_NID,
6774 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006775 [ALC885_MBP3] = {
6776 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6777 .init_verbs = { alc885_mbp3_init_verbs,
6778 alc880_gpio1_init_verbs },
6779 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6780 .dac_nids = alc882_dac_nids,
6781 .channel_mode = alc885_mbp_6ch_modes,
6782 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6783 .input_mux = &alc882_capture_source,
6784 .dig_out_nid = ALC882_DIGOUT_NID,
6785 .dig_in_nid = ALC882_DIGIN_NID,
6786 .unsol_event = alc885_mbp3_unsol_event,
6787 .init_hook = alc885_mbp3_automute,
6788 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006789 [ALC885_MACPRO] = {
6790 .mixers = { alc882_macpro_mixer },
6791 .init_verbs = { alc882_macpro_init_verbs },
6792 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6793 .dac_nids = alc882_dac_nids,
6794 .dig_out_nid = ALC882_DIGOUT_NID,
6795 .dig_in_nid = ALC882_DIGIN_NID,
6796 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6797 .channel_mode = alc882_ch_modes,
6798 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006799 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006800 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006801 [ALC885_IMAC24] = {
6802 .mixers = { alc885_imac24_mixer },
6803 .init_verbs = { alc885_imac24_init_verbs },
6804 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6805 .dac_nids = alc882_dac_nids,
6806 .dig_out_nid = ALC882_DIGOUT_NID,
6807 .dig_in_nid = ALC882_DIGIN_NID,
6808 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6809 .channel_mode = alc882_ch_modes,
6810 .input_mux = &alc882_capture_source,
6811 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006812 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006813 },
Kailang Yang272a5272007-05-14 11:00:38 +02006814 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006815 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006816 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6817 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6818 .dac_nids = alc882_dac_nids,
6819 .dig_out_nid = ALC882_DIGOUT_NID,
6820 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6821 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006822 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006823 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6824 .channel_mode = alc882_3ST_6ch_modes,
6825 .need_dac_fix = 1,
6826 .input_mux = &alc882_capture_source,
6827 .unsol_event = alc882_targa_unsol_event,
6828 .init_hook = alc882_targa_automute,
6829 },
6830 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006831 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006832 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6833 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6834 .dac_nids = alc882_dac_nids,
6835 .dig_out_nid = ALC882_DIGOUT_NID,
6836 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6837 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006838 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006839 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6840 .channel_mode = alc882_3ST_6ch_modes,
6841 .need_dac_fix = 1,
6842 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006843 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006844 [ALC882_ASUS_A7M] = {
6845 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6846 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6847 alc880_gpio1_init_verbs,
6848 alc882_asus_a7m_verbs },
6849 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6850 .dac_nids = alc882_dac_nids,
6851 .dig_out_nid = ALC882_DIGOUT_NID,
6852 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6853 .channel_mode = alc880_threestack_modes,
6854 .need_dac_fix = 1,
6855 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006856 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006857};
6858
6859
6860/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006861 * Pin config fixes
6862 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006863enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006864 PINFIX_ABIT_AW9D_MAX
6865};
6866
6867static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6868 { 0x15, 0x01080104 }, /* side */
6869 { 0x16, 0x01011012 }, /* rear */
6870 { 0x17, 0x01016011 }, /* clfe */
6871 { }
6872};
6873
6874static const struct alc_pincfg *alc882_pin_fixes[] = {
6875 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6876};
6877
6878static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6879 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6880 {}
6881};
6882
6883/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006884 * BIOS auto configuration
6885 */
6886static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6887 hda_nid_t nid, int pin_type,
6888 int dac_idx)
6889{
6890 /* set as output */
6891 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006892 int idx;
6893
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006894 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006895 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6896 idx = 4;
6897 else
6898 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006899 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6900
6901}
6902
6903static void alc882_auto_init_multi_out(struct hda_codec *codec)
6904{
6905 struct alc_spec *spec = codec->spec;
6906 int i;
6907
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006908 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006909 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006910 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006911 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006912 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006913 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006914 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006915 }
6916}
6917
6918static void alc882_auto_init_hp_out(struct hda_codec *codec)
6919{
6920 struct alc_spec *spec = codec->spec;
6921 hda_nid_t pin;
6922
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006923 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006924 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006925 /* use dac 0 */
6926 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006927 pin = spec->autocfg.speaker_pins[0];
6928 if (pin)
6929 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006930}
6931
6932#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6933#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6934
6935static void alc882_auto_init_analog_input(struct hda_codec *codec)
6936{
6937 struct alc_spec *spec = codec->spec;
6938 int i;
6939
6940 for (i = 0; i < AUTO_PIN_LAST; i++) {
6941 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006942 unsigned int vref;
6943 if (!nid)
6944 continue;
6945 vref = PIN_IN;
6946 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006947 unsigned int pincap;
6948 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6949 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006950 AC_PINCAP_VREF_80)
6951 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006952 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006953 snd_hda_codec_write(codec, nid, 0,
6954 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6955 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6956 snd_hda_codec_write(codec, nid, 0,
6957 AC_VERB_SET_AMP_GAIN_MUTE,
6958 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006959 }
6960}
6961
Takashi Iwaif511b012008-08-15 16:46:42 +02006962static void alc882_auto_init_input_src(struct hda_codec *codec)
6963{
6964 struct alc_spec *spec = codec->spec;
Takashi Iwaif511b012008-08-15 16:46:42 +02006965 int c;
6966
6967 for (c = 0; c < spec->num_adc_nids; c++) {
6968 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6969 hda_nid_t nid = spec->capsrc_nids[c];
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02006970 unsigned int mux_idx;
6971 const struct hda_input_mux *imux;
Takashi Iwaif511b012008-08-15 16:46:42 +02006972 int conns, mute, idx, item;
6973
6974 conns = snd_hda_get_connections(codec, nid, conn_list,
6975 ARRAY_SIZE(conn_list));
6976 if (conns < 0)
6977 continue;
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02006978 mux_idx = c >= spec->num_mux_defs ? 0 : c;
6979 imux = &spec->input_mux[mux_idx];
Takashi Iwaif511b012008-08-15 16:46:42 +02006980 for (idx = 0; idx < conns; idx++) {
6981 /* if the current connection is the selected one,
6982 * unmute it as default - otherwise mute it
6983 */
6984 mute = AMP_IN_MUTE(idx);
6985 for (item = 0; item < imux->num_items; item++) {
6986 if (imux->items[item].index == idx) {
6987 if (spec->cur_mux[c] == item)
6988 mute = AMP_IN_UNMUTE(idx);
6989 break;
6990 }
6991 }
Herton Ronaldo Krzesinskib98b7b32009-01-29 13:18:31 -02006992 /* check if we have a selector or mixer
6993 * we could check for the widget type instead, but
6994 * just check for Amp-In presence (in case of mixer
6995 * without amp-in there is something wrong, this
6996 * function shouldn't be used or capsrc nid is wrong)
6997 */
6998 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
6999 snd_hda_codec_write(codec, nid, 0,
7000 AC_VERB_SET_AMP_GAIN_MUTE,
7001 mute);
7002 else if (mute != AMP_IN_MUTE(idx))
7003 snd_hda_codec_write(codec, nid, 0,
7004 AC_VERB_SET_CONNECT_SEL,
7005 idx);
Takashi Iwaif511b012008-08-15 16:46:42 +02007006 }
7007 }
7008}
7009
Takashi Iwai776e1842007-08-29 15:07:11 +02007010/* add mic boosts if needed */
7011static int alc_auto_add_mic_boost(struct hda_codec *codec)
7012{
7013 struct alc_spec *spec = codec->spec;
7014 int err;
7015 hda_nid_t nid;
7016
7017 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007018 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007019 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7020 "Mic Boost",
7021 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7022 if (err < 0)
7023 return err;
7024 }
7025 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01007026 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02007027 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7028 "Front Mic Boost",
7029 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
7030 if (err < 0)
7031 return err;
7032 }
7033 return 0;
7034}
7035
Kailang Yangdf694da2005-12-05 19:42:22 +01007036/* almost identical with ALC880 parser... */
7037static int alc882_parse_auto_config(struct hda_codec *codec)
7038{
7039 struct alc_spec *spec = codec->spec;
7040 int err = alc880_parse_auto_config(codec);
7041
7042 if (err < 0)
7043 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02007044 else if (!err)
7045 return 0; /* no config found */
7046
7047 err = alc_auto_add_mic_boost(codec);
7048 if (err < 0)
7049 return err;
7050
7051 /* hack - override the init verbs */
7052 spec->init_verbs[0] = alc882_auto_init_verbs;
7053
7054 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01007055}
7056
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007057/* additional initialization for auto-configuration model */
7058static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007059{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007060 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007061 alc882_auto_init_multi_out(codec);
7062 alc882_auto_init_hp_out(codec);
7063 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02007064 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007065 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007066 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007067}
7068
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007069static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
7070
Linus Torvalds1da177e2005-04-16 15:20:36 -07007071static int patch_alc882(struct hda_codec *codec)
7072{
7073 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007074 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007075
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007076 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007077 if (spec == NULL)
7078 return -ENOMEM;
7079
Linus Torvalds1da177e2005-04-16 15:20:36 -07007080 codec->spec = spec;
7081
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007082 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
7083 alc882_models,
7084 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007085
Kailang Yangdf694da2005-12-05 19:42:22 +01007086 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01007087 /* Pick up systems that don't supply PCI SSID */
7088 switch (codec->subsystem_id) {
7089 case 0x106b0c00: /* Mac Pro */
7090 board_config = ALC885_MACPRO;
7091 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007092 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02007093 case 0x106b2800: /* AppleTV */
Mark Eggleston3077e442009-01-31 17:57:54 +01007094 case 0x106b3e00: /* iMac 24 Aluminium */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007095 board_config = ALC885_IMAC24;
7096 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02007097 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07007098 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007099 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02007100 case 0x106b3600: /* Macbook 3.1 */
Luke Yelavich2a884642009-01-28 15:58:38 +11007101 case 0x106b3800: /* MacbookPro4,1 - latter revision */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007102 board_config = ALC885_MBP3;
7103 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01007104 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007105 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02007106 if (codec->revision_id == 0x100101 ||
7107 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02007108 alc_free(codec);
7109 return patch_alc883(codec);
7110 }
Tobin Davis081d17c2007-02-15 17:46:18 +01007111 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
7112 "trying auto-probe from BIOS...\n");
7113 board_config = ALC882_AUTO;
7114 }
Kailang Yangdf694da2005-12-05 19:42:22 +01007115 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007116
Takashi Iwaif95474e2007-07-10 00:47:43 +02007117 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
7118
Kailang Yangdf694da2005-12-05 19:42:22 +01007119 if (board_config == ALC882_AUTO) {
7120 /* automatic parse from the BIOS config */
7121 err = alc882_parse_auto_config(codec);
7122 if (err < 0) {
7123 alc_free(codec);
7124 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007125 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007126 printk(KERN_INFO
7127 "hda_codec: Cannot set up configuration "
7128 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007129 board_config = ALC882_3ST_DIG;
7130 }
7131 }
7132
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007133 err = snd_hda_attach_beep_device(codec, 0x1);
7134 if (err < 0) {
7135 alc_free(codec);
7136 return err;
7137 }
7138
Kailang Yangdf694da2005-12-05 19:42:22 +01007139 if (board_config != ALC882_AUTO)
7140 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007141
Kailang Yang2f893282008-05-27 12:14:47 +02007142 if (codec->vendor_id == 0x10ec0885) {
7143 spec->stream_name_analog = "ALC885 Analog";
7144 spec->stream_name_digital = "ALC885 Digital";
7145 } else {
7146 spec->stream_name_analog = "ALC882 Analog";
7147 spec->stream_name_digital = "ALC882 Digital";
7148 }
7149
Kailang Yangdf694da2005-12-05 19:42:22 +01007150 spec->stream_analog_playback = &alc882_pcm_analog_playback;
7151 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01007152 /* FIXME: setup DAC5 */
7153 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
7154 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007155
Kailang Yangdf694da2005-12-05 19:42:22 +01007156 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7157 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007158
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007159 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007160 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01007161 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01007162 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007163 /* get type */
7164 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01007165 if (wcap != AC_WID_AUD_IN) {
7166 spec->adc_nids = alc882_adc_nids_alt;
7167 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01007168 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01007169 } else {
7170 spec->adc_nids = alc882_adc_nids;
7171 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01007172 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01007173 }
7174 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007175 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007176 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007177
Takashi Iwai2134ea42008-01-10 16:53:55 +01007178 spec->vmaster_nid = 0x0c;
7179
Linus Torvalds1da177e2005-04-16 15:20:36 -07007180 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007181 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007182 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007183#ifdef CONFIG_SND_HDA_POWER_SAVE
7184 if (!spec->loopback.amplist)
7185 spec->loopback.amplist = alc882_loopbacks;
7186#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01007187 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007188
7189 return 0;
7190}
7191
7192/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007193 * ALC883 support
7194 *
7195 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
7196 * configuration. Each pin widget can choose any input DACs and a mixer.
7197 * Each ADC is connected from a mixer of all inputs. This makes possible
7198 * 6-channel independent captures.
7199 *
7200 * In addition, an independent DAC for the multi-playback (not used in this
7201 * driver yet).
7202 */
7203#define ALC883_DIGOUT_NID 0x06
7204#define ALC883_DIGIN_NID 0x0a
7205
Wu Fengguang3ab90932008-11-17 09:51:09 +01007206#define ALC1200_DIGOUT_NID 0x10
7207
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007208static hda_nid_t alc883_dac_nids[4] = {
7209 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007210 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007211};
7212
7213static hda_nid_t alc883_adc_nids[2] = {
7214 /* ADC1-2 */
7215 0x08, 0x09,
7216};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007217
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007218static hda_nid_t alc883_adc_nids_alt[1] = {
7219 /* ADC1 */
7220 0x08,
7221};
7222
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007223static hda_nid_t alc883_adc_nids_rev[2] = {
7224 /* ADC2-1 */
7225 0x09, 0x08
7226};
7227
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007228#define alc889_adc_nids alc880_adc_nids
7229
Takashi Iwaie1406342008-02-11 18:32:32 +01007230static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7231
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08007232static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7233
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007234#define alc889_capsrc_nids alc882_capsrc_nids
7235
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007236/* input MUX */
7237/* FIXME: should be a matrix-type input source selection */
7238
7239static struct hda_input_mux alc883_capture_source = {
7240 .num_items = 4,
7241 .items = {
7242 { "Mic", 0x0 },
7243 { "Front Mic", 0x1 },
7244 { "Line", 0x2 },
7245 { "CD", 0x4 },
7246 },
7247};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007248
Jiang zhe17bba1b2008-06-04 12:11:07 +02007249static struct hda_input_mux alc883_3stack_6ch_intel = {
7250 .num_items = 4,
7251 .items = {
7252 { "Mic", 0x1 },
7253 { "Front Mic", 0x0 },
7254 { "Line", 0x2 },
7255 { "CD", 0x4 },
7256 },
7257};
7258
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007259static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7260 .num_items = 2,
7261 .items = {
7262 { "Mic", 0x1 },
7263 { "Line", 0x2 },
7264 },
7265};
7266
Kailang Yang272a5272007-05-14 11:00:38 +02007267static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7268 .num_items = 4,
7269 .items = {
7270 { "Mic", 0x0 },
7271 { "iMic", 0x1 },
7272 { "Line", 0x2 },
7273 { "CD", 0x4 },
7274 },
7275};
7276
Jiang zhefb97dc62008-03-06 11:07:11 +01007277static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7278 .num_items = 2,
7279 .items = {
7280 { "Mic", 0x0 },
7281 { "Int Mic", 0x1 },
7282 },
7283};
7284
Kailang Yange2757d52008-08-26 13:17:46 +02007285static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7286 .num_items = 3,
7287 .items = {
7288 { "Mic", 0x0 },
7289 { "Front Mic", 0x1 },
7290 { "Line", 0x4 },
7291 },
7292};
7293
7294static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7295 .num_items = 2,
7296 .items = {
7297 { "Mic", 0x0 },
7298 { "Line", 0x2 },
7299 },
7300};
7301
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007302/*
7303 * 2ch mode
7304 */
7305static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7306 { 2, NULL }
7307};
7308
7309/*
7310 * 2ch mode
7311 */
7312static struct hda_verb alc883_3ST_ch2_init[] = {
7313 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7314 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7315 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7316 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7317 { } /* end */
7318};
7319
7320/*
Tobin Davisb2011312007-09-17 12:45:11 +02007321 * 4ch mode
7322 */
7323static struct hda_verb alc883_3ST_ch4_init[] = {
7324 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7325 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7326 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7327 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7328 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7329 { } /* end */
7330};
7331
7332/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007333 * 6ch mode
7334 */
7335static struct hda_verb alc883_3ST_ch6_init[] = {
7336 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7337 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7338 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7339 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7340 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7341 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7342 { } /* end */
7343};
7344
Tobin Davisb2011312007-09-17 12:45:11 +02007345static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007346 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007347 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007348 { 6, alc883_3ST_ch6_init },
7349};
7350
7351/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007352 * 2ch mode
7353 */
7354static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7355 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7356 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7357 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7358 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7359 { } /* end */
7360};
7361
7362/*
7363 * 4ch mode
7364 */
7365static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7366 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7367 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7368 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7369 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7370 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7371 { } /* end */
7372};
7373
7374/*
7375 * 6ch mode
7376 */
7377static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7378 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7379 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7380 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7381 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7382 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7383 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7384 { } /* end */
7385};
7386
7387static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7388 { 2, alc883_3ST_ch2_intel_init },
7389 { 4, alc883_3ST_ch4_intel_init },
7390 { 6, alc883_3ST_ch6_intel_init },
7391};
7392
7393/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007394 * 6ch mode
7395 */
7396static struct hda_verb alc883_sixstack_ch6_init[] = {
7397 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7398 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7399 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7400 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7401 { } /* end */
7402};
7403
7404/*
7405 * 8ch mode
7406 */
7407static struct hda_verb alc883_sixstack_ch8_init[] = {
7408 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7409 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7410 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7411 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7412 { } /* end */
7413};
7414
7415static struct hda_channel_mode alc883_sixstack_modes[2] = {
7416 { 6, alc883_sixstack_ch6_init },
7417 { 8, alc883_sixstack_ch8_init },
7418};
7419
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007420static struct hda_verb alc883_medion_eapd_verbs[] = {
7421 /* eanable EAPD on medion laptop */
7422 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7423 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7424 { }
7425};
7426
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007427/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7428 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7429 */
7430
7431static struct snd_kcontrol_new alc883_base_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("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7435 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7436 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7437 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7438 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7439 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7440 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7441 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7442 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7443 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7444 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7445 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7446 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7447 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007448 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007449 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7450 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007451 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007452 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007453 { } /* end */
7454};
7455
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007456static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7457 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7458 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7459 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7460 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7461 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7462 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7463 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7464 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7465 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7467 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7468 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7469 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007470 { } /* end */
7471};
7472
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007473static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007474 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7475 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7476 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7477 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7478 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7479 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7480 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7481 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7482 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7483 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007484 { } /* end */
7485};
7486
Jiang zhefb97dc62008-03-06 11:07:11 +01007487static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7488 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7489 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7490 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7491 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7492 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7493 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7494 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7495 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7496 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7497 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007498 { } /* end */
7499};
7500
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007501static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7502 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7503 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7504 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7505 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7506 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7507 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7508 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7509 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007510 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007511 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7512 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007513 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007514 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007515 { } /* end */
7516};
7517
7518static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7519 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7520 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7521 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7522 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7523 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7524 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7525 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7526 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7527 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7528 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7529 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7530 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7531 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7532 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007533 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007534 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7535 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007536 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007537 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007538 { } /* end */
7539};
7540
Jiang zhe17bba1b2008-06-04 12:11:07 +02007541static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7542 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7543 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7544 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7545 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7546 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7547 HDA_OUTPUT),
7548 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7549 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7550 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7551 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7552 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7553 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7554 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7555 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7556 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7557 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7558 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7559 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7560 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7561 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007562 { } /* end */
7563};
7564
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007565static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007566 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007567 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007568 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007569 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007570 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7571 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007572 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7573 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007574 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7575 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7576 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7577 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7578 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7579 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007580 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007581 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7582 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007583 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007584 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007585 { } /* end */
7586};
7587
Kailang Yangccc656c2006-10-17 12:32:26 +02007588static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7589 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7591 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7592 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7593 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7594 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7595 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7596 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7597 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7598 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7599 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7600 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7601 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7602 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007603 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007605 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007606};
Kailang Yangccc656c2006-10-17 12:32:26 +02007607
7608static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7609 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7610 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7611 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7612 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7613 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007615 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007616 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007617 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7618 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7619 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007620 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007621};
Kailang Yangccc656c2006-10-17 12:32:26 +02007622
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007623static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7624 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7625 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007626 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7627 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007628 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7629 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7630 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7631 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007632 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007633};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007634
Kailang Yang272a5272007-05-14 11:00:38 +02007635static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7636 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7637 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7638 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7639 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7640 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7641 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7642 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7643 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7644 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007645 { } /* end */
7646};
7647
7648static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7649 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7650 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7651 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7652 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7653 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7654 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7655 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7656 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7657 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007658 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007659};
Kailang Yang272a5272007-05-14 11:00:38 +02007660
Tobin Davis2880a862007-08-07 11:50:26 +02007661static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007662 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7663 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007664 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007665 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7666 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7668 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7669 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007670 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007671};
Tobin Davis2880a862007-08-07 11:50:26 +02007672
Kailang Yange2757d52008-08-26 13:17:46 +02007673static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7674 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7675 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7676 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7677 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7678 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7679 0x0d, 1, 0x0, HDA_OUTPUT),
7680 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7681 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7682 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7683 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7684 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7685 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7686 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7687 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7688 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7689 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7690 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7691 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7692 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7693 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7694 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7695 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7696 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007697 { } /* end */
7698};
7699
7700static struct hda_bind_ctls alc883_bind_cap_vol = {
7701 .ops = &snd_hda_bind_vol,
7702 .values = {
7703 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7704 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7705 0
7706 },
7707};
7708
7709static struct hda_bind_ctls alc883_bind_cap_switch = {
7710 .ops = &snd_hda_bind_sw,
7711 .values = {
7712 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7713 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7714 0
7715 },
7716};
7717
7718static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7719 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7720 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7721 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7722 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7723 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7724 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7725 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7726 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007727 { } /* end */
7728};
7729
7730static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007731 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7732 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7733 {
7734 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7735 /* .name = "Capture Source", */
7736 .name = "Input Source",
7737 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007738 .info = alc_mux_enum_info,
7739 .get = alc_mux_enum_get,
7740 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007741 },
7742 { } /* end */
7743};
7744
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007745static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7746 {
7747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7748 .name = "Channel Mode",
7749 .info = alc_ch_mode_info,
7750 .get = alc_ch_mode_get,
7751 .put = alc_ch_mode_put,
7752 },
7753 { } /* end */
7754};
7755
7756static struct hda_verb alc883_init_verbs[] = {
7757 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007758 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007759 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7760 /* ADC2: mute amp left and right */
7761 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7762 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7763 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7764 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7765 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7766 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7767 /* Rear mixer */
7768 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7769 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7770 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7771 /* CLFE mixer */
7772 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7773 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7774 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7775 /* Side mixer */
7776 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7777 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7778 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7779
Takashi Iwaicb53c622007-08-10 17:21:45 +02007780 /* mute analog input loopbacks */
7781 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7782 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7783 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7784 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7785 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007786
7787 /* Front Pin: output 0 (0x0c) */
7788 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7789 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7790 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7791 /* Rear Pin: output 1 (0x0d) */
7792 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7794 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7795 /* CLFE Pin: output 2 (0x0e) */
7796 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7797 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7798 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7799 /* Side Pin: output 3 (0x0f) */
7800 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7801 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7802 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7803 /* Mic (rear) pin: input vref at 80% */
7804 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7805 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7806 /* Front Mic pin: input vref at 80% */
7807 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7808 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7809 /* Line In pin: input */
7810 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7811 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7812 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7813 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7814 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7815 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7816 /* CD pin widget for input */
7817 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7818
7819 /* FIXME: use matrix-type input source selection */
7820 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7821 /* Input mixer2 */
7822 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007823 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7824 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7825 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007826 /* Input mixer3 */
7827 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007828 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7829 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7830 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007831 { }
7832};
7833
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007834/* toggle speaker-output according to the hp-jack state */
7835static void alc883_mitac_hp_automute(struct hda_codec *codec)
7836{
7837 unsigned int present;
7838
7839 present = snd_hda_codec_read(codec, 0x15, 0,
7840 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7841 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7842 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7843 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7844 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7845}
7846
7847/* auto-toggle front mic */
7848/*
7849static void alc883_mitac_mic_automute(struct hda_codec *codec)
7850{
7851 unsigned int present;
7852 unsigned char bits;
7853
7854 present = snd_hda_codec_read(codec, 0x18, 0,
7855 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7856 bits = present ? HDA_AMP_MUTE : 0;
7857 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7858}
7859*/
7860
7861static void alc883_mitac_automute(struct hda_codec *codec)
7862{
7863 alc883_mitac_hp_automute(codec);
7864 /* alc883_mitac_mic_automute(codec); */
7865}
7866
7867static void alc883_mitac_unsol_event(struct hda_codec *codec,
7868 unsigned int res)
7869{
7870 switch (res >> 26) {
7871 case ALC880_HP_EVENT:
7872 alc883_mitac_hp_automute(codec);
7873 break;
7874 case ALC880_MIC_EVENT:
7875 /* alc883_mitac_mic_automute(codec); */
7876 break;
7877 }
7878}
7879
7880static struct hda_verb alc883_mitac_verbs[] = {
7881 /* HP */
7882 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7883 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7884 /* Subwoofer */
7885 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7886 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7887
7888 /* enable unsolicited event */
7889 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7890 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7891
7892 { } /* end */
7893};
7894
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007895static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007896 /* HP */
7897 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7898 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7899 /* Int speaker */
7900 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7901 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7902
7903 /* enable unsolicited event */
7904 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007905 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007906
7907 { } /* end */
7908};
7909
Jiang zhefb97dc62008-03-06 11:07:11 +01007910static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7911 /* HP */
7912 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7913 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7914 /* Subwoofer */
7915 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7916 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7917
7918 /* enable unsolicited event */
7919 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7920
7921 { } /* end */
7922};
7923
Kailang Yangccc656c2006-10-17 12:32:26 +02007924static struct hda_verb alc883_tagra_verbs[] = {
7925 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7926 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7927
7928 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7929 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007930
Kailang Yangccc656c2006-10-17 12:32:26 +02007931 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7932 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7933 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7934
7935 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007936 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7937 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7938 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007939
7940 { } /* end */
7941};
7942
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007943static struct hda_verb alc883_lenovo_101e_verbs[] = {
7944 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7945 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7946 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7947 { } /* end */
7948};
7949
Kailang Yang272a5272007-05-14 11:00:38 +02007950static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7951 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7952 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7953 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7954 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7955 { } /* end */
7956};
7957
7958static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7959 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7960 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7961 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7962 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7963 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7964 { } /* end */
7965};
7966
Kailang Yang189609a2007-08-20 11:31:23 +02007967static struct hda_verb alc883_haier_w66_verbs[] = {
7968 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7969 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7970
7971 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7972
7973 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7974 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7975 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7976 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7977 { } /* end */
7978};
7979
Kailang Yange2757d52008-08-26 13:17:46 +02007980static struct hda_verb alc888_lenovo_sky_verbs[] = {
7981 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7982 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7983 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7984 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7985 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7986 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7987 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7988 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7989 { } /* end */
7990};
7991
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007992static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007993 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007994 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7995 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007996 { }
7997};
7998
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007999static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008000 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8001 { }
8002};
8003
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008004static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008005 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8006 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8007 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8008 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8009 { }
8010};
8011
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008012static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008013 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8014 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8015 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8016 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8017 { }
8018};
8019
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008020static struct hda_channel_mode alc888_3st_hp_modes[2] = {
8021 { 2, alc888_3st_hp_2ch_init },
8022 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008023};
8024
Kailang Yang272a5272007-05-14 11:00:38 +02008025/* toggle front-jack and RCA according to the hp-jack state */
8026static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8027{
8028 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008029
Kailang Yang272a5272007-05-14 11:00:38 +02008030 present = snd_hda_codec_read(codec, 0x1b, 0,
8031 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008032 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8033 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8034 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8035 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008036}
8037
8038/* toggle RCA according to the front-jack state */
8039static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8040{
8041 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008042
Kailang Yang272a5272007-05-14 11:00:38 +02008043 present = snd_hda_codec_read(codec, 0x14, 0,
8044 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008045 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8046 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008047}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008048
Kailang Yang272a5272007-05-14 11:00:38 +02008049static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8050 unsigned int res)
8051{
8052 if ((res >> 26) == ALC880_HP_EVENT)
8053 alc888_lenovo_ms7195_front_automute(codec);
8054 if ((res >> 26) == ALC880_FRONT_EVENT)
8055 alc888_lenovo_ms7195_rca_automute(codec);
8056}
8057
8058static struct hda_verb alc883_medion_md2_verbs[] = {
8059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8060 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8061
8062 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8063
8064 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8065 { } /* end */
8066};
8067
8068/* toggle speaker-output according to the hp-jack state */
8069static void alc883_medion_md2_automute(struct hda_codec *codec)
8070{
8071 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008072
Kailang Yang272a5272007-05-14 11:00:38 +02008073 present = snd_hda_codec_read(codec, 0x14, 0,
8074 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008075 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8076 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008077}
8078
8079static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
8080 unsigned int res)
8081{
8082 if ((res >> 26) == ALC880_HP_EVENT)
8083 alc883_medion_md2_automute(codec);
8084}
8085
Kailang Yangccc656c2006-10-17 12:32:26 +02008086/* toggle speaker-output according to the hp-jack state */
8087static void alc883_tagra_automute(struct hda_codec *codec)
8088{
8089 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008090 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02008091
8092 present = snd_hda_codec_read(codec, 0x14, 0,
8093 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008094 bits = present ? HDA_AMP_MUTE : 0;
8095 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
8096 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008097 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
8098 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02008099}
8100
8101static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
8102{
8103 if ((res >> 26) == ALC880_HP_EVENT)
8104 alc883_tagra_automute(codec);
8105}
8106
Jiang zhe368c7a92008-03-04 11:20:33 +01008107/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008108static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01008109{
8110 unsigned int present;
8111 unsigned char bits;
8112
8113 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
8114 & AC_PINSENSE_PRESENCE;
8115 bits = present ? HDA_AMP_MUTE : 0;
8116 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8117 HDA_AMP_MUTE, bits);
8118}
8119
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008120static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8121{
8122 unsigned int present;
8123
8124 present = snd_hda_codec_read(codec, 0x18, 0,
8125 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8126 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8127 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8128}
8129
8130static void alc883_clevo_m720_automute(struct hda_codec *codec)
8131{
8132 alc883_clevo_m720_hp_automute(codec);
8133 alc883_clevo_m720_mic_automute(codec);
8134}
8135
8136static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008137 unsigned int res)
8138{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008139 switch (res >> 26) {
8140 case ALC880_HP_EVENT:
8141 alc883_clevo_m720_hp_automute(codec);
8142 break;
8143 case ALC880_MIC_EVENT:
8144 alc883_clevo_m720_mic_automute(codec);
8145 break;
8146 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008147}
8148
Jiang zhefb97dc62008-03-06 11:07:11 +01008149/* toggle speaker-output according to the hp-jack state */
8150static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
8151{
8152 unsigned int present;
8153 unsigned char bits;
8154
8155 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8156 & AC_PINSENSE_PRESENCE;
8157 bits = present ? HDA_AMP_MUTE : 0;
8158 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8159 HDA_AMP_MUTE, bits);
8160}
8161
8162static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
8163 unsigned int res)
8164{
8165 if ((res >> 26) == ALC880_HP_EVENT)
8166 alc883_2ch_fujitsu_pi2515_automute(codec);
8167}
8168
Kailang Yang189609a2007-08-20 11:31:23 +02008169static void alc883_haier_w66_automute(struct hda_codec *codec)
8170{
8171 unsigned int present;
8172 unsigned char bits;
8173
8174 present = snd_hda_codec_read(codec, 0x1b, 0,
8175 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8176 bits = present ? 0x80 : 0;
8177 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8178 0x80, bits);
8179}
8180
8181static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
8182 unsigned int res)
8183{
8184 if ((res >> 26) == ALC880_HP_EVENT)
8185 alc883_haier_w66_automute(codec);
8186}
8187
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008188static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8189{
8190 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008191 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008192
8193 present = snd_hda_codec_read(codec, 0x14, 0,
8194 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008195 bits = present ? HDA_AMP_MUTE : 0;
8196 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8197 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008198}
8199
8200static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8201{
8202 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008203 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008204
8205 present = snd_hda_codec_read(codec, 0x1b, 0,
8206 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008207 bits = present ? HDA_AMP_MUTE : 0;
8208 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8209 HDA_AMP_MUTE, bits);
8210 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8211 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008212}
8213
8214static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8215 unsigned int res)
8216{
8217 if ((res >> 26) == ALC880_HP_EVENT)
8218 alc883_lenovo_101e_all_automute(codec);
8219 if ((res >> 26) == ALC880_FRONT_EVENT)
8220 alc883_lenovo_101e_ispeaker_automute(codec);
8221}
8222
Takashi Iwai676a9b52007-08-16 15:23:35 +02008223/* toggle speaker-output according to the hp-jack state */
8224static void alc883_acer_aspire_automute(struct hda_codec *codec)
8225{
8226 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008227
Takashi Iwai676a9b52007-08-16 15:23:35 +02008228 present = snd_hda_codec_read(codec, 0x14, 0,
8229 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8230 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8231 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8232 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8233 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8234}
8235
8236static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
8237 unsigned int res)
8238{
8239 if ((res >> 26) == ALC880_HP_EVENT)
8240 alc883_acer_aspire_automute(codec);
8241}
8242
Kailang Yangd1a991a2007-08-15 16:21:59 +02008243static struct hda_verb alc883_acer_eapd_verbs[] = {
8244 /* HP Pin: output 0 (0x0c) */
8245 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8246 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8247 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8248 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008249 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8250 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008251 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008252 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8253 /* eanable EAPD on medion laptop */
8254 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8255 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008256 /* enable unsolicited event */
8257 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008258 { }
8259};
8260
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008261static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8262{
8263 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008264
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008265 present = snd_hda_codec_read(codec, 0x1b, 0,
8266 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8267 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8268 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8269 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8270 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8271 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8272 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8273 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8274 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8275}
8276
8277static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8278 unsigned int res)
8279{
8280 switch (res >> 26) {
8281 case ALC880_HP_EVENT:
Takashi Iwai939778a2009-02-05 15:57:55 +01008282 /* printk(KERN_DEBUG "hp_event\n"); */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008283 alc888_6st_dell_front_automute(codec);
8284 break;
8285 }
8286}
8287
Kailang Yange2757d52008-08-26 13:17:46 +02008288static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8289{
8290 unsigned int mute;
8291 unsigned int present;
8292
8293 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8294 present = snd_hda_codec_read(codec, 0x1b, 0,
8295 AC_VERB_GET_PIN_SENSE, 0);
8296 present = (present & 0x80000000) != 0;
8297 if (present) {
8298 /* mute internal speaker */
8299 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8300 HDA_AMP_MUTE, HDA_AMP_MUTE);
8301 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8302 HDA_AMP_MUTE, HDA_AMP_MUTE);
8303 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8304 HDA_AMP_MUTE, HDA_AMP_MUTE);
8305 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8306 HDA_AMP_MUTE, HDA_AMP_MUTE);
8307 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8308 HDA_AMP_MUTE, HDA_AMP_MUTE);
8309 } else {
8310 /* unmute internal speaker if necessary */
8311 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8312 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8313 HDA_AMP_MUTE, mute);
8314 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8315 HDA_AMP_MUTE, mute);
8316 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8317 HDA_AMP_MUTE, mute);
8318 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8319 HDA_AMP_MUTE, mute);
8320 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8321 HDA_AMP_MUTE, mute);
8322 }
8323}
8324
8325static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8326 unsigned int res)
8327{
8328 if ((res >> 26) == ALC880_HP_EVENT)
8329 alc888_lenovo_sky_front_automute(codec);
8330}
8331
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008332/*
8333 * generic initialization of ADC, input mixers and output mixers
8334 */
8335static struct hda_verb alc883_auto_init_verbs[] = {
8336 /*
8337 * Unmute ADC0-2 and set the default input to mic-in
8338 */
8339 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8340 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8341 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8343
Takashi Iwaicb53c622007-08-10 17:21:45 +02008344 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008345 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008346 * Note: PASD motherboards uses the Line In 2 as the input for
8347 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008348 */
8349 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008350 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8351 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8352 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8353 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8354 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008355
8356 /*
8357 * Set up output mixers (0x0c - 0x0f)
8358 */
8359 /* set vol=0 to output mixers */
8360 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8361 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8362 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8363 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8364 /* set up input amps for analog loopback */
8365 /* Amp Indices: DAC = 0, mixer = 1 */
8366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8367 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8368 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8369 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8370 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8371 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8372 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8373 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8374 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8375 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8376
8377 /* FIXME: use matrix-type input source selection */
8378 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8379 /* Input mixer1 */
8380 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8381 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8382 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008383 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008384 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8385 /* Input mixer2 */
8386 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8387 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8388 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008389 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008390 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008391
8392 { }
8393};
8394
Kailang Yange2757d52008-08-26 13:17:46 +02008395static struct hda_verb alc888_asus_m90v_verbs[] = {
8396 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8397 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8398 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8399 /* enable unsolicited event */
8400 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8401 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8402 { } /* end */
8403};
8404
8405static void alc883_nb_mic_automute(struct hda_codec *codec)
8406{
8407 unsigned int present;
8408
8409 present = snd_hda_codec_read(codec, 0x18, 0,
8410 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8411 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8412 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8413 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8414 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8415}
8416
8417static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8418{
8419 unsigned int present;
8420 unsigned char bits;
8421
8422 present = snd_hda_codec_read(codec, 0x1b, 0,
8423 AC_VERB_GET_PIN_SENSE, 0)
8424 & AC_PINSENSE_PRESENCE;
8425 bits = present ? 0 : PIN_OUT;
8426 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8427 bits);
8428 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8429 bits);
8430 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8431 bits);
8432}
8433
8434static void alc883_mode2_unsol_event(struct hda_codec *codec,
8435 unsigned int res)
8436{
8437 switch (res >> 26) {
8438 case ALC880_HP_EVENT:
8439 alc883_M90V_speaker_automute(codec);
8440 break;
8441 case ALC880_MIC_EVENT:
8442 alc883_nb_mic_automute(codec);
8443 break;
8444 }
8445}
8446
8447static void alc883_mode2_inithook(struct hda_codec *codec)
8448{
8449 alc883_M90V_speaker_automute(codec);
8450 alc883_nb_mic_automute(codec);
8451}
8452
8453static struct hda_verb alc888_asus_eee1601_verbs[] = {
8454 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8455 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8457 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8458 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8459 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8460 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8461 /* enable unsolicited event */
8462 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8463 { } /* end */
8464};
8465
8466static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8467{
8468 unsigned int present;
8469 unsigned char bits;
8470
8471 present = snd_hda_codec_read(codec, 0x14, 0,
8472 AC_VERB_GET_PIN_SENSE, 0)
8473 & AC_PINSENSE_PRESENCE;
8474 bits = present ? 0 : PIN_OUT;
8475 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8476 bits);
8477}
8478
8479static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8480 unsigned int res)
8481{
8482 switch (res >> 26) {
8483 case ALC880_HP_EVENT:
8484 alc883_eee1601_speaker_automute(codec);
8485 break;
8486 }
8487}
8488
8489static void alc883_eee1601_inithook(struct hda_codec *codec)
8490{
8491 alc883_eee1601_speaker_automute(codec);
8492}
8493
Takashi Iwaicb53c622007-08-10 17:21:45 +02008494#ifdef CONFIG_SND_HDA_POWER_SAVE
8495#define alc883_loopbacks alc880_loopbacks
8496#endif
8497
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008498/* pcm configuration: identiacal with ALC880 */
8499#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8500#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008501#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008502#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8503#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8504
8505/*
8506 * configuration and preset
8507 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008508static const char *alc883_models[ALC883_MODEL_LAST] = {
8509 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8510 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8511 [ALC883_3ST_6ch] = "3stack-6ch",
8512 [ALC883_6ST_DIG] = "6stack-dig",
8513 [ALC883_TARGA_DIG] = "targa-dig",
8514 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008515 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008516 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008517 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008518 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008519 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008520 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008521 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008522 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8523 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008524 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008525 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008526 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008527 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008528 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008529 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008530 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008531 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008532 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008533 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008534 [ALC883_AUTO] = "auto",
8535};
8536
8537static struct snd_pci_quirk alc883_cfg_tbl[] = {
8538 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008539 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008540 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008541 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8542 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008543 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008544 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8545 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008546 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8547 ALC888_ACER_ASPIRE_4930G),
Takashi Iwai94683502009-02-13 09:31:20 +01008548 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008549 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8550 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008551 /* default Acer */
8552 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008553 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008554 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008555 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8556 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008557 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008558 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008559 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008560 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008561 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008562 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008563 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008564 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008565 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008566 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008567 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8568 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008569 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008570 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008571 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008572 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8573 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8574 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008575 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008576 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008577 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008578 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8579 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8580 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8581 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8582 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8583 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8584 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8585 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8586 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008587 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8588 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008589 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008590 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008591 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008592 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008593 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008594 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008595 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008596 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8597 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008598 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008599 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008600 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaif67d8172009-02-04 23:30:19 +01008601 SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550",
8602 ALC883_FUJITSU_PI2515),
Jiang zhefb97dc62008-03-06 11:07:11 +01008603 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008604 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8605 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008606 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008607 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008608 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8609 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008610 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008611 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008612 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008613 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008614 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008615 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8616 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008617 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008618 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008619 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008620 {}
8621};
8622
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008623static hda_nid_t alc1200_slave_dig_outs[] = {
8624 ALC883_DIGOUT_NID, 0,
8625};
8626
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008627static struct alc_config_preset alc883_presets[] = {
8628 [ALC883_3ST_2ch_DIG] = {
8629 .mixers = { alc883_3ST_2ch_mixer },
8630 .init_verbs = { alc883_init_verbs },
8631 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8632 .dac_nids = alc883_dac_nids,
8633 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008634 .dig_in_nid = ALC883_DIGIN_NID,
8635 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8636 .channel_mode = alc883_3ST_2ch_modes,
8637 .input_mux = &alc883_capture_source,
8638 },
8639 [ALC883_3ST_6ch_DIG] = {
8640 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8641 .init_verbs = { alc883_init_verbs },
8642 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8643 .dac_nids = alc883_dac_nids,
8644 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008645 .dig_in_nid = ALC883_DIGIN_NID,
8646 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8647 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008648 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008649 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008650 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008651 [ALC883_3ST_6ch] = {
8652 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8653 .init_verbs = { alc883_init_verbs },
8654 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8655 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008656 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8657 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008658 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008659 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008660 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008661 [ALC883_3ST_6ch_INTEL] = {
8662 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8663 .init_verbs = { alc883_init_verbs },
8664 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8665 .dac_nids = alc883_dac_nids,
8666 .dig_out_nid = ALC883_DIGOUT_NID,
8667 .dig_in_nid = ALC883_DIGIN_NID,
8668 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8669 .channel_mode = alc883_3ST_6ch_intel_modes,
8670 .need_dac_fix = 1,
8671 .input_mux = &alc883_3stack_6ch_intel,
8672 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008673 [ALC883_6ST_DIG] = {
8674 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8675 .init_verbs = { alc883_init_verbs },
8676 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8677 .dac_nids = alc883_dac_nids,
8678 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008679 .dig_in_nid = ALC883_DIGIN_NID,
8680 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8681 .channel_mode = alc883_sixstack_modes,
8682 .input_mux = &alc883_capture_source,
8683 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008684 [ALC883_TARGA_DIG] = {
8685 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8686 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8687 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8688 .dac_nids = alc883_dac_nids,
8689 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008690 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8691 .channel_mode = alc883_3ST_6ch_modes,
8692 .need_dac_fix = 1,
8693 .input_mux = &alc883_capture_source,
8694 .unsol_event = alc883_tagra_unsol_event,
8695 .init_hook = alc883_tagra_automute,
8696 },
8697 [ALC883_TARGA_2ch_DIG] = {
8698 .mixers = { alc883_tagra_2ch_mixer},
8699 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8700 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8701 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008702 .adc_nids = alc883_adc_nids_alt,
8703 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008704 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008705 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8706 .channel_mode = alc883_3ST_2ch_modes,
8707 .input_mux = &alc883_capture_source,
8708 .unsol_event = alc883_tagra_unsol_event,
8709 .init_hook = alc883_tagra_automute,
8710 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008711 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008712 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008713 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8714 * and the headphone jack. Turn this on and rely on the
8715 * standard mute methods whenever the user wants to turn
8716 * these outputs off.
8717 */
8718 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8719 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8720 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02008721 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8722 .channel_mode = alc883_3ST_2ch_modes,
8723 .input_mux = &alc883_capture_source,
8724 },
Tobin Davis2880a862007-08-07 11:50:26 +02008725 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008726 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008727 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008728 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8729 .dac_nids = alc883_dac_nids,
8730 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008731 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8732 .channel_mode = alc883_3ST_2ch_modes,
8733 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008734 .unsol_event = alc883_acer_aspire_unsol_event,
8735 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008736 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008737 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008738 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008739 alc883_chmode_mixer },
8740 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8741 alc888_acer_aspire_4930g_verbs },
8742 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8743 .dac_nids = alc883_dac_nids,
8744 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8745 .adc_nids = alc883_adc_nids_rev,
8746 .capsrc_nids = alc883_capsrc_nids_rev,
8747 .dig_out_nid = ALC883_DIGOUT_NID,
8748 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8749 .channel_mode = alc883_3ST_6ch_modes,
8750 .need_dac_fix = 1,
8751 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008752 ARRAY_SIZE(alc888_2_capture_sources),
8753 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008754 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8755 .init_hook = alc888_acer_aspire_4930g_automute,
8756 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008757 [ALC883_MEDION] = {
8758 .mixers = { alc883_fivestack_mixer,
8759 alc883_chmode_mixer },
8760 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008761 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008762 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8763 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008764 .adc_nids = alc883_adc_nids_alt,
8765 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008766 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8767 .channel_mode = alc883_sixstack_modes,
8768 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008769 },
Kailang Yang272a5272007-05-14 11:00:38 +02008770 [ALC883_MEDION_MD2] = {
8771 .mixers = { alc883_medion_md2_mixer},
8772 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8773 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8774 .dac_nids = alc883_dac_nids,
8775 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008776 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8777 .channel_mode = alc883_3ST_2ch_modes,
8778 .input_mux = &alc883_capture_source,
8779 .unsol_event = alc883_medion_md2_unsol_event,
8780 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008781 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008782 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008783 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008784 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8785 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8786 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008787 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8788 .channel_mode = alc883_3ST_2ch_modes,
8789 .input_mux = &alc883_capture_source,
8790 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008791 [ALC883_CLEVO_M720] = {
8792 .mixers = { alc883_clevo_m720_mixer },
8793 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008794 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8795 .dac_nids = alc883_dac_nids,
8796 .dig_out_nid = ALC883_DIGOUT_NID,
8797 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8798 .channel_mode = alc883_3ST_2ch_modes,
8799 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008800 .unsol_event = alc883_clevo_m720_unsol_event,
8801 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008802 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008803 [ALC883_LENOVO_101E_2ch] = {
8804 .mixers = { alc883_lenovo_101e_2ch_mixer},
8805 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8806 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8807 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008808 .adc_nids = alc883_adc_nids_alt,
8809 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008810 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8811 .channel_mode = alc883_3ST_2ch_modes,
8812 .input_mux = &alc883_lenovo_101e_capture_source,
8813 .unsol_event = alc883_lenovo_101e_unsol_event,
8814 .init_hook = alc883_lenovo_101e_all_automute,
8815 },
Kailang Yang272a5272007-05-14 11:00:38 +02008816 [ALC883_LENOVO_NB0763] = {
8817 .mixers = { alc883_lenovo_nb0763_mixer },
8818 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8819 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8820 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008821 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8822 .channel_mode = alc883_3ST_2ch_modes,
8823 .need_dac_fix = 1,
8824 .input_mux = &alc883_lenovo_nb0763_capture_source,
8825 .unsol_event = alc883_medion_md2_unsol_event,
8826 .init_hook = alc883_medion_md2_automute,
8827 },
8828 [ALC888_LENOVO_MS7195_DIG] = {
8829 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8830 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8831 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8832 .dac_nids = alc883_dac_nids,
8833 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008834 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8835 .channel_mode = alc883_3ST_6ch_modes,
8836 .need_dac_fix = 1,
8837 .input_mux = &alc883_capture_source,
8838 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8839 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008840 },
8841 [ALC883_HAIER_W66] = {
8842 .mixers = { alc883_tagra_2ch_mixer},
8843 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8844 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8845 .dac_nids = alc883_dac_nids,
8846 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008847 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8848 .channel_mode = alc883_3ST_2ch_modes,
8849 .input_mux = &alc883_capture_source,
8850 .unsol_event = alc883_haier_w66_unsol_event,
8851 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008852 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008853 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008854 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008855 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008856 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8857 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008858 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8859 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008860 .need_dac_fix = 1,
8861 .input_mux = &alc883_capture_source,
8862 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008863 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008864 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008865 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8866 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8867 .dac_nids = alc883_dac_nids,
8868 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008869 .dig_in_nid = ALC883_DIGIN_NID,
8870 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8871 .channel_mode = alc883_sixstack_modes,
8872 .input_mux = &alc883_capture_source,
8873 .unsol_event = alc888_6st_dell_unsol_event,
8874 .init_hook = alc888_6st_dell_front_automute,
8875 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008876 [ALC883_MITAC] = {
8877 .mixers = { alc883_mitac_mixer },
8878 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8879 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8880 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008881 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8882 .channel_mode = alc883_3ST_2ch_modes,
8883 .input_mux = &alc883_capture_source,
8884 .unsol_event = alc883_mitac_unsol_event,
8885 .init_hook = alc883_mitac_automute,
8886 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008887 [ALC883_FUJITSU_PI2515] = {
8888 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8889 .init_verbs = { alc883_init_verbs,
8890 alc883_2ch_fujitsu_pi2515_verbs},
8891 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8892 .dac_nids = alc883_dac_nids,
8893 .dig_out_nid = ALC883_DIGOUT_NID,
8894 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8895 .channel_mode = alc883_3ST_2ch_modes,
8896 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8897 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8898 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8899 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008900 [ALC888_FUJITSU_XA3530] = {
8901 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8902 .init_verbs = { alc883_init_verbs,
8903 alc888_fujitsu_xa3530_verbs },
8904 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8905 .dac_nids = alc883_dac_nids,
8906 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8907 .adc_nids = alc883_adc_nids_rev,
8908 .capsrc_nids = alc883_capsrc_nids_rev,
8909 .dig_out_nid = ALC883_DIGOUT_NID,
8910 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8911 .channel_mode = alc888_4ST_8ch_intel_modes,
8912 .num_mux_defs =
8913 ARRAY_SIZE(alc888_2_capture_sources),
8914 .input_mux = alc888_2_capture_sources,
8915 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
8916 .init_hook = alc888_fujitsu_xa3530_automute,
8917 },
Kailang Yange2757d52008-08-26 13:17:46 +02008918 [ALC888_LENOVO_SKY] = {
8919 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8920 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8921 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8922 .dac_nids = alc883_dac_nids,
8923 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02008924 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8925 .channel_mode = alc883_sixstack_modes,
8926 .need_dac_fix = 1,
8927 .input_mux = &alc883_lenovo_sky_capture_source,
8928 .unsol_event = alc883_lenovo_sky_unsol_event,
8929 .init_hook = alc888_lenovo_sky_front_automute,
8930 },
8931 [ALC888_ASUS_M90V] = {
8932 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8933 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8934 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8935 .dac_nids = alc883_dac_nids,
8936 .dig_out_nid = ALC883_DIGOUT_NID,
8937 .dig_in_nid = ALC883_DIGIN_NID,
8938 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8939 .channel_mode = alc883_3ST_6ch_modes,
8940 .need_dac_fix = 1,
8941 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8942 .unsol_event = alc883_mode2_unsol_event,
8943 .init_hook = alc883_mode2_inithook,
8944 },
8945 [ALC888_ASUS_EEE1601] = {
8946 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008947 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02008948 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8949 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8950 .dac_nids = alc883_dac_nids,
8951 .dig_out_nid = ALC883_DIGOUT_NID,
8952 .dig_in_nid = ALC883_DIGIN_NID,
8953 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8954 .channel_mode = alc883_3ST_2ch_modes,
8955 .need_dac_fix = 1,
8956 .input_mux = &alc883_asus_eee1601_capture_source,
8957 .unsol_event = alc883_eee1601_unsol_event,
8958 .init_hook = alc883_eee1601_inithook,
8959 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01008960 [ALC1200_ASUS_P5Q] = {
8961 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8962 .init_verbs = { alc883_init_verbs },
8963 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8964 .dac_nids = alc883_dac_nids,
8965 .dig_out_nid = ALC1200_DIGOUT_NID,
8966 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008967 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01008968 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8969 .channel_mode = alc883_sixstack_modes,
8970 .input_mux = &alc883_capture_source,
8971 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008972};
8973
8974
8975/*
8976 * BIOS auto configuration
8977 */
8978static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8979 hda_nid_t nid, int pin_type,
8980 int dac_idx)
8981{
8982 /* set as output */
8983 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008984 int idx;
8985
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008986 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008987 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8988 idx = 4;
8989 else
8990 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008991 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8992
8993}
8994
8995static void alc883_auto_init_multi_out(struct hda_codec *codec)
8996{
8997 struct alc_spec *spec = codec->spec;
8998 int i;
8999
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009000 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009001 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009002 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009003 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009004 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009005 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009006 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009007 }
9008}
9009
9010static void alc883_auto_init_hp_out(struct hda_codec *codec)
9011{
9012 struct alc_spec *spec = codec->spec;
9013 hda_nid_t pin;
9014
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009015 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009016 if (pin) /* connect to front */
9017 /* use dac 0 */
9018 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009019 pin = spec->autocfg.speaker_pins[0];
9020 if (pin)
9021 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009022}
9023
9024#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9025#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9026
9027static void alc883_auto_init_analog_input(struct hda_codec *codec)
9028{
9029 struct alc_spec *spec = codec->spec;
9030 int i;
9031
9032 for (i = 0; i < AUTO_PIN_LAST; i++) {
9033 hda_nid_t nid = spec->autocfg.input_pins[i];
9034 if (alc883_is_input_pin(nid)) {
9035 snd_hda_codec_write(codec, nid, 0,
9036 AC_VERB_SET_PIN_WIDGET_CONTROL,
9037 (i <= AUTO_PIN_FRONT_MIC ?
9038 PIN_VREF80 : PIN_IN));
9039 if (nid != ALC883_PIN_CD_NID)
9040 snd_hda_codec_write(codec, nid, 0,
9041 AC_VERB_SET_AMP_GAIN_MUTE,
9042 AMP_OUT_MUTE);
9043 }
9044 }
9045}
9046
Takashi Iwaif511b012008-08-15 16:46:42 +02009047#define alc883_auto_init_input_src alc882_auto_init_input_src
9048
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009049/* almost identical with ALC880 parser... */
9050static int alc883_parse_auto_config(struct hda_codec *codec)
9051{
9052 struct alc_spec *spec = codec->spec;
9053 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009054 struct auto_pin_cfg *cfg = &spec->autocfg;
9055 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009056
9057 if (err < 0)
9058 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009059 else if (!err)
9060 return 0; /* no config found */
9061
9062 err = alc_auto_add_mic_boost(codec);
9063 if (err < 0)
9064 return err;
9065
9066 /* hack - override the init verbs */
9067 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009068
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009069 /* setup input_mux for ALC889 */
9070 if (codec->vendor_id == 0x10ec0889) {
9071 /* digital-mic input pin is excluded in alc880_auto_create..()
9072 * because it's under 0x18
9073 */
9074 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9075 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9076 struct hda_input_mux *imux = &spec->private_imux[0];
9077 for (i = 1; i < 3; i++)
9078 memcpy(&spec->private_imux[i],
9079 &spec->private_imux[0],
9080 sizeof(spec->private_imux[0]));
9081 imux->items[imux->num_items].label = "Int DMic";
9082 imux->items[imux->num_items].index = 0x0b;
9083 imux->num_items++;
9084 spec->num_mux_defs = 3;
9085 spec->input_mux = spec->private_imux;
9086 }
9087 }
9088
Takashi Iwai776e1842007-08-29 15:07:11 +02009089 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009090}
9091
9092/* additional initialization for auto-configuration model */
9093static void alc883_auto_init(struct hda_codec *codec)
9094{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009095 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009096 alc883_auto_init_multi_out(codec);
9097 alc883_auto_init_hp_out(codec);
9098 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009099 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009100 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009101 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009102}
9103
9104static int patch_alc883(struct hda_codec *codec)
9105{
9106 struct alc_spec *spec;
9107 int err, board_config;
9108
9109 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9110 if (spec == NULL)
9111 return -ENOMEM;
9112
9113 codec->spec = spec;
9114
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009115 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9116
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009117 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9118 alc883_models,
9119 alc883_cfg_tbl);
9120 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009121 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9122 "trying auto-probe from BIOS...\n");
9123 board_config = ALC883_AUTO;
9124 }
9125
9126 if (board_config == ALC883_AUTO) {
9127 /* automatic parse from the BIOS config */
9128 err = alc883_parse_auto_config(codec);
9129 if (err < 0) {
9130 alc_free(codec);
9131 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009132 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009133 printk(KERN_INFO
9134 "hda_codec: Cannot set up configuration "
9135 "from BIOS. Using base mode...\n");
9136 board_config = ALC883_3ST_2ch_DIG;
9137 }
9138 }
9139
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009140 err = snd_hda_attach_beep_device(codec, 0x1);
9141 if (err < 0) {
9142 alc_free(codec);
9143 return err;
9144 }
9145
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009146 if (board_config != ALC883_AUTO)
9147 setup_preset(spec, &alc883_presets[board_config]);
9148
Kailang Yang2f893282008-05-27 12:14:47 +02009149 switch (codec->vendor_id) {
9150 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009151 if (codec->revision_id == 0x100101) {
9152 spec->stream_name_analog = "ALC1200 Analog";
9153 spec->stream_name_digital = "ALC1200 Digital";
9154 } else {
9155 spec->stream_name_analog = "ALC888 Analog";
9156 spec->stream_name_digital = "ALC888 Digital";
9157 }
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009158 if (!spec->num_adc_nids) {
9159 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9160 spec->adc_nids = alc883_adc_nids;
9161 }
9162 if (!spec->capsrc_nids)
9163 spec->capsrc_nids = alc883_capsrc_nids;
9164 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009165 break;
9166 case 0x10ec0889:
9167 spec->stream_name_analog = "ALC889 Analog";
9168 spec->stream_name_digital = "ALC889 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009169 if (!spec->num_adc_nids) {
9170 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9171 spec->adc_nids = alc889_adc_nids;
9172 }
9173 if (!spec->capsrc_nids)
9174 spec->capsrc_nids = alc889_capsrc_nids;
9175 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9176 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009177 break;
9178 default:
9179 spec->stream_name_analog = "ALC883 Analog";
9180 spec->stream_name_digital = "ALC883 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009181 if (!spec->num_adc_nids) {
9182 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9183 spec->adc_nids = alc883_adc_nids;
9184 }
9185 if (!spec->capsrc_nids)
9186 spec->capsrc_nids = alc883_capsrc_nids;
9187 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009188 break;
9189 }
9190
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009191 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9192 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009193 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009194
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009195 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9196 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9197
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009198 if (!spec->cap_mixer)
9199 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009200 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009201
Takashi Iwai2134ea42008-01-10 16:53:55 +01009202 spec->vmaster_nid = 0x0c;
9203
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009204 codec->patch_ops = alc_patch_ops;
9205 if (board_config == ALC883_AUTO)
9206 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009207
Takashi Iwaicb53c622007-08-10 17:21:45 +02009208#ifdef CONFIG_SND_HDA_POWER_SAVE
9209 if (!spec->loopback.amplist)
9210 spec->loopback.amplist = alc883_loopbacks;
9211#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009212 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009213
9214 return 0;
9215}
9216
9217/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009218 * ALC262 support
9219 */
9220
9221#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9222#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9223
9224#define alc262_dac_nids alc260_dac_nids
9225#define alc262_adc_nids alc882_adc_nids
9226#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009227#define alc262_capsrc_nids alc882_capsrc_nids
9228#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009229
9230#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009231#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009232
Kailang Yang4e555fe2008-08-26 13:05:55 +02009233static hda_nid_t alc262_dmic_adc_nids[1] = {
9234 /* ADC0 */
9235 0x09
9236};
9237
9238static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9239
Kailang Yangdf694da2005-12-05 19:42:22 +01009240static struct snd_kcontrol_new alc262_base_mixer[] = {
9241 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9242 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9243 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9244 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9245 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9246 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9247 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9248 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009249 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009250 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9251 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009252 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009253 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9254 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9255 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9256 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009257 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009258};
9259
Kailang Yangccc656c2006-10-17 12:32:26 +02009260static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9261 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9262 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9263 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9264 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9265 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9266 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9267 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9268 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009269 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009270 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9271 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009272 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009273 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9274 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9275 { } /* end */
9276};
9277
Takashi Iwaice875f02008-01-28 18:17:43 +01009278/* update HP, line and mono-out pins according to the master switch */
9279static void alc262_hp_master_update(struct hda_codec *codec)
9280{
9281 struct alc_spec *spec = codec->spec;
9282 int val = spec->master_sw;
9283
9284 /* HP & line-out */
9285 snd_hda_codec_write_cache(codec, 0x1b, 0,
9286 AC_VERB_SET_PIN_WIDGET_CONTROL,
9287 val ? PIN_HP : 0);
9288 snd_hda_codec_write_cache(codec, 0x15, 0,
9289 AC_VERB_SET_PIN_WIDGET_CONTROL,
9290 val ? PIN_HP : 0);
9291 /* mono (speaker) depending on the HP jack sense */
9292 val = val && !spec->jack_present;
9293 snd_hda_codec_write_cache(codec, 0x16, 0,
9294 AC_VERB_SET_PIN_WIDGET_CONTROL,
9295 val ? PIN_OUT : 0);
9296}
9297
9298static void alc262_hp_bpc_automute(struct hda_codec *codec)
9299{
9300 struct alc_spec *spec = codec->spec;
9301 unsigned int presence;
9302 presence = snd_hda_codec_read(codec, 0x1b, 0,
9303 AC_VERB_GET_PIN_SENSE, 0);
9304 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9305 alc262_hp_master_update(codec);
9306}
9307
9308static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9309{
9310 if ((res >> 26) != ALC880_HP_EVENT)
9311 return;
9312 alc262_hp_bpc_automute(codec);
9313}
9314
9315static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9316{
9317 struct alc_spec *spec = codec->spec;
9318 unsigned int presence;
9319 presence = snd_hda_codec_read(codec, 0x15, 0,
9320 AC_VERB_GET_PIN_SENSE, 0);
9321 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9322 alc262_hp_master_update(codec);
9323}
9324
9325static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9326 unsigned int res)
9327{
9328 if ((res >> 26) != ALC880_HP_EVENT)
9329 return;
9330 alc262_hp_wildwest_automute(codec);
9331}
9332
9333static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9334 struct snd_ctl_elem_value *ucontrol)
9335{
9336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9337 struct alc_spec *spec = codec->spec;
9338 *ucontrol->value.integer.value = spec->master_sw;
9339 return 0;
9340}
9341
9342static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9343 struct snd_ctl_elem_value *ucontrol)
9344{
9345 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9346 struct alc_spec *spec = codec->spec;
9347 int val = !!*ucontrol->value.integer.value;
9348
9349 if (val == spec->master_sw)
9350 return 0;
9351 spec->master_sw = val;
9352 alc262_hp_master_update(codec);
9353 return 1;
9354}
9355
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009356static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009357 {
9358 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9359 .name = "Master Playback Switch",
9360 .info = snd_ctl_boolean_mono_info,
9361 .get = alc262_hp_master_sw_get,
9362 .put = alc262_hp_master_sw_put,
9363 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009364 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9365 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9366 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009367 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9368 HDA_OUTPUT),
9369 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9370 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009371 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9372 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009373 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009374 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9375 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009376 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009377 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9378 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9379 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9380 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009381 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9382 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9383 { } /* end */
9384};
9385
Kailang Yangcd7509a2007-01-26 18:33:17 +01009386static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009387 {
9388 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9389 .name = "Master Playback Switch",
9390 .info = snd_ctl_boolean_mono_info,
9391 .get = alc262_hp_master_sw_get,
9392 .put = alc262_hp_master_sw_put,
9393 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009394 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9395 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9396 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9397 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009398 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9399 HDA_OUTPUT),
9400 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9401 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009402 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9403 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009404 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009405 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9406 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9407 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9408 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009409 { } /* end */
9410};
9411
9412static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9413 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9414 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009415 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009416 { } /* end */
9417};
9418
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009419/* mute/unmute internal speaker according to the hp jack and mute state */
9420static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9421{
9422 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009423
9424 if (force || !spec->sense_updated) {
9425 unsigned int present;
9426 present = snd_hda_codec_read(codec, 0x15, 0,
9427 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009428 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009429 spec->sense_updated = 1;
9430 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009431 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9432 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009433}
9434
9435static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9436 unsigned int res)
9437{
9438 if ((res >> 26) != ALC880_HP_EVENT)
9439 return;
9440 alc262_hp_t5735_automute(codec, 1);
9441}
9442
9443static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9444{
9445 alc262_hp_t5735_automute(codec, 1);
9446}
9447
9448static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009449 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9450 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009451 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9452 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9454 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9455 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9456 { } /* end */
9457};
9458
9459static struct hda_verb alc262_hp_t5735_verbs[] = {
9460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9462
9463 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9464 { }
9465};
9466
Kailang Yang8c427222008-01-10 13:03:59 +01009467static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009468 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9469 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009470 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9471 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009472 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9473 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9474 { } /* end */
9475};
9476
9477static struct hda_verb alc262_hp_rp5700_verbs[] = {
9478 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9479 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9480 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9481 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9483 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9484 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9485 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9487 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9488 {}
9489};
9490
9491static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9492 .num_items = 1,
9493 .items = {
9494 { "Line", 0x1 },
9495 },
9496};
9497
Takashi Iwai0724ea22007-08-23 00:31:43 +02009498/* bind hp and internal speaker mute (with plug check) */
9499static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9500 struct snd_ctl_elem_value *ucontrol)
9501{
9502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9503 long *valp = ucontrol->value.integer.value;
9504 int change;
9505
9506 /* change hp mute */
9507 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9508 HDA_AMP_MUTE,
9509 valp[0] ? 0 : HDA_AMP_MUTE);
9510 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9511 HDA_AMP_MUTE,
9512 valp[1] ? 0 : HDA_AMP_MUTE);
9513 if (change) {
9514 /* change speaker according to HP jack state */
9515 struct alc_spec *spec = codec->spec;
9516 unsigned int mute;
9517 if (spec->jack_present)
9518 mute = HDA_AMP_MUTE;
9519 else
9520 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9521 HDA_OUTPUT, 0);
9522 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9523 HDA_AMP_MUTE, mute);
9524 }
9525 return change;
9526}
Takashi Iwai5b319542007-07-26 11:49:22 +02009527
Kailang Yang272a5272007-05-14 11:00:38 +02009528static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009529 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9530 {
9531 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9532 .name = "Master Playback Switch",
9533 .info = snd_hda_mixer_amp_switch_info,
9534 .get = snd_hda_mixer_amp_switch_get,
9535 .put = alc262_sony_master_sw_put,
9536 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9537 },
Kailang Yang272a5272007-05-14 11:00:38 +02009538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9539 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9540 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9541 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9542 { } /* end */
9543};
9544
Kailang Yang83c34212007-07-05 11:43:05 +02009545static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9546 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9547 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9548 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9550 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9551 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9552 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9553 { } /* end */
9554};
Kailang Yang272a5272007-05-14 11:00:38 +02009555
Tony Vroonba340e82009-02-02 19:01:30 +00009556static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9557 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9558 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9559 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9560 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9561 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9562 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9563 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9564 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9565 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9566 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9567 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9568 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9569 { } /* end */
9570};
9571
9572static struct hda_verb alc262_tyan_verbs[] = {
9573 /* Headphone automute */
9574 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9575 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9576 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9577
9578 /* P11 AUX_IN, white 4-pin connector */
9579 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9580 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9581 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9582 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9583
9584 {}
9585};
9586
9587/* unsolicited event for HP jack sensing */
9588static void alc262_tyan_automute(struct hda_codec *codec)
9589{
9590 unsigned int mute;
9591 unsigned int present;
9592
9593 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9594 present = snd_hda_codec_read(codec, 0x1b, 0,
9595 AC_VERB_GET_PIN_SENSE, 0);
9596 present = (present & 0x80000000) != 0;
9597 if (present) {
9598 /* mute line output on ATX panel */
9599 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9600 HDA_AMP_MUTE, HDA_AMP_MUTE);
9601 } else {
9602 /* unmute line output if necessary */
9603 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9604 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9605 HDA_AMP_MUTE, mute);
9606 }
9607}
9608
9609static void alc262_tyan_unsol_event(struct hda_codec *codec,
9610 unsigned int res)
9611{
9612 if ((res >> 26) != ALC880_HP_EVENT)
9613 return;
9614 alc262_tyan_automute(codec);
9615}
9616
Kailang Yangdf694da2005-12-05 19:42:22 +01009617#define alc262_capture_mixer alc882_capture_mixer
9618#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9619
9620/*
9621 * generic initialization of ADC, input mixers and output mixers
9622 */
9623static struct hda_verb alc262_init_verbs[] = {
9624 /*
9625 * Unmute ADC0-2 and set the default input to mic-in
9626 */
9627 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9629 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9631 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9632 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9633
Takashi Iwaicb53c622007-08-10 17:21:45 +02009634 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009635 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009636 * Note: PASD motherboards uses the Line In 2 as the input for
9637 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009638 */
9639 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009645
9646 /*
9647 * Set up output mixers (0x0c - 0x0e)
9648 */
9649 /* set vol=0 to output mixers */
9650 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9651 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9652 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9653 /* set up input amps for analog loopback */
9654 /* Amp Indices: DAC = 0, mixer = 1 */
9655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9657 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9658 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9659 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9660 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9661
9662 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9663 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9664 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9665 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9666 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9667 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9668
9669 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9670 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9671 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9672 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9673 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009674
Kailang Yangdf694da2005-12-05 19:42:22 +01009675 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9676 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009677
Kailang Yangdf694da2005-12-05 19:42:22 +01009678 /* FIXME: use matrix-type input source selection */
9679 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9680 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9681 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9682 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9683 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9684 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9685 /* Input mixer2 */
9686 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9687 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9688 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9689 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9690 /* Input mixer3 */
9691 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9692 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9693 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009694 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009695
9696 { }
9697};
9698
Kailang Yang4e555fe2008-08-26 13:05:55 +02009699static struct hda_verb alc262_eapd_verbs[] = {
9700 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9701 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9702 { }
9703};
9704
Kailang Yangccc656c2006-10-17 12:32:26 +02009705static struct hda_verb alc262_hippo_unsol_verbs[] = {
9706 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9708 {}
9709};
9710
9711static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9712 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9713 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9714 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9715
9716 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9717 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9718 {}
9719};
9720
Kailang Yang272a5272007-05-14 11:00:38 +02009721static struct hda_verb alc262_sony_unsol_verbs[] = {
9722 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9723 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9724 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9725
9726 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9727 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009728 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009729};
9730
Kailang Yang4e555fe2008-08-26 13:05:55 +02009731static struct hda_input_mux alc262_dmic_capture_source = {
9732 .num_items = 2,
9733 .items = {
9734 { "Int DMic", 0x9 },
9735 { "Mic", 0x0 },
9736 },
9737};
9738
9739static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9740 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9741 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9742 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9744 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009745 { } /* end */
9746};
9747
9748static struct hda_verb alc262_toshiba_s06_verbs[] = {
9749 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9750 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9752 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9753 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9754 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9755 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9756 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9757 {}
9758};
9759
9760static void alc262_dmic_automute(struct hda_codec *codec)
9761{
9762 unsigned int present;
9763
9764 present = snd_hda_codec_read(codec, 0x18, 0,
9765 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9766 snd_hda_codec_write(codec, 0x22, 0,
9767 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9768}
9769
9770/* toggle speaker-output according to the hp-jack state */
9771static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9772{
9773 unsigned int present;
9774 unsigned char bits;
9775
9776 present = snd_hda_codec_read(codec, 0x15, 0,
9777 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9778 bits = present ? 0 : PIN_OUT;
9779 snd_hda_codec_write(codec, 0x14, 0,
9780 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9781}
9782
9783
9784
9785/* unsolicited event for HP jack sensing */
9786static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9787 unsigned int res)
9788{
9789 if ((res >> 26) == ALC880_HP_EVENT)
9790 alc262_toshiba_s06_speaker_automute(codec);
9791 if ((res >> 26) == ALC880_MIC_EVENT)
9792 alc262_dmic_automute(codec);
9793
9794}
9795
9796static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9797{
9798 alc262_toshiba_s06_speaker_automute(codec);
9799 alc262_dmic_automute(codec);
9800}
9801
Kailang Yangccc656c2006-10-17 12:32:26 +02009802/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009803static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009804{
9805 struct alc_spec *spec = codec->spec;
9806 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009807 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009808
Takashi Iwai5b319542007-07-26 11:49:22 +02009809 /* need to execute and sync at first */
9810 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9811 present = snd_hda_codec_read(codec, 0x15, 0,
9812 AC_VERB_GET_PIN_SENSE, 0);
9813 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009814 if (spec->jack_present) {
9815 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009816 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9817 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009818 } else {
9819 /* unmute internal speaker if necessary */
9820 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009821 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9822 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009823 }
9824}
9825
9826/* unsolicited event for HP jack sensing */
9827static void alc262_hippo_unsol_event(struct hda_codec *codec,
9828 unsigned int res)
9829{
9830 if ((res >> 26) != ALC880_HP_EVENT)
9831 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009832 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009833}
9834
Takashi Iwai5b319542007-07-26 11:49:22 +02009835static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009836{
Kailang Yangccc656c2006-10-17 12:32:26 +02009837 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009838 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009839
Takashi Iwai5b319542007-07-26 11:49:22 +02009840 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9841 present = snd_hda_codec_read(codec, 0x1b, 0,
9842 AC_VERB_GET_PIN_SENSE, 0);
9843 present = (present & 0x80000000) != 0;
9844 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009845 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009846 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9847 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009848 } else {
9849 /* unmute internal speaker if necessary */
9850 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009851 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9852 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009853 }
9854}
9855
9856/* unsolicited event for HP jack sensing */
9857static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9858 unsigned int res)
9859{
9860 if ((res >> 26) != ALC880_HP_EVENT)
9861 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009862 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009863}
9864
Takashi Iwai834be882006-03-01 14:16:17 +01009865/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009866 * nec model
9867 * 0x15 = headphone
9868 * 0x16 = internal speaker
9869 * 0x18 = external mic
9870 */
9871
9872static struct snd_kcontrol_new alc262_nec_mixer[] = {
9873 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9874 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9875
9876 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9877 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9878 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9879
9880 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9881 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9882 { } /* end */
9883};
9884
9885static struct hda_verb alc262_nec_verbs[] = {
9886 /* Unmute Speaker */
9887 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9888
9889 /* Headphone */
9890 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9891 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9892
9893 /* External mic to headphone */
9894 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9895 /* External mic to speaker */
9896 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9897 {}
9898};
9899
9900/*
Takashi Iwai834be882006-03-01 14:16:17 +01009901 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009902 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9903 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009904 */
9905
9906#define ALC_HP_EVENT 0x37
9907
9908static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9909 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9910 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009911 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9912 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009913 {}
9914};
9915
Jiang zhe0e31daf2008-03-20 12:12:39 +01009916static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9917 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9918 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9919 {}
9920};
9921
Takashi Iwai834be882006-03-01 14:16:17 +01009922static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009923 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009924 .items = {
9925 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009926 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009927 { "CD", 0x4 },
9928 },
9929};
9930
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009931static struct hda_input_mux alc262_HP_capture_source = {
9932 .num_items = 5,
9933 .items = {
9934 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009935 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009936 { "Line", 0x2 },
9937 { "CD", 0x4 },
9938 { "AUX IN", 0x6 },
9939 },
9940};
9941
zhejiangaccbe492007-08-31 12:36:05 +02009942static struct hda_input_mux alc262_HP_D7000_capture_source = {
9943 .num_items = 4,
9944 .items = {
9945 { "Mic", 0x0 },
9946 { "Front Mic", 0x2 },
9947 { "Line", 0x1 },
9948 { "CD", 0x4 },
9949 },
9950};
9951
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009952/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009953static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9954{
9955 struct alc_spec *spec = codec->spec;
9956 unsigned int mute;
9957
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009958 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009959 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009960 /* need to execute and sync at first */
9961 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009962 /* check laptop HP jack */
9963 present = snd_hda_codec_read(codec, 0x14, 0,
9964 AC_VERB_GET_PIN_SENSE, 0);
9965 /* need to execute and sync at first */
9966 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9967 /* check docking HP jack */
9968 present |= snd_hda_codec_read(codec, 0x1b, 0,
9969 AC_VERB_GET_PIN_SENSE, 0);
9970 if (present & AC_PINSENSE_PRESENCE)
9971 spec->jack_present = 1;
9972 else
9973 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009974 spec->sense_updated = 1;
9975 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009976 /* unmute internal speaker only if both HPs are unplugged and
9977 * master switch is on
9978 */
9979 if (spec->jack_present)
9980 mute = HDA_AMP_MUTE;
9981 else
Takashi Iwai834be882006-03-01 14:16:17 +01009982 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009983 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9984 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009985}
9986
9987/* unsolicited event for HP jack sensing */
9988static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9989 unsigned int res)
9990{
9991 if ((res >> 26) != ALC_HP_EVENT)
9992 return;
9993 alc262_fujitsu_automute(codec, 1);
9994}
9995
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009996static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9997{
9998 alc262_fujitsu_automute(codec, 1);
9999}
10000
Takashi Iwai834be882006-03-01 14:16:17 +010010001/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010002static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10003 .ops = &snd_hda_bind_vol,
10004 .values = {
10005 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10006 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10007 0
10008 },
10009};
Takashi Iwai834be882006-03-01 14:16:17 +010010010
Jiang zhe0e31daf2008-03-20 12:12:39 +010010011/* mute/unmute internal speaker according to the hp jack and mute state */
10012static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10013{
10014 struct alc_spec *spec = codec->spec;
10015 unsigned int mute;
10016
10017 if (force || !spec->sense_updated) {
10018 unsigned int present_int_hp;
10019 /* need to execute and sync at first */
10020 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10021 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10022 AC_VERB_GET_PIN_SENSE, 0);
10023 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10024 spec->sense_updated = 1;
10025 }
10026 if (spec->jack_present) {
10027 /* mute internal speaker */
10028 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10029 HDA_AMP_MUTE, HDA_AMP_MUTE);
10030 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10031 HDA_AMP_MUTE, HDA_AMP_MUTE);
10032 } else {
10033 /* unmute internal speaker if necessary */
10034 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10035 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10036 HDA_AMP_MUTE, mute);
10037 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10038 HDA_AMP_MUTE, mute);
10039 }
10040}
10041
10042/* unsolicited event for HP jack sensing */
10043static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10044 unsigned int res)
10045{
10046 if ((res >> 26) != ALC_HP_EVENT)
10047 return;
10048 alc262_lenovo_3000_automute(codec, 1);
10049}
10050
Takashi Iwai834be882006-03-01 14:16:17 +010010051/* bind hp and internal speaker mute (with plug check) */
10052static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10053 struct snd_ctl_elem_value *ucontrol)
10054{
10055 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10056 long *valp = ucontrol->value.integer.value;
10057 int change;
10058
Tony Vroon5d9fab22008-03-14 17:09:18 +010010059 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10060 HDA_AMP_MUTE,
10061 valp ? 0 : HDA_AMP_MUTE);
10062 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10063 HDA_AMP_MUTE,
10064 valp ? 0 : HDA_AMP_MUTE);
10065
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010066 if (change)
10067 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010068 return change;
10069}
10070
10071static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010072 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010073 {
10074 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10075 .name = "Master Playback Switch",
10076 .info = snd_hda_mixer_amp_switch_info,
10077 .get = snd_hda_mixer_amp_switch_get,
10078 .put = alc262_fujitsu_master_sw_put,
10079 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10080 },
10081 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10082 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10083 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10084 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010086 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10087 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10088 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010089 { } /* end */
10090};
10091
Jiang zhe0e31daf2008-03-20 12:12:39 +010010092/* bind hp and internal speaker mute (with plug check) */
10093static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10094 struct snd_ctl_elem_value *ucontrol)
10095{
10096 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10097 long *valp = ucontrol->value.integer.value;
10098 int change;
10099
10100 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10101 HDA_AMP_MUTE,
10102 valp ? 0 : HDA_AMP_MUTE);
10103
10104 if (change)
10105 alc262_lenovo_3000_automute(codec, 0);
10106 return change;
10107}
10108
10109static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10110 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10111 {
10112 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10113 .name = "Master Playback Switch",
10114 .info = snd_hda_mixer_amp_switch_info,
10115 .get = snd_hda_mixer_amp_switch_get,
10116 .put = alc262_lenovo_3000_master_sw_put,
10117 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10118 },
10119 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10120 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10121 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10124 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10125 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10126 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10127 { } /* end */
10128};
10129
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010130static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10131 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10132 {
10133 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10134 .name = "Master Playback Switch",
10135 .info = snd_hda_mixer_amp_switch_info,
10136 .get = snd_hda_mixer_amp_switch_get,
10137 .put = alc262_sony_master_sw_put,
10138 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
10139 },
10140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10141 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10142 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10143 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10144 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10145 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10146 { } /* end */
10147};
10148
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010149/* additional init verbs for Benq laptops */
10150static struct hda_verb alc262_EAPD_verbs[] = {
10151 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10152 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10153 {}
10154};
10155
Kailang Yang83c34212007-07-05 11:43:05 +020010156static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10157 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10158 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10159
10160 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10161 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10162 {}
10163};
10164
Tobin Davisf651b502007-10-26 12:40:47 +020010165/* Samsung Q1 Ultra Vista model setup */
10166static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010167 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10168 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010169 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10170 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10171 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010172 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010173 { } /* end */
10174};
10175
10176static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010177 /* output mixer */
10178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10180 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10181 /* speaker */
10182 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10183 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10184 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10185 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10186 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010187 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10190 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10191 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10192 /* internal mic */
10193 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10194 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10195 /* ADC, choose mic */
10196 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10197 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10200 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10201 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10202 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10203 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10204 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10205 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010206 {}
10207};
10208
Tobin Davisf651b502007-10-26 12:40:47 +020010209/* mute/unmute internal speaker according to the hp jack and mute state */
10210static void alc262_ultra_automute(struct hda_codec *codec)
10211{
10212 struct alc_spec *spec = codec->spec;
10213 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010214
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010215 mute = 0;
10216 /* auto-mute only when HP is used as HP */
10217 if (!spec->cur_mux[0]) {
10218 unsigned int present;
10219 /* need to execute and sync at first */
10220 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10221 present = snd_hda_codec_read(codec, 0x15, 0,
10222 AC_VERB_GET_PIN_SENSE, 0);
10223 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10224 if (spec->jack_present)
10225 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010226 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010227 /* mute/unmute internal speaker */
10228 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10229 HDA_AMP_MUTE, mute);
10230 /* mute/unmute HP */
10231 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10232 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010233}
10234
10235/* unsolicited event for HP jack sensing */
10236static void alc262_ultra_unsol_event(struct hda_codec *codec,
10237 unsigned int res)
10238{
10239 if ((res >> 26) != ALC880_HP_EVENT)
10240 return;
10241 alc262_ultra_automute(codec);
10242}
10243
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010244static struct hda_input_mux alc262_ultra_capture_source = {
10245 .num_items = 2,
10246 .items = {
10247 { "Mic", 0x1 },
10248 { "Headphone", 0x7 },
10249 },
10250};
10251
10252static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10253 struct snd_ctl_elem_value *ucontrol)
10254{
10255 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10256 struct alc_spec *spec = codec->spec;
10257 int ret;
10258
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010259 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010260 if (!ret)
10261 return 0;
10262 /* reprogram the HP pin as mic or HP according to the input source */
10263 snd_hda_codec_write_cache(codec, 0x15, 0,
10264 AC_VERB_SET_PIN_WIDGET_CONTROL,
10265 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10266 alc262_ultra_automute(codec); /* mute/unmute HP */
10267 return ret;
10268}
10269
10270static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10271 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10272 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10273 {
10274 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10275 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010276 .info = alc_mux_enum_info,
10277 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010278 .put = alc262_ultra_mux_enum_put,
10279 },
10280 { } /* end */
10281};
10282
Kailang Yangdf694da2005-12-05 19:42:22 +010010283/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010284static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10285 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010286{
10287 hda_nid_t nid;
10288 int err;
10289
10290 spec->multiout.num_dacs = 1; /* only use one dac */
10291 spec->multiout.dac_nids = spec->private_dac_nids;
10292 spec->multiout.dac_nids[0] = 2;
10293
10294 nid = cfg->line_out_pins[0];
10295 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010296 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10297 "Front Playback Volume",
10298 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10299 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010300 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010301 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10302 "Front Playback Switch",
10303 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10304 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010305 return err;
10306 }
10307
Takashi Iwai82bc9552006-03-21 11:24:42 +010010308 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010309 if (nid) {
10310 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010311 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10312 "Speaker Playback Volume",
10313 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10314 HDA_OUTPUT));
10315 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010316 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010317 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10318 "Speaker Playback Switch",
10319 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10320 HDA_OUTPUT));
10321 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010322 return err;
10323 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010324 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10325 "Speaker Playback Switch",
10326 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10327 HDA_OUTPUT));
10328 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010329 return err;
10330 }
10331 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010332 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010333 if (nid) {
10334 /* spec->multiout.hp_nid = 2; */
10335 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010336 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10337 "Headphone Playback Volume",
10338 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10339 HDA_OUTPUT));
10340 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010341 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010342 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10343 "Headphone Playback Switch",
10344 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10345 HDA_OUTPUT));
10346 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010347 return err;
10348 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010349 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10350 "Headphone Playback Switch",
10351 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10352 HDA_OUTPUT));
10353 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010354 return err;
10355 }
10356 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010357 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010358}
10359
10360/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010361#define alc262_auto_create_analog_input_ctls \
10362 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010363
10364/*
10365 * generic initialization of ADC, input mixers and output mixers
10366 */
10367static struct hda_verb alc262_volume_init_verbs[] = {
10368 /*
10369 * Unmute ADC0-2 and set the default input to mic-in
10370 */
10371 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10372 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10373 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10374 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10375 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10376 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10377
Takashi Iwaicb53c622007-08-10 17:21:45 +020010378 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010379 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010380 * Note: PASD motherboards uses the Line In 2 as the input for
10381 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010382 */
10383 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010384 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10385 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10387 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10388 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010389
10390 /*
10391 * Set up output mixers (0x0c - 0x0f)
10392 */
10393 /* set vol=0 to output mixers */
10394 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10395 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010397
Kailang Yangdf694da2005-12-05 19:42:22 +010010398 /* set up input amps for analog loopback */
10399 /* Amp Indices: DAC = 0, mixer = 1 */
10400 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10401 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10402 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10403 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10404 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10405 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10406
10407 /* FIXME: use matrix-type input source selection */
10408 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10409 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10410 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10411 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10412 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10413 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10414 /* Input mixer2 */
10415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10416 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10417 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10418 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10419 /* Input mixer3 */
10420 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10421 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10422 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10423 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10424
10425 { }
10426};
10427
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010428static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10429 /*
10430 * Unmute ADC0-2 and set the default input to mic-in
10431 */
10432 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10434 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10435 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10436 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10437 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10438
Takashi Iwaicb53c622007-08-10 17:21:45 +020010439 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010440 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010441 * Note: PASD motherboards uses the Line In 2 as the input for
10442 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010443 */
10444 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10447 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10448 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10449 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10450 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10451 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010452
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010453 /*
10454 * Set up output mixers (0x0c - 0x0e)
10455 */
10456 /* set vol=0 to output mixers */
10457 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10458 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10459 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10460
10461 /* set up input amps for analog loopback */
10462 /* Amp Indices: DAC = 0, mixer = 1 */
10463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10466 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10468 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10469
Takashi Iwaice875f02008-01-28 18:17:43 +010010470 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010471 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10472 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10473
10474 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10475 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10476
10477 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10478 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10479
10480 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10481 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10483 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10484 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10485
10486 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10487 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10488 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10489 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10490 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10491 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10492
10493
10494 /* FIXME: use matrix-type input source selection */
10495 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10496 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10497 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10498 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10499 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10500 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10501 /* Input mixer2 */
10502 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10503 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10505 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10506 /* Input mixer3 */
10507 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10510 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10511
Takashi Iwaice875f02008-01-28 18:17:43 +010010512 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10513
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010514 { }
10515};
10516
Kailang Yangcd7509a2007-01-26 18:33:17 +010010517static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10518 /*
10519 * Unmute ADC0-2 and set the default input to mic-in
10520 */
10521 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10522 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10523 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10524 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10525 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10526 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10527
Takashi Iwaicb53c622007-08-10 17:21:45 +020010528 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010529 * mixer widget
10530 * Note: PASD motherboards uses the Line In 2 as the input for front
10531 * panel mic (mic 2)
10532 */
10533 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010534 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10535 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10536 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010542 /*
10543 * Set up output mixers (0x0c - 0x0e)
10544 */
10545 /* set vol=0 to output mixers */
10546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10547 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10548 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10549
10550 /* set up input amps for analog loopback */
10551 /* Amp Indices: DAC = 0, mixer = 1 */
10552 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10554 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10555 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10556 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10557 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10558
10559
10560 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10561 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10562 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10563 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10564 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10565 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10566 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10567
10568 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10569 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10570
10571 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10572 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10573
10574 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10575 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10576 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10577 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10578 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10579 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10580
10581 /* FIXME: use matrix-type input source selection */
10582 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10583 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10584 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10585 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10586 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10587 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10588 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10589 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10590 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10591 /* Input mixer2 */
10592 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10593 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10594 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10595 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10596 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10597 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10598 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10599 /* Input mixer3 */
10600 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10601 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10603 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10604 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10605 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10606 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10607
Takashi Iwaice875f02008-01-28 18:17:43 +010010608 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10609
Kailang Yangcd7509a2007-01-26 18:33:17 +010010610 { }
10611};
10612
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010613static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10614
10615 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10616 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10617 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10618
10619 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10620 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10621 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10622 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10623
10624 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10625 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10626 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10627 {}
10628};
10629
10630
Takashi Iwaicb53c622007-08-10 17:21:45 +020010631#ifdef CONFIG_SND_HDA_POWER_SAVE
10632#define alc262_loopbacks alc880_loopbacks
10633#endif
10634
Kailang Yangdf694da2005-12-05 19:42:22 +010010635/* pcm configuration: identiacal with ALC880 */
10636#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10637#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10638#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10639#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10640
10641/*
10642 * BIOS auto configuration
10643 */
10644static int alc262_parse_auto_config(struct hda_codec *codec)
10645{
10646 struct alc_spec *spec = codec->spec;
10647 int err;
10648 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10649
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010650 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10651 alc262_ignore);
10652 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010653 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010654 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010655 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010656 spec->multiout.max_channels = 2;
10657 spec->no_analog = 1;
10658 goto dig_only;
10659 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010660 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010661 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010662 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10663 if (err < 0)
10664 return err;
10665 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10666 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010667 return err;
10668
10669 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10670
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010671 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010672 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010673 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010674 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010675 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010676 if (spec->autocfg.dig_in_pin)
10677 spec->dig_in_nid = ALC262_DIGIN_NID;
10678
Takashi Iwai603c4012008-07-30 15:01:44 +020010679 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010680 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010681
Takashi Iwaid88897e2008-10-31 15:01:37 +010010682 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010683 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010684 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010685
Takashi Iwai776e1842007-08-29 15:07:11 +020010686 err = alc_auto_add_mic_boost(codec);
10687 if (err < 0)
10688 return err;
10689
Takashi Iwaie044c392008-10-27 16:56:24 +010010690 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010691 return 1;
10692}
10693
10694#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10695#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10696#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010697#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010698
10699
10700/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010701static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010702{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010703 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010704 alc262_auto_init_multi_out(codec);
10705 alc262_auto_init_hp_out(codec);
10706 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010707 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010708 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010709 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010710}
10711
10712/*
10713 * configuration and preset
10714 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010715static const char *alc262_models[ALC262_MODEL_LAST] = {
10716 [ALC262_BASIC] = "basic",
10717 [ALC262_HIPPO] = "hippo",
10718 [ALC262_HIPPO_1] = "hippo_1",
10719 [ALC262_FUJITSU] = "fujitsu",
10720 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010721 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010722 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010723 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010724 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010725 [ALC262_BENQ_T31] = "benq-t31",
10726 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010727 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010728 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010729 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010730 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010731 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010732 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010733 [ALC262_AUTO] = "auto",
10734};
10735
10736static struct snd_pci_quirk alc262_cfg_tbl[] = {
10737 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010738 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010739 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10740 ALC262_HP_BPC),
10741 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10742 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010743 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010744 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010745 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010746 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010747 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010748 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010749 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010750 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010751 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10752 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10753 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010754 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10755 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010756 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010757 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010758 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010759 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10760 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10761 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwai57a5ef42008-11-28 14:46:28 +010010762 SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN",
10763 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010764 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010765 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010766 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010767 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010768 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010769 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010770 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10771 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010772 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010773 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010774 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010775 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010776 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010777 {}
10778};
10779
10780static struct alc_config_preset alc262_presets[] = {
10781 [ALC262_BASIC] = {
10782 .mixers = { alc262_base_mixer },
10783 .init_verbs = { alc262_init_verbs },
10784 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10785 .dac_nids = alc262_dac_nids,
10786 .hp_nid = 0x03,
10787 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10788 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010789 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010790 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010791 [ALC262_HIPPO] = {
10792 .mixers = { alc262_base_mixer },
10793 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10794 .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_capture_source,
10801 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010802 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010803 },
10804 [ALC262_HIPPO_1] = {
10805 .mixers = { alc262_hippo1_mixer },
10806 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10807 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10808 .dac_nids = alc262_dac_nids,
10809 .hp_nid = 0x02,
10810 .dig_out_nid = ALC262_DIGOUT_NID,
10811 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10812 .channel_mode = alc262_modes,
10813 .input_mux = &alc262_capture_source,
10814 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010815 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010816 },
Takashi Iwai834be882006-03-01 14:16:17 +010010817 [ALC262_FUJITSU] = {
10818 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010819 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10820 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010821 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10822 .dac_nids = alc262_dac_nids,
10823 .hp_nid = 0x03,
10824 .dig_out_nid = ALC262_DIGOUT_NID,
10825 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10826 .channel_mode = alc262_modes,
10827 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010828 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010829 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010830 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010831 [ALC262_HP_BPC] = {
10832 .mixers = { alc262_HP_BPC_mixer },
10833 .init_verbs = { alc262_HP_BPC_init_verbs },
10834 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10835 .dac_nids = alc262_dac_nids,
10836 .hp_nid = 0x03,
10837 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10838 .channel_mode = alc262_modes,
10839 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010840 .unsol_event = alc262_hp_bpc_unsol_event,
10841 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010842 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010843 [ALC262_HP_BPC_D7000_WF] = {
10844 .mixers = { alc262_HP_BPC_WildWest_mixer },
10845 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10846 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10847 .dac_nids = alc262_dac_nids,
10848 .hp_nid = 0x03,
10849 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10850 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010851 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010852 .unsol_event = alc262_hp_wildwest_unsol_event,
10853 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010854 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010855 [ALC262_HP_BPC_D7000_WL] = {
10856 .mixers = { alc262_HP_BPC_WildWest_mixer,
10857 alc262_HP_BPC_WildWest_option_mixer },
10858 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10859 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10860 .dac_nids = alc262_dac_nids,
10861 .hp_nid = 0x03,
10862 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10863 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010864 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010865 .unsol_event = alc262_hp_wildwest_unsol_event,
10866 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010867 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010868 [ALC262_HP_TC_T5735] = {
10869 .mixers = { alc262_hp_t5735_mixer },
10870 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10871 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10872 .dac_nids = alc262_dac_nids,
10873 .hp_nid = 0x03,
10874 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10875 .channel_mode = alc262_modes,
10876 .input_mux = &alc262_capture_source,
10877 .unsol_event = alc262_hp_t5735_unsol_event,
10878 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010879 },
10880 [ALC262_HP_RP5700] = {
10881 .mixers = { alc262_hp_rp5700_mixer },
10882 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10883 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10884 .dac_nids = alc262_dac_nids,
10885 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10886 .channel_mode = alc262_modes,
10887 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010888 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010889 [ALC262_BENQ_ED8] = {
10890 .mixers = { alc262_base_mixer },
10891 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10892 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10893 .dac_nids = alc262_dac_nids,
10894 .hp_nid = 0x03,
10895 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10896 .channel_mode = alc262_modes,
10897 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010898 },
Kailang Yang272a5272007-05-14 11:00:38 +020010899 [ALC262_SONY_ASSAMD] = {
10900 .mixers = { alc262_sony_mixer },
10901 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10902 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10903 .dac_nids = alc262_dac_nids,
10904 .hp_nid = 0x02,
10905 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10906 .channel_mode = alc262_modes,
10907 .input_mux = &alc262_capture_source,
10908 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010909 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010910 },
10911 [ALC262_BENQ_T31] = {
10912 .mixers = { alc262_benq_t31_mixer },
10913 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10914 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10915 .dac_nids = alc262_dac_nids,
10916 .hp_nid = 0x03,
10917 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10918 .channel_mode = alc262_modes,
10919 .input_mux = &alc262_capture_source,
10920 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010921 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010922 },
Tobin Davisf651b502007-10-26 12:40:47 +020010923 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010924 .mixers = { alc262_ultra_mixer },
10925 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010926 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010927 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10928 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010929 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10930 .channel_mode = alc262_modes,
10931 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010932 .adc_nids = alc262_adc_nids, /* ADC0 */
10933 .capsrc_nids = alc262_capsrc_nids,
10934 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010935 .unsol_event = alc262_ultra_unsol_event,
10936 .init_hook = alc262_ultra_automute,
10937 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010938 [ALC262_LENOVO_3000] = {
10939 .mixers = { alc262_lenovo_3000_mixer },
10940 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10941 alc262_lenovo_3000_unsol_verbs },
10942 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10943 .dac_nids = alc262_dac_nids,
10944 .hp_nid = 0x03,
10945 .dig_out_nid = ALC262_DIGOUT_NID,
10946 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10947 .channel_mode = alc262_modes,
10948 .input_mux = &alc262_fujitsu_capture_source,
10949 .unsol_event = alc262_lenovo_3000_unsol_event,
10950 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010951 [ALC262_NEC] = {
10952 .mixers = { alc262_nec_mixer },
10953 .init_verbs = { alc262_nec_verbs },
10954 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10955 .dac_nids = alc262_dac_nids,
10956 .hp_nid = 0x03,
10957 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10958 .channel_mode = alc262_modes,
10959 .input_mux = &alc262_capture_source,
10960 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010961 [ALC262_TOSHIBA_S06] = {
10962 .mixers = { alc262_toshiba_s06_mixer },
10963 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10964 alc262_eapd_verbs },
10965 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10966 .capsrc_nids = alc262_dmic_capsrc_nids,
10967 .dac_nids = alc262_dac_nids,
10968 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10969 .dig_out_nid = ALC262_DIGOUT_NID,
10970 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10971 .channel_mode = alc262_modes,
10972 .input_mux = &alc262_dmic_capture_source,
10973 .unsol_event = alc262_toshiba_s06_unsol_event,
10974 .init_hook = alc262_toshiba_s06_init_hook,
10975 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010976 [ALC262_TOSHIBA_RX1] = {
10977 .mixers = { alc262_toshiba_rx1_mixer },
10978 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10979 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10980 .dac_nids = alc262_dac_nids,
10981 .hp_nid = 0x03,
10982 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10983 .channel_mode = alc262_modes,
10984 .input_mux = &alc262_capture_source,
10985 .unsol_event = alc262_hippo_unsol_event,
10986 .init_hook = alc262_hippo_automute,
10987 },
Tony Vroonba340e82009-02-02 19:01:30 +000010988 [ALC262_TYAN] = {
10989 .mixers = { alc262_tyan_mixer },
10990 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
10991 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10992 .dac_nids = alc262_dac_nids,
10993 .hp_nid = 0x02,
10994 .dig_out_nid = ALC262_DIGOUT_NID,
10995 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10996 .channel_mode = alc262_modes,
10997 .input_mux = &alc262_capture_source,
10998 .unsol_event = alc262_tyan_unsol_event,
10999 .init_hook = alc262_tyan_automute,
11000 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011001};
11002
11003static int patch_alc262(struct hda_codec *codec)
11004{
11005 struct alc_spec *spec;
11006 int board_config;
11007 int err;
11008
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011009 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011010 if (spec == NULL)
11011 return -ENOMEM;
11012
11013 codec->spec = spec;
11014#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011015 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11016 * under-run
11017 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011018 {
11019 int tmp;
11020 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11021 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11022 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11023 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11024 }
11025#endif
11026
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011027 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11028
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011029 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11030 alc262_models,
11031 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011032
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011033 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011034 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11035 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011036 board_config = ALC262_AUTO;
11037 }
11038
11039 if (board_config == ALC262_AUTO) {
11040 /* automatic parse from the BIOS config */
11041 err = alc262_parse_auto_config(codec);
11042 if (err < 0) {
11043 alc_free(codec);
11044 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011045 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011046 printk(KERN_INFO
11047 "hda_codec: Cannot set up configuration "
11048 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011049 board_config = ALC262_BASIC;
11050 }
11051 }
11052
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011053 err = snd_hda_attach_beep_device(codec, 0x1);
11054 if (err < 0) {
11055 alc_free(codec);
11056 return err;
11057 }
11058
Kailang Yangdf694da2005-12-05 19:42:22 +010011059 if (board_config != ALC262_AUTO)
11060 setup_preset(spec, &alc262_presets[board_config]);
11061
11062 spec->stream_name_analog = "ALC262 Analog";
11063 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11064 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011065
Kailang Yangdf694da2005-12-05 19:42:22 +010011066 spec->stream_name_digital = "ALC262 Digital";
11067 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11068 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11069
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011070 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011071 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011072 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011073 unsigned int wcap = get_wcaps(codec, 0x07);
11074
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011075 /* get type */
11076 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011077 if (wcap != AC_WID_AUD_IN) {
11078 spec->adc_nids = alc262_adc_nids_alt;
11079 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011080 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011081 } else {
11082 spec->adc_nids = alc262_adc_nids;
11083 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011084 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011085 }
11086 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011087 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011088 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010011089 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011090
Takashi Iwai2134ea42008-01-10 16:53:55 +010011091 spec->vmaster_nid = 0x0c;
11092
Kailang Yangdf694da2005-12-05 19:42:22 +010011093 codec->patch_ops = alc_patch_ops;
11094 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011095 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011096#ifdef CONFIG_SND_HDA_POWER_SAVE
11097 if (!spec->loopback.amplist)
11098 spec->loopback.amplist = alc262_loopbacks;
11099#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011100 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011101
Kailang Yangdf694da2005-12-05 19:42:22 +010011102 return 0;
11103}
11104
Kailang Yangdf694da2005-12-05 19:42:22 +010011105/*
Kailang Yanga361d842007-06-05 12:30:55 +020011106 * ALC268 channel source setting (2 channel)
11107 */
11108#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11109#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011110
Kailang Yanga361d842007-06-05 12:30:55 +020011111static hda_nid_t alc268_dac_nids[2] = {
11112 /* front, hp */
11113 0x02, 0x03
11114};
11115
11116static hda_nid_t alc268_adc_nids[2] = {
11117 /* ADC0-1 */
11118 0x08, 0x07
11119};
11120
11121static hda_nid_t alc268_adc_nids_alt[1] = {
11122 /* ADC0 */
11123 0x08
11124};
11125
Takashi Iwaie1406342008-02-11 18:32:32 +010011126static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11127
Kailang Yanga361d842007-06-05 12:30:55 +020011128static struct snd_kcontrol_new alc268_base_mixer[] = {
11129 /* output mixer control */
11130 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11131 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11132 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11133 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011134 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11135 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11136 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011137 { }
11138};
11139
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011140/* bind Beep switches of both NID 0x0f and 0x10 */
11141static struct hda_bind_ctls alc268_bind_beep_sw = {
11142 .ops = &snd_hda_bind_sw,
11143 .values = {
11144 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11145 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11146 0
11147 },
11148};
11149
11150static struct snd_kcontrol_new alc268_beep_mixer[] = {
11151 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11152 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11153 { }
11154};
11155
Kailang Yangd1a991a2007-08-15 16:21:59 +020011156static struct hda_verb alc268_eapd_verbs[] = {
11157 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11158 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11159 { }
11160};
11161
Takashi Iwaid2738092007-08-16 14:59:45 +020011162/* Toshiba specific */
11163#define alc268_toshiba_automute alc262_hippo_automute
11164
11165static struct hda_verb alc268_toshiba_verbs[] = {
11166 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11167 { } /* end */
11168};
11169
Kailang Yang8ef355d2008-08-26 13:10:22 +020011170static struct hda_input_mux alc268_acer_lc_capture_source = {
11171 .num_items = 2,
11172 .items = {
11173 { "i-Mic", 0x6 },
11174 { "E-Mic", 0x0 },
11175 },
11176};
11177
Takashi Iwaid2738092007-08-16 14:59:45 +020011178/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011179/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011180static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11181 .ops = &snd_hda_bind_vol,
11182 .values = {
11183 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11184 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11185 0
11186 },
11187};
11188
Takashi Iwai889c4392007-08-23 18:56:52 +020011189/* mute/unmute internal speaker according to the hp jack and mute state */
11190static void alc268_acer_automute(struct hda_codec *codec, int force)
11191{
11192 struct alc_spec *spec = codec->spec;
11193 unsigned int mute;
11194
11195 if (force || !spec->sense_updated) {
11196 unsigned int present;
11197 present = snd_hda_codec_read(codec, 0x14, 0,
11198 AC_VERB_GET_PIN_SENSE, 0);
11199 spec->jack_present = (present & 0x80000000) != 0;
11200 spec->sense_updated = 1;
11201 }
11202 if (spec->jack_present)
11203 mute = HDA_AMP_MUTE; /* mute internal speaker */
11204 else /* unmute internal speaker if necessary */
11205 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11206 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11207 HDA_AMP_MUTE, mute);
11208}
11209
11210
11211/* bind hp and internal speaker mute (with plug check) */
11212static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11213 struct snd_ctl_elem_value *ucontrol)
11214{
11215 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11216 long *valp = ucontrol->value.integer.value;
11217 int change;
11218
11219 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11220 HDA_AMP_MUTE,
11221 valp[0] ? 0 : HDA_AMP_MUTE);
11222 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11223 HDA_AMP_MUTE,
11224 valp[1] ? 0 : HDA_AMP_MUTE);
11225 if (change)
11226 alc268_acer_automute(codec, 0);
11227 return change;
11228}
Takashi Iwaid2738092007-08-16 14:59:45 +020011229
Kailang Yang8ef355d2008-08-26 13:10:22 +020011230static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11231 /* output mixer control */
11232 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11233 {
11234 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11235 .name = "Master Playback Switch",
11236 .info = snd_hda_mixer_amp_switch_info,
11237 .get = snd_hda_mixer_amp_switch_get,
11238 .put = alc268_acer_master_sw_put,
11239 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11240 },
11241 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11242 { }
11243};
11244
Takashi Iwaid2738092007-08-16 14:59:45 +020011245static struct snd_kcontrol_new alc268_acer_mixer[] = {
11246 /* output mixer control */
11247 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11248 {
11249 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11250 .name = "Master Playback Switch",
11251 .info = snd_hda_mixer_amp_switch_info,
11252 .get = snd_hda_mixer_amp_switch_get,
11253 .put = alc268_acer_master_sw_put,
11254 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11255 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011256 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11257 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11258 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011259 { }
11260};
11261
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011262static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11263 /* output mixer control */
11264 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11265 {
11266 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11267 .name = "Master Playback Switch",
11268 .info = snd_hda_mixer_amp_switch_info,
11269 .get = snd_hda_mixer_amp_switch_get,
11270 .put = alc268_acer_master_sw_put,
11271 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11272 },
11273 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11274 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11275 { }
11276};
11277
Kailang Yang8ef355d2008-08-26 13:10:22 +020011278static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11279 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11280 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11281 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11282 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11283 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11284 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11285 { }
11286};
11287
Takashi Iwaid2738092007-08-16 14:59:45 +020011288static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011289 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11290 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011291 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11292 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011293 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11294 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011295 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11296 { }
11297};
11298
11299/* unsolicited event for HP jack sensing */
11300static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11301 unsigned int res)
11302{
Takashi Iwai889c4392007-08-23 18:56:52 +020011303 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011304 return;
11305 alc268_toshiba_automute(codec);
11306}
11307
11308static void alc268_acer_unsol_event(struct hda_codec *codec,
11309 unsigned int res)
11310{
Takashi Iwai889c4392007-08-23 18:56:52 +020011311 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011312 return;
11313 alc268_acer_automute(codec, 1);
11314}
11315
Takashi Iwai889c4392007-08-23 18:56:52 +020011316static void alc268_acer_init_hook(struct hda_codec *codec)
11317{
11318 alc268_acer_automute(codec, 1);
11319}
11320
Kailang Yang8ef355d2008-08-26 13:10:22 +020011321/* toggle speaker-output according to the hp-jack state */
11322static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11323{
11324 unsigned int present;
11325 unsigned char bits;
11326
11327 present = snd_hda_codec_read(codec, 0x15, 0,
11328 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11329 bits = present ? AMP_IN_MUTE(0) : 0;
11330 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11331 AMP_IN_MUTE(0), bits);
11332 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11333 AMP_IN_MUTE(0), bits);
11334}
11335
11336
11337static void alc268_acer_mic_automute(struct hda_codec *codec)
11338{
11339 unsigned int present;
11340
11341 present = snd_hda_codec_read(codec, 0x18, 0,
11342 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11343 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11344 present ? 0x0 : 0x6);
11345}
11346
11347static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11348 unsigned int res)
11349{
11350 if ((res >> 26) == ALC880_HP_EVENT)
11351 alc268_aspire_one_speaker_automute(codec);
11352 if ((res >> 26) == ALC880_MIC_EVENT)
11353 alc268_acer_mic_automute(codec);
11354}
11355
11356static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11357{
11358 alc268_aspire_one_speaker_automute(codec);
11359 alc268_acer_mic_automute(codec);
11360}
11361
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011362static struct snd_kcontrol_new alc268_dell_mixer[] = {
11363 /* output mixer control */
11364 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11365 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11366 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11367 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11368 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11369 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11370 { }
11371};
11372
11373static struct hda_verb alc268_dell_verbs[] = {
11374 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11375 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11376 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11377 { }
11378};
11379
11380/* mute/unmute internal speaker according to the hp jack and mute state */
11381static void alc268_dell_automute(struct hda_codec *codec)
11382{
11383 unsigned int present;
11384 unsigned int mute;
11385
11386 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11387 if (present & 0x80000000)
11388 mute = HDA_AMP_MUTE;
11389 else
11390 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11391 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11392 HDA_AMP_MUTE, mute);
11393}
11394
11395static void alc268_dell_unsol_event(struct hda_codec *codec,
11396 unsigned int res)
11397{
11398 if ((res >> 26) != ALC880_HP_EVENT)
11399 return;
11400 alc268_dell_automute(codec);
11401}
11402
11403#define alc268_dell_init_hook alc268_dell_automute
11404
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011405static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11406 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11407 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11408 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11409 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11410 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11411 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11412 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11413 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11414 { }
11415};
11416
11417static struct hda_verb alc267_quanta_il1_verbs[] = {
11418 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11419 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11420 { }
11421};
11422
11423static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11424{
11425 unsigned int present;
11426
11427 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11428 & AC_PINSENSE_PRESENCE;
11429 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11430 present ? 0 : PIN_OUT);
11431}
11432
11433static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11434{
11435 unsigned int present;
11436
11437 present = snd_hda_codec_read(codec, 0x18, 0,
11438 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11439 snd_hda_codec_write(codec, 0x23, 0,
11440 AC_VERB_SET_CONNECT_SEL,
11441 present ? 0x00 : 0x01);
11442}
11443
11444static void alc267_quanta_il1_automute(struct hda_codec *codec)
11445{
11446 alc267_quanta_il1_hp_automute(codec);
11447 alc267_quanta_il1_mic_automute(codec);
11448}
11449
11450static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11451 unsigned int res)
11452{
11453 switch (res >> 26) {
11454 case ALC880_HP_EVENT:
11455 alc267_quanta_il1_hp_automute(codec);
11456 break;
11457 case ALC880_MIC_EVENT:
11458 alc267_quanta_il1_mic_automute(codec);
11459 break;
11460 }
11461}
11462
Kailang Yanga361d842007-06-05 12:30:55 +020011463/*
11464 * generic initialization of ADC, input mixers and output mixers
11465 */
11466static struct hda_verb alc268_base_init_verbs[] = {
11467 /* Unmute DAC0-1 and set vol = 0 */
11468 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011469 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011470
11471 /*
11472 * Set up output mixers (0x0c - 0x0e)
11473 */
11474 /* set vol=0 to output mixers */
11475 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011476 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11477
11478 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11479 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11480
11481 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11483 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11484 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11485 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11486 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11487 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11488 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11489
11490 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11491 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11492 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11493 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011494 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011495
11496 /* set PCBEEP vol = 0, mute connections */
11497 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11498 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11499 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011500
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011501 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011502
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011503 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11505 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11506 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011507
Kailang Yanga361d842007-06-05 12:30:55 +020011508 { }
11509};
11510
11511/*
11512 * generic initialization of ADC, input mixers and output mixers
11513 */
11514static struct hda_verb alc268_volume_init_verbs[] = {
11515 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011516 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11517 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011518
11519 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11520 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11521 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11522 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11523 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11524
Kailang Yanga361d842007-06-05 12:30:55 +020011525 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011526 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11527 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11528
11529 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011530 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011531
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011532 /* set PCBEEP vol = 0, mute connections */
11533 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11534 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11535 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011536
11537 { }
11538};
11539
Kailang Yanga361d842007-06-05 12:30:55 +020011540static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11541 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11542 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11543 {
11544 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11545 /* The multiple "Capture Source" controls confuse alsamixer
11546 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011547 */
11548 /* .name = "Capture Source", */
11549 .name = "Input Source",
11550 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011551 .info = alc_mux_enum_info,
11552 .get = alc_mux_enum_get,
11553 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011554 },
11555 { } /* end */
11556};
11557
11558static struct snd_kcontrol_new alc268_capture_mixer[] = {
11559 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11560 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11561 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11562 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11563 {
11564 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11565 /* The multiple "Capture Source" controls confuse alsamixer
11566 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011567 */
11568 /* .name = "Capture Source", */
11569 .name = "Input Source",
11570 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011571 .info = alc_mux_enum_info,
11572 .get = alc_mux_enum_get,
11573 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011574 },
11575 { } /* end */
11576};
11577
11578static struct hda_input_mux alc268_capture_source = {
11579 .num_items = 4,
11580 .items = {
11581 { "Mic", 0x0 },
11582 { "Front Mic", 0x1 },
11583 { "Line", 0x2 },
11584 { "CD", 0x3 },
11585 },
11586};
11587
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011588static struct hda_input_mux alc268_acer_capture_source = {
11589 .num_items = 3,
11590 .items = {
11591 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011592 { "Internal Mic", 0x1 },
11593 { "Line", 0x2 },
11594 },
11595};
11596
11597static struct hda_input_mux alc268_acer_dmic_capture_source = {
11598 .num_items = 3,
11599 .items = {
11600 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011601 { "Internal Mic", 0x6 },
11602 { "Line", 0x2 },
11603 },
11604};
11605
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011606#ifdef CONFIG_SND_DEBUG
11607static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011608 /* Volume widgets */
11609 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11610 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11611 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11612 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11613 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11614 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11615 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11616 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11617 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11618 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11619 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11620 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11621 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011622 /* The below appears problematic on some hardwares */
11623 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011624 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11625 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11626 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11627 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11628
11629 /* Modes for retasking pin widgets */
11630 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11631 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11632 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11633 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11634
11635 /* Controls for GPIO pins, assuming they are configured as outputs */
11636 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11637 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11638 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11639 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11640
11641 /* Switches to allow the digital SPDIF output pin to be enabled.
11642 * The ALC268 does not have an SPDIF input.
11643 */
11644 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11645
11646 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11647 * this output to turn on an external amplifier.
11648 */
11649 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11650 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11651
11652 { } /* end */
11653};
11654#endif
11655
Kailang Yanga361d842007-06-05 12:30:55 +020011656/* create input playback/capture controls for the given pin */
11657static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11658 const char *ctlname, int idx)
11659{
11660 char name[32];
11661 int err;
11662
11663 sprintf(name, "%s Playback Volume", ctlname);
11664 if (nid == 0x14) {
11665 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11666 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11667 HDA_OUTPUT));
11668 if (err < 0)
11669 return err;
11670 } else if (nid == 0x15) {
11671 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11672 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11673 HDA_OUTPUT));
11674 if (err < 0)
11675 return err;
11676 } else
11677 return -1;
11678 sprintf(name, "%s Playback Switch", ctlname);
11679 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11680 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11681 if (err < 0)
11682 return err;
11683 return 0;
11684}
11685
11686/* add playback controls from the parsed DAC table */
11687static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11688 const struct auto_pin_cfg *cfg)
11689{
11690 hda_nid_t nid;
11691 int err;
11692
11693 spec->multiout.num_dacs = 2; /* only use one dac */
11694 spec->multiout.dac_nids = spec->private_dac_nids;
11695 spec->multiout.dac_nids[0] = 2;
11696 spec->multiout.dac_nids[1] = 3;
11697
11698 nid = cfg->line_out_pins[0];
11699 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011700 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011701
11702 nid = cfg->speaker_pins[0];
11703 if (nid == 0x1d) {
11704 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11705 "Speaker Playback Volume",
11706 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11707 if (err < 0)
11708 return err;
11709 }
11710 nid = cfg->hp_pins[0];
11711 if (nid)
11712 alc268_new_analog_output(spec, nid, "Headphone", 0);
11713
11714 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11715 if (nid == 0x16) {
11716 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11717 "Mono Playback Switch",
11718 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11719 if (err < 0)
11720 return err;
11721 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011722 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011723}
11724
11725/* create playback/capture controls for input pins */
11726static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11727 const struct auto_pin_cfg *cfg)
11728{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011729 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011730 int i, idx1;
11731
11732 for (i = 0; i < AUTO_PIN_LAST; i++) {
11733 switch(cfg->input_pins[i]) {
11734 case 0x18:
11735 idx1 = 0; /* Mic 1 */
11736 break;
11737 case 0x19:
11738 idx1 = 1; /* Mic 2 */
11739 break;
11740 case 0x1a:
11741 idx1 = 2; /* Line In */
11742 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011743 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011744 idx1 = 3; /* CD */
11745 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011746 case 0x12:
11747 case 0x13:
11748 idx1 = 6; /* digital mics */
11749 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011750 default:
11751 continue;
11752 }
11753 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11754 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011755 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011756 }
11757 return 0;
11758}
11759
11760static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11761{
11762 struct alc_spec *spec = codec->spec;
11763 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11764 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11765 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11766 unsigned int dac_vol1, dac_vol2;
11767
11768 if (speaker_nid) {
11769 snd_hda_codec_write(codec, speaker_nid, 0,
11770 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11771 snd_hda_codec_write(codec, 0x0f, 0,
11772 AC_VERB_SET_AMP_GAIN_MUTE,
11773 AMP_IN_UNMUTE(1));
11774 snd_hda_codec_write(codec, 0x10, 0,
11775 AC_VERB_SET_AMP_GAIN_MUTE,
11776 AMP_IN_UNMUTE(1));
11777 } else {
11778 snd_hda_codec_write(codec, 0x0f, 0,
11779 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11780 snd_hda_codec_write(codec, 0x10, 0,
11781 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11782 }
11783
11784 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011785 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011786 dac_vol2 = AMP_OUT_ZERO;
11787 else if (line_nid == 0x15)
11788 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011789 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011790 dac_vol2 = AMP_OUT_ZERO;
11791 else if (hp_nid == 0x15)
11792 dac_vol1 = AMP_OUT_ZERO;
11793 if (line_nid != 0x16 || hp_nid != 0x16 ||
11794 spec->autocfg.line_out_pins[1] != 0x16 ||
11795 spec->autocfg.line_out_pins[2] != 0x16)
11796 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11797
11798 snd_hda_codec_write(codec, 0x02, 0,
11799 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11800 snd_hda_codec_write(codec, 0x03, 0,
11801 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11802}
11803
11804/* pcm configuration: identiacal with ALC880 */
11805#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11806#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011807#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011808#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11809
11810/*
11811 * BIOS auto configuration
11812 */
11813static int alc268_parse_auto_config(struct hda_codec *codec)
11814{
11815 struct alc_spec *spec = codec->spec;
11816 int err;
11817 static hda_nid_t alc268_ignore[] = { 0 };
11818
11819 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11820 alc268_ignore);
11821 if (err < 0)
11822 return err;
11823 if (!spec->autocfg.line_outs)
11824 return 0; /* can't find valid BIOS pin config */
11825
11826 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11827 if (err < 0)
11828 return err;
11829 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11830 if (err < 0)
11831 return err;
11832
11833 spec->multiout.max_channels = 2;
11834
11835 /* digital only support output */
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011836 if (spec->autocfg.dig_outs)
Kailang Yanga361d842007-06-05 12:30:55 +020011837 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11838
Takashi Iwai603c4012008-07-30 15:01:44 +020011839 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011840 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011841
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011842 if (spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011843 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011844
Takashi Iwaid88897e2008-10-31 15:01:37 +010011845 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011846 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011847 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011848
Takashi Iwai776e1842007-08-29 15:07:11 +020011849 err = alc_auto_add_mic_boost(codec);
11850 if (err < 0)
11851 return err;
11852
Takashi Iwaie044c392008-10-27 16:56:24 +010011853 store_pin_configs(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011854 return 1;
11855}
11856
11857#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11858#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11859#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11860
11861/* init callback for auto-configuration model -- overriding the default init */
11862static void alc268_auto_init(struct hda_codec *codec)
11863{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011864 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011865 alc268_auto_init_multi_out(codec);
11866 alc268_auto_init_hp_out(codec);
11867 alc268_auto_init_mono_speaker_out(codec);
11868 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011869 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011870 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011871}
11872
11873/*
11874 * configuration and preset
11875 */
11876static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011877 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011878 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011879 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011880 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011881 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011882 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011883 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011884 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011885#ifdef CONFIG_SND_DEBUG
11886 [ALC268_TEST] = "test",
11887#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011888 [ALC268_AUTO] = "auto",
11889};
11890
11891static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011892 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011893 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011894 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011895 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011896 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011897 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11898 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011899 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010011900 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011901 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011902 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011903 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011904 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011905 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011906 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011907 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011908 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011909 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011910 {}
11911};
11912
11913static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011914 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010011915 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011916 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11917 alc267_quanta_il1_verbs },
11918 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11919 .dac_nids = alc268_dac_nids,
11920 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11921 .adc_nids = alc268_adc_nids_alt,
11922 .hp_nid = 0x03,
11923 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11924 .channel_mode = alc268_modes,
11925 .input_mux = &alc268_capture_source,
11926 .unsol_event = alc267_quanta_il1_unsol_event,
11927 .init_hook = alc267_quanta_il1_automute,
11928 },
Kailang Yanga361d842007-06-05 12:30:55 +020011929 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011930 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11931 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011932 .init_verbs = { alc268_base_init_verbs },
11933 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11934 .dac_nids = alc268_dac_nids,
11935 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11936 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011937 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011938 .hp_nid = 0x03,
11939 .dig_out_nid = ALC268_DIGOUT_NID,
11940 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11941 .channel_mode = alc268_modes,
11942 .input_mux = &alc268_capture_source,
11943 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011944 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011945 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11946 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011947 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11948 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011949 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11950 .dac_nids = alc268_dac_nids,
11951 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11952 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011953 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011954 .hp_nid = 0x03,
11955 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11956 .channel_mode = alc268_modes,
11957 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011958 .unsol_event = alc268_toshiba_unsol_event,
11959 .init_hook = alc268_toshiba_automute,
11960 },
11961 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011962 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11963 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011964 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11965 alc268_acer_verbs },
11966 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11967 .dac_nids = alc268_dac_nids,
11968 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11969 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011970 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011971 .hp_nid = 0x02,
11972 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11973 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011974 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011975 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011976 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011977 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011978 [ALC268_ACER_DMIC] = {
11979 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
11980 alc268_beep_mixer },
11981 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11982 alc268_acer_verbs },
11983 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11984 .dac_nids = alc268_dac_nids,
11985 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11986 .adc_nids = alc268_adc_nids_alt,
11987 .capsrc_nids = alc268_capsrc_nids,
11988 .hp_nid = 0x02,
11989 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11990 .channel_mode = alc268_modes,
11991 .input_mux = &alc268_acer_dmic_capture_source,
11992 .unsol_event = alc268_acer_unsol_event,
11993 .init_hook = alc268_acer_init_hook,
11994 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011995 [ALC268_ACER_ASPIRE_ONE] = {
11996 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010011997 alc268_beep_mixer,
11998 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011999 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12000 alc268_acer_aspire_one_verbs },
12001 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12002 .dac_nids = alc268_dac_nids,
12003 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12004 .adc_nids = alc268_adc_nids_alt,
12005 .capsrc_nids = alc268_capsrc_nids,
12006 .hp_nid = 0x03,
12007 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12008 .channel_mode = alc268_modes,
12009 .input_mux = &alc268_acer_lc_capture_source,
12010 .unsol_event = alc268_acer_lc_unsol_event,
12011 .init_hook = alc268_acer_lc_init_hook,
12012 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012013 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012014 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012015 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12016 alc268_dell_verbs },
12017 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12018 .dac_nids = alc268_dac_nids,
12019 .hp_nid = 0x02,
12020 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12021 .channel_mode = alc268_modes,
12022 .unsol_event = alc268_dell_unsol_event,
12023 .init_hook = alc268_dell_init_hook,
12024 .input_mux = &alc268_capture_source,
12025 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012026 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012027 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12028 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012029 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12030 alc268_toshiba_verbs },
12031 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12032 .dac_nids = alc268_dac_nids,
12033 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12034 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012035 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012036 .hp_nid = 0x03,
12037 .dig_out_nid = ALC268_DIGOUT_NID,
12038 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12039 .channel_mode = alc268_modes,
12040 .input_mux = &alc268_capture_source,
12041 .unsol_event = alc268_toshiba_unsol_event,
12042 .init_hook = alc268_toshiba_automute
12043 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012044#ifdef CONFIG_SND_DEBUG
12045 [ALC268_TEST] = {
12046 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12047 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12048 alc268_volume_init_verbs },
12049 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12050 .dac_nids = alc268_dac_nids,
12051 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12052 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012053 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012054 .hp_nid = 0x03,
12055 .dig_out_nid = ALC268_DIGOUT_NID,
12056 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12057 .channel_mode = alc268_modes,
12058 .input_mux = &alc268_capture_source,
12059 },
12060#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012061};
12062
12063static int patch_alc268(struct hda_codec *codec)
12064{
12065 struct alc_spec *spec;
12066 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012067 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012068
12069 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12070 if (spec == NULL)
12071 return -ENOMEM;
12072
12073 codec->spec = spec;
12074
12075 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12076 alc268_models,
12077 alc268_cfg_tbl);
12078
12079 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12080 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12081 "trying auto-probe from BIOS...\n");
12082 board_config = ALC268_AUTO;
12083 }
12084
12085 if (board_config == ALC268_AUTO) {
12086 /* automatic parse from the BIOS config */
12087 err = alc268_parse_auto_config(codec);
12088 if (err < 0) {
12089 alc_free(codec);
12090 return err;
12091 } else if (!err) {
12092 printk(KERN_INFO
12093 "hda_codec: Cannot set up configuration "
12094 "from BIOS. Using base mode...\n");
12095 board_config = ALC268_3ST;
12096 }
12097 }
12098
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012099 err = snd_hda_attach_beep_device(codec, 0x1);
12100 if (err < 0) {
12101 alc_free(codec);
12102 return err;
12103 }
12104
Kailang Yanga361d842007-06-05 12:30:55 +020012105 if (board_config != ALC268_AUTO)
12106 setup_preset(spec, &alc268_presets[board_config]);
12107
Kailang Yang2f893282008-05-27 12:14:47 +020012108 if (codec->vendor_id == 0x10ec0267) {
12109 spec->stream_name_analog = "ALC267 Analog";
12110 spec->stream_name_digital = "ALC267 Digital";
12111 } else {
12112 spec->stream_name_analog = "ALC268 Analog";
12113 spec->stream_name_digital = "ALC268 Digital";
12114 }
12115
Kailang Yanga361d842007-06-05 12:30:55 +020012116 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12117 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012118 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012119
Kailang Yanga361d842007-06-05 12:30:55 +020012120 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12121
Takashi Iwai22971e32009-02-10 11:56:44 +010012122 has_beep = 0;
12123 for (i = 0; i < spec->num_mixers; i++) {
12124 if (spec->mixers[i] == alc268_beep_mixer) {
12125 has_beep = 1;
12126 break;
12127 }
12128 }
12129
12130 if (has_beep) {
12131 err = snd_hda_attach_beep_device(codec, 0x1);
12132 if (err < 0) {
12133 alc_free(codec);
12134 return err;
12135 }
12136 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12137 /* override the amp caps for beep generator */
12138 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012139 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12140 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12141 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12142 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012143 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012144
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012145 if (!spec->adc_nids && spec->input_mux) {
12146 /* check whether NID 0x07 is valid */
12147 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012148 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012149
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012150 /* get type */
12151 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012152 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012153 spec->adc_nids = alc268_adc_nids_alt;
12154 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012155 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012156 } else {
12157 spec->adc_nids = alc268_adc_nids;
12158 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012159 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012160 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012161 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012162 /* set default input source */
12163 for (i = 0; i < spec->num_adc_nids; i++)
12164 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12165 0, AC_VERB_SET_CONNECT_SEL,
12166 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012167 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012168
12169 spec->vmaster_nid = 0x02;
12170
Kailang Yanga361d842007-06-05 12:30:55 +020012171 codec->patch_ops = alc_patch_ops;
12172 if (board_config == ALC268_AUTO)
12173 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012174
Takashi Iwaidaead532008-11-28 12:55:36 +010012175 codec->proc_widget_hook = print_realtek_coef;
12176
Kailang Yanga361d842007-06-05 12:30:55 +020012177 return 0;
12178}
12179
12180/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012181 * ALC269 channel source setting (2 channel)
12182 */
12183#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12184
12185#define alc269_dac_nids alc260_dac_nids
12186
12187static hda_nid_t alc269_adc_nids[1] = {
12188 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012189 0x08,
12190};
12191
Takashi Iwaie01bf502008-08-21 16:25:07 +020012192static hda_nid_t alc269_capsrc_nids[1] = {
12193 0x23,
12194};
12195
12196/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12197 * not a mux!
12198 */
12199
Kailang Yangf53281e2008-07-18 12:36:43 +020012200static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12201 .num_items = 2,
12202 .items = {
12203 { "i-Mic", 0x5 },
12204 { "e-Mic", 0x0 },
12205 },
12206};
12207
12208static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12209 .num_items = 2,
12210 .items = {
12211 { "i-Mic", 0x1 },
12212 { "e-Mic", 0x0 },
12213 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012214};
12215
12216#define alc269_modes alc260_modes
12217#define alc269_capture_source alc880_lg_lw_capture_source
12218
12219static struct snd_kcontrol_new alc269_base_mixer[] = {
12220 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12221 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12222 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12223 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12224 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12225 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12226 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12227 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12228 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12229 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12230 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12231 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12232 { } /* end */
12233};
12234
Kailang Yang60db6b52008-08-26 13:13:00 +020012235static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12236 /* output mixer control */
12237 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12238 {
12239 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12240 .name = "Master Playback Switch",
12241 .info = snd_hda_mixer_amp_switch_info,
12242 .get = snd_hda_mixer_amp_switch_get,
12243 .put = alc268_acer_master_sw_put,
12244 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12245 },
12246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12247 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12248 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12249 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12250 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12251 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012252 { }
12253};
12254
Tony Vroon64154832008-11-06 15:08:49 +000012255static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12256 /* output mixer control */
12257 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12258 {
12259 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12260 .name = "Master Playback Switch",
12261 .info = snd_hda_mixer_amp_switch_info,
12262 .get = snd_hda_mixer_amp_switch_get,
12263 .put = alc268_acer_master_sw_put,
12264 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12265 },
12266 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12267 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12268 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12269 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12270 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12271 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12272 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12273 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12274 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012275 { }
12276};
12277
Kailang Yangf53281e2008-07-18 12:36:43 +020012278/* bind volumes of both NID 0x0c and 0x0d */
12279static struct hda_bind_ctls alc269_epc_bind_vol = {
12280 .ops = &snd_hda_bind_vol,
12281 .values = {
12282 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12283 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12284 0
12285 },
12286};
12287
12288static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12289 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12290 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12291 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12292 { } /* end */
12293};
12294
Kailang Yangf6a92242007-12-13 16:52:54 +010012295/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012296static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12297 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12298 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012299 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12300 { } /* end */
12301};
12302
12303/* FSC amilo */
12304static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12305 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12306 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12307 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012308 { } /* end */
12309};
12310
Kailang Yang60db6b52008-08-26 13:13:00 +020012311static struct hda_verb alc269_quanta_fl1_verbs[] = {
12312 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12313 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12314 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12315 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12316 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12317 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12318 { }
12319};
12320
Tony Vroon64154832008-11-06 15:08:49 +000012321static struct hda_verb alc269_lifebook_verbs[] = {
12322 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12323 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12324 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12325 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12326 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12327 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12328 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12329 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12330 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12331 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12332 { }
12333};
12334
Kailang Yang60db6b52008-08-26 13:13:00 +020012335/* toggle speaker-output according to the hp-jack state */
12336static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12337{
12338 unsigned int present;
12339 unsigned char bits;
12340
12341 present = snd_hda_codec_read(codec, 0x15, 0,
12342 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12343 bits = present ? AMP_IN_MUTE(0) : 0;
12344 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12345 AMP_IN_MUTE(0), bits);
12346 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12347 AMP_IN_MUTE(0), bits);
12348
12349 snd_hda_codec_write(codec, 0x20, 0,
12350 AC_VERB_SET_COEF_INDEX, 0x0c);
12351 snd_hda_codec_write(codec, 0x20, 0,
12352 AC_VERB_SET_PROC_COEF, 0x680);
12353
12354 snd_hda_codec_write(codec, 0x20, 0,
12355 AC_VERB_SET_COEF_INDEX, 0x0c);
12356 snd_hda_codec_write(codec, 0x20, 0,
12357 AC_VERB_SET_PROC_COEF, 0x480);
12358}
12359
Tony Vroon64154832008-11-06 15:08:49 +000012360/* toggle speaker-output according to the hp-jacks state */
12361static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12362{
12363 unsigned int present;
12364 unsigned char bits;
12365
12366 /* Check laptop headphone socket */
12367 present = snd_hda_codec_read(codec, 0x15, 0,
12368 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12369
12370 /* Check port replicator headphone socket */
12371 present |= snd_hda_codec_read(codec, 0x1a, 0,
12372 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12373
12374 bits = present ? AMP_IN_MUTE(0) : 0;
12375 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12376 AMP_IN_MUTE(0), bits);
12377 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12378 AMP_IN_MUTE(0), bits);
12379
12380 snd_hda_codec_write(codec, 0x20, 0,
12381 AC_VERB_SET_COEF_INDEX, 0x0c);
12382 snd_hda_codec_write(codec, 0x20, 0,
12383 AC_VERB_SET_PROC_COEF, 0x680);
12384
12385 snd_hda_codec_write(codec, 0x20, 0,
12386 AC_VERB_SET_COEF_INDEX, 0x0c);
12387 snd_hda_codec_write(codec, 0x20, 0,
12388 AC_VERB_SET_PROC_COEF, 0x480);
12389}
12390
Kailang Yang60db6b52008-08-26 13:13:00 +020012391static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12392{
12393 unsigned int present;
12394
12395 present = snd_hda_codec_read(codec, 0x18, 0,
12396 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12397 snd_hda_codec_write(codec, 0x23, 0,
12398 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12399}
12400
Tony Vroon64154832008-11-06 15:08:49 +000012401static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12402{
12403 unsigned int present_laptop;
12404 unsigned int present_dock;
12405
12406 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12407 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12408
12409 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12410 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12411
12412 /* Laptop mic port overrides dock mic port, design decision */
12413 if (present_dock)
12414 snd_hda_codec_write(codec, 0x23, 0,
12415 AC_VERB_SET_CONNECT_SEL, 0x3);
12416 if (present_laptop)
12417 snd_hda_codec_write(codec, 0x23, 0,
12418 AC_VERB_SET_CONNECT_SEL, 0x0);
12419 if (!present_dock && !present_laptop)
12420 snd_hda_codec_write(codec, 0x23, 0,
12421 AC_VERB_SET_CONNECT_SEL, 0x1);
12422}
12423
Kailang Yang60db6b52008-08-26 13:13:00 +020012424static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12425 unsigned int res)
12426{
12427 if ((res >> 26) == ALC880_HP_EVENT)
12428 alc269_quanta_fl1_speaker_automute(codec);
12429 if ((res >> 26) == ALC880_MIC_EVENT)
12430 alc269_quanta_fl1_mic_automute(codec);
12431}
12432
Tony Vroon64154832008-11-06 15:08:49 +000012433static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12434 unsigned int res)
12435{
12436 if ((res >> 26) == ALC880_HP_EVENT)
12437 alc269_lifebook_speaker_automute(codec);
12438 if ((res >> 26) == ALC880_MIC_EVENT)
12439 alc269_lifebook_mic_autoswitch(codec);
12440}
12441
Kailang Yang60db6b52008-08-26 13:13:00 +020012442static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12443{
12444 alc269_quanta_fl1_speaker_automute(codec);
12445 alc269_quanta_fl1_mic_automute(codec);
12446}
12447
Tony Vroon64154832008-11-06 15:08:49 +000012448static void alc269_lifebook_init_hook(struct hda_codec *codec)
12449{
12450 alc269_lifebook_speaker_automute(codec);
12451 alc269_lifebook_mic_autoswitch(codec);
12452}
12453
Kailang Yang60db6b52008-08-26 13:13:00 +020012454static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12455 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12456 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12457 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12458 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12459 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12460 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12461 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12462 {}
12463};
12464
12465static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12466 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12467 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12468 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12469 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12470 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12471 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12472 {}
12473};
12474
12475/* toggle speaker-output according to the hp-jack state */
12476static void alc269_speaker_automute(struct hda_codec *codec)
12477{
12478 unsigned int present;
12479 unsigned char bits;
12480
12481 present = snd_hda_codec_read(codec, 0x15, 0,
12482 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12483 bits = present ? AMP_IN_MUTE(0) : 0;
12484 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12485 AMP_IN_MUTE(0), bits);
12486 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12487 AMP_IN_MUTE(0), bits);
12488}
12489
12490static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12491{
12492 unsigned int present;
12493
12494 present = snd_hda_codec_read(codec, 0x18, 0,
12495 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12496 snd_hda_codec_write(codec, 0x23, 0,
12497 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12498}
12499
12500static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12501{
12502 unsigned int present;
12503
12504 present = snd_hda_codec_read(codec, 0x18, 0,
12505 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12506 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12507 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12508 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12509 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12510}
12511
12512/* unsolicited event for HP jack sensing */
12513static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12514 unsigned int res)
12515{
12516 if ((res >> 26) == ALC880_HP_EVENT)
12517 alc269_speaker_automute(codec);
12518
12519 if ((res >> 26) == ALC880_MIC_EVENT)
12520 alc269_eeepc_dmic_automute(codec);
12521}
12522
12523static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12524{
12525 alc269_speaker_automute(codec);
12526 alc269_eeepc_dmic_automute(codec);
12527}
12528
12529/* unsolicited event for HP jack sensing */
12530static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12531 unsigned int res)
12532{
12533 if ((res >> 26) == ALC880_HP_EVENT)
12534 alc269_speaker_automute(codec);
12535
12536 if ((res >> 26) == ALC880_MIC_EVENT)
12537 alc269_eeepc_amic_automute(codec);
12538}
12539
12540static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12541{
12542 alc269_speaker_automute(codec);
12543 alc269_eeepc_amic_automute(codec);
12544}
12545
Kailang Yangf6a92242007-12-13 16:52:54 +010012546/*
12547 * generic initialization of ADC, input mixers and output mixers
12548 */
12549static struct hda_verb alc269_init_verbs[] = {
12550 /*
12551 * Unmute ADC0 and set the default input to mic-in
12552 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012554
12555 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12556 * analog-loopback mixer widget
12557 * Note: PASD motherboards uses the Line In 2 as the input for
12558 * front panel mic (mic 2)
12559 */
12560 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12561 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12562 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12563 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12564 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12565 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12566
12567 /*
12568 * Set up output mixers (0x0c - 0x0e)
12569 */
12570 /* set vol=0 to output mixers */
12571 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12572 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12573
12574 /* set up input amps for analog loopback */
12575 /* Amp Indices: DAC = 0, mixer = 1 */
12576 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12577 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12578 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12579 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12580 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12581 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12582
12583 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12585 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12586 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12587 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12588 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12589 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12590
12591 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12592 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12593 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12594 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12595 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12596 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12597 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12598
12599 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12600 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12601
12602 /* FIXME: use matrix-type input source selection */
12603 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12604 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012605 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12606 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012607 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12608 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12609
12610 /* set EAPD */
12611 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12612 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12613 { }
12614};
12615
12616/* add playback controls from the parsed DAC table */
12617static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12618 const struct auto_pin_cfg *cfg)
12619{
12620 hda_nid_t nid;
12621 int err;
12622
12623 spec->multiout.num_dacs = 1; /* only use one dac */
12624 spec->multiout.dac_nids = spec->private_dac_nids;
12625 spec->multiout.dac_nids[0] = 2;
12626
12627 nid = cfg->line_out_pins[0];
12628 if (nid) {
12629 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12630 "Front Playback Volume",
12631 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12632 if (err < 0)
12633 return err;
12634 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12635 "Front Playback Switch",
12636 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12637 if (err < 0)
12638 return err;
12639 }
12640
12641 nid = cfg->speaker_pins[0];
12642 if (nid) {
12643 if (!cfg->line_out_pins[0]) {
12644 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12645 "Speaker Playback Volume",
12646 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12647 HDA_OUTPUT));
12648 if (err < 0)
12649 return err;
12650 }
12651 if (nid == 0x16) {
12652 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12653 "Speaker Playback Switch",
12654 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12655 HDA_OUTPUT));
12656 if (err < 0)
12657 return err;
12658 } else {
12659 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12660 "Speaker Playback Switch",
12661 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12662 HDA_OUTPUT));
12663 if (err < 0)
12664 return err;
12665 }
12666 }
12667 nid = cfg->hp_pins[0];
12668 if (nid) {
12669 /* spec->multiout.hp_nid = 2; */
12670 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12671 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12672 "Headphone Playback Volume",
12673 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12674 HDA_OUTPUT));
12675 if (err < 0)
12676 return err;
12677 }
12678 if (nid == 0x16) {
12679 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12680 "Headphone Playback Switch",
12681 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12682 HDA_OUTPUT));
12683 if (err < 0)
12684 return err;
12685 } else {
12686 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12687 "Headphone Playback Switch",
12688 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12689 HDA_OUTPUT));
12690 if (err < 0)
12691 return err;
12692 }
12693 }
12694 return 0;
12695}
12696
Takashi Iwaiee956e02008-10-31 17:16:31 +010012697static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12698 const struct auto_pin_cfg *cfg)
12699{
12700 int err;
12701
12702 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12703 if (err < 0)
12704 return err;
12705 /* digital-mic input pin is excluded in alc880_auto_create..()
12706 * because it's under 0x18
12707 */
12708 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12709 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012710 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012711 imux->items[imux->num_items].label = "Int Mic";
12712 imux->items[imux->num_items].index = 0x05;
12713 imux->num_items++;
12714 }
12715 return 0;
12716}
Kailang Yangf6a92242007-12-13 16:52:54 +010012717
12718#ifdef CONFIG_SND_HDA_POWER_SAVE
12719#define alc269_loopbacks alc880_loopbacks
12720#endif
12721
12722/* pcm configuration: identiacal with ALC880 */
12723#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12724#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12725#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12726#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12727
12728/*
12729 * BIOS auto configuration
12730 */
12731static int alc269_parse_auto_config(struct hda_codec *codec)
12732{
12733 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012734 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012735 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12736
12737 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12738 alc269_ignore);
12739 if (err < 0)
12740 return err;
12741
12742 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12743 if (err < 0)
12744 return err;
12745 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12746 if (err < 0)
12747 return err;
12748
12749 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12750
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012751 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012752 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12753
Takashi Iwai603c4012008-07-30 15:01:44 +020012754 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012755 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012756
Takashi Iwaid88897e2008-10-31 15:01:37 +010012757 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012758 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012759 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012760 /* set default input source */
12761 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12762 0, AC_VERB_SET_CONNECT_SEL,
12763 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012764
12765 err = alc_auto_add_mic_boost(codec);
12766 if (err < 0)
12767 return err;
12768
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012769 if (!spec->cap_mixer)
12770 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012771
Takashi Iwaie044c392008-10-27 16:56:24 +010012772 store_pin_configs(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012773 return 1;
12774}
12775
12776#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12777#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12778#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12779
12780
12781/* init callback for auto-configuration model -- overriding the default init */
12782static void alc269_auto_init(struct hda_codec *codec)
12783{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012784 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012785 alc269_auto_init_multi_out(codec);
12786 alc269_auto_init_hp_out(codec);
12787 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012788 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012789 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012790}
12791
12792/*
12793 * configuration and preset
12794 */
12795static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012796 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012797 [ALC269_QUANTA_FL1] = "quanta",
12798 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012799 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012800 [ALC269_FUJITSU] = "fujitsu",
12801 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012802};
12803
12804static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012805 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012806 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12807 ALC269_ASUS_EEEPC_P703),
12808 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12809 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012810 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12811 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012812 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012813 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012814 {}
12815};
12816
12817static struct alc_config_preset alc269_presets[] = {
12818 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012819 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012820 .init_verbs = { alc269_init_verbs },
12821 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12822 .dac_nids = alc269_dac_nids,
12823 .hp_nid = 0x03,
12824 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12825 .channel_mode = alc269_modes,
12826 .input_mux = &alc269_capture_source,
12827 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012828 [ALC269_QUANTA_FL1] = {
12829 .mixers = { alc269_quanta_fl1_mixer },
12830 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12831 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12832 .dac_nids = alc269_dac_nids,
12833 .hp_nid = 0x03,
12834 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12835 .channel_mode = alc269_modes,
12836 .input_mux = &alc269_capture_source,
12837 .unsol_event = alc269_quanta_fl1_unsol_event,
12838 .init_hook = alc269_quanta_fl1_init_hook,
12839 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012840 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012841 .mixers = { alc269_eeepc_mixer },
12842 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012843 .init_verbs = { alc269_init_verbs,
12844 alc269_eeepc_amic_init_verbs },
12845 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12846 .dac_nids = alc269_dac_nids,
12847 .hp_nid = 0x03,
12848 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12849 .channel_mode = alc269_modes,
12850 .input_mux = &alc269_eeepc_amic_capture_source,
12851 .unsol_event = alc269_eeepc_amic_unsol_event,
12852 .init_hook = alc269_eeepc_amic_inithook,
12853 },
12854 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012855 .mixers = { alc269_eeepc_mixer },
12856 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012857 .init_verbs = { alc269_init_verbs,
12858 alc269_eeepc_dmic_init_verbs },
12859 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12860 .dac_nids = alc269_dac_nids,
12861 .hp_nid = 0x03,
12862 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12863 .channel_mode = alc269_modes,
12864 .input_mux = &alc269_eeepc_dmic_capture_source,
12865 .unsol_event = alc269_eeepc_dmic_unsol_event,
12866 .init_hook = alc269_eeepc_dmic_inithook,
12867 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012868 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012869 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012870 .cap_mixer = alc269_epc_capture_mixer,
12871 .init_verbs = { alc269_init_verbs,
12872 alc269_eeepc_dmic_init_verbs },
12873 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12874 .dac_nids = alc269_dac_nids,
12875 .hp_nid = 0x03,
12876 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12877 .channel_mode = alc269_modes,
12878 .input_mux = &alc269_eeepc_dmic_capture_source,
12879 .unsol_event = alc269_eeepc_dmic_unsol_event,
12880 .init_hook = alc269_eeepc_dmic_inithook,
12881 },
Tony Vroon64154832008-11-06 15:08:49 +000012882 [ALC269_LIFEBOOK] = {
12883 .mixers = { alc269_lifebook_mixer },
12884 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12885 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12886 .dac_nids = alc269_dac_nids,
12887 .hp_nid = 0x03,
12888 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12889 .channel_mode = alc269_modes,
12890 .input_mux = &alc269_capture_source,
12891 .unsol_event = alc269_lifebook_unsol_event,
12892 .init_hook = alc269_lifebook_init_hook,
12893 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012894};
12895
12896static int patch_alc269(struct hda_codec *codec)
12897{
12898 struct alc_spec *spec;
12899 int board_config;
12900 int err;
12901
12902 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12903 if (spec == NULL)
12904 return -ENOMEM;
12905
12906 codec->spec = spec;
12907
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012908 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12909
Kailang Yangf6a92242007-12-13 16:52:54 +010012910 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12911 alc269_models,
12912 alc269_cfg_tbl);
12913
12914 if (board_config < 0) {
12915 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12916 "trying auto-probe from BIOS...\n");
12917 board_config = ALC269_AUTO;
12918 }
12919
12920 if (board_config == ALC269_AUTO) {
12921 /* automatic parse from the BIOS config */
12922 err = alc269_parse_auto_config(codec);
12923 if (err < 0) {
12924 alc_free(codec);
12925 return err;
12926 } else if (!err) {
12927 printk(KERN_INFO
12928 "hda_codec: Cannot set up configuration "
12929 "from BIOS. Using base mode...\n");
12930 board_config = ALC269_BASIC;
12931 }
12932 }
12933
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012934 err = snd_hda_attach_beep_device(codec, 0x1);
12935 if (err < 0) {
12936 alc_free(codec);
12937 return err;
12938 }
12939
Kailang Yangf6a92242007-12-13 16:52:54 +010012940 if (board_config != ALC269_AUTO)
12941 setup_preset(spec, &alc269_presets[board_config]);
12942
12943 spec->stream_name_analog = "ALC269 Analog";
12944 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12945 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12946
12947 spec->stream_name_digital = "ALC269 Digital";
12948 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12949 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12950
12951 spec->adc_nids = alc269_adc_nids;
12952 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012953 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012954 if (!spec->cap_mixer)
12955 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012956 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010012957
12958 codec->patch_ops = alc_patch_ops;
12959 if (board_config == ALC269_AUTO)
12960 spec->init_hook = alc269_auto_init;
12961#ifdef CONFIG_SND_HDA_POWER_SAVE
12962 if (!spec->loopback.amplist)
12963 spec->loopback.amplist = alc269_loopbacks;
12964#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010012965 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010012966
12967 return 0;
12968}
12969
12970/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012971 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12972 */
12973
12974/*
12975 * set the path ways for 2 channel output
12976 * need to set the codec line out and mic 1 pin widgets to inputs
12977 */
12978static struct hda_verb alc861_threestack_ch2_init[] = {
12979 /* set pin widget 1Ah (line in) for input */
12980 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012981 /* set pin widget 18h (mic1/2) for input, for mic also enable
12982 * the vref
12983 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012984 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12985
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012986 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12987#if 0
12988 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12989 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12990#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012991 { } /* end */
12992};
12993/*
12994 * 6ch mode
12995 * need to set the codec line out and mic 1 pin widgets to outputs
12996 */
12997static struct hda_verb alc861_threestack_ch6_init[] = {
12998 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12999 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13000 /* set pin widget 18h (mic1) for output (CLFE)*/
13001 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13002
13003 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013004 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013005
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013006 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13007#if 0
13008 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13009 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13010#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013011 { } /* end */
13012};
13013
13014static struct hda_channel_mode alc861_threestack_modes[2] = {
13015 { 2, alc861_threestack_ch2_init },
13016 { 6, alc861_threestack_ch6_init },
13017};
Takashi Iwai22309c32006-08-09 16:57:28 +020013018/* Set mic1 as input and unmute the mixer */
13019static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13020 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13021 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13022 { } /* end */
13023};
13024/* Set mic1 as output and mute mixer */
13025static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13026 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13027 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13028 { } /* end */
13029};
13030
13031static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13032 { 2, alc861_uniwill_m31_ch2_init },
13033 { 4, alc861_uniwill_m31_ch4_init },
13034};
Kailang Yangdf694da2005-12-05 19:42:22 +010013035
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013036/* Set mic1 and line-in as input and unmute the mixer */
13037static struct hda_verb alc861_asus_ch2_init[] = {
13038 /* set pin widget 1Ah (line in) for input */
13039 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013040 /* set pin widget 18h (mic1/2) for input, for mic also enable
13041 * the vref
13042 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013043 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13044
13045 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13046#if 0
13047 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13048 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13049#endif
13050 { } /* end */
13051};
13052/* Set mic1 nad line-in as output and mute mixer */
13053static struct hda_verb alc861_asus_ch6_init[] = {
13054 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13055 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13056 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13057 /* set pin widget 18h (mic1) for output (CLFE)*/
13058 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13059 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13060 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13061 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13062
13063 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13064#if 0
13065 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13066 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13067#endif
13068 { } /* end */
13069};
13070
13071static struct hda_channel_mode alc861_asus_modes[2] = {
13072 { 2, alc861_asus_ch2_init },
13073 { 6, alc861_asus_ch6_init },
13074};
13075
Kailang Yangdf694da2005-12-05 19:42:22 +010013076/* patch-ALC861 */
13077
13078static struct snd_kcontrol_new alc861_base_mixer[] = {
13079 /* output mixer control */
13080 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13081 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13082 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13083 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13084 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13085
13086 /*Input mixer control */
13087 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13088 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13089 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13090 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13091 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13092 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13093 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13094 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13095 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13096 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013097
Kailang Yangdf694da2005-12-05 19:42:22 +010013098 { } /* end */
13099};
13100
13101static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13102 /* output mixer control */
13103 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13104 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13105 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13106 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13107 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13108
13109 /* Input mixer control */
13110 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13111 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13112 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13113 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13114 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13115 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13117 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13118 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13119 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013120
Kailang Yangdf694da2005-12-05 19:42:22 +010013121 {
13122 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13123 .name = "Channel Mode",
13124 .info = alc_ch_mode_info,
13125 .get = alc_ch_mode_get,
13126 .put = alc_ch_mode_put,
13127 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13128 },
13129 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013130};
13131
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013132static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013133 /* output mixer control */
13134 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13135 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13136 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013137
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013138 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013139};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013140
Takashi Iwai22309c32006-08-09 16:57:28 +020013141static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13142 /* output mixer control */
13143 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13144 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13145 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13146 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13147 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13148
13149 /* Input mixer control */
13150 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13151 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13152 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13153 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13154 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13155 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13157 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13158 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13159 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013160
Takashi Iwai22309c32006-08-09 16:57:28 +020013161 {
13162 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13163 .name = "Channel Mode",
13164 .info = alc_ch_mode_info,
13165 .get = alc_ch_mode_get,
13166 .put = alc_ch_mode_put,
13167 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13168 },
13169 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013170};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013171
13172static struct snd_kcontrol_new alc861_asus_mixer[] = {
13173 /* output mixer control */
13174 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13175 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13176 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13177 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13178 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13179
13180 /* Input mixer control */
13181 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13182 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13183 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13184 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13185 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13186 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13187 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13188 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13189 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013190 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13191
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013192 {
13193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13194 .name = "Channel Mode",
13195 .info = alc_ch_mode_info,
13196 .get = alc_ch_mode_get,
13197 .put = alc_ch_mode_put,
13198 .private_value = ARRAY_SIZE(alc861_asus_modes),
13199 },
13200 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013201};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013202
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013203/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013204static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013205 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13206 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013207 { }
13208};
13209
Kailang Yangdf694da2005-12-05 19:42:22 +010013210/*
13211 * generic initialization of ADC, input mixers and output mixers
13212 */
13213static struct hda_verb alc861_base_init_verbs[] = {
13214 /*
13215 * Unmute ADC0 and set the default input to mic-in
13216 */
13217 /* port-A for surround (rear panel) */
13218 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13219 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13220 /* port-B for mic-in (rear panel) with vref */
13221 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13222 /* port-C for line-in (rear panel) */
13223 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13224 /* port-D for Front */
13225 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13226 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13227 /* port-E for HP out (front panel) */
13228 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13229 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013230 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013231 /* port-F for mic-in (front panel) with vref */
13232 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13233 /* port-G for CLFE (rear panel) */
13234 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13235 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13236 /* port-H for side (rear panel) */
13237 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13238 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13239 /* CD-in */
13240 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13241 /* route front mic to ADC1*/
13242 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13243 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013244
Kailang Yangdf694da2005-12-05 19:42:22 +010013245 /* Unmute DAC0~3 & spdif out*/
13246 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13247 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13248 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13249 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013251
Kailang Yangdf694da2005-12-05 19:42:22 +010013252 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13253 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13254 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13255 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13256 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013257
Kailang Yangdf694da2005-12-05 19:42:22 +010013258 /* Unmute Stereo Mixer 15 */
13259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13260 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13261 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013262 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013263
13264 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13265 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13266 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13267 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13269 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13270 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13271 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013272 /* hp used DAC 3 (Front) */
13273 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13275
13276 { }
13277};
13278
13279static struct hda_verb alc861_threestack_init_verbs[] = {
13280 /*
13281 * Unmute ADC0 and set the default input to mic-in
13282 */
13283 /* port-A for surround (rear panel) */
13284 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13285 /* port-B for mic-in (rear panel) with vref */
13286 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13287 /* port-C for line-in (rear panel) */
13288 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13289 /* port-D for Front */
13290 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13291 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13292 /* port-E for HP out (front panel) */
13293 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13294 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013295 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013296 /* port-F for mic-in (front panel) with vref */
13297 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13298 /* port-G for CLFE (rear panel) */
13299 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13300 /* port-H for side (rear panel) */
13301 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13302 /* CD-in */
13303 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13304 /* route front mic to ADC1*/
13305 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13307 /* Unmute DAC0~3 & spdif out*/
13308 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13309 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13310 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13311 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13312 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013313
Kailang Yangdf694da2005-12-05 19:42:22 +010013314 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13315 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13316 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13317 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13318 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013319
Kailang Yangdf694da2005-12-05 19:42:22 +010013320 /* Unmute Stereo Mixer 15 */
13321 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13322 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13323 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013324 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013325
13326 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13327 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13328 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13329 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13330 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13331 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13332 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13333 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013334 /* hp used DAC 3 (Front) */
13335 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013336 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13337 { }
13338};
Takashi Iwai22309c32006-08-09 16:57:28 +020013339
13340static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13341 /*
13342 * Unmute ADC0 and set the default input to mic-in
13343 */
13344 /* port-A for surround (rear panel) */
13345 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13346 /* port-B for mic-in (rear panel) with vref */
13347 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13348 /* port-C for line-in (rear panel) */
13349 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13350 /* port-D for Front */
13351 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13352 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13353 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013354 /* this has to be set to VREF80 */
13355 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013356 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013357 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013358 /* port-F for mic-in (front panel) with vref */
13359 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13360 /* port-G for CLFE (rear panel) */
13361 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13362 /* port-H for side (rear panel) */
13363 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13364 /* CD-in */
13365 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13366 /* route front mic to ADC1*/
13367 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13368 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13369 /* Unmute DAC0~3 & spdif out*/
13370 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13371 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13372 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13373 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13374 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013375
Takashi Iwai22309c32006-08-09 16:57:28 +020013376 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13377 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13378 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13379 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13380 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013381
Takashi Iwai22309c32006-08-09 16:57:28 +020013382 /* Unmute Stereo Mixer 15 */
13383 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13384 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13385 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013386 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013387
13388 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13389 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13390 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13391 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13392 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13393 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13394 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13395 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013396 /* hp used DAC 3 (Front) */
13397 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013398 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13399 { }
13400};
13401
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013402static struct hda_verb alc861_asus_init_verbs[] = {
13403 /*
13404 * Unmute ADC0 and set the default input to mic-in
13405 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013406 /* port-A for surround (rear panel)
13407 * according to codec#0 this is the HP jack
13408 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013409 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13410 /* route front PCM to HP */
13411 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13412 /* port-B for mic-in (rear panel) with vref */
13413 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13414 /* port-C for line-in (rear panel) */
13415 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13416 /* port-D for Front */
13417 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13418 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13419 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013420 /* this has to be set to VREF80 */
13421 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013422 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013423 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013424 /* port-F for mic-in (front panel) with vref */
13425 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13426 /* port-G for CLFE (rear panel) */
13427 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13428 /* port-H for side (rear panel) */
13429 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13430 /* CD-in */
13431 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13432 /* route front mic to ADC1*/
13433 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13434 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13435 /* Unmute DAC0~3 & spdif out*/
13436 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13437 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13438 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13439 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13441 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13442 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13443 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13444 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13445 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013446
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013447 /* Unmute Stereo Mixer 15 */
13448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13449 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13450 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013451 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013452
13453 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13454 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13455 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13456 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13457 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13458 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13459 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13460 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013461 /* hp used DAC 3 (Front) */
13462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013463 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13464 { }
13465};
13466
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013467/* additional init verbs for ASUS laptops */
13468static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13469 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13470 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13471 { }
13472};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013473
Kailang Yangdf694da2005-12-05 19:42:22 +010013474/*
13475 * generic initialization of ADC, input mixers and output mixers
13476 */
13477static struct hda_verb alc861_auto_init_verbs[] = {
13478 /*
13479 * Unmute ADC0 and set the default input to mic-in
13480 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013481 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013482 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013483
Kailang Yangdf694da2005-12-05 19:42:22 +010013484 /* Unmute DAC0~3 & spdif out*/
13485 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13486 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13487 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13488 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13489 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013490
Kailang Yangdf694da2005-12-05 19:42:22 +010013491 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13492 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13493 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13494 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13495 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013496
Kailang Yangdf694da2005-12-05 19:42:22 +010013497 /* Unmute Stereo Mixer 15 */
13498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13499 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13500 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13501 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13502
13503 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13504 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13505 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13506 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13507 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13508 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13509 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13510 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13511
13512 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13513 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013514 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13515 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013516 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13517 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013518 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13519 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013520
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013521 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013522
13523 { }
13524};
13525
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013526static struct hda_verb alc861_toshiba_init_verbs[] = {
13527 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013528
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013529 { }
13530};
13531
13532/* toggle speaker-output according to the hp-jack state */
13533static void alc861_toshiba_automute(struct hda_codec *codec)
13534{
13535 unsigned int present;
13536
13537 present = snd_hda_codec_read(codec, 0x0f, 0,
13538 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013539 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13540 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13541 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13542 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013543}
13544
13545static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13546 unsigned int res)
13547{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013548 if ((res >> 26) == ALC880_HP_EVENT)
13549 alc861_toshiba_automute(codec);
13550}
13551
Kailang Yangdf694da2005-12-05 19:42:22 +010013552/* pcm configuration: identiacal with ALC880 */
13553#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13554#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13555#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13556#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13557
13558
13559#define ALC861_DIGOUT_NID 0x07
13560
13561static struct hda_channel_mode alc861_8ch_modes[1] = {
13562 { 8, NULL }
13563};
13564
13565static hda_nid_t alc861_dac_nids[4] = {
13566 /* front, surround, clfe, side */
13567 0x03, 0x06, 0x05, 0x04
13568};
13569
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013570static hda_nid_t alc660_dac_nids[3] = {
13571 /* front, clfe, surround */
13572 0x03, 0x05, 0x06
13573};
13574
Kailang Yangdf694da2005-12-05 19:42:22 +010013575static hda_nid_t alc861_adc_nids[1] = {
13576 /* ADC0-2 */
13577 0x08,
13578};
13579
13580static struct hda_input_mux alc861_capture_source = {
13581 .num_items = 5,
13582 .items = {
13583 { "Mic", 0x0 },
13584 { "Front Mic", 0x3 },
13585 { "Line", 0x1 },
13586 { "CD", 0x4 },
13587 { "Mixer", 0x5 },
13588 },
13589};
13590
13591/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013592static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13593 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013594{
13595 int i;
13596 hda_nid_t nid;
13597
13598 spec->multiout.dac_nids = spec->private_dac_nids;
13599 for (i = 0; i < cfg->line_outs; i++) {
13600 nid = cfg->line_out_pins[i];
13601 if (nid) {
13602 if (i >= ARRAY_SIZE(alc861_dac_nids))
13603 continue;
13604 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13605 }
13606 }
13607 spec->multiout.num_dacs = cfg->line_outs;
13608 return 0;
13609}
13610
13611/* add playback controls from the parsed DAC table */
13612static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13613 const struct auto_pin_cfg *cfg)
13614{
13615 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013616 static const char *chname[4] = {
13617 "Front", "Surround", NULL /*CLFE*/, "Side"
13618 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013619 hda_nid_t nid;
13620 int i, idx, err;
13621
13622 for (i = 0; i < cfg->line_outs; i++) {
13623 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013624 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013625 continue;
13626 if (nid == 0x05) {
13627 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013628 err = add_control(spec, ALC_CTL_BIND_MUTE,
13629 "Center Playback Switch",
13630 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13631 HDA_OUTPUT));
13632 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013633 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013634 err = add_control(spec, ALC_CTL_BIND_MUTE,
13635 "LFE Playback Switch",
13636 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13637 HDA_OUTPUT));
13638 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013639 return err;
13640 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013641 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13642 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013643 if (nid == alc861_dac_nids[idx])
13644 break;
13645 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013646 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13647 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13648 HDA_OUTPUT));
13649 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013650 return err;
13651 }
13652 }
13653 return 0;
13654}
13655
13656static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13657{
13658 int err;
13659 hda_nid_t nid;
13660
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013661 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013662 return 0;
13663
13664 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13665 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013666 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13667 "Headphone Playback Switch",
13668 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13669 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013670 return err;
13671 spec->multiout.hp_nid = nid;
13672 }
13673 return 0;
13674}
13675
13676/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013677static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13678 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013679{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013680 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013681 int i, err, idx, idx1;
13682
13683 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013684 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013685 case 0x0c:
13686 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013687 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013688 break;
13689 case 0x0f:
13690 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013691 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013692 break;
13693 case 0x0d:
13694 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013695 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013696 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013697 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013698 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013699 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013700 break;
13701 case 0x11:
13702 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013703 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013704 break;
13705 default:
13706 continue;
13707 }
13708
Takashi Iwai4a471b72005-12-07 13:56:29 +010013709 err = new_analog_input(spec, cfg->input_pins[i],
13710 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013711 if (err < 0)
13712 return err;
13713
Takashi Iwai4a471b72005-12-07 13:56:29 +010013714 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013715 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013716 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013717 }
13718 return 0;
13719}
13720
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013721static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13722 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013723 int pin_type, int dac_idx)
13724{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013725 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13726 pin_type);
13727 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13728 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013729}
13730
13731static void alc861_auto_init_multi_out(struct hda_codec *codec)
13732{
13733 struct alc_spec *spec = codec->spec;
13734 int i;
13735
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013736 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013737 for (i = 0; i < spec->autocfg.line_outs; i++) {
13738 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013739 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013740 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013741 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013742 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013743 }
13744}
13745
13746static void alc861_auto_init_hp_out(struct hda_codec *codec)
13747{
13748 struct alc_spec *spec = codec->spec;
13749 hda_nid_t pin;
13750
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013751 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013752 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013753 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13754 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013755 pin = spec->autocfg.speaker_pins[0];
13756 if (pin)
13757 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013758}
13759
13760static void alc861_auto_init_analog_input(struct hda_codec *codec)
13761{
13762 struct alc_spec *spec = codec->spec;
13763 int i;
13764
13765 for (i = 0; i < AUTO_PIN_LAST; i++) {
13766 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013767 if (nid >= 0x0c && nid <= 0x11) {
13768 snd_hda_codec_write(codec, nid, 0,
13769 AC_VERB_SET_PIN_WIDGET_CONTROL,
13770 i <= AUTO_PIN_FRONT_MIC ?
13771 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013772 }
13773 }
13774}
13775
13776/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013777/* return 1 if successful, 0 if the proper config is not found,
13778 * or a negative error code
13779 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013780static int alc861_parse_auto_config(struct hda_codec *codec)
13781{
13782 struct alc_spec *spec = codec->spec;
13783 int err;
13784 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13785
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013786 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13787 alc861_ignore);
13788 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013789 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013790 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013791 return 0; /* can't find valid BIOS pin config */
13792
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013793 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13794 if (err < 0)
13795 return err;
13796 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13797 if (err < 0)
13798 return err;
13799 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13800 if (err < 0)
13801 return err;
13802 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13803 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013804 return err;
13805
13806 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13807
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013808 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013809 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13810
Takashi Iwai603c4012008-07-30 15:01:44 +020013811 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013812 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013813
Takashi Iwaid88897e2008-10-31 15:01:37 +010013814 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013815
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013816 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013817 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013818
13819 spec->adc_nids = alc861_adc_nids;
13820 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013821 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013822
Takashi Iwaie044c392008-10-27 16:56:24 +010013823 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013824 return 1;
13825}
13826
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013827/* additional initialization for auto-configuration model */
13828static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013829{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013830 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013831 alc861_auto_init_multi_out(codec);
13832 alc861_auto_init_hp_out(codec);
13833 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013834 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013835 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013836}
13837
Takashi Iwaicb53c622007-08-10 17:21:45 +020013838#ifdef CONFIG_SND_HDA_POWER_SAVE
13839static struct hda_amp_list alc861_loopbacks[] = {
13840 { 0x15, HDA_INPUT, 0 },
13841 { 0x15, HDA_INPUT, 1 },
13842 { 0x15, HDA_INPUT, 2 },
13843 { 0x15, HDA_INPUT, 3 },
13844 { } /* end */
13845};
13846#endif
13847
Kailang Yangdf694da2005-12-05 19:42:22 +010013848
13849/*
13850 * configuration and preset
13851 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013852static const char *alc861_models[ALC861_MODEL_LAST] = {
13853 [ALC861_3ST] = "3stack",
13854 [ALC660_3ST] = "3stack-660",
13855 [ALC861_3ST_DIG] = "3stack-dig",
13856 [ALC861_6ST_DIG] = "6stack-dig",
13857 [ALC861_UNIWILL_M31] = "uniwill-m31",
13858 [ALC861_TOSHIBA] = "toshiba",
13859 [ALC861_ASUS] = "asus",
13860 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13861 [ALC861_AUTO] = "auto",
13862};
13863
13864static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013865 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013866 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13867 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13868 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013869 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013870 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013871 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013872 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13873 * Any other models that need this preset?
13874 */
13875 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013876 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13877 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013878 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13879 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13880 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13881 /* FIXME: the below seems conflict */
13882 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13883 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13884 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013885 {}
13886};
13887
13888static struct alc_config_preset alc861_presets[] = {
13889 [ALC861_3ST] = {
13890 .mixers = { alc861_3ST_mixer },
13891 .init_verbs = { alc861_threestack_init_verbs },
13892 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13893 .dac_nids = alc861_dac_nids,
13894 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13895 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013896 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013897 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13898 .adc_nids = alc861_adc_nids,
13899 .input_mux = &alc861_capture_source,
13900 },
13901 [ALC861_3ST_DIG] = {
13902 .mixers = { alc861_base_mixer },
13903 .init_verbs = { alc861_threestack_init_verbs },
13904 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13905 .dac_nids = alc861_dac_nids,
13906 .dig_out_nid = ALC861_DIGOUT_NID,
13907 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13908 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013909 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013910 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13911 .adc_nids = alc861_adc_nids,
13912 .input_mux = &alc861_capture_source,
13913 },
13914 [ALC861_6ST_DIG] = {
13915 .mixers = { alc861_base_mixer },
13916 .init_verbs = { alc861_base_init_verbs },
13917 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13918 .dac_nids = alc861_dac_nids,
13919 .dig_out_nid = ALC861_DIGOUT_NID,
13920 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13921 .channel_mode = alc861_8ch_modes,
13922 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13923 .adc_nids = alc861_adc_nids,
13924 .input_mux = &alc861_capture_source,
13925 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013926 [ALC660_3ST] = {
13927 .mixers = { alc861_3ST_mixer },
13928 .init_verbs = { alc861_threestack_init_verbs },
13929 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13930 .dac_nids = alc660_dac_nids,
13931 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13932 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013933 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013934 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13935 .adc_nids = alc861_adc_nids,
13936 .input_mux = &alc861_capture_source,
13937 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013938 [ALC861_UNIWILL_M31] = {
13939 .mixers = { alc861_uniwill_m31_mixer },
13940 .init_verbs = { alc861_uniwill_m31_init_verbs },
13941 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13942 .dac_nids = alc861_dac_nids,
13943 .dig_out_nid = ALC861_DIGOUT_NID,
13944 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13945 .channel_mode = alc861_uniwill_m31_modes,
13946 .need_dac_fix = 1,
13947 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13948 .adc_nids = alc861_adc_nids,
13949 .input_mux = &alc861_capture_source,
13950 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013951 [ALC861_TOSHIBA] = {
13952 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013953 .init_verbs = { alc861_base_init_verbs,
13954 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013955 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13956 .dac_nids = alc861_dac_nids,
13957 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13958 .channel_mode = alc883_3ST_2ch_modes,
13959 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13960 .adc_nids = alc861_adc_nids,
13961 .input_mux = &alc861_capture_source,
13962 .unsol_event = alc861_toshiba_unsol_event,
13963 .init_hook = alc861_toshiba_automute,
13964 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013965 [ALC861_ASUS] = {
13966 .mixers = { alc861_asus_mixer },
13967 .init_verbs = { alc861_asus_init_verbs },
13968 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13969 .dac_nids = alc861_dac_nids,
13970 .dig_out_nid = ALC861_DIGOUT_NID,
13971 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13972 .channel_mode = alc861_asus_modes,
13973 .need_dac_fix = 1,
13974 .hp_nid = 0x06,
13975 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13976 .adc_nids = alc861_adc_nids,
13977 .input_mux = &alc861_capture_source,
13978 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013979 [ALC861_ASUS_LAPTOP] = {
13980 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13981 .init_verbs = { alc861_asus_init_verbs,
13982 alc861_asus_laptop_init_verbs },
13983 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13984 .dac_nids = alc861_dac_nids,
13985 .dig_out_nid = ALC861_DIGOUT_NID,
13986 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13987 .channel_mode = alc883_3ST_2ch_modes,
13988 .need_dac_fix = 1,
13989 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13990 .adc_nids = alc861_adc_nids,
13991 .input_mux = &alc861_capture_source,
13992 },
13993};
Kailang Yangdf694da2005-12-05 19:42:22 +010013994
13995
13996static int patch_alc861(struct hda_codec *codec)
13997{
13998 struct alc_spec *spec;
13999 int board_config;
14000 int err;
14001
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014002 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014003 if (spec == NULL)
14004 return -ENOMEM;
14005
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014006 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014007
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014008 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14009 alc861_models,
14010 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014011
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014012 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014013 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14014 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014015 board_config = ALC861_AUTO;
14016 }
14017
14018 if (board_config == ALC861_AUTO) {
14019 /* automatic parse from the BIOS config */
14020 err = alc861_parse_auto_config(codec);
14021 if (err < 0) {
14022 alc_free(codec);
14023 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014024 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014025 printk(KERN_INFO
14026 "hda_codec: Cannot set up configuration "
14027 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014028 board_config = ALC861_3ST_DIG;
14029 }
14030 }
14031
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014032 err = snd_hda_attach_beep_device(codec, 0x23);
14033 if (err < 0) {
14034 alc_free(codec);
14035 return err;
14036 }
14037
Kailang Yangdf694da2005-12-05 19:42:22 +010014038 if (board_config != ALC861_AUTO)
14039 setup_preset(spec, &alc861_presets[board_config]);
14040
14041 spec->stream_name_analog = "ALC861 Analog";
14042 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14043 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14044
14045 spec->stream_name_digital = "ALC861 Digital";
14046 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14047 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14048
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014049 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14050
Takashi Iwai2134ea42008-01-10 16:53:55 +010014051 spec->vmaster_nid = 0x03;
14052
Kailang Yangdf694da2005-12-05 19:42:22 +010014053 codec->patch_ops = alc_patch_ops;
14054 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014055 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014056#ifdef CONFIG_SND_HDA_POWER_SAVE
14057 if (!spec->loopback.amplist)
14058 spec->loopback.amplist = alc861_loopbacks;
14059#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014060 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014061
Kailang Yangdf694da2005-12-05 19:42:22 +010014062 return 0;
14063}
14064
14065/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014066 * ALC861-VD support
14067 *
14068 * Based on ALC882
14069 *
14070 * In addition, an independent DAC
14071 */
14072#define ALC861VD_DIGOUT_NID 0x06
14073
14074static hda_nid_t alc861vd_dac_nids[4] = {
14075 /* front, surr, clfe, side surr */
14076 0x02, 0x03, 0x04, 0x05
14077};
14078
14079/* dac_nids for ALC660vd are in a different order - according to
14080 * Realtek's driver.
14081 * This should probably tesult in a different mixer for 6stack models
14082 * of ALC660vd codecs, but for now there is only 3stack mixer
14083 * - and it is the same as in 861vd.
14084 * adc_nids in ALC660vd are (is) the same as in 861vd
14085 */
14086static hda_nid_t alc660vd_dac_nids[3] = {
14087 /* front, rear, clfe, rear_surr */
14088 0x02, 0x04, 0x03
14089};
14090
14091static hda_nid_t alc861vd_adc_nids[1] = {
14092 /* ADC0 */
14093 0x09,
14094};
14095
Takashi Iwaie1406342008-02-11 18:32:32 +010014096static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14097
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014098/* input MUX */
14099/* FIXME: should be a matrix-type input source selection */
14100static struct hda_input_mux alc861vd_capture_source = {
14101 .num_items = 4,
14102 .items = {
14103 { "Mic", 0x0 },
14104 { "Front Mic", 0x1 },
14105 { "Line", 0x2 },
14106 { "CD", 0x4 },
14107 },
14108};
14109
Kailang Yang272a5272007-05-14 11:00:38 +020014110static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014111 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014112 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014113 { "Ext Mic", 0x0 },
14114 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014115 },
14116};
14117
Kailang Yangd1a991a2007-08-15 16:21:59 +020014118static struct hda_input_mux alc861vd_hp_capture_source = {
14119 .num_items = 2,
14120 .items = {
14121 { "Front Mic", 0x0 },
14122 { "ATAPI Mic", 0x1 },
14123 },
14124};
14125
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014126/*
14127 * 2ch mode
14128 */
14129static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14130 { 2, NULL }
14131};
14132
14133/*
14134 * 6ch mode
14135 */
14136static struct hda_verb alc861vd_6stack_ch6_init[] = {
14137 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14138 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14139 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14140 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14141 { } /* end */
14142};
14143
14144/*
14145 * 8ch mode
14146 */
14147static struct hda_verb alc861vd_6stack_ch8_init[] = {
14148 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14149 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14150 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14151 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14152 { } /* end */
14153};
14154
14155static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14156 { 6, alc861vd_6stack_ch6_init },
14157 { 8, alc861vd_6stack_ch8_init },
14158};
14159
14160static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14161 {
14162 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14163 .name = "Channel Mode",
14164 .info = alc_ch_mode_info,
14165 .get = alc_ch_mode_get,
14166 .put = alc_ch_mode_put,
14167 },
14168 { } /* end */
14169};
14170
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014171/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14172 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14173 */
14174static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14175 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14176 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14177
14178 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14179 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14180
14181 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14182 HDA_OUTPUT),
14183 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14184 HDA_OUTPUT),
14185 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14186 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14187
14188 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14189 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14190
14191 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14192
14193 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14194 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14195 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14196
14197 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14198 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14199 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14200
14201 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14202 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14203
14204 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14205 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14206
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014207 { } /* end */
14208};
14209
14210static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14211 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14212 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14213
14214 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14215
14216 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14217 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14218 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14219
14220 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14221 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14222 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14223
14224 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14225 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14226
14227 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14228 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14229
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014230 { } /* end */
14231};
14232
Kailang Yangbdd148a2007-05-08 15:19:08 +020014233static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14234 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14235 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14236 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14237
14238 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14239
14240 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14241 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14242 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14243
14244 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14245 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14246 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14247
14248 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14249 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14250
14251 { } /* end */
14252};
14253
Tobin Davisb419f342008-03-07 11:57:51 +010014254/* Pin assignment: Speaker=0x14, HP = 0x15,
14255 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014256 */
14257static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014258 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14259 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014260 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14261 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014262 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14263 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14264 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14265 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14266 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14267 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014268 { } /* end */
14269};
14270
Kailang Yangd1a991a2007-08-15 16:21:59 +020014271/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14272 * Front Mic=0x18, ATAPI Mic = 0x19,
14273 */
14274static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14275 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14276 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14277 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14278 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14279 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14280 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14281 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14282 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014283
Kailang Yangd1a991a2007-08-15 16:21:59 +020014284 { } /* end */
14285};
14286
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014287/*
14288 * generic initialization of ADC, input mixers and output mixers
14289 */
14290static struct hda_verb alc861vd_volume_init_verbs[] = {
14291 /*
14292 * Unmute ADC0 and set the default input to mic-in
14293 */
14294 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14295 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14296
14297 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14298 * the analog-loopback mixer widget
14299 */
14300 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014301 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14302 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14303 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14304 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14305 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014306
14307 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014308 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14309 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14310 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014312
14313 /*
14314 * Set up output mixers (0x02 - 0x05)
14315 */
14316 /* set vol=0 to output mixers */
14317 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14318 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14319 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14320 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14321
14322 /* set up input amps for analog loopback */
14323 /* Amp Indices: DAC = 0, mixer = 1 */
14324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14327 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14328 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14329 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14330 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14331 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14332
14333 { }
14334};
14335
14336/*
14337 * 3-stack pin configuration:
14338 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14339 */
14340static struct hda_verb alc861vd_3stack_init_verbs[] = {
14341 /*
14342 * Set pin mode and muting
14343 */
14344 /* set front pin widgets 0x14 for output */
14345 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14346 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14347 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14348
14349 /* Mic (rear) pin: input vref at 80% */
14350 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14351 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14352 /* Front Mic pin: input vref at 80% */
14353 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14354 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14355 /* Line In pin: input */
14356 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14357 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14358 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14359 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14360 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14361 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14362 /* CD pin widget for input */
14363 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14364
14365 { }
14366};
14367
14368/*
14369 * 6-stack pin configuration:
14370 */
14371static struct hda_verb alc861vd_6stack_init_verbs[] = {
14372 /*
14373 * Set pin mode and muting
14374 */
14375 /* set front pin widgets 0x14 for output */
14376 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14377 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14378 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14379
14380 /* Rear Pin: output 1 (0x0d) */
14381 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14382 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14383 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14384 /* CLFE Pin: output 2 (0x0e) */
14385 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14386 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14387 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14388 /* Side Pin: output 3 (0x0f) */
14389 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14390 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14391 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14392
14393 /* Mic (rear) pin: input vref at 80% */
14394 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14395 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14396 /* Front Mic pin: input vref at 80% */
14397 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14398 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14399 /* Line In pin: input */
14400 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14401 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14402 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14403 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14404 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14405 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14406 /* CD pin widget for input */
14407 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14408
14409 { }
14410};
14411
Kailang Yangbdd148a2007-05-08 15:19:08 +020014412static struct hda_verb alc861vd_eapd_verbs[] = {
14413 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14414 { }
14415};
14416
Kailang Yangf9423e72008-05-27 12:32:25 +020014417static struct hda_verb alc660vd_eapd_verbs[] = {
14418 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14419 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14420 { }
14421};
14422
Kailang Yangbdd148a2007-05-08 15:19:08 +020014423static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14424 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14426 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14427 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014428 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014429 {}
14430};
14431
14432/* toggle speaker-output according to the hp-jack state */
14433static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14434{
14435 unsigned int present;
14436 unsigned char bits;
14437
14438 present = snd_hda_codec_read(codec, 0x1b, 0,
14439 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014440 bits = present ? HDA_AMP_MUTE : 0;
14441 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14442 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014443}
14444
14445static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14446{
14447 unsigned int present;
14448 unsigned char bits;
14449
14450 present = snd_hda_codec_read(codec, 0x18, 0,
14451 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014452 bits = present ? HDA_AMP_MUTE : 0;
14453 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14454 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014455}
14456
14457static void alc861vd_lenovo_automute(struct hda_codec *codec)
14458{
14459 alc861vd_lenovo_hp_automute(codec);
14460 alc861vd_lenovo_mic_automute(codec);
14461}
14462
14463static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14464 unsigned int res)
14465{
14466 switch (res >> 26) {
14467 case ALC880_HP_EVENT:
14468 alc861vd_lenovo_hp_automute(codec);
14469 break;
14470 case ALC880_MIC_EVENT:
14471 alc861vd_lenovo_mic_automute(codec);
14472 break;
14473 }
14474}
14475
Kailang Yang272a5272007-05-14 11:00:38 +020014476static struct hda_verb alc861vd_dallas_verbs[] = {
14477 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14478 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14479 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14480 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14481
14482 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14483 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14484 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14485 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14486 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14487 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14488 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14489 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014490
Kailang Yang272a5272007-05-14 11:00:38 +020014491 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14492 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14493 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14494 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14495 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14496 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14497 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14498 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14499
14500 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14501 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14502 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14503 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14504 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14505 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14506 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14507 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14508
14509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14510 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14512 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14513
14514 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014515 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014516 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14517
14518 { } /* end */
14519};
14520
14521/* toggle speaker-output according to the hp-jack state */
14522static void alc861vd_dallas_automute(struct hda_codec *codec)
14523{
14524 unsigned int present;
14525
14526 present = snd_hda_codec_read(codec, 0x15, 0,
14527 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014528 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14529 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014530}
14531
14532static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14533{
14534 if ((res >> 26) == ALC880_HP_EVENT)
14535 alc861vd_dallas_automute(codec);
14536}
14537
Takashi Iwaicb53c622007-08-10 17:21:45 +020014538#ifdef CONFIG_SND_HDA_POWER_SAVE
14539#define alc861vd_loopbacks alc880_loopbacks
14540#endif
14541
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014542/* pcm configuration: identiacal with ALC880 */
14543#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14544#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14545#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14546#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14547
14548/*
14549 * configuration and preset
14550 */
14551static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14552 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014553 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014554 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014555 [ALC861VD_3ST] = "3stack",
14556 [ALC861VD_3ST_DIG] = "3stack-digout",
14557 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014558 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014559 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014560 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014561 [ALC861VD_AUTO] = "auto",
14562};
14563
14564static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014565 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14566 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014567 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014568 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014569 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014570 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014571 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014572 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014573 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014574 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014575 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014576 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014577 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014578 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014579 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014580 {}
14581};
14582
14583static struct alc_config_preset alc861vd_presets[] = {
14584 [ALC660VD_3ST] = {
14585 .mixers = { alc861vd_3st_mixer },
14586 .init_verbs = { alc861vd_volume_init_verbs,
14587 alc861vd_3stack_init_verbs },
14588 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14589 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014590 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14591 .channel_mode = alc861vd_3stack_2ch_modes,
14592 .input_mux = &alc861vd_capture_source,
14593 },
Mike Crash6963f842007-06-25 12:12:51 +020014594 [ALC660VD_3ST_DIG] = {
14595 .mixers = { alc861vd_3st_mixer },
14596 .init_verbs = { alc861vd_volume_init_verbs,
14597 alc861vd_3stack_init_verbs },
14598 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14599 .dac_nids = alc660vd_dac_nids,
14600 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014601 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14602 .channel_mode = alc861vd_3stack_2ch_modes,
14603 .input_mux = &alc861vd_capture_source,
14604 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014605 [ALC861VD_3ST] = {
14606 .mixers = { alc861vd_3st_mixer },
14607 .init_verbs = { alc861vd_volume_init_verbs,
14608 alc861vd_3stack_init_verbs },
14609 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14610 .dac_nids = alc861vd_dac_nids,
14611 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14612 .channel_mode = alc861vd_3stack_2ch_modes,
14613 .input_mux = &alc861vd_capture_source,
14614 },
14615 [ALC861VD_3ST_DIG] = {
14616 .mixers = { alc861vd_3st_mixer },
14617 .init_verbs = { alc861vd_volume_init_verbs,
14618 alc861vd_3stack_init_verbs },
14619 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14620 .dac_nids = alc861vd_dac_nids,
14621 .dig_out_nid = ALC861VD_DIGOUT_NID,
14622 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14623 .channel_mode = alc861vd_3stack_2ch_modes,
14624 .input_mux = &alc861vd_capture_source,
14625 },
14626 [ALC861VD_6ST_DIG] = {
14627 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14628 .init_verbs = { alc861vd_volume_init_verbs,
14629 alc861vd_6stack_init_verbs },
14630 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14631 .dac_nids = alc861vd_dac_nids,
14632 .dig_out_nid = ALC861VD_DIGOUT_NID,
14633 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14634 .channel_mode = alc861vd_6stack_modes,
14635 .input_mux = &alc861vd_capture_source,
14636 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014637 [ALC861VD_LENOVO] = {
14638 .mixers = { alc861vd_lenovo_mixer },
14639 .init_verbs = { alc861vd_volume_init_verbs,
14640 alc861vd_3stack_init_verbs,
14641 alc861vd_eapd_verbs,
14642 alc861vd_lenovo_unsol_verbs },
14643 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14644 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014645 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14646 .channel_mode = alc861vd_3stack_2ch_modes,
14647 .input_mux = &alc861vd_capture_source,
14648 .unsol_event = alc861vd_lenovo_unsol_event,
14649 .init_hook = alc861vd_lenovo_automute,
14650 },
Kailang Yang272a5272007-05-14 11:00:38 +020014651 [ALC861VD_DALLAS] = {
14652 .mixers = { alc861vd_dallas_mixer },
14653 .init_verbs = { alc861vd_dallas_verbs },
14654 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14655 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014656 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14657 .channel_mode = alc861vd_3stack_2ch_modes,
14658 .input_mux = &alc861vd_dallas_capture_source,
14659 .unsol_event = alc861vd_dallas_unsol_event,
14660 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014661 },
14662 [ALC861VD_HP] = {
14663 .mixers = { alc861vd_hp_mixer },
14664 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14665 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14666 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014667 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014668 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14669 .channel_mode = alc861vd_3stack_2ch_modes,
14670 .input_mux = &alc861vd_hp_capture_source,
14671 .unsol_event = alc861vd_dallas_unsol_event,
14672 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014673 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014674 [ALC660VD_ASUS_V1S] = {
14675 .mixers = { alc861vd_lenovo_mixer },
14676 .init_verbs = { alc861vd_volume_init_verbs,
14677 alc861vd_3stack_init_verbs,
14678 alc861vd_eapd_verbs,
14679 alc861vd_lenovo_unsol_verbs },
14680 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14681 .dac_nids = alc660vd_dac_nids,
14682 .dig_out_nid = ALC861VD_DIGOUT_NID,
14683 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14684 .channel_mode = alc861vd_3stack_2ch_modes,
14685 .input_mux = &alc861vd_capture_source,
14686 .unsol_event = alc861vd_lenovo_unsol_event,
14687 .init_hook = alc861vd_lenovo_automute,
14688 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014689};
14690
14691/*
14692 * BIOS auto configuration
14693 */
14694static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14695 hda_nid_t nid, int pin_type, int dac_idx)
14696{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014697 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014698}
14699
14700static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14701{
14702 struct alc_spec *spec = codec->spec;
14703 int i;
14704
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014705 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014706 for (i = 0; i <= HDA_SIDE; i++) {
14707 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014708 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014709 if (nid)
14710 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014711 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014712 }
14713}
14714
14715
14716static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14717{
14718 struct alc_spec *spec = codec->spec;
14719 hda_nid_t pin;
14720
14721 pin = spec->autocfg.hp_pins[0];
14722 if (pin) /* connect to front and use dac 0 */
14723 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014724 pin = spec->autocfg.speaker_pins[0];
14725 if (pin)
14726 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014727}
14728
14729#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14730#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14731
14732static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14733{
14734 struct alc_spec *spec = codec->spec;
14735 int i;
14736
14737 for (i = 0; i < AUTO_PIN_LAST; i++) {
14738 hda_nid_t nid = spec->autocfg.input_pins[i];
14739 if (alc861vd_is_input_pin(nid)) {
14740 snd_hda_codec_write(codec, nid, 0,
14741 AC_VERB_SET_PIN_WIDGET_CONTROL,
14742 i <= AUTO_PIN_FRONT_MIC ?
14743 PIN_VREF80 : PIN_IN);
14744 if (nid != ALC861VD_PIN_CD_NID)
14745 snd_hda_codec_write(codec, nid, 0,
14746 AC_VERB_SET_AMP_GAIN_MUTE,
14747 AMP_OUT_MUTE);
14748 }
14749 }
14750}
14751
Takashi Iwaif511b012008-08-15 16:46:42 +020014752#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14753
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014754#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14755#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14756
14757/* add playback controls from the parsed DAC table */
14758/* Based on ALC880 version. But ALC861VD has separate,
14759 * different NIDs for mute/unmute switch and volume control */
14760static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14761 const struct auto_pin_cfg *cfg)
14762{
14763 char name[32];
14764 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14765 hda_nid_t nid_v, nid_s;
14766 int i, err;
14767
14768 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014769 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014770 continue;
14771 nid_v = alc861vd_idx_to_mixer_vol(
14772 alc880_dac_to_idx(
14773 spec->multiout.dac_nids[i]));
14774 nid_s = alc861vd_idx_to_mixer_switch(
14775 alc880_dac_to_idx(
14776 spec->multiout.dac_nids[i]));
14777
14778 if (i == 2) {
14779 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014780 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14781 "Center Playback Volume",
14782 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14783 HDA_OUTPUT));
14784 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014785 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014786 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14787 "LFE Playback Volume",
14788 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14789 HDA_OUTPUT));
14790 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014791 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014792 err = add_control(spec, ALC_CTL_BIND_MUTE,
14793 "Center Playback Switch",
14794 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14795 HDA_INPUT));
14796 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014797 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014798 err = add_control(spec, ALC_CTL_BIND_MUTE,
14799 "LFE Playback Switch",
14800 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14801 HDA_INPUT));
14802 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014803 return err;
14804 } else {
14805 sprintf(name, "%s Playback Volume", chname[i]);
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,
14808 HDA_OUTPUT));
14809 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014810 return err;
14811 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014812 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014813 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014814 HDA_INPUT));
14815 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014816 return err;
14817 }
14818 }
14819 return 0;
14820}
14821
14822/* add playback controls for speaker and HP outputs */
14823/* Based on ALC880 version. But ALC861VD has separate,
14824 * different NIDs for mute/unmute switch and volume control */
14825static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14826 hda_nid_t pin, const char *pfx)
14827{
14828 hda_nid_t nid_v, nid_s;
14829 int err;
14830 char name[32];
14831
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014832 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014833 return 0;
14834
14835 if (alc880_is_fixed_pin(pin)) {
14836 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14837 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014838 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014839 spec->multiout.hp_nid = nid_v;
14840 else
14841 spec->multiout.extra_out_nid[0] = nid_v;
14842 /* control HP volume/switch on the output mixer amp */
14843 nid_v = alc861vd_idx_to_mixer_vol(
14844 alc880_fixed_pin_idx(pin));
14845 nid_s = alc861vd_idx_to_mixer_switch(
14846 alc880_fixed_pin_idx(pin));
14847
14848 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014849 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14850 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14851 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014852 return err;
14853 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014854 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14855 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14856 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014857 return err;
14858 } else if (alc880_is_multi_pin(pin)) {
14859 /* set manual connection */
14860 /* we have only a switch on HP-out PIN */
14861 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014862 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14863 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14864 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014865 return err;
14866 }
14867 return 0;
14868}
14869
14870/* parse the BIOS configuration and set up the alc_spec
14871 * return 1 if successful, 0 if the proper config is not found,
14872 * or a negative error code
14873 * Based on ALC880 version - had to change it to override
14874 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14875static int alc861vd_parse_auto_config(struct hda_codec *codec)
14876{
14877 struct alc_spec *spec = codec->spec;
14878 int err;
14879 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14880
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014881 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14882 alc861vd_ignore);
14883 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014884 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014885 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014886 return 0; /* can't find valid BIOS pin config */
14887
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014888 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14889 if (err < 0)
14890 return err;
14891 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14892 if (err < 0)
14893 return err;
14894 err = alc861vd_auto_create_extra_out(spec,
14895 spec->autocfg.speaker_pins[0],
14896 "Speaker");
14897 if (err < 0)
14898 return err;
14899 err = alc861vd_auto_create_extra_out(spec,
14900 spec->autocfg.hp_pins[0],
14901 "Headphone");
14902 if (err < 0)
14903 return err;
14904 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14905 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014906 return err;
14907
14908 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14909
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014910 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014911 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14912
Takashi Iwai603c4012008-07-30 15:01:44 +020014913 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014914 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014915
Takashi Iwaid88897e2008-10-31 15:01:37 +010014916 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014917
14918 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014919 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014920
Takashi Iwai776e1842007-08-29 15:07:11 +020014921 err = alc_auto_add_mic_boost(codec);
14922 if (err < 0)
14923 return err;
14924
Takashi Iwaie044c392008-10-27 16:56:24 +010014925 store_pin_configs(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014926 return 1;
14927}
14928
14929/* additional initialization for auto-configuration model */
14930static void alc861vd_auto_init(struct hda_codec *codec)
14931{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014932 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014933 alc861vd_auto_init_multi_out(codec);
14934 alc861vd_auto_init_hp_out(codec);
14935 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014936 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014937 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014938 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014939}
14940
14941static int patch_alc861vd(struct hda_codec *codec)
14942{
14943 struct alc_spec *spec;
14944 int err, board_config;
14945
14946 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14947 if (spec == NULL)
14948 return -ENOMEM;
14949
14950 codec->spec = spec;
14951
14952 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14953 alc861vd_models,
14954 alc861vd_cfg_tbl);
14955
14956 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14957 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14958 "ALC861VD, trying auto-probe from BIOS...\n");
14959 board_config = ALC861VD_AUTO;
14960 }
14961
14962 if (board_config == ALC861VD_AUTO) {
14963 /* automatic parse from the BIOS config */
14964 err = alc861vd_parse_auto_config(codec);
14965 if (err < 0) {
14966 alc_free(codec);
14967 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014968 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014969 printk(KERN_INFO
14970 "hda_codec: Cannot set up configuration "
14971 "from BIOS. Using base mode...\n");
14972 board_config = ALC861VD_3ST;
14973 }
14974 }
14975
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014976 err = snd_hda_attach_beep_device(codec, 0x23);
14977 if (err < 0) {
14978 alc_free(codec);
14979 return err;
14980 }
14981
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014982 if (board_config != ALC861VD_AUTO)
14983 setup_preset(spec, &alc861vd_presets[board_config]);
14984
Kailang Yang2f893282008-05-27 12:14:47 +020014985 if (codec->vendor_id == 0x10ec0660) {
14986 spec->stream_name_analog = "ALC660-VD Analog";
14987 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014988 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010014989 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020014990 } else {
14991 spec->stream_name_analog = "ALC861VD Analog";
14992 spec->stream_name_digital = "ALC861VD Digital";
14993 }
14994
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014995 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14996 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14997
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014998 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14999 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15000
15001 spec->adc_nids = alc861vd_adc_nids;
15002 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015003 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015004 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015005
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015006 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015007 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015008
Takashi Iwai2134ea42008-01-10 16:53:55 +010015009 spec->vmaster_nid = 0x02;
15010
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015011 codec->patch_ops = alc_patch_ops;
15012
15013 if (board_config == ALC861VD_AUTO)
15014 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015015#ifdef CONFIG_SND_HDA_POWER_SAVE
15016 if (!spec->loopback.amplist)
15017 spec->loopback.amplist = alc861vd_loopbacks;
15018#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015019 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015020
15021 return 0;
15022}
15023
15024/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015025 * ALC662 support
15026 *
15027 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15028 * configuration. Each pin widget can choose any input DACs and a mixer.
15029 * Each ADC is connected from a mixer of all inputs. This makes possible
15030 * 6-channel independent captures.
15031 *
15032 * In addition, an independent DAC for the multi-playback (not used in this
15033 * driver yet).
15034 */
15035#define ALC662_DIGOUT_NID 0x06
15036#define ALC662_DIGIN_NID 0x0a
15037
15038static hda_nid_t alc662_dac_nids[4] = {
15039 /* front, rear, clfe, rear_surr */
15040 0x02, 0x03, 0x04
15041};
15042
15043static hda_nid_t alc662_adc_nids[1] = {
15044 /* ADC1-2 */
15045 0x09,
15046};
Takashi Iwaie1406342008-02-11 18:32:32 +010015047
Kailang Yang77a261b2008-02-19 11:38:05 +010015048static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010015049
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015050/* input MUX */
15051/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015052static struct hda_input_mux alc662_capture_source = {
15053 .num_items = 4,
15054 .items = {
15055 { "Mic", 0x0 },
15056 { "Front Mic", 0x1 },
15057 { "Line", 0x2 },
15058 { "CD", 0x4 },
15059 },
15060};
15061
15062static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15063 .num_items = 2,
15064 .items = {
15065 { "Mic", 0x1 },
15066 { "Line", 0x2 },
15067 },
15068};
Kailang Yang291702f2007-10-16 14:28:03 +020015069
15070static struct hda_input_mux alc662_eeepc_capture_source = {
15071 .num_items = 2,
15072 .items = {
15073 { "i-Mic", 0x1 },
15074 { "e-Mic", 0x0 },
15075 },
15076};
15077
Kailang Yang6dda9f42008-05-27 12:05:31 +020015078static struct hda_input_mux alc663_capture_source = {
15079 .num_items = 3,
15080 .items = {
15081 { "Mic", 0x0 },
15082 { "Front Mic", 0x1 },
15083 { "Line", 0x2 },
15084 },
15085};
15086
15087static struct hda_input_mux alc663_m51va_capture_source = {
15088 .num_items = 2,
15089 .items = {
15090 { "Ext-Mic", 0x0 },
15091 { "D-Mic", 0x9 },
15092 },
15093};
15094
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015095/*
15096 * 2ch mode
15097 */
15098static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15099 { 2, NULL }
15100};
15101
15102/*
15103 * 2ch mode
15104 */
15105static struct hda_verb alc662_3ST_ch2_init[] = {
15106 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15107 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15108 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15109 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15110 { } /* end */
15111};
15112
15113/*
15114 * 6ch mode
15115 */
15116static struct hda_verb alc662_3ST_ch6_init[] = {
15117 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15118 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15119 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15120 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15121 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15122 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15123 { } /* end */
15124};
15125
15126static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15127 { 2, alc662_3ST_ch2_init },
15128 { 6, alc662_3ST_ch6_init },
15129};
15130
15131/*
15132 * 2ch mode
15133 */
15134static struct hda_verb alc662_sixstack_ch6_init[] = {
15135 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15136 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15137 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15138 { } /* end */
15139};
15140
15141/*
15142 * 6ch mode
15143 */
15144static struct hda_verb alc662_sixstack_ch8_init[] = {
15145 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15146 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15147 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15148 { } /* end */
15149};
15150
15151static struct hda_channel_mode alc662_5stack_modes[2] = {
15152 { 2, alc662_sixstack_ch6_init },
15153 { 6, alc662_sixstack_ch8_init },
15154};
15155
15156/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15157 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15158 */
15159
15160static struct snd_kcontrol_new alc662_base_mixer[] = {
15161 /* output mixer control */
15162 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015163 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015164 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015165 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015166 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15167 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015168 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15169 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015170 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15171
15172 /*Input mixer control */
15173 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15174 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15175 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15176 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15177 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15178 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15179 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15180 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015181 { } /* end */
15182};
15183
15184static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15185 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015186 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15188 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15189 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15190 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15191 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15193 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15194 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15195 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015196 { } /* end */
15197};
15198
15199static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15200 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015201 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015202 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015203 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015204 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15205 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015206 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15207 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015208 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15209 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15210 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15211 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15212 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15213 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15214 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15215 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15216 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015217 { } /* end */
15218};
15219
15220static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15221 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15222 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015223 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15224 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015225 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15226 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15227 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15229 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015230 { } /* end */
15231};
15232
Kailang Yang291702f2007-10-16 14:28:03 +020015233static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015234 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015235
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015236 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15237 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015238
15239 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15240 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15241 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15242
15243 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15244 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15245 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15246 { } /* end */
15247};
15248
Kailang Yang8c427222008-01-10 13:03:59 +010015249static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015250 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15251 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015252 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15253 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15254 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15255 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15256 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15257 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015258 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015259 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15260 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15261 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15263 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15264 { } /* end */
15265};
15266
Kailang Yangf1d4e282008-08-26 14:03:29 +020015267static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15268 .ops = &snd_hda_bind_vol,
15269 .values = {
15270 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15271 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15272 0
15273 },
15274};
15275
15276static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15277 .ops = &snd_hda_bind_sw,
15278 .values = {
15279 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15280 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15281 0
15282 },
15283};
15284
Kailang Yang6dda9f42008-05-27 12:05:31 +020015285static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015286 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15287 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15289 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15290 { } /* end */
15291};
15292
15293static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15294 .ops = &snd_hda_bind_sw,
15295 .values = {
15296 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15297 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15298 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15299 0
15300 },
15301};
15302
15303static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15304 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15305 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15306 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15307 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15308 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15309 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15310
15311 { } /* end */
15312};
15313
15314static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15315 .ops = &snd_hda_bind_sw,
15316 .values = {
15317 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15318 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15319 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15320 0
15321 },
15322};
15323
15324static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15325 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15326 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15327 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15328 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15329 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15330 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15331 { } /* end */
15332};
15333
15334static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015335 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15336 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015337 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15338 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15339 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15340 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15341 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15342 { } /* end */
15343};
15344
15345static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15346 .ops = &snd_hda_bind_vol,
15347 .values = {
15348 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15349 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15350 0
15351 },
15352};
15353
15354static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15355 .ops = &snd_hda_bind_sw,
15356 .values = {
15357 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15358 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15359 0
15360 },
15361};
15362
15363static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15364 HDA_BIND_VOL("Master Playback Volume",
15365 &alc663_asus_two_bind_master_vol),
15366 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15367 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015368 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15369 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15370 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015371 { } /* end */
15372};
15373
15374static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15375 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15376 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15377 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15378 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15379 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15380 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015381 { } /* end */
15382};
15383
15384static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15385 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15386 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15387 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15388 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15389 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15390
15391 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15392 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15393 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15394 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15395 { } /* end */
15396};
15397
15398static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15399 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15400 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15401 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15402
15403 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15404 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15405 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15406 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15407 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15408 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15409 { } /* end */
15410};
15411
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015412static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15413 {
15414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15415 .name = "Channel Mode",
15416 .info = alc_ch_mode_info,
15417 .get = alc_ch_mode_get,
15418 .put = alc_ch_mode_put,
15419 },
15420 { } /* end */
15421};
15422
15423static struct hda_verb alc662_init_verbs[] = {
15424 /* ADC: mute amp left and right */
15425 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15426 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15427 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15428
Takashi Iwaicb53c622007-08-10 17:21:45 +020015429 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15430 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15431 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15432 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15433 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015434
Kailang Yangb60dd392007-09-20 12:50:29 +020015435 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15437 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15438 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15440 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015441
15442 /* Front Pin: output 0 (0x0c) */
15443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15445
15446 /* Rear Pin: output 1 (0x0d) */
15447 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15449
15450 /* CLFE Pin: output 2 (0x0e) */
15451 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15452 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15453
15454 /* Mic (rear) pin: input vref at 80% */
15455 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15456 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15457 /* Front Mic pin: input vref at 80% */
15458 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15459 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15460 /* Line In pin: input */
15461 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15463 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15464 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15465 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15466 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15467 /* CD pin widget for input */
15468 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15469
15470 /* FIXME: use matrix-type input source selection */
15471 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15472 /* Input mixer */
15473 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15474 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15475 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15476 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015477
15478 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15479 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15480 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15481 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015482
15483 /* always trun on EAPD */
15484 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15485 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15486
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015487 { }
15488};
15489
15490static struct hda_verb alc662_sue_init_verbs[] = {
15491 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15492 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015493 {}
15494};
15495
15496static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15497 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15498 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15499 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015500};
15501
Kailang Yang8c427222008-01-10 13:03:59 +010015502/* Set Unsolicited Event*/
15503static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15504 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15505 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15506 {}
15507};
15508
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015509/*
15510 * generic initialization of ADC, input mixers and output mixers
15511 */
15512static struct hda_verb alc662_auto_init_verbs[] = {
15513 /*
15514 * Unmute ADC and set the default input to mic-in
15515 */
15516 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15517 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15518
15519 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15520 * mixer widget
15521 * Note: PASD motherboards uses the Line In 2 as the input for front
15522 * panel mic (mic 2)
15523 */
15524 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015525 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15526 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15527 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15528 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15529 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015530
15531 /*
15532 * Set up output mixers (0x0c - 0x0f)
15533 */
15534 /* set vol=0 to output mixers */
15535 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15536 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15537 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15538
15539 /* set up input amps for analog loopback */
15540 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015541 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15542 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15543 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15544 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15545 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15546 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015547
15548
15549 /* FIXME: use matrix-type input source selection */
15550 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15551 /* Input mixer */
15552 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015553 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015554 { }
15555};
15556
Takashi Iwai24fb9172008-09-02 14:48:20 +020015557/* additional verbs for ALC663 */
15558static struct hda_verb alc663_auto_init_verbs[] = {
15559 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15560 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15561 { }
15562};
15563
Kailang Yang6dda9f42008-05-27 12:05:31 +020015564static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015565 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15566 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015567 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15568 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015569 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15570 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015572 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15573 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15574 {}
15575};
15576
Kailang Yangf1d4e282008-08-26 14:03:29 +020015577static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15578 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15579 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15580 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15581 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15582 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15583 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15584 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15585 {}
15586};
15587
15588static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15589 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15590 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15591 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15592 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15593 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15595 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15596 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15597 {}
15598};
15599
15600static struct hda_verb alc663_15jd_amic_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 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15605 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15606 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15607 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15608 {}
15609};
15610
15611static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15612 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15613 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15614 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15615 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15616 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15617 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15618 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15621 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15622 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15623 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15624 {}
15625};
15626
15627static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15628 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15629 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15630 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15631 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15632 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15633 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15634 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15635 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15636 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15637 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15638 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15639 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15640 {}
15641};
15642
Kailang Yang6dda9f42008-05-27 12:05:31 +020015643static struct hda_verb alc663_g71v_init_verbs[] = {
15644 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15645 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15646 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15647
15648 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15649 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15650 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15651
15652 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15653 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15654 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15655 {}
15656};
15657
15658static struct hda_verb alc663_g50v_init_verbs[] = {
15659 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15660 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15661 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15662
15663 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15664 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15665 {}
15666};
15667
Kailang Yangf1d4e282008-08-26 14:03:29 +020015668static struct hda_verb alc662_ecs_init_verbs[] = {
15669 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15671 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15672 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15673 {}
15674};
15675
Kailang Yangf1d4e282008-08-26 14:03:29 +020015676static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15677 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15678 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15679 { } /* end */
15680};
15681
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015682static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15683{
15684 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015685 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015686
15687 present = snd_hda_codec_read(codec, 0x14, 0,
15688 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015689 bits = present ? HDA_AMP_MUTE : 0;
15690 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15691 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015692}
15693
15694static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15695{
15696 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015697 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015698
15699 present = snd_hda_codec_read(codec, 0x1b, 0,
15700 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015701 bits = present ? HDA_AMP_MUTE : 0;
15702 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15703 HDA_AMP_MUTE, bits);
15704 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15705 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015706}
15707
15708static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15709 unsigned int res)
15710{
15711 if ((res >> 26) == ALC880_HP_EVENT)
15712 alc662_lenovo_101e_all_automute(codec);
15713 if ((res >> 26) == ALC880_FRONT_EVENT)
15714 alc662_lenovo_101e_ispeaker_automute(codec);
15715}
15716
Kailang Yang291702f2007-10-16 14:28:03 +020015717static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15718{
15719 unsigned int present;
15720
15721 present = snd_hda_codec_read(codec, 0x18, 0,
15722 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15723 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15724 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15725 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15726 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15727 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15728 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15729 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15730 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15731}
15732
15733/* unsolicited event for HP jack sensing */
15734static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15735 unsigned int res)
15736{
15737 if ((res >> 26) == ALC880_HP_EVENT)
15738 alc262_hippo1_automute( codec );
15739
15740 if ((res >> 26) == ALC880_MIC_EVENT)
15741 alc662_eeepc_mic_automute(codec);
15742}
15743
15744static void alc662_eeepc_inithook(struct hda_codec *codec)
15745{
15746 alc262_hippo1_automute( codec );
15747 alc662_eeepc_mic_automute(codec);
15748}
15749
Kailang Yang8c427222008-01-10 13:03:59 +010015750static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15751{
15752 unsigned int mute;
15753 unsigned int present;
15754
15755 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15756 present = snd_hda_codec_read(codec, 0x14, 0,
15757 AC_VERB_GET_PIN_SENSE, 0);
15758 present = (present & 0x80000000) != 0;
15759 if (present) {
15760 /* mute internal speaker */
15761 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015762 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015763 } else {
15764 /* unmute internal speaker if necessary */
15765 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15766 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015767 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015768 }
15769}
15770
15771/* unsolicited event for HP jack sensing */
15772static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15773 unsigned int res)
15774{
15775 if ((res >> 26) == ALC880_HP_EVENT)
15776 alc662_eeepc_ep20_automute(codec);
15777}
15778
15779static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15780{
15781 alc662_eeepc_ep20_automute(codec);
15782}
15783
Kailang Yang6dda9f42008-05-27 12:05:31 +020015784static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15785{
15786 unsigned int present;
15787 unsigned char bits;
15788
15789 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015790 AC_VERB_GET_PIN_SENSE, 0)
15791 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015792 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015793 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15794 AMP_IN_MUTE(0), bits);
15795 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15796 AMP_IN_MUTE(0), bits);
15797}
15798
15799static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15800{
15801 unsigned int present;
15802 unsigned char bits;
15803
15804 present = snd_hda_codec_read(codec, 0x21, 0,
15805 AC_VERB_GET_PIN_SENSE, 0)
15806 & AC_PINSENSE_PRESENCE;
15807 bits = present ? HDA_AMP_MUTE : 0;
15808 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15809 AMP_IN_MUTE(0), bits);
15810 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15811 AMP_IN_MUTE(0), bits);
15812 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15813 AMP_IN_MUTE(0), bits);
15814 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15815 AMP_IN_MUTE(0), bits);
15816}
15817
15818static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15819{
15820 unsigned int present;
15821 unsigned char bits;
15822
15823 present = snd_hda_codec_read(codec, 0x15, 0,
15824 AC_VERB_GET_PIN_SENSE, 0)
15825 & AC_PINSENSE_PRESENCE;
15826 bits = present ? HDA_AMP_MUTE : 0;
15827 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15828 AMP_IN_MUTE(0), bits);
15829 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15830 AMP_IN_MUTE(0), bits);
15831 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15832 AMP_IN_MUTE(0), bits);
15833 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15834 AMP_IN_MUTE(0), bits);
15835}
15836
15837static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15838{
15839 unsigned int present;
15840 unsigned char bits;
15841
15842 present = snd_hda_codec_read(codec, 0x1b, 0,
15843 AC_VERB_GET_PIN_SENSE, 0)
15844 & AC_PINSENSE_PRESENCE;
15845 bits = present ? 0 : PIN_OUT;
15846 snd_hda_codec_write(codec, 0x14, 0,
15847 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15848}
15849
15850static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15851{
15852 unsigned int present1, present2;
15853
15854 present1 = snd_hda_codec_read(codec, 0x21, 0,
15855 AC_VERB_GET_PIN_SENSE, 0)
15856 & AC_PINSENSE_PRESENCE;
15857 present2 = snd_hda_codec_read(codec, 0x15, 0,
15858 AC_VERB_GET_PIN_SENSE, 0)
15859 & AC_PINSENSE_PRESENCE;
15860
15861 if (present1 || present2) {
15862 snd_hda_codec_write_cache(codec, 0x14, 0,
15863 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15864 } else {
15865 snd_hda_codec_write_cache(codec, 0x14, 0,
15866 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15867 }
15868}
15869
15870static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15871{
15872 unsigned int present1, present2;
15873
15874 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15875 AC_VERB_GET_PIN_SENSE, 0)
15876 & AC_PINSENSE_PRESENCE;
15877 present2 = snd_hda_codec_read(codec, 0x15, 0,
15878 AC_VERB_GET_PIN_SENSE, 0)
15879 & AC_PINSENSE_PRESENCE;
15880
15881 if (present1 || present2) {
15882 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15883 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15884 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15885 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15886 } else {
15887 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15888 AMP_IN_MUTE(0), 0);
15889 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15890 AMP_IN_MUTE(0), 0);
15891 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015892}
15893
15894static void alc663_m51va_mic_automute(struct hda_codec *codec)
15895{
15896 unsigned int present;
15897
15898 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015899 AC_VERB_GET_PIN_SENSE, 0)
15900 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015901 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015902 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015903 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015904 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015905 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015906 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015907 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015908 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015909}
15910
15911static void alc663_m51va_unsol_event(struct hda_codec *codec,
15912 unsigned int res)
15913{
15914 switch (res >> 26) {
15915 case ALC880_HP_EVENT:
15916 alc663_m51va_speaker_automute(codec);
15917 break;
15918 case ALC880_MIC_EVENT:
15919 alc663_m51va_mic_automute(codec);
15920 break;
15921 }
15922}
15923
15924static void alc663_m51va_inithook(struct hda_codec *codec)
15925{
15926 alc663_m51va_speaker_automute(codec);
15927 alc663_m51va_mic_automute(codec);
15928}
15929
Kailang Yangf1d4e282008-08-26 14:03:29 +020015930/* ***************** Mode1 ******************************/
15931static void alc663_mode1_unsol_event(struct hda_codec *codec,
15932 unsigned int res)
15933{
15934 switch (res >> 26) {
15935 case ALC880_HP_EVENT:
15936 alc663_m51va_speaker_automute(codec);
15937 break;
15938 case ALC880_MIC_EVENT:
15939 alc662_eeepc_mic_automute(codec);
15940 break;
15941 }
15942}
15943
15944static void alc663_mode1_inithook(struct hda_codec *codec)
15945{
15946 alc663_m51va_speaker_automute(codec);
15947 alc662_eeepc_mic_automute(codec);
15948}
15949/* ***************** Mode2 ******************************/
15950static void alc662_mode2_unsol_event(struct hda_codec *codec,
15951 unsigned int res)
15952{
15953 switch (res >> 26) {
15954 case ALC880_HP_EVENT:
15955 alc662_f5z_speaker_automute(codec);
15956 break;
15957 case ALC880_MIC_EVENT:
15958 alc662_eeepc_mic_automute(codec);
15959 break;
15960 }
15961}
15962
15963static void alc662_mode2_inithook(struct hda_codec *codec)
15964{
15965 alc662_f5z_speaker_automute(codec);
15966 alc662_eeepc_mic_automute(codec);
15967}
15968/* ***************** Mode3 ******************************/
15969static void alc663_mode3_unsol_event(struct hda_codec *codec,
15970 unsigned int res)
15971{
15972 switch (res >> 26) {
15973 case ALC880_HP_EVENT:
15974 alc663_two_hp_m1_speaker_automute(codec);
15975 break;
15976 case ALC880_MIC_EVENT:
15977 alc662_eeepc_mic_automute(codec);
15978 break;
15979 }
15980}
15981
15982static void alc663_mode3_inithook(struct hda_codec *codec)
15983{
15984 alc663_two_hp_m1_speaker_automute(codec);
15985 alc662_eeepc_mic_automute(codec);
15986}
15987/* ***************** Mode4 ******************************/
15988static void alc663_mode4_unsol_event(struct hda_codec *codec,
15989 unsigned int res)
15990{
15991 switch (res >> 26) {
15992 case ALC880_HP_EVENT:
15993 alc663_21jd_two_speaker_automute(codec);
15994 break;
15995 case ALC880_MIC_EVENT:
15996 alc662_eeepc_mic_automute(codec);
15997 break;
15998 }
15999}
16000
16001static void alc663_mode4_inithook(struct hda_codec *codec)
16002{
16003 alc663_21jd_two_speaker_automute(codec);
16004 alc662_eeepc_mic_automute(codec);
16005}
16006/* ***************** Mode5 ******************************/
16007static void alc663_mode5_unsol_event(struct hda_codec *codec,
16008 unsigned int res)
16009{
16010 switch (res >> 26) {
16011 case ALC880_HP_EVENT:
16012 alc663_15jd_two_speaker_automute(codec);
16013 break;
16014 case ALC880_MIC_EVENT:
16015 alc662_eeepc_mic_automute(codec);
16016 break;
16017 }
16018}
16019
16020static void alc663_mode5_inithook(struct hda_codec *codec)
16021{
16022 alc663_15jd_two_speaker_automute(codec);
16023 alc662_eeepc_mic_automute(codec);
16024}
16025/* ***************** Mode6 ******************************/
16026static void alc663_mode6_unsol_event(struct hda_codec *codec,
16027 unsigned int res)
16028{
16029 switch (res >> 26) {
16030 case ALC880_HP_EVENT:
16031 alc663_two_hp_m2_speaker_automute(codec);
16032 break;
16033 case ALC880_MIC_EVENT:
16034 alc662_eeepc_mic_automute(codec);
16035 break;
16036 }
16037}
16038
16039static void alc663_mode6_inithook(struct hda_codec *codec)
16040{
16041 alc663_two_hp_m2_speaker_automute(codec);
16042 alc662_eeepc_mic_automute(codec);
16043}
16044
Kailang Yang6dda9f42008-05-27 12:05:31 +020016045static void alc663_g71v_hp_automute(struct hda_codec *codec)
16046{
16047 unsigned int present;
16048 unsigned char bits;
16049
16050 present = snd_hda_codec_read(codec, 0x21, 0,
16051 AC_VERB_GET_PIN_SENSE, 0)
16052 & AC_PINSENSE_PRESENCE;
16053 bits = present ? HDA_AMP_MUTE : 0;
16054 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16055 HDA_AMP_MUTE, bits);
16056 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16057 HDA_AMP_MUTE, bits);
16058}
16059
16060static void alc663_g71v_front_automute(struct hda_codec *codec)
16061{
16062 unsigned int present;
16063 unsigned char bits;
16064
16065 present = snd_hda_codec_read(codec, 0x15, 0,
16066 AC_VERB_GET_PIN_SENSE, 0)
16067 & AC_PINSENSE_PRESENCE;
16068 bits = present ? HDA_AMP_MUTE : 0;
16069 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16070 HDA_AMP_MUTE, bits);
16071}
16072
16073static void alc663_g71v_unsol_event(struct hda_codec *codec,
16074 unsigned int res)
16075{
16076 switch (res >> 26) {
16077 case ALC880_HP_EVENT:
16078 alc663_g71v_hp_automute(codec);
16079 break;
16080 case ALC880_FRONT_EVENT:
16081 alc663_g71v_front_automute(codec);
16082 break;
16083 case ALC880_MIC_EVENT:
16084 alc662_eeepc_mic_automute(codec);
16085 break;
16086 }
16087}
16088
16089static void alc663_g71v_inithook(struct hda_codec *codec)
16090{
16091 alc663_g71v_front_automute(codec);
16092 alc663_g71v_hp_automute(codec);
16093 alc662_eeepc_mic_automute(codec);
16094}
16095
16096static void alc663_g50v_unsol_event(struct hda_codec *codec,
16097 unsigned int res)
16098{
16099 switch (res >> 26) {
16100 case ALC880_HP_EVENT:
16101 alc663_m51va_speaker_automute(codec);
16102 break;
16103 case ALC880_MIC_EVENT:
16104 alc662_eeepc_mic_automute(codec);
16105 break;
16106 }
16107}
16108
16109static void alc663_g50v_inithook(struct hda_codec *codec)
16110{
16111 alc663_m51va_speaker_automute(codec);
16112 alc662_eeepc_mic_automute(codec);
16113}
16114
Kailang Yangf1d4e282008-08-26 14:03:29 +020016115/* bind hp and internal speaker mute (with plug check) */
16116static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16117 struct snd_ctl_elem_value *ucontrol)
16118{
16119 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16120 long *valp = ucontrol->value.integer.value;
16121 int change;
16122
16123 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16124 HDA_AMP_MUTE,
16125 valp[0] ? 0 : HDA_AMP_MUTE);
16126 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16127 HDA_AMP_MUTE,
16128 valp[1] ? 0 : HDA_AMP_MUTE);
16129 if (change)
16130 alc262_hippo1_automute(codec);
16131 return change;
16132}
16133
16134static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16135 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16136 {
16137 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16138 .name = "Master Playback Switch",
16139 .info = snd_hda_mixer_amp_switch_info,
16140 .get = snd_hda_mixer_amp_switch_get,
16141 .put = alc662_ecs_master_sw_put,
16142 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16143 },
16144
16145 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16146 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16147 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16148
16149 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16150 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16151 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16152 { } /* end */
16153};
16154
Takashi Iwaicb53c622007-08-10 17:21:45 +020016155#ifdef CONFIG_SND_HDA_POWER_SAVE
16156#define alc662_loopbacks alc880_loopbacks
16157#endif
16158
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016159
16160/* pcm configuration: identiacal with ALC880 */
16161#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16162#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16163#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16164#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16165
16166/*
16167 * configuration and preset
16168 */
16169static const char *alc662_models[ALC662_MODEL_LAST] = {
16170 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16171 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16172 [ALC662_3ST_6ch] = "3stack-6ch",
16173 [ALC662_5ST_DIG] = "6stack-dig",
16174 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016175 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016176 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016177 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016178 [ALC663_ASUS_M51VA] = "m51va",
16179 [ALC663_ASUS_G71V] = "g71v",
16180 [ALC663_ASUS_H13] = "h13",
16181 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016182 [ALC663_ASUS_MODE1] = "asus-mode1",
16183 [ALC662_ASUS_MODE2] = "asus-mode2",
16184 [ALC663_ASUS_MODE3] = "asus-mode3",
16185 [ALC663_ASUS_MODE4] = "asus-mode4",
16186 [ALC663_ASUS_MODE5] = "asus-mode5",
16187 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016188 [ALC662_AUTO] = "auto",
16189};
16190
16191static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016192 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16193 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16194 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16195 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16196 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16197 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16198 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16199 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16200 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16201 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16202 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16203 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16204 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16205 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16206 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16207 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16208 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16209 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16210 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016211 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016212 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16213 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16214 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16215 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16216 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16217 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16218 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16219 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16220 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016221 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016222 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16223 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16224 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16225 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16226 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016227 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016228 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016229 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016230 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016231 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16232 ALC662_3ST_6ch_DIG),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016233 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16234 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016235 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016236 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016237 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016238 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016239 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16240 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016241 {}
16242};
16243
16244static struct alc_config_preset alc662_presets[] = {
16245 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016246 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016247 .init_verbs = { alc662_init_verbs },
16248 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16249 .dac_nids = alc662_dac_nids,
16250 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016251 .dig_in_nid = ALC662_DIGIN_NID,
16252 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16253 .channel_mode = alc662_3ST_2ch_modes,
16254 .input_mux = &alc662_capture_source,
16255 },
16256 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016257 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016258 .init_verbs = { alc662_init_verbs },
16259 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16260 .dac_nids = alc662_dac_nids,
16261 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016262 .dig_in_nid = ALC662_DIGIN_NID,
16263 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16264 .channel_mode = alc662_3ST_6ch_modes,
16265 .need_dac_fix = 1,
16266 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016267 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016268 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016269 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016270 .init_verbs = { alc662_init_verbs },
16271 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16272 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016273 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16274 .channel_mode = alc662_3ST_6ch_modes,
16275 .need_dac_fix = 1,
16276 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016277 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016278 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016279 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016280 .init_verbs = { alc662_init_verbs },
16281 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16282 .dac_nids = alc662_dac_nids,
16283 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016284 .dig_in_nid = ALC662_DIGIN_NID,
16285 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16286 .channel_mode = alc662_5stack_modes,
16287 .input_mux = &alc662_capture_source,
16288 },
16289 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016290 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016291 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16292 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16293 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016294 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16295 .channel_mode = alc662_3ST_2ch_modes,
16296 .input_mux = &alc662_lenovo_101e_capture_source,
16297 .unsol_event = alc662_lenovo_101e_unsol_event,
16298 .init_hook = alc662_lenovo_101e_all_automute,
16299 },
Kailang Yang291702f2007-10-16 14:28:03 +020016300 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016301 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016302 .init_verbs = { alc662_init_verbs,
16303 alc662_eeepc_sue_init_verbs },
16304 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16305 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016306 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16307 .channel_mode = alc662_3ST_2ch_modes,
16308 .input_mux = &alc662_eeepc_capture_source,
16309 .unsol_event = alc662_eeepc_unsol_event,
16310 .init_hook = alc662_eeepc_inithook,
16311 },
Kailang Yang8c427222008-01-10 13:03:59 +010016312 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016313 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016314 alc662_chmode_mixer },
16315 .init_verbs = { alc662_init_verbs,
16316 alc662_eeepc_ep20_sue_init_verbs },
16317 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16318 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016319 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16320 .channel_mode = alc662_3ST_6ch_modes,
16321 .input_mux = &alc662_lenovo_101e_capture_source,
16322 .unsol_event = alc662_eeepc_ep20_unsol_event,
16323 .init_hook = alc662_eeepc_ep20_inithook,
16324 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016325 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016326 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016327 .init_verbs = { alc662_init_verbs,
16328 alc662_ecs_init_verbs },
16329 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16330 .dac_nids = alc662_dac_nids,
16331 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16332 .channel_mode = alc662_3ST_2ch_modes,
16333 .input_mux = &alc662_eeepc_capture_source,
16334 .unsol_event = alc662_eeepc_unsol_event,
16335 .init_hook = alc662_eeepc_inithook,
16336 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016337 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016338 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016339 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16340 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16341 .dac_nids = alc662_dac_nids,
16342 .dig_out_nid = ALC662_DIGOUT_NID,
16343 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16344 .channel_mode = alc662_3ST_2ch_modes,
16345 .input_mux = &alc663_m51va_capture_source,
16346 .unsol_event = alc663_m51va_unsol_event,
16347 .init_hook = alc663_m51va_inithook,
16348 },
16349 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016350 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016351 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16352 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16353 .dac_nids = alc662_dac_nids,
16354 .dig_out_nid = ALC662_DIGOUT_NID,
16355 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16356 .channel_mode = alc662_3ST_2ch_modes,
16357 .input_mux = &alc662_eeepc_capture_source,
16358 .unsol_event = alc663_g71v_unsol_event,
16359 .init_hook = alc663_g71v_inithook,
16360 },
16361 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016362 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016363 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16364 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16365 .dac_nids = alc662_dac_nids,
16366 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16367 .channel_mode = alc662_3ST_2ch_modes,
16368 .input_mux = &alc663_m51va_capture_source,
16369 .unsol_event = alc663_m51va_unsol_event,
16370 .init_hook = alc663_m51va_inithook,
16371 },
16372 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016373 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016374 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16375 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16376 .dac_nids = alc662_dac_nids,
16377 .dig_out_nid = ALC662_DIGOUT_NID,
16378 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16379 .channel_mode = alc662_3ST_6ch_modes,
16380 .input_mux = &alc663_capture_source,
16381 .unsol_event = alc663_g50v_unsol_event,
16382 .init_hook = alc663_g50v_inithook,
16383 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016384 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016385 .mixers = { alc663_m51va_mixer },
16386 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016387 .init_verbs = { alc662_init_verbs,
16388 alc663_21jd_amic_init_verbs },
16389 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16390 .hp_nid = 0x03,
16391 .dac_nids = alc662_dac_nids,
16392 .dig_out_nid = ALC662_DIGOUT_NID,
16393 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16394 .channel_mode = alc662_3ST_2ch_modes,
16395 .input_mux = &alc662_eeepc_capture_source,
16396 .unsol_event = alc663_mode1_unsol_event,
16397 .init_hook = alc663_mode1_inithook,
16398 },
16399 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016400 .mixers = { alc662_1bjd_mixer },
16401 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016402 .init_verbs = { alc662_init_verbs,
16403 alc662_1bjd_amic_init_verbs },
16404 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16405 .dac_nids = alc662_dac_nids,
16406 .dig_out_nid = ALC662_DIGOUT_NID,
16407 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16408 .channel_mode = alc662_3ST_2ch_modes,
16409 .input_mux = &alc662_eeepc_capture_source,
16410 .unsol_event = alc662_mode2_unsol_event,
16411 .init_hook = alc662_mode2_inithook,
16412 },
16413 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016414 .mixers = { alc663_two_hp_m1_mixer },
16415 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016416 .init_verbs = { alc662_init_verbs,
16417 alc663_two_hp_amic_m1_init_verbs },
16418 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16419 .hp_nid = 0x03,
16420 .dac_nids = alc662_dac_nids,
16421 .dig_out_nid = ALC662_DIGOUT_NID,
16422 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16423 .channel_mode = alc662_3ST_2ch_modes,
16424 .input_mux = &alc662_eeepc_capture_source,
16425 .unsol_event = alc663_mode3_unsol_event,
16426 .init_hook = alc663_mode3_inithook,
16427 },
16428 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016429 .mixers = { alc663_asus_21jd_clfe_mixer },
16430 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016431 .init_verbs = { alc662_init_verbs,
16432 alc663_21jd_amic_init_verbs},
16433 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16434 .hp_nid = 0x03,
16435 .dac_nids = alc662_dac_nids,
16436 .dig_out_nid = ALC662_DIGOUT_NID,
16437 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16438 .channel_mode = alc662_3ST_2ch_modes,
16439 .input_mux = &alc662_eeepc_capture_source,
16440 .unsol_event = alc663_mode4_unsol_event,
16441 .init_hook = alc663_mode4_inithook,
16442 },
16443 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016444 .mixers = { alc663_asus_15jd_clfe_mixer },
16445 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016446 .init_verbs = { alc662_init_verbs,
16447 alc663_15jd_amic_init_verbs },
16448 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16449 .hp_nid = 0x03,
16450 .dac_nids = alc662_dac_nids,
16451 .dig_out_nid = ALC662_DIGOUT_NID,
16452 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16453 .channel_mode = alc662_3ST_2ch_modes,
16454 .input_mux = &alc662_eeepc_capture_source,
16455 .unsol_event = alc663_mode5_unsol_event,
16456 .init_hook = alc663_mode5_inithook,
16457 },
16458 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016459 .mixers = { alc663_two_hp_m2_mixer },
16460 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016461 .init_verbs = { alc662_init_verbs,
16462 alc663_two_hp_amic_m2_init_verbs },
16463 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16464 .hp_nid = 0x03,
16465 .dac_nids = alc662_dac_nids,
16466 .dig_out_nid = ALC662_DIGOUT_NID,
16467 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16468 .channel_mode = alc662_3ST_2ch_modes,
16469 .input_mux = &alc662_eeepc_capture_source,
16470 .unsol_event = alc663_mode6_unsol_event,
16471 .init_hook = alc663_mode6_inithook,
16472 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016473};
16474
16475
16476/*
16477 * BIOS auto configuration
16478 */
16479
16480/* add playback controls from the parsed DAC table */
16481static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16482 const struct auto_pin_cfg *cfg)
16483{
16484 char name[32];
16485 static const char *chname[4] = {
16486 "Front", "Surround", NULL /*CLFE*/, "Side"
16487 };
16488 hda_nid_t nid;
16489 int i, err;
16490
16491 for (i = 0; i < cfg->line_outs; i++) {
16492 if (!spec->multiout.dac_nids[i])
16493 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016494 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016495 if (i == 2) {
16496 /* Center/LFE */
16497 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16498 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016499 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16500 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016501 if (err < 0)
16502 return err;
16503 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16504 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016505 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16506 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016507 if (err < 0)
16508 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016509 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016510 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016511 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016512 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016513 if (err < 0)
16514 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016515 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016516 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016517 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016518 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016519 if (err < 0)
16520 return err;
16521 } else {
16522 sprintf(name, "%s Playback Volume", chname[i]);
16523 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016524 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16525 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016526 if (err < 0)
16527 return err;
16528 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016529 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16530 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16531 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016532 if (err < 0)
16533 return err;
16534 }
16535 }
16536 return 0;
16537}
16538
16539/* add playback controls for speaker and HP outputs */
16540static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16541 const char *pfx)
16542{
16543 hda_nid_t nid;
16544 int err;
16545 char name[32];
16546
16547 if (!pin)
16548 return 0;
16549
Takashi Iwai24fb9172008-09-02 14:48:20 +020016550 if (pin == 0x17) {
16551 /* ALC663 has a mono output pin on 0x17 */
16552 sprintf(name, "%s Playback Switch", pfx);
16553 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16554 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16555 return err;
16556 }
16557
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016558 if (alc880_is_fixed_pin(pin)) {
16559 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016560 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016561 /* specify the DAC as the extra output */
16562 if (!spec->multiout.hp_nid)
16563 spec->multiout.hp_nid = nid;
16564 else
16565 spec->multiout.extra_out_nid[0] = nid;
16566 /* control HP volume/switch on the output mixer amp */
16567 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16568 sprintf(name, "%s Playback Volume", pfx);
16569 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16570 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16571 if (err < 0)
16572 return err;
16573 sprintf(name, "%s Playback Switch", pfx);
16574 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16575 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16576 if (err < 0)
16577 return err;
16578 } else if (alc880_is_multi_pin(pin)) {
16579 /* set manual connection */
16580 /* we have only a switch on HP-out PIN */
16581 sprintf(name, "%s Playback Switch", pfx);
16582 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16583 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16584 if (err < 0)
16585 return err;
16586 }
16587 return 0;
16588}
16589
16590/* create playback/capture controls for input pins */
16591static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16592 const struct auto_pin_cfg *cfg)
16593{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016594 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016595 int i, err, idx;
16596
16597 for (i = 0; i < AUTO_PIN_LAST; i++) {
16598 if (alc880_is_input_pin(cfg->input_pins[i])) {
16599 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16600 err = new_analog_input(spec, cfg->input_pins[i],
16601 auto_pin_cfg_labels[i],
16602 idx, 0x0b);
16603 if (err < 0)
16604 return err;
16605 imux->items[imux->num_items].label =
16606 auto_pin_cfg_labels[i];
16607 imux->items[imux->num_items].index =
16608 alc880_input_pin_idx(cfg->input_pins[i]);
16609 imux->num_items++;
16610 }
16611 }
16612 return 0;
16613}
16614
16615static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16616 hda_nid_t nid, int pin_type,
16617 int dac_idx)
16618{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016619 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016620 /* need the manual connection? */
16621 if (alc880_is_multi_pin(nid)) {
16622 struct alc_spec *spec = codec->spec;
16623 int idx = alc880_multi_pin_idx(nid);
16624 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16625 AC_VERB_SET_CONNECT_SEL,
16626 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16627 }
16628}
16629
16630static void alc662_auto_init_multi_out(struct hda_codec *codec)
16631{
16632 struct alc_spec *spec = codec->spec;
16633 int i;
16634
Kailang Yang8c427222008-01-10 13:03:59 +010016635 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016636 for (i = 0; i <= HDA_SIDE; i++) {
16637 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016638 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016639 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016640 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016641 i);
16642 }
16643}
16644
16645static void alc662_auto_init_hp_out(struct hda_codec *codec)
16646{
16647 struct alc_spec *spec = codec->spec;
16648 hda_nid_t pin;
16649
16650 pin = spec->autocfg.hp_pins[0];
16651 if (pin) /* connect to front */
16652 /* use dac 0 */
16653 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016654 pin = spec->autocfg.speaker_pins[0];
16655 if (pin)
16656 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016657}
16658
16659#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16660#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16661
16662static void alc662_auto_init_analog_input(struct hda_codec *codec)
16663{
16664 struct alc_spec *spec = codec->spec;
16665 int i;
16666
16667 for (i = 0; i < AUTO_PIN_LAST; i++) {
16668 hda_nid_t nid = spec->autocfg.input_pins[i];
16669 if (alc662_is_input_pin(nid)) {
16670 snd_hda_codec_write(codec, nid, 0,
16671 AC_VERB_SET_PIN_WIDGET_CONTROL,
16672 (i <= AUTO_PIN_FRONT_MIC ?
16673 PIN_VREF80 : PIN_IN));
16674 if (nid != ALC662_PIN_CD_NID)
16675 snd_hda_codec_write(codec, nid, 0,
16676 AC_VERB_SET_AMP_GAIN_MUTE,
16677 AMP_OUT_MUTE);
16678 }
16679 }
16680}
16681
Takashi Iwaif511b012008-08-15 16:46:42 +020016682#define alc662_auto_init_input_src alc882_auto_init_input_src
16683
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016684static int alc662_parse_auto_config(struct hda_codec *codec)
16685{
16686 struct alc_spec *spec = codec->spec;
16687 int err;
16688 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16689
16690 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16691 alc662_ignore);
16692 if (err < 0)
16693 return err;
16694 if (!spec->autocfg.line_outs)
16695 return 0; /* can't find valid BIOS pin config */
16696
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016697 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16698 if (err < 0)
16699 return err;
16700 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16701 if (err < 0)
16702 return err;
16703 err = alc662_auto_create_extra_out(spec,
16704 spec->autocfg.speaker_pins[0],
16705 "Speaker");
16706 if (err < 0)
16707 return err;
16708 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16709 "Headphone");
16710 if (err < 0)
16711 return err;
16712 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16713 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016714 return err;
16715
16716 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16717
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016718 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016719 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16720
Takashi Iwai603c4012008-07-30 15:01:44 +020016721 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016722 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016723
16724 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016725 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016726
Takashi Iwaid88897e2008-10-31 15:01:37 +010016727 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016728 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016729 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016730
16731 err = alc_auto_add_mic_boost(codec);
16732 if (err < 0)
16733 return err;
16734
Takashi Iwaie044c392008-10-27 16:56:24 +010016735 store_pin_configs(codec);
Takashi Iwai8c872862007-06-19 12:11:16 +020016736 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016737}
16738
16739/* additional initialization for auto-configuration model */
16740static void alc662_auto_init(struct hda_codec *codec)
16741{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016742 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016743 alc662_auto_init_multi_out(codec);
16744 alc662_auto_init_hp_out(codec);
16745 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016746 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016747 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016748 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016749}
16750
16751static int patch_alc662(struct hda_codec *codec)
16752{
16753 struct alc_spec *spec;
16754 int err, board_config;
16755
16756 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16757 if (!spec)
16758 return -ENOMEM;
16759
16760 codec->spec = spec;
16761
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016762 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16763
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016764 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16765 alc662_models,
16766 alc662_cfg_tbl);
16767 if (board_config < 0) {
16768 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16769 "trying auto-probe from BIOS...\n");
16770 board_config = ALC662_AUTO;
16771 }
16772
16773 if (board_config == ALC662_AUTO) {
16774 /* automatic parse from the BIOS config */
16775 err = alc662_parse_auto_config(codec);
16776 if (err < 0) {
16777 alc_free(codec);
16778 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020016779 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016780 printk(KERN_INFO
16781 "hda_codec: Cannot set up configuration "
16782 "from BIOS. Using base mode...\n");
16783 board_config = ALC662_3ST_2ch_DIG;
16784 }
16785 }
16786
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016787 err = snd_hda_attach_beep_device(codec, 0x1);
16788 if (err < 0) {
16789 alc_free(codec);
16790 return err;
16791 }
16792
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016793 if (board_config != ALC662_AUTO)
16794 setup_preset(spec, &alc662_presets[board_config]);
16795
Kailang Yang6dda9f42008-05-27 12:05:31 +020016796 if (codec->vendor_id == 0x10ec0663) {
16797 spec->stream_name_analog = "ALC663 Analog";
16798 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016799 } else if (codec->vendor_id == 0x10ec0272) {
16800 spec->stream_name_analog = "ALC272 Analog";
16801 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016802 } else {
16803 spec->stream_name_analog = "ALC662 Analog";
16804 spec->stream_name_digital = "ALC662 Digital";
16805 }
16806
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016807 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16808 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16809
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016810 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16811 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16812
Takashi Iwaie1406342008-02-11 18:32:32 +010016813 spec->adc_nids = alc662_adc_nids;
16814 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16815 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016816 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016817
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016818 if (!spec->cap_mixer)
16819 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016820 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016821
Takashi Iwai2134ea42008-01-10 16:53:55 +010016822 spec->vmaster_nid = 0x02;
16823
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016824 codec->patch_ops = alc_patch_ops;
16825 if (board_config == ALC662_AUTO)
16826 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016827#ifdef CONFIG_SND_HDA_POWER_SAVE
16828 if (!spec->loopback.amplist)
16829 spec->loopback.amplist = alc662_loopbacks;
16830#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016831 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016832
16833 return 0;
16834}
16835
16836/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016837 * patch entries
16838 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016839static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016840 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016841 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016842 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016843 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016844 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016845 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016846 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016847 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016848 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16849 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16850 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016851 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16852 .patch = patch_alc883 },
16853 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16854 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016855 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016856 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016857 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016858 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016859 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16860 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016861 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016862 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016863 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016864 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016865 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16866 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080016867 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016868 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016869 {} /* terminator */
16870};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016871
16872MODULE_ALIAS("snd-hda-codec-id:10ec*");
16873
16874MODULE_LICENSE("GPL");
16875MODULE_DESCRIPTION("Realtek HD-audio codec");
16876
16877static struct hda_codec_preset_list realtek_list = {
16878 .preset = snd_hda_preset_realtek,
16879 .owner = THIS_MODULE,
16880};
16881
16882static int __init patch_realtek_init(void)
16883{
16884 return snd_hda_add_codec_preset(&realtek_list);
16885}
16886
16887static void __exit patch_realtek_exit(void)
16888{
16889 snd_hda_delete_codec_preset(&realtek_list);
16890}
16891
16892module_init(patch_realtek_init)
16893module_exit(patch_realtek_exit)